From patchwork Sat Feb 6 09:51:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matwey V. Kornilov" X-Patchwork-Id: 12072063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BA9C433E0 for ; Sat, 6 Feb 2021 09:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A44BC64E5A for ; Sat, 6 Feb 2021 09:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbhBFJxJ (ORCPT ); Sat, 6 Feb 2021 04:53:09 -0500 Received: from lnfm1.sai.msu.ru ([93.180.26.255]:39749 "EHLO lnfm1.sai.msu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbhBFJxH (ORCPT ); Sat, 6 Feb 2021 04:53:07 -0500 Received: from dragon.sai.msu.ru (dragon.sai.msu.ru [93.180.26.172]) by lnfm1.sai.msu.ru (8.14.1/8.12.8) with ESMTP id 1169pesx029777; Sat, 6 Feb 2021 12:51:45 +0300 Received: from oak.local (unknown [83.167.113.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by dragon.sai.msu.ru (Postfix) with ESMTPSA id 807601CDFD; Sat, 6 Feb 2021 12:51:41 +0300 (MSK) From: "Matwey V. Kornilov" To: Jean Delvare , Guenter Roeck , Rob Herring , linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, "Matwey V. Kornilov" , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v4 1/4] hwmon: lm75: Add lm75 to of_match list Date: Sat, 6 Feb 2021 12:51:18 +0300 Message-Id: <20210206095121.20625-2-matwey@sai.msu.ru> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206095121.20625-1-matwey@sai.msu.ru> References: <2588ea5c-630e-6509-689d-4c8fea358e9b@roeck-us.net> <20210206095121.20625-1-matwey@sai.msu.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Currently, many boards use just 'lm75' as a compatible string. Signed-off-by: Matwey V. Kornilov --- Documentation/devicetree/bindings/hwmon/lm75.yaml | 1 + drivers/hwmon/lm75.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml index 96eed5cc7841..aec8edd1e0c6 100644 --- a/Documentation/devicetree/bindings/hwmon/lm75.yaml +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml @@ -13,6 +13,7 @@ maintainers: properties: compatible: enum: + - lm75 - adi,adt75 - dallas,ds1775 - dallas,ds75 diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index e447febd121a..08cde1c446db 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -667,6 +667,10 @@ static const struct i2c_device_id lm75_ids[] = { MODULE_DEVICE_TABLE(i2c, lm75_ids); static const struct of_device_id __maybe_unused lm75_of_match[] = { + { + .compatible = "lm75", + .data = (void *)lm75 + }, { .compatible = "adi,adt75", .data = (void *)adt75 From patchwork Sat Feb 6 09:51:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matwey V. Kornilov" X-Patchwork-Id: 12072059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6BF6C433DB for ; Sat, 6 Feb 2021 09:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EB3B64E53 for ; Sat, 6 Feb 2021 09:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbhBFJxG (ORCPT ); Sat, 6 Feb 2021 04:53:06 -0500 Received: from lnfm1.sai.msu.ru ([93.180.26.255]:39746 "EHLO lnfm1.sai.msu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbhBFJxA (ORCPT ); Sat, 6 Feb 2021 04:53:00 -0500 Received: from dragon.sai.msu.ru (dragon.sai.msu.ru [93.180.26.172]) by lnfm1.sai.msu.ru (8.14.1/8.12.8) with ESMTP id 1169pfA7029779; Sat, 6 Feb 2021 12:51:46 +0300 Received: from oak.local (unknown [83.167.113.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by dragon.sai.msu.ru (Postfix) with ESMTPSA id 9527A2CCA0; Sat, 6 Feb 2021 12:51:42 +0300 (MSK) From: "Matwey V. Kornilov" To: Jean Delvare , Guenter Roeck , Rob Herring , linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, "Matwey V. Kornilov" , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v4 2/4] hwmon: lm75: Add nxp,lm75a to of_match list Date: Sat, 6 Feb 2021 12:51:19 +0300 Message-Id: <20210206095121.20625-3-matwey@sai.msu.ru> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206095121.20625-1-matwey@sai.msu.ru> References: <2588ea5c-630e-6509-689d-4c8fea358e9b@roeck-us.net> <20210206095121.20625-1-matwey@sai.msu.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org NXP LM75A is compatible with original LM75A while it has improved 11-bit precision. https://www.nxp.com/docs/en/data-sheet/LM75A.pdf Signed-off-by: Matwey V. Kornilov --- Documentation/devicetree/bindings/hwmon/lm75.yaml | 1 + drivers/hwmon/lm75.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml index aec8edd1e0c6..8c3848f4c277 100644 --- a/Documentation/devicetree/bindings/hwmon/lm75.yaml +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml @@ -22,6 +22,7 @@ properties: - national,lm75 - national,lm75a - national,lm75b + - nxp,lm75a - maxim,max6625 - maxim,max6626 - maxim,max31725 diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 08cde1c446db..9c54c7d86771 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -33,6 +33,7 @@ enum lm75_type { /* keep sorted in alphabetical order */ lm75, lm75a, lm75b, + nxp_lm75, max6625, max6626, max31725, @@ -182,6 +183,11 @@ static const struct lm75_params device_params[] = { .default_resolution = 11, .default_sample_time = MSEC_PER_SEC / 10, }, + [nxp_lm75] = { + .default_resolution = 11, + .default_sample_time = MSEC_PER_SEC / 10, + .resolution_limits = 9, + }, [max6625] = { .default_resolution = 9, .default_sample_time = MSEC_PER_SEC / 7, @@ -644,6 +650,7 @@ static const struct i2c_device_id lm75_ids[] = { { "lm75", lm75, }, { "lm75a", lm75a, }, { "lm75b", lm75b, }, + { "nxp_lm75a", nxp_lm75, }, { "max6625", max6625, }, { "max6626", max6626, }, { "max31725", max31725, }, @@ -703,6 +710,10 @@ static const struct of_device_id __maybe_unused lm75_of_match[] = { .compatible = "national,lm75b", .data = (void *)lm75b }, + { + .compatible = "nxp,lm75a", + .data = (void *)nxp_lm75 + }, { .compatible = "maxim,max6625", .data = (void *)max6625 From patchwork Sat Feb 6 09:51:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matwey V. Kornilov" X-Patchwork-Id: 12072061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB1A2C433E6 for ; Sat, 6 Feb 2021 09:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A7C764E57 for ; Sat, 6 Feb 2021 09:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbhBFJxI (ORCPT ); Sat, 6 Feb 2021 04:53:08 -0500 Received: from lnfm1.sai.msu.ru ([93.180.26.255]:39747 "EHLO lnfm1.sai.msu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbhBFJxB (ORCPT ); Sat, 6 Feb 2021 04:53:01 -0500 Received: from dragon.sai.msu.ru (dragon.sai.msu.ru [93.180.26.172]) by lnfm1.sai.msu.ru (8.14.1/8.12.8) with ESMTP id 1169pgBO029781; Sat, 6 Feb 2021 12:51:47 +0300 Received: from oak.local (unknown [83.167.113.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by dragon.sai.msu.ru (Postfix) with ESMTPSA id 72B5A6D827; Sat, 6 Feb 2021 12:51:43 +0300 (MSK) From: "Matwey V. Kornilov" To: Jean Delvare , Guenter Roeck , Rob Herring , linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, "Matwey V. Kornilov" , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v4 3/4] hwmon: lm75: Add ti,lm75 to of_match list Date: Sat, 6 Feb 2021 12:51:20 +0300 Message-Id: <20210206095121.20625-4-matwey@sai.msu.ru> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206095121.20625-1-matwey@sai.msu.ru> References: <2588ea5c-630e-6509-689d-4c8fea358e9b@roeck-us.net> <20210206095121.20625-1-matwey@sai.msu.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Currently, armada-388-helios4.dts and nuvoton-npcm730-kudo.dts use "ti,lm75" compatible string. TI LM75A/B are compatible with original LM75A https://www.ti.com/lit/ds/symlink/lm75a.pdf https://www.ti.com/lit/ds/symlink/lm75b.pdf Signed-off-by: Matwey V. Kornilov --- Documentation/devicetree/bindings/hwmon/lm75.yaml | 1 + drivers/hwmon/lm75.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml index 8c3848f4c277..721e77ce4390 100644 --- a/Documentation/devicetree/bindings/hwmon/lm75.yaml +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml @@ -32,6 +32,7 @@ properties: - st,stds75 - st,stlm75 - microchip,tcn75 + - ti,lm75 - ti,tmp100 - ti,tmp101 - ti,tmp105 diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 9c54c7d86771..3e4374aa2f99 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -750,6 +750,10 @@ static const struct of_device_id __maybe_unused lm75_of_match[] = { .compatible = "microchip,tcn75", .data = (void *)tcn75 }, + { + .compatible = "ti,lm75", + .data = (void *)lm75a + }, { .compatible = "ti,tmp100", .data = (void *)tmp100 From patchwork Sat Feb 6 09:51:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matwey V. Kornilov" X-Patchwork-Id: 12072065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95CAFC433DB for ; Sat, 6 Feb 2021 09:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 587FA64E5A for ; Sat, 6 Feb 2021 09:56:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbhBFJ4I (ORCPT ); Sat, 6 Feb 2021 04:56:08 -0500 Received: from lnfm1.sai.msu.ru ([93.180.26.255]:39770 "EHLO lnfm1.sai.msu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbhBFJ4H (ORCPT ); Sat, 6 Feb 2021 04:56:07 -0500 Received: from dragon.sai.msu.ru (dragon.sai.msu.ru [93.180.26.172]) by lnfm1.sai.msu.ru (8.14.1/8.12.8) with ESMTP id 1169ph2D029783; Sat, 6 Feb 2021 12:51:48 +0300 Received: from oak.local (unknown [83.167.113.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by dragon.sai.msu.ru (Postfix) with ESMTPSA id 348F87B645; Sat, 6 Feb 2021 12:51:44 +0300 (MSK) From: "Matwey V. Kornilov" To: Jean Delvare , Guenter Roeck , Javier Martinez Canillas , linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-kernel@vger.kernel.org (open list) Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, "Matwey V. Kornilov" Subject: [PATCH v4 4/4] hwmon: lm75: Handle broken device nodes gracefully Date: Sat, 6 Feb 2021 12:51:21 +0300 Message-Id: <20210206095121.20625-5-matwey@sai.msu.ru> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206095121.20625-1-matwey@sai.msu.ru> References: <2588ea5c-630e-6509-689d-4c8fea358e9b@roeck-us.net> <20210206095121.20625-1-matwey@sai.msu.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org There is a logical flaw in lm75_probe() function introduced in e97a45f1b460 ("hwmon: (lm75) Add OF device ID table") Note, that of_device_get_match_data() returns NULL when no match is found. This is the case when OF node exists but has unknown compatible line, while the module is still loaded via i2c detection. arch/powerpc/boot/dts/fsl/p2041rdb.dts: lm75b@48 { compatible = "nxp,lm75a"; reg = <0x48>; }; In this case, the sensor is mistakenly considered as ADT75 variant. Fixes: e97a45f1b460 ("hwmon: (lm75) Add OF device ID table") Signed-off-by: Matwey V. Kornilov --- drivers/hwmon/lm75.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 3e4374aa2f99..cd2cda4f557a 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -567,10 +567,17 @@ static int lm75_probe(struct i2c_client *client) int status, err; enum lm75_type kind; - if (client->dev.of_node) - kind = (enum lm75_type)of_device_get_match_data(&client->dev); - else + if (dev->of_node) { + const struct of_device_id *match = + of_match_device(dev->driver->of_match_table, dev); + + if (!match) + return -ENODEV; + + kind = (enum lm75_type)(match->data); + } else { kind = i2c_match_id(lm75_ids, client)->driver_data; + } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))