From dca5480ab7b77a889088ab7cac81934604510ac7 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 27 Apr 2023 13:21:52 +0200 Subject: w1: w1_therm: fix locking behavior in convert_t The commit 67b392f7b8ed ("w1_therm: optimizing temperature read timings") accidentially inverted the logic for lock handling of the bus mutex. Before: pullup -> release lock before sleep no pullup -> release lock after sleep After: pullup -> release lock after sleep no pullup -> release lock before sleep This cause spurious measurements of 85 degree (powerup value) on the Tarragon board with connected 1-w temperature sensor (w1_therm.w1_strong_pull=0). In the meantime a new feature for polling the conversion completion has been integrated in these branches with commit 021da53e65fd ("w1: w1_therm: Add sysfs entries to control conversion time and driver features"). But this feature isn't available for parasite power mode, so handle this separately. Link: https://lore.kernel.org/regressions/2023042645-attentive-amends-7b0b@gregkh/T/ Fixes: 67b392f7b8ed ("w1_therm: optimizing temperature read timings") Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/20230427112152.12313-1-stefan.wahren@i2se.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/slaves/w1_therm.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 067692626cf0..99c58bd9d2df 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -1159,29 +1159,26 @@ static int convert_t(struct w1_slave *sl, struct therm_info *info) w1_write_8(dev_master, W1_CONVERT_TEMP); - if (strong_pullup) { /*some device need pullup */ + if (SLAVE_FEATURES(sl) & W1_THERM_POLL_COMPLETION) { + ret = w1_poll_completion(dev_master, W1_POLL_CONVERT_TEMP); + if (ret) { + dev_dbg(&sl->dev, "%s: Timeout\n", __func__); + goto mt_unlock; + } + mutex_unlock(&dev_master->bus_mutex); + } else if (!strong_pullup) { /*no device need pullup */ sleep_rem = msleep_interruptible(t_conv); if (sleep_rem != 0) { ret = -EINTR; goto mt_unlock; } mutex_unlock(&dev_master->bus_mutex); - } else { /*no device need pullup */ - if (SLAVE_FEATURES(sl) & W1_THERM_POLL_COMPLETION) { - ret = w1_poll_completion(dev_master, W1_POLL_CONVERT_TEMP); - if (ret) { - dev_dbg(&sl->dev, "%s: Timeout\n", __func__); - goto mt_unlock; - } - mutex_unlock(&dev_master->bus_mutex); - } else { - /* Fixed delay */ - mutex_unlock(&dev_master->bus_mutex); - sleep_rem = msleep_interruptible(t_conv); - if (sleep_rem != 0) { - ret = -EINTR; - goto dec_refcnt; - } + } else { /*some device need pullup */ + mutex_unlock(&dev_master->bus_mutex); + sleep_rem = msleep_interruptible(t_conv); + if (sleep_rem != 0) { + ret = -EINTR; + goto dec_refcnt; } } ret = read_scratchpad(sl, info); -- cgit v1.2.3 From 388f22fe5d91d707352b4b743368b30e21d9d9bf Mon Sep 17 00:00:00 2001 From: Lizhe Date: Sun, 19 Mar 2023 12:41:07 +0800 Subject: w1: Remove driver match function If there is no driver match function, the driver core assumes that each candidate pair (driver, device) matches, see driver_match_device(). Drop the bus's match function that always returned 1 and so implements the same behaviour as when there is no match function Signed-off-by: Lizhe Link: https://lore.kernel.org/r/20230319044107.311555-1-sensor1010@163.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/w1.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 9d199fed9628..e7e42f9dabf4 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -58,11 +58,6 @@ MODULE_PARM_DESC(slave_ttl, DEFINE_MUTEX(w1_mlock); LIST_HEAD(w1_masters); -static int w1_master_match(struct device *dev, struct device_driver *drv) -{ - return 1; -} - static int w1_master_probe(struct device *dev) { return -ENODEV; @@ -174,7 +169,6 @@ static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env); static struct bus_type w1_bus_type = { .name = "w1", - .match = w1_master_match, .uevent = w1_uevent, }; -- cgit v1.2.3 From 5dfd3c73ff81618fee0ef682b6fd7779863f41e4 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Thu, 18 Aug 2022 23:01:21 +0200 Subject: w1: sgi: move from strlcpy with unused retval to strscpy Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang Link: https://lore.kernel.org/r/20220818210121.7589-1-wsa+renesas@sang-engineering.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/masters/sgi_w1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/w1/masters/sgi_w1.c b/drivers/w1/masters/sgi_w1.c index e8c7fa68d3cc..d7fbc3c146e1 100644 --- a/drivers/w1/masters/sgi_w1.c +++ b/drivers/w1/masters/sgi_w1.c @@ -93,7 +93,7 @@ static int sgi_w1_probe(struct platform_device *pdev) pdata = dev_get_platdata(&pdev->dev); if (pdata) { - strlcpy(sdev->dev_id, pdata->dev_id, sizeof(sdev->dev_id)); + strscpy(sdev->dev_id, pdata->dev_id, sizeof(sdev->dev_id)); sdev->bus_master.dev_id = sdev->dev_id; } -- cgit v1.2.3 From 4f5a5badb4eee46e43dc45be5e6058bff767eb80 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 20 Nov 2019 21:38:26 +0800 Subject: w1: Fix Kconfig indentation Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^ /\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20191120133826.12964-1-krzk@kernel.org Signed-off-by: Krzysztof Kozlowski --- drivers/w1/slaves/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 687753889c34..32b8a757744e 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig @@ -71,8 +71,8 @@ config W1_SLAVE_DS2805 help Say Y here if you want to use a 1-wire is a 112-byte user-programmable EEPROM is - organized as 7 pages of 16 bytes each with 64bit - unique number. Requires OverDrive Speed to talk to. + organized as 7 pages of 16 bytes each with 64bit + unique number. Requires OverDrive Speed to talk to. config W1_SLAVE_DS2430 tristate "256b EEPROM family support (DS2430)" -- cgit v1.2.3 From a8c4dda94115c4079d3aaa35ba238f2376b6aa53 Mon Sep 17 00:00:00 2001 From: zuoqilin Date: Fri, 18 Jun 2021 17:24:18 +0800 Subject: w1: Simplify the atribute show There is no necessary to define variable assignment, return directly. Signed-off-by: zuoqilin Link: https://lore.kernel.org/r/20210618092418.1424-1-zuoqilin1@163.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/w1.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index e7e42f9dabf4..0da9f528b6c1 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -295,17 +295,13 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct devic static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct device_attribute *attr, char *buf) { - ssize_t count; - count = sprintf(buf, "%d\n", w1_timeout); - return count; + return sprintf(buf, "%d\n", w1_timeout); } static ssize_t w1_master_attribute_show_timeout_us(struct device *dev, struct device_attribute *attr, char *buf) { - ssize_t count; - count = sprintf(buf, "%d\n", w1_timeout_us); - return count; + return sprintf(buf, "%d\n", w1_timeout_us); } static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, -- cgit v1.2.3 From 9033ff4c0fc65f3f168ee029b7e302a999c152ca Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 21 Jul 2021 11:34:51 +0100 Subject: w1: remove redundant initialization to variable result The variable result is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20210721103451.43026-1-colin.king@canonical.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/w1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 0da9f528b6c1..074bbdb67f0e 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -491,7 +491,7 @@ static ssize_t w1_master_attribute_store_remove(struct device *dev, struct w1_master *md = dev_to_w1_master(dev); struct w1_reg_num rn; struct w1_slave *sl; - ssize_t result = count; + ssize_t result; if (w1_atoreg_num(dev, buf, count, &rn)) return -EINVAL; -- cgit v1.2.3 From 83f3fcf96fcc7e5405b37d9424c7ef26bfa203f8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 19 May 2021 17:17:45 +0300 Subject: w1: fix loop in w1_fini() The __w1_remove_master_device() function calls: list_del(&dev->w1_master_entry); So presumably this can cause an endless loop. Fixes: 7785925dd8e0 ("[PATCH] w1: cleanups.") Signed-off-by: Dan Carpenter Signed-off-by: Krzysztof Kozlowski --- drivers/w1/w1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 074bbdb67f0e..b651e42161e6 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -1253,10 +1253,10 @@ err_out_exit_init: static void __exit w1_fini(void) { - struct w1_master *dev; + struct w1_master *dev, *n; /* Set netlink removal messages and some cleanup */ - list_for_each_entry(dev, &w1_masters, w1_master_entry) + list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) __w1_remove_master_device(dev); w1_fini_netlink(); -- cgit v1.2.3 From 1aa75bf5174c8243505a27476422060fce630cb1 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Thu, 10 Mar 2022 18:29:29 +0800 Subject: w1: w1_therm: Use max() instead of doing it manually Fix following coccicheck warning: drivers/w1/slaves/w1_therm.c:1452:18-19: WARNING opportunity for max() Signed-off-by: Haowen Bai Link: https://lore.kernel.org/r/1646908169-8050-1-git-send-email-baihaowen@meizu.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/slaves/w1_therm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 99c58bd9d2df..fa7c162c661f 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -1512,7 +1512,7 @@ static int trigger_bulk_read(struct w1_master *dev_master) if (bulk_read_support(sl)) { int t_cur = conversion_time(sl); - t_conv = t_cur > t_conv ? t_cur : t_conv; + t_conv = max(t_cur, t_conv); strong_pullup = strong_pullup || (w1_strong_pullup == 2 || (!SLAVE_POWERMODE(sl) && -- cgit v1.2.3 From 7f25058c96a0631f4a1ccb4c70831c52e71decf2 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 21 May 2022 13:10:16 +0200 Subject: w1: w1_therm: fix typo in comment Spelling mistake (triple letters) in comment. Detected with the help of Coccinelle. Signed-off-by: Julia Lawall Link: https://lore.kernel.org/r/20220521111145.81697-6-Julia.Lawall@inria.fr Signed-off-by: Krzysztof Kozlowski --- drivers/w1/slaves/w1_therm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index fa7c162c661f..ab7a411578f8 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -284,7 +284,7 @@ static int read_powermode(struct w1_slave *sl); * trigger_bulk_read() - function to trigger a bulk read on the bus * @dev_master: the device master of the bus * - * Send a SKIP ROM follow by a CONVERT T commmand on the bus. + * Send a SKIP ROM follow by a CONVERT T command on the bus. * It also set the status flag in each slave &struct w1_therm_family_data * to signal that a conversion is in progress. * -- cgit v1.2.3 From ee896c5bf21cbac3bed8f958507a449168e965d3 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 22 May 2022 20:46:22 +0100 Subject: w1: ds2438: remove redundant initialization of variable crc Variable crc is being initialized with a value that is never read, it is being re-assigned later on. The initialization is redundant and can be removed. Cleans up clang scan build warning: warning: Value stored to 'crc' is never read [deadcode.DeadStores] Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20220522194622.13277-1-colin.i.king@gmail.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/slaves/w1_ds2438.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2438.c b/drivers/w1/slaves/w1_ds2438.c index ca64f99c8f3d..e008c27b3db9 100644 --- a/drivers/w1/slaves/w1_ds2438.c +++ b/drivers/w1/slaves/w1_ds2438.c @@ -66,8 +66,6 @@ static int w1_ds2438_get_page(struct w1_slave *sl, int pageno, u8 *buf) size_t count; while (retries--) { - crc = 0; - if (w1_reset_select_slave(sl)) continue; w1_buf[0] = W1_DS2438_RECALL_MEMORY; -- cgit v1.2.3 From ecaed1a26f7215f48420a9c02e229b84b5fbb882 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Sun, 8 May 2022 10:34:00 +0800 Subject: w1: no need to initialise statics to 0 Static variables do not need to be initialised to 0, because compiler will initialise all uninitialised statics to 0. Thus, remove the unneeded initializations. Signed-off-by: Jason Wang Link: https://lore.kernel.org/r/20220508023400.102244-1-wangborong@cdjrlc.com Signed-off-by: Krzysztof Kozlowski --- drivers/w1/w1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index b651e42161e6..bc11cdd2e4f2 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -32,7 +32,7 @@ static int w1_timeout = 10; module_param_named(timeout, w1_timeout, int, 0); MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); -static int w1_timeout_us = 0; +static int w1_timeout_us; module_param_named(timeout_us, w1_timeout_us, int, 0); MODULE_PARM_DESC(timeout_us, "time in microseconds between automatic slave searches"); -- cgit v1.2.3 From 51cbbcd6469b2a32e222ec220039af20a16f2769 Mon Sep 17 00:00:00 2001 From: Liang He Date: Wed, 15 Jun 2022 20:51:05 +0800 Subject: w1: Add missing of_node_put() in w1.c In __w1_attach_slave_device, we really need not to use of_node_put in normal path as the reference is escaped by sl. However, we need of_node_put in the fail path before put_device. Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220615125105.3966317-1-windhl@126.com [krzysztof: fix whitespace / checkpatch] Signed-off-by: Krzysztof Kozlowski --- drivers/w1/w1.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index bc11cdd2e4f2..e16a60872226 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -692,6 +692,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl) dev_err(&sl->dev, "Device registration [%s] failed. err=%d\n", dev_name(&sl->dev), err); + of_node_put(sl->dev.of_node); put_device(&sl->dev); return err; } -- cgit v1.2.3 From 0df2a5e99d0cb10a3da93fd71dd6753af5adc79f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 7 Apr 2023 17:01:21 +0200 Subject: w1: therm: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Link: https://lore.kernel.org/r/20230407150121.79887-1-krzysztof.kozlowski@linaro.org Signed-off-by: Krzysztof Kozlowski --- drivers/w1/slaves/w1_therm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index ab7a411578f8..c85e80c7e130 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -454,7 +454,7 @@ static const struct hwmon_channel_info w1_temp = { .config = w1_temp_config, }; -static const struct hwmon_channel_info *w1_info[] = { +static const struct hwmon_channel_info * const w1_info[] = { &w1_temp, NULL }; -- cgit v1.2.3 From a4ec431fbf6b9533d2bb21fa328d88c1436106cf Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Mon, 10 Apr 2023 09:45:16 -0400 Subject: counter: 104-quad-8: Remove reference in Kconfig to 25-bit counter value Support for 25-bit counter values was removed in commit 4aa3b75c7460 ("counter: 104-quad-8: Fix race condition between FLAG and CNTR reads"). Adjust the Kconfig description of CONFIG_104_QUAD_8 to remove reference of 25-bit counter values. Link: https://lore.kernel.org/r/20230410134516.102886-1-william.gray@linaro.org/ Signed-off-by: William Breathitt Gray --- drivers/counter/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/counter/Kconfig b/drivers/counter/Kconfig index 4228be917038..3000816f8f95 100644 --- a/drivers/counter/Kconfig +++ b/drivers/counter/Kconfig @@ -21,9 +21,9 @@ config 104_QUAD_8 encoder counter/interface device family (104-QUAD-8, 104-QUAD-4). A counter's respective error flag may be cleared by performing a write - operation on the respective count value attribute. Although the - 104-QUAD-8 counters have a 25-bit range, only the lower 24 bits may be - set, either directly or via the counter's preset attribute. + operation on the respective count value attribute. The 104-QUAD-8 + counters may be set either directly or via the counter's preset + attribute. The base port addresses for the devices may be configured via the base array module parameter. The interrupt line numbers for the devices may -- cgit v1.2.3 From 5272145d5cccd7cb73a8ce4b0b90c1c6b37a6a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 13 Apr 2023 23:23:39 +0200 Subject: counter: stm32-timer-cnt: Reset TIM_TISEL to its default value in probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The driver assumes that the input selection register (TIM_TISEL) is at its reset default value. Usually this is the case, but the bootloader might have modified it. This bases on a similar patch submitted by Olivier Moysan for pwm-stm32. Reviewed-by: Fabrice Gasnier Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20230413212339.3611722-1-u.kleine-koenig@pengutronix.de/ Signed-off-by: William Breathitt Gray --- drivers/counter/stm32-timer-cnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index 9bf20a5d6bda..6206d2dc3d47 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -342,6 +342,9 @@ static int stm32_timer_cnt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); + /* Reset input selector to its default input */ + regmap_write(priv->regmap, TIM_TISEL, 0x0); + /* Register Counter device */ ret = devm_counter_add(dev, counter); if (ret < 0) -- cgit v1.2.3 From 6a9a092eb25851e16ecacc04ca2b155635d4e52f Mon Sep 17 00:00:00 2001 From: Rong Tao Date: Sat, 22 Apr 2023 22:35:53 +0800 Subject: tools/counter: Add .gitignore Ignore counter_example and include/linux/counter.h. Signed-off-by: Rong Tao Link: https://lore.kernel.org/r/tencent_3E0341A1C9AC8FCB7915E7D791D117445707@qq.com/ Signed-off-by: William Breathitt Gray --- tools/counter/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tools/counter/.gitignore diff --git a/tools/counter/.gitignore b/tools/counter/.gitignore new file mode 100644 index 000000000000..9fd290d4bf43 --- /dev/null +++ b/tools/counter/.gitignore @@ -0,0 +1,2 @@ +/counter_example +/include/linux/counter.h -- cgit v1.2.3 From 228354ed692faa08f40f2630658c0771f77da457 Mon Sep 17 00:00:00 2001 From: Rong Tao Date: Sat, 22 Apr 2023 22:27:38 +0800 Subject: tools/counter: Makefile: Remove lingering 'include' directories on make clean `make` creates 'include' directories where necessary, so remove them as appropriate on `make clean`. Signed-off-by: Rong Tao Link: https://lore.kernel.org/r/tencent_F85E314661100B0CE2845EB27E2E2F558C09@qq.com/ Signed-off-by: William Breathitt Gray --- tools/counter/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/counter/Makefile b/tools/counter/Makefile index 8843f0fa6119..a0f4cab71fe5 100644 --- a/tools/counter/Makefile +++ b/tools/counter/Makefile @@ -40,6 +40,7 @@ $(OUTPUT)counter_example: $(COUNTER_EXAMPLE) clean: rm -f $(ALL_PROGRAMS) rm -rf $(OUTPUT)include/linux/counter.h + rmdir -p $(OUTPUT)include/linux find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete install: $(ALL_PROGRAMS) -- cgit v1.2.3 From 800936191a26a5aba5caa3cbd70a4154b45eb94a Mon Sep 17 00:00:00 2001 From: Chuang Zhang Date: Mon, 24 Apr 2023 19:05:14 +0800 Subject: Binder: Add timestamp to transaction record This patch adds a timestamp field to the binder_transaction structure to track the time consumed during transmission when reading binder_transaction records. Signed-off-by: Chuang Zhang Acked-by: Carlos Llamas Link: https://lore.kernel.org/r/5ac8c0d09392290be789423f0dd78a520b830fab.1682333709.git.zhangchuang3@xiaomi.com Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder.c | 9 +++++++-- drivers/android/binder_internal.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index fb56bfc45096..b6413652906e 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -66,6 +66,7 @@ #include #include #include +#include #include @@ -2904,6 +2905,7 @@ static void binder_transaction(struct binder_proc *proc, binder_size_t last_fixup_min_off = 0; struct binder_context *context = proc->context; int t_debug_id = atomic_inc_return(&binder_last_id); + ktime_t t_start_time = ktime_get(); char *secctx = NULL; u32 secctx_sz = 0; struct list_head sgc_head; @@ -3145,6 +3147,7 @@ static void binder_transaction(struct binder_proc *proc, binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE); t->debug_id = t_debug_id; + t->start_time = t_start_time; if (reply) binder_debug(BINDER_DEBUG_TRANSACTION, @@ -5930,17 +5933,19 @@ static void print_binder_transaction_ilocked(struct seq_file *m, { struct binder_proc *to_proc; struct binder_buffer *buffer = t->buffer; + ktime_t current_time = ktime_get(); spin_lock(&t->lock); to_proc = t->to_proc; seq_printf(m, - "%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %ld r%d", + "%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %ld r%d elapsed %lldms", prefix, t->debug_id, t, t->from ? t->from->proc->pid : 0, t->from ? t->from->pid : 0, to_proc ? to_proc->pid : 0, t->to_thread ? t->to_thread->pid : 0, - t->code, t->flags, t->priority, t->need_reply); + t->code, t->flags, t->priority, t->need_reply, + ktime_ms_delta(current_time, t->start_time)); spin_unlock(&t->lock); if (proc != to_proc) { diff --git a/drivers/android/binder_internal.h b/drivers/android/binder_internal.h index 28ef5b3704b1..92e64007f2b0 100644 --- a/drivers/android/binder_internal.h +++ b/drivers/android/binder_internal.h @@ -528,6 +528,7 @@ struct binder_transaction { long priority; long saved_priority; kuid_t sender_euid; + ktime_t start_time; struct list_head fd_fixups; binder_uintptr_t security_ctx; /** -- cgit v1.2.3 From c21c0f9a20a963f5a1874657a4e3d657503f7815 Mon Sep 17 00:00:00 2001 From: Chuang Zhang Date: Mon, 24 Apr 2023 19:05:15 +0800 Subject: Binder: Add async from to transaction record This commit adds support for getting the pid and tid information of the sender for asynchronous transfers in binderfs transfer records. In previous versions, it was not possible to obtain this information from the transfer records. While this information may not be necessary for all use cases, it can be useful in some scenarios. Signed-off-by: Chuang Zhang Acked-by: Carlos Llamas Link: https://lore.kernel.org/r/0c1e8bd37c68dd1518bb737b06b768cde9659386.1682333709.git.zhangchuang3@xiaomi.com Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder.c | 6 ++++-- drivers/android/binder_internal.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index b6413652906e..6674619845e0 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -3172,6 +3172,8 @@ static void binder_transaction(struct binder_proc *proc, t->from = thread; else t->from = NULL; + t->from_pid = proc->pid; + t->from_tid = thread->pid; t->sender_euid = task_euid(proc->tsk); t->to_proc = target_proc; t->to_thread = target_thread; @@ -5940,8 +5942,8 @@ static void print_binder_transaction_ilocked(struct seq_file *m, seq_printf(m, "%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %ld r%d elapsed %lldms", prefix, t->debug_id, t, - t->from ? t->from->proc->pid : 0, - t->from ? t->from->pid : 0, + t->from_pid, + t->from_tid, to_proc ? to_proc->pid : 0, t->to_thread ? t->to_thread->pid : 0, t->code, t->flags, t->priority, t->need_reply, diff --git a/drivers/android/binder_internal.h b/drivers/android/binder_internal.h index 92e64007f2b0..7270d4d22207 100644 --- a/drivers/android/binder_internal.h +++ b/drivers/android/binder_internal.h @@ -515,6 +515,8 @@ struct binder_transaction { int debug_id; struct binder_work work; struct binder_thread *from; + pid_t from_pid; + pid_t from_tid; struct binder_transaction *from_parent; struct binder_proc *to_proc; struct binder_thread *to_thread; -- cgit v1.2.3 From ef513aa7aa5038d2f53e9f2932af5006f37ed0b6 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Fri, 14 Apr 2023 01:17:49 +0200 Subject: dt-bindings: iio: adc: qcom,spmi-vadc: Allow 1/16 for pre-scaling The channel ADC5_USB_IN_V_16 is using 1/16 pre-scaling on at least pm7250b and pmi632. Allow that in the schema. Signed-off-by: Luca Weiss Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20230414-pmi632-v1-5-fe94dc414832@z3ntu.xyz Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml index bd6e0d6f6e0c..365aa3528a87 100644 --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml @@ -101,7 +101,7 @@ patternProperties: oneOf: - items: - const: 1 - - enum: [ 1, 3, 4, 6, 20, 8, 10 ] + - enum: [ 1, 3, 4, 6, 20, 8, 10, 16 ] - items: - const: 10 - const: 81 -- cgit v1.2.3 From 9445368bca2f62cadfcf98e06219f784ae94dce0 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sun, 16 Apr 2023 01:11:25 +0200 Subject: iio: accel: st_accel: Add LSM303D The lsm303d has the same register mapping as the lsm9ds0, thus we can just re-use that. Tested on a Lenovo Yoga Tablet 2 1051-F. Signed-off-by: Marius Hoch Reviewed-by: Linus Walleij Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20230415231130.115094-2-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 1 + include/linux/iio/common/st_sensors.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 5f7d81b44b1d..7c4f58c90f94 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -1007,6 +1007,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LSM9DS0_IMU_DEV_NAME, + [1] = LSM303D_IMU_DEV_NAME, }, .ch = (struct iio_chan_spec *)st_accel_16bit_channels, .odr = { diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index f5f3ee57bc70..607c3a89a647 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -22,6 +22,7 @@ #include #define LSM9DS0_IMU_DEV_NAME "lsm9ds0" +#define LSM303D_IMU_DEV_NAME "lsm303d" /* * Buffer size max case: 2bytes per channel, 3 channels in total + -- cgit v1.2.3 From a9e19f636036567284ef41008b930f5730acd974 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sun, 16 Apr 2023 01:11:26 +0200 Subject: iio: magnetometer: st_accel: Add LSM303D The lsm303d has the same register mapping as the lsm9ds0, thus we can just re-use that. Tested on a Lenovo Yoga Tablet 2 1051-F. Signed-off-by: Marius Hoch Reviewed-by: Linus Walleij Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20230415231130.115094-3-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/st_magn_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 8faa7409d9e1..6cc0dfd31821 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -427,6 +427,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LSM9DS0_IMU_DEV_NAME, + [1] = LSM303D_IMU_DEV_NAME, }, .ch = (struct iio_chan_spec *)st_magn_4_16bit_channels, .odr = { -- cgit v1.2.3 From c0f68439ae06c8612e4d64e24b70a5c82fcdede6 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sun, 16 Apr 2023 01:11:27 +0200 Subject: iio: st_sensors: Add lsm303d support to the LSM9DS0 IMU driver The lsm303d is basically the lsm9ds0 without the gyroscope (which the LSM9DS0 IMU driver doesn't handle), as far as I can tell. Signed-off-by: Marius Hoch Reviewed-by: Linus Walleij Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20230415231130.115094-4-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm9ds0/Kconfig | 3 ++- drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 5 +++++ drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/st_lsm9ds0/Kconfig b/drivers/iio/imu/st_lsm9ds0/Kconfig index d29558edee60..7aef714b6ecb 100644 --- a/drivers/iio/imu/st_lsm9ds0/Kconfig +++ b/drivers/iio/imu/st_lsm9ds0/Kconfig @@ -10,7 +10,8 @@ config IIO_ST_LSM9DS0 help Say yes here to build support for STMicroelectronics LSM9DS0 IMU - sensor. Supported devices: accelerometer/magnetometer of lsm9ds0. + sensor. Supported devices: accelerometer/magnetometer of lsm9ds0 + and lsm303d. To compile this driver as a module, choose M here: the module will be called st_lsm9ds0. diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c index a90138d8b06a..611515c6a73d 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c @@ -18,6 +18,10 @@ #include "st_lsm9ds0.h" static const struct of_device_id st_lsm9ds0_of_match[] = { + { + .compatible = "st,lsm303d-imu", + .data = LSM303D_IMU_DEV_NAME, + }, { .compatible = "st,lsm9ds0-imu", .data = LSM9DS0_IMU_DEV_NAME, @@ -27,6 +31,7 @@ static const struct of_device_id st_lsm9ds0_of_match[] = { MODULE_DEVICE_TABLE(of, st_lsm9ds0_of_match); static const struct i2c_device_id st_lsm9ds0_id_table[] = { + { LSM303D_IMU_DEV_NAME }, { LSM9DS0_IMU_DEV_NAME }, {} }; diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c index b743bf3546a7..8cc041d56cf7 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c @@ -18,6 +18,10 @@ #include "st_lsm9ds0.h" static const struct of_device_id st_lsm9ds0_of_match[] = { + { + .compatible = "st,lsm303d-imu", + .data = LSM303D_IMU_DEV_NAME, + }, { .compatible = "st,lsm9ds0-imu", .data = LSM9DS0_IMU_DEV_NAME, @@ -27,6 +31,7 @@ static const struct of_device_id st_lsm9ds0_of_match[] = { MODULE_DEVICE_TABLE(of, st_lsm9ds0_of_match); static const struct spi_device_id st_lsm9ds0_id_table[] = { + { LSM303D_IMU_DEV_NAME }, { LSM9DS0_IMU_DEV_NAME }, {} }; -- cgit v1.2.3 From 598e971fabf8c7c560896394b06175330b1c1aba Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sun, 16 Apr 2023 01:11:28 +0200 Subject: iio: st_sensors: Add ACPI support for lsm303d to the LSM9DS0 IMU driver The lsm303d can be found as ACCL0001 on various Lenovo devices, including the Lenovo Yoga Tablet 2 1051-F, where I tested this patch. Dropped SPI support as per discussion in thread linked below. Signed-off-by: Marius Hoch Acked-by: Linus Walleij Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20230415231130.115094-5-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c index 611515c6a73d..a0b9b2df11ce 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c @@ -37,6 +37,12 @@ static const struct i2c_device_id st_lsm9ds0_id_table[] = { }; MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table); +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = { + {"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match); + static const struct regmap_config st_lsm9ds0_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -73,6 +79,7 @@ static struct i2c_driver st_lsm9ds0_driver = { .driver = { .name = "st-lsm9ds0-i2c", .of_match_table = st_lsm9ds0_of_match, + .acpi_match_table = st_lsm9ds0_acpi_match, }, .probe_new = st_lsm9ds0_i2c_probe, .id_table = st_lsm9ds0_id_table, -- cgit v1.2.3 From 69ee1fb21340cb83df531175f298010697a87448 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sun, 16 Apr 2023 01:11:29 +0200 Subject: iio: Comment that the LSM303D also has the Magnetometer DRDY Per its datasheet, the LSM303D also features that pin. Signed-off-by: Marius Hoch Reviewed-by: Linus Walleij Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20230415231130.115094-6-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- include/linux/platform_data/st_sensors_pdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h index 897051e51b78..a657830232ae 100644 --- a/include/linux/platform_data/st_sensors_pdata.h +++ b/include/linux/platform_data/st_sensors_pdata.h @@ -15,7 +15,7 @@ * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). * Available only for accelerometer, magnetometer and pressure sensors. * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). - * Magnetometer DRDY is supported only on LSM9DS0. + * Magnetometer DRDY is supported only on LSM9DS0 and LSM303D. * @open_drain: set the interrupt line to be open drain if possible. * @spi_3wire: enable spi-3wire mode. * @pullups: enable/disable i2c controller pullup resistors. -- cgit v1.2.3 From 773aa06d706ce1c2055b7a3f1616c2978ca66dac Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sun, 16 Apr 2023 01:11:30 +0200 Subject: dt-bindings: iio: st-sensors: Add LSM303D accelerometer+magnetometer Same as the lsm9ds0, except that the lsm303d doesn't feature a gyroscope. Signed-off-by: Marius Hoch Acked-by: Krzysztof Kozlowski Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20230415231130.115094-7-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/st,st-sensors.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml index 1ff3afca9149..e450821a741d 100644 --- a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml +++ b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml @@ -84,6 +84,7 @@ properties: - st,lps35hw - description: IMUs enum: + - st,lsm303d-imu - st,lsm9ds0-imu - description: Deprecated bindings enum: -- cgit v1.2.3 From b4d32eb31f49358ad9de1baed92844e7a4cc5de0 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sat, 15 Apr 2023 18:25:41 +0200 Subject: iio: accel: bma400: Simplify an error message dev_err_probe() already display the error code. There is no need to duplicate it explicitly in the error message. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/9373d41b0a1f3dc3fc0d31c1daaa19d9a7ec4dcd.1681575924.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bma400_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c index a68b845f5b4f..e90e2f01550a 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -868,8 +868,7 @@ static int bma400_init(struct bma400_data *data) ARRAY_SIZE(regulator_names), regulator_names); if (ret) - return dev_err_probe(data->dev, ret, "Failed to get regulators: %d\n", - ret); + return dev_err_probe(data->dev, ret, "Failed to get regulators\n"); /* Try to read chip_id register. It must return 0x90. */ ret = regmap_read(data->regmap, BMA400_CHIP_ID_REG, &val); -- cgit v1.2.3 From 5b24fdd991e53f10514cb6a6096f76bf555ffeac Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Fri, 21 Apr 2023 01:26:31 +0200 Subject: iio: light: al3320a: Handle ACPI device CALS0001 This sensor can be found as CALS0001 on the Lenovo Yoga Tablet 2 series. Tested on a Lenovo Yoga Tablet 2 1051-F. Signed-off-by: Marius Hoch Tested-by: Hans de Goede Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20230420232631.68864-1-mail@mariushoch.de Signed-off-by: Jonathan Cameron --- drivers/iio/light/al3320a.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c index 9ff28bbf34bb..36214d790f71 100644 --- a/drivers/iio/light/al3320a.c +++ b/drivers/iio/light/al3320a.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -247,11 +248,18 @@ static const struct of_device_id al3320a_of_match[] = { }; MODULE_DEVICE_TABLE(of, al3320a_of_match); +static const struct acpi_device_id al3320a_acpi_match[] = { + {"CALS0001"}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, al3320a_acpi_match); + static struct i2c_driver al3320a_driver = { .driver = { .name = AL3320A_DRV_NAME, .of_match_table = al3320a_of_match, .pm = pm_sleep_ptr(&al3320a_pm_ops), + .acpi_match_table = al3320a_acpi_match, }, .probe_new = al3320a_probe, .id_table = al3320a_id, -- cgit v1.2.3 From 7b0d54ae76e3c6e4f0222c5af3e3d7531f62b58e Mon Sep 17 00:00:00 2001 From: Sean Nyekjaer Date: Fri, 21 Apr 2023 10:38:58 +0200 Subject: iio: adc: stm32-adc: add debug info if dt uses legacy channel config Since nearly all stm32 dt's are using the legacy adc channel config, we should warn users about using it. Signed-off-by: Sean Nyekjaer Link: https://lore.kernel.org/r/20230421083858.2613289-1-sean@geanix.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-adc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 1aadb2ad2cab..e179b6611e4d 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1993,6 +1993,8 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm const struct stm32_adc_info *adc_info = adc->cfg->adc_info; int num_channels = 0, ret; + dev_dbg(&indio_dev->dev, "using legacy channel config\n"); + ret = device_property_count_u32(dev, "st,adc-channels"); if (ret > adc_info->max_channels) { dev_err(&indio_dev->dev, "Bad st,adc-channels?\n"); -- cgit v1.2.3 From e88d989fb01fa06b0fe77be3ce9041c7a4ea9f9c Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Fri, 21 Apr 2023 15:20:42 +0200 Subject: dt-bindings: iio: adc: Add support for MT7986 Add compatible string and specific clock property for mt7986. Signed-off-by: Frank Wunderlich Link: https://lore.kernel.org/r/20230421132047.42166-3-linux@fw-web.de Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml index 7f79a06e76f5..6168b44ea72c 100644 --- a/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml @@ -26,6 +26,7 @@ properties: - mediatek,mt2712-auxadc - mediatek,mt6765-auxadc - mediatek,mt7622-auxadc + - mediatek,mt7986-auxadc - mediatek,mt8173-auxadc - items: - enum: -- cgit v1.2.3 From b8ddd02281401658b41d491bfa02d152cba806a5 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Mon, 24 Apr 2023 09:11:51 +0200 Subject: iio: adc: palmas: Remove the unneeded include This driver does not use i2c, so there is no point in including Remove it. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/9d23cd04d7f99dc8d813584aae5268b57f92fcd8.1682320298.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jonathan Cameron --- drivers/iio/adc/palmas_gpadc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index c1c439215aeb..42c519504529 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 480abd88c04a56f1817985f6854333a5ea2d26fa Mon Sep 17 00:00:00 2001 From: Stefan Windfeldt-Prytz Date: Wed, 26 Apr 2023 13:57:29 +0200 Subject: dt-bindings: iio: light: Document TI OPT4001 light sensor Add devicetree bindings for opt4001 ambient light sensor. Signed-off-by: Stefan Windfeldt-Prytz Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20230323-add-opt4001-driver-v3-1-62e121dab294@axis.com Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/light/ti,opt4001.yaml | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ti,opt4001.yaml diff --git a/Documentation/devicetree/bindings/iio/light/ti,opt4001.yaml b/Documentation/devicetree/bindings/iio/light/ti,opt4001.yaml new file mode 100644 index 000000000000..12b0c7ed5d72 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/ti,opt4001.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/ti,opt4001.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments OPT4001 Ambient Light Sensor + +maintainers: + - Stefan Windfeldt-Prytz + +description: + Ambient light sensor with an i2c interface. + Last part of compatible is for the packaging used. + Picostar is a 4 pinned SMT and sot-5x3 is a 8 pinned SOT. + https://www.ti.com/lit/gpn/opt4001 + +properties: + compatible: + enum: + - ti,opt4001-picostar + - ti,opt4001-sot-5x3 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vdd-supply: + description: Regulator that provides power to the sensor + +required: + - compatible + - reg + +allOf: + - if: + properties: + compatible: + contains: + const: ti,opt4001-sot-5x3 + then: + properties: + interrupts: + maxItems: 1 + else: + properties: + interrupts: false + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@44 { + compatible = "ti,opt4001-sot-5x3"; + reg = <0x44>; + vdd-supply = <&vdd_reg>; + interrupt-parent = <&gpio1>; + interrupts = <28 IRQ_TYPE_EDGE_FALLING>; + }; + }; +... -- cgit v1.2.3 From 9a9608418292bb8733805c3f3123dfe0454fadac Mon Sep 17 00:00:00 2001 From: Stefan Windfeldt-Prytz Date: Wed, 26 Apr 2023 13:57:30 +0200 Subject: iio: light: Add support for TI OPT4001 light sensor This driver uses the continuous mode of the chip and integration time can be configured through sysfs. The constants for calculating lux value differs between packaging so it uses different compatible string for the two versions "ti,opt4001-picostar" and "ti,opt4001-sot-5x3" since the device id is the same. Datasheet: https://www.ti.com/lit/gpn/opt4001 Signed-off-by: Stefan Windfeldt-Prytz Link: https://lore.kernel.org/r/20230323-add-opt4001-driver-v3-2-62e121dab294@axis.com Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 11 ++ drivers/iio/light/Makefile | 1 + drivers/iio/light/opt4001.c | 467 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 479 insertions(+) create mode 100644 drivers/iio/light/opt4001.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 6fa31fcd71a1..811fa9599abc 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -413,6 +413,17 @@ config OPT3001 If built as a dynamically linked module, it will be called opt3001. +config OPT4001 + tristate "Texas Instruments OPT4001 Light Sensor" + depends on I2C + select REGMAP_I2C + help + If you say Y or M here, you get support for Texas Instruments + OPT4001 Ambient Light Sensor. + + If built as a dynamically linked module, it will be called + opt4001. + config PA12203001 tristate "TXC PA12203001 light and proximity sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 985f6feaccd4..810ed6ffd9c4 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_MAX44000) += max44000.o obj-$(CONFIG_MAX44009) += max44009.o obj-$(CONFIG_NOA1305) += noa1305.o obj-$(CONFIG_OPT3001) += opt3001.o +obj-$(CONFIG_OPT4001) += opt4001.o obj-$(CONFIG_PA12203001) += pa12203001.o obj-$(CONFIG_ROHM_BU27034) += rohm-bu27034.o obj-$(CONFIG_RPR0521) += rpr0521.o diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c new file mode 100644 index 000000000000..feb57cb99aa4 --- /dev/null +++ b/drivers/iio/light/opt4001.c @@ -0,0 +1,467 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 Axis Communications AB + * + * Datasheet: https://www.ti.com/lit/gpn/opt4001 + * + * Device driver for the Texas Instruments OPT4001. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* OPT4001 register set */ +#define OPT4001_LIGHT1_MSB 0x00 +#define OPT4001_LIGHT1_LSB 0x01 +#define OPT4001_CTRL 0x0A +#define OPT4001_DEVICE_ID 0x11 + +/* OPT4001 register mask */ +#define OPT4001_EXPONENT_MASK GENMASK(15, 12) +#define OPT4001_MSB_MASK GENMASK(11, 0) +#define OPT4001_LSB_MASK GENMASK(15, 8) +#define OPT4001_COUNTER_MASK GENMASK(7, 4) +#define OPT4001_CRC_MASK GENMASK(3, 0) + +/* OPT4001 device id mask */ +#define OPT4001_DEVICE_ID_MASK GENMASK(11, 0) + +/* OPT4001 control registers mask */ +#define OPT4001_CTRL_QWAKE_MASK GENMASK(15, 15) +#define OPT4001_CTRL_RANGE_MASK GENMASK(13, 10) +#define OPT4001_CTRL_CONV_TIME_MASK GENMASK(9, 6) +#define OPT4001_CTRL_OPER_MODE_MASK GENMASK(5, 4) +#define OPT4001_CTRL_LATCH_MASK GENMASK(3, 3) +#define OPT4001_CTRL_INT_POL_MASK GENMASK(2, 2) +#define OPT4001_CTRL_FAULT_COUNT GENMASK(0, 1) + +/* OPT4001 constants */ +#define OPT4001_DEVICE_ID_VAL 0x121 + +/* OPT4001 operating modes */ +#define OPT4001_CTRL_OPER_MODE_OFF 0x0 +#define OPT4001_CTRL_OPER_MODE_FORCED 0x1 +#define OPT4001_CTRL_OPER_MODE_ONE_SHOT 0x2 +#define OPT4001_CTRL_OPER_MODE_CONTINUOUS 0x3 + +/* OPT4001 conversion control register definitions */ +#define OPT4001_CTRL_CONVERSION_0_6MS 0x0 +#define OPT4001_CTRL_CONVERSION_1MS 0x1 +#define OPT4001_CTRL_CONVERSION_1_8MS 0x2 +#define OPT4001_CTRL_CONVERSION_3_4MS 0x3 +#define OPT4001_CTRL_CONVERSION_6_5MS 0x4 +#define OPT4001_CTRL_CONVERSION_12_7MS 0x5 +#define OPT4001_CTRL_CONVERSION_25MS 0x6 +#define OPT4001_CTRL_CONVERSION_50MS 0x7 +#define OPT4001_CTRL_CONVERSION_100MS 0x8 +#define OPT4001_CTRL_CONVERSION_200MS 0x9 +#define OPT4001_CTRL_CONVERSION_400MS 0xa +#define OPT4001_CTRL_CONVERSION_800MS 0xb + +/* OPT4001 scale light level range definitions */ +#define OPT4001_CTRL_LIGHT_SCALE_AUTO 12 + +/* OPT4001 default values */ +#define OPT4001_DEFAULT_CONVERSION_TIME OPT4001_CTRL_CONVERSION_800MS + +/* + * The different packaging of OPT4001 has different constants used when calculating + * lux values. + */ +struct opt4001_chip_info { + int mul; + int div; + const char *name; +}; + +struct opt4001_chip { + struct regmap *regmap; + struct i2c_client *client; + u8 int_time; + const struct opt4001_chip_info *chip_info; +}; + +static const struct opt4001_chip_info opt4001_sot_5x3_info = { + .mul = 4375, + .div = 10000000, + .name = "opt4001-sot-5x3" +}; + +static const struct opt4001_chip_info opt4001_picostar_info = { + .mul = 3125, + .div = 10000000, + .name = "opt4001-picostar" +}; + +static const int opt4001_int_time_available[][2] = { + { 0, 600 }, + { 0, 1000 }, + { 0, 1800 }, + { 0, 3400 }, + { 0, 6500 }, + { 0, 12700 }, + { 0, 25000 }, + { 0, 50000 }, + { 0, 100000 }, + { 0, 200000 }, + { 0, 400000 }, + { 0, 800000 }, +}; + +/* + * Conversion time is integration time + time to set register + * this is used as integration time. + */ +static const int opt4001_int_time_reg[][2] = { + { 600, OPT4001_CTRL_CONVERSION_0_6MS }, + { 1000, OPT4001_CTRL_CONVERSION_1MS }, + { 1800, OPT4001_CTRL_CONVERSION_1_8MS }, + { 3400, OPT4001_CTRL_CONVERSION_3_4MS }, + { 6500, OPT4001_CTRL_CONVERSION_6_5MS }, + { 12700, OPT4001_CTRL_CONVERSION_12_7MS }, + { 25000, OPT4001_CTRL_CONVERSION_25MS }, + { 50000, OPT4001_CTRL_CONVERSION_50MS }, + { 100000, OPT4001_CTRL_CONVERSION_100MS }, + { 200000, OPT4001_CTRL_CONVERSION_200MS }, + { 400000, OPT4001_CTRL_CONVERSION_400MS }, + { 800000, OPT4001_CTRL_CONVERSION_800MS }, +}; + +static int opt4001_als_time_to_index(const u32 als_integration_time) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(opt4001_int_time_available); i++) { + if (als_integration_time == opt4001_int_time_available[i][1]) + return i; + } + + return -EINVAL; +} + +static u8 opt4001_calculate_crc(u8 exp, u32 mantissa, u8 count) +{ + u8 crc; + + crc = (hweight32(mantissa) + hweight32(exp) + hweight32(count)) % 2; + crc |= ((hweight32(mantissa & 0xAAAAA) + hweight32(exp & 0xA) + + hweight32(count & 0xA)) % 2) << 1; + crc |= ((hweight32(mantissa & 0x88888) + hweight32(exp & 0x8) + + hweight32(count & 0x8)) % 2) << 2; + crc |= (hweight32(mantissa & 0x80808) % 2) << 3; + + return crc; +} + +static int opt4001_read_lux_value(struct iio_dev *indio_dev, + int *val, int *val2) +{ + struct opt4001_chip *chip = iio_priv(indio_dev); + struct device *dev = &chip->client->dev; + unsigned int light1; + unsigned int light2; + u16 msb; + u16 lsb; + u8 exp; + u8 count; + u8 crc; + u8 calc_crc; + u64 lux_raw; + int ret; + + ret = regmap_read(chip->regmap, OPT4001_LIGHT1_MSB, &light1); + if (ret < 0) { + dev_err(dev, "Failed to read data bytes"); + return ret; + } + + ret = regmap_read(chip->regmap, OPT4001_LIGHT1_LSB, &light2); + if (ret < 0) { + dev_err(dev, "Failed to read data bytes"); + return ret; + } + + count = FIELD_GET(OPT4001_COUNTER_MASK, light2); + exp = FIELD_GET(OPT4001_EXPONENT_MASK, light1); + crc = FIELD_GET(OPT4001_CRC_MASK, light2); + msb = FIELD_GET(OPT4001_MSB_MASK, light1); + lsb = FIELD_GET(OPT4001_LSB_MASK, light2); + lux_raw = (msb << 8) + lsb; + calc_crc = opt4001_calculate_crc(exp, lux_raw, count); + if (calc_crc != crc) + return -EIO; + + lux_raw = lux_raw << exp; + lux_raw = lux_raw * chip->chip_info->mul; + *val = div_u64_rem(lux_raw, chip->chip_info->div, val2); + *val2 = *val2 * 100; + + return IIO_VAL_INT_PLUS_NANO; +} + +static int opt4001_set_conf(struct opt4001_chip *chip) +{ + struct device *dev = &chip->client->dev; + u16 reg; + int ret; + + reg = FIELD_PREP(OPT4001_CTRL_RANGE_MASK, OPT4001_CTRL_LIGHT_SCALE_AUTO); + reg |= FIELD_PREP(OPT4001_CTRL_CONV_TIME_MASK, chip->int_time); + reg |= FIELD_PREP(OPT4001_CTRL_OPER_MODE_MASK, OPT4001_CTRL_OPER_MODE_CONTINUOUS); + + ret = regmap_write(chip->regmap, OPT4001_CTRL, reg); + if (ret) + dev_err(dev, "Failed to set configuration\n"); + + return ret; +} + +static int opt4001_power_down(struct opt4001_chip *chip) +{ + struct device *dev = &chip->client->dev; + int ret; + unsigned int reg; + + ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, ®); + if (ret) { + dev_err(dev, "Failed to read configuration\n"); + return ret; + } + + /* MODE_OFF is 0x0 so just set bits to 0 */ + reg &= ~OPT4001_CTRL_OPER_MODE_MASK; + + ret = regmap_write(chip->regmap, OPT4001_CTRL, reg); + if (ret) + dev_err(dev, "Failed to set configuration to power down\n"); + + return ret; +} + +static void opt4001_chip_off_action(void *data) +{ + struct opt4001_chip *chip = data; + + opt4001_power_down(chip); +} + +static const struct iio_chan_spec opt4001_channels[] = { + { + .type = IIO_LIGHT, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) + }, +}; + +static int opt4001_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct opt4001_chip *chip = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + return opt4001_read_lux_value(indio_dev, val, val2); + case IIO_CHAN_INFO_INT_TIME: + *val = 0; + *val2 = opt4001_int_time_reg[chip->int_time][0]; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } +} + +static int opt4001_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct opt4001_chip *chip = iio_priv(indio_dev); + int int_time; + + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + int_time = opt4001_als_time_to_index(val2); + if (int_time < 0) + return int_time; + chip->int_time = int_time; + return opt4001_set_conf(chip); + default: + return -EINVAL; + } +} + +static int opt4001_read_available(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + *length = ARRAY_SIZE(opt4001_int_time_available) * 2; + *vals = (const int *)opt4001_int_time_available; + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + + default: + return -EINVAL; + } +} + +static const struct iio_info opt4001_info_no_irq = { + .read_raw = opt4001_read_raw, + .write_raw = opt4001_write_raw, + .read_avail = opt4001_read_available, +}; + +static int opt4001_load_defaults(struct opt4001_chip *chip) +{ + chip->int_time = OPT4001_DEFAULT_CONVERSION_TIME; + + return opt4001_set_conf(chip); +} + +static bool opt4001_readable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case OPT4001_LIGHT1_MSB: + case OPT4001_LIGHT1_LSB: + case OPT4001_CTRL: + case OPT4001_DEVICE_ID: + return true; + default: + return false; + } +} + +static bool opt4001_writable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case OPT4001_CTRL: + return true; + default: + return false; + } +} + +static bool opt4001_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case OPT4001_LIGHT1_MSB: + case OPT4001_LIGHT1_LSB: + return true; + default: + return false; + } +} + +static const struct regmap_config opt4001_regmap_config = { + .name = "opt4001", + .reg_bits = 8, + .val_bits = 16, + .cache_type = REGCACHE_RBTREE, + .max_register = OPT4001_DEVICE_ID, + .readable_reg = opt4001_readable_reg, + .writeable_reg = opt4001_writable_reg, + .volatile_reg = opt4001_volatile_reg, + .val_format_endian = REGMAP_ENDIAN_BIG, +}; + +static int opt4001_probe(struct i2c_client *client) +{ + struct opt4001_chip *chip; + struct iio_dev *indio_dev; + int ret; + uint dev_id; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); + if (!indio_dev) + return -ENOMEM; + + chip = iio_priv(indio_dev); + + ret = devm_regulator_get_enable(&client->dev, "vdd"); + if (ret) + return dev_err_probe(&client->dev, ret, "Failed to enable vdd supply\n"); + + chip->regmap = devm_regmap_init_i2c(client, &opt4001_regmap_config); + if (IS_ERR(chip->regmap)) + return dev_err_probe(&client->dev, PTR_ERR(chip->regmap), + "regmap initialization failed\n"); + chip->client = client; + + indio_dev->info = &opt4001_info_no_irq; + + ret = regmap_reinit_cache(chip->regmap, &opt4001_regmap_config); + if (ret) + return dev_err_probe(&client->dev, ret, + "failed to reinit regmap cache\n"); + + ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, &dev_id); + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "Failed to read the device ID register\n"); + + dev_id = FIELD_GET(OPT4001_DEVICE_ID_MASK, dev_id); + if (dev_id != OPT4001_DEVICE_ID_VAL) + dev_warn(&client->dev, "Device ID: %#04x unknown\n", dev_id); + + chip->chip_info = device_get_match_data(&client->dev); + + indio_dev->channels = opt4001_channels; + indio_dev->num_channels = ARRAY_SIZE(opt4001_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->name = chip->chip_info->name; + + ret = opt4001_load_defaults(chip); + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "Failed to set sensor defaults\n"); + + ret = devm_add_action_or_reset(&client->dev, + opt4001_chip_off_action, + chip); + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "Failed to setup power off action\n"); + + return devm_iio_device_register(&client->dev, indio_dev); +} + +/* + * The compatible string determines which constants to use depending on + * opt4001 packaging + */ +static const struct i2c_device_id opt4001_id[] = { + { "opt4001-sot-5x3", (kernel_ulong_t)&opt4001_sot_5x3_info }, + { "opt4001-picostar", (kernel_ulong_t)&opt4001_picostar_info }, + { } +}; +MODULE_DEVICE_TABLE(i2c, opt4001_id); + +static const struct of_device_id opt4001_of_match[] = { + { .compatible = "ti,opt4001-sot-5x3", .data = &opt4001_sot_5x3_info}, + { .compatible = "ti,opt4001-picostar", .data = &opt4001_picostar_info}, + {} +}; +MODULE_DEVICE_TABLE(of, opt4001_of_match); + +static struct i2c_driver opt4001_driver = { + .driver = { + .name = "opt4001", + .of_match_table = opt4001_of_match, + }, + .probe_new = opt4001_probe, + .id_table = opt4001_id, +}; +module_i2c_driver(opt4001_driver); + +MODULE_AUTHOR("Stefan Windfeldt-Prytz "); +MODULE_DESCRIPTION("Texas Instruments opt4001 ambient light sensor driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 26e46ef7758922e983a9a2f688369f649cc1a635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Thu, 16 Feb 2023 11:14:52 +0100 Subject: iio: buffer: fix coding style warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just cosmetics. No functional change intended... Signed-off-by: Nuno Sá Reviewed-by: Lars-Peter Clausen Link: https://lore.kernel.org/r/20230216101452.591805-4-nuno.sa@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 98 +++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index a7a080bed180..176d31d9f9d8 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -194,7 +194,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf, written = 0; add_wait_queue(&rb->pollq, &wait); do { - if (indio_dev->info == NULL) + if (!indio_dev->info) return -ENODEV; if (!iio_buffer_space_available(rb)) { @@ -210,7 +210,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf, } wait_woken(&wait, TASK_INTERRUPTIBLE, - MAX_SCHEDULE_TIMEOUT); + MAX_SCHEDULE_TIMEOUT); continue; } @@ -242,7 +242,7 @@ static __poll_t iio_buffer_poll(struct file *filp, struct iio_buffer *rb = ib->buffer; struct iio_dev *indio_dev = ib->indio_dev; - if (!indio_dev->info || rb == NULL) + if (!indio_dev->info || !rb) return 0; poll_wait(filp, &rb->pollq, wait); @@ -407,9 +407,9 @@ static ssize_t iio_scan_el_show(struct device *d