Message ID | 20230418233656.869055-2-chris.packham@alliedtelesis.co.nz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3203764vqo; Tue, 18 Apr 2023 16:54:56 -0700 (PDT) X-Google-Smtp-Source: AKy350aeA3BL/8QylcSLRN798YMMYgzJTIWvMVm4t39DLv/V4Y+0VKjstYhQ1Hhm7KckHQ65aDHF X-Received: by 2002:a05:6a20:8e03:b0:f0:98ff:97e2 with SMTP id y3-20020a056a208e0300b000f098ff97e2mr1483322pzj.24.1681862096377; Tue, 18 Apr 2023 16:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681862096; cv=none; d=google.com; s=arc-20160816; b=F2IUAOKdjhnOCP2xdgc5VsH1t+DKH24qisDzYZiq5H8bw/Jj8sNzgV4HMVMgWc6fVn NEHITRZOqJNZpfXTcORAnyhHtJXnpjV5O+aMvffStiGy6jOgdQ1kCxMYXLI9GgrfoGOk 09Z6SGaRzWiameCTwMmUZKuK/SziaAniZgmxIa5R6A0lCujNiY0h/4Gr/253HYRiIYTF Tb0lFl+Lmzl7q9HpRQbxEUTBb2dd0h7jk/YzfW3vlpwYSMv5WowjGgrXq8dBJDbqjUEW QsbRyk0Nk+OGAPnxYAQ2hJuzO3v8oDLbvgDkTCtaQHF0U7SyhOHBtrZ8zp/eVkUVIa4g koCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y/ABsNUxwyuzEHBQbd2U/Nx2OtSkchcGJaNSSxnkzcs=; b=eCUvnSbk22Sq352gNFADbIowChR/+xhOYvKHNbTJUem7vbEg8WA/z7A28324Bvt9PD pSi0nDNkj+LF0p1zt+QeZEc/NTb8tD1/Vpk3mNEFIQ0mPyC4Ie9vmvSFUe0jV+cnJqO+ +aWh/YRDSKOVJa4gZwVgzO5EYAtHTIOfOFBNAnVI+lG6zfemeC5ebfp+hRYZY7Ek4C7Y uAAQXgvkOL2uLYyWmOVkfAQCDKAY7NSSKKaF6bYdOne2Do+R7vYfERGDLsp66pzkkFkv SSHAkEaQZoP/Qvh8Iz/+KufL4/u0c8O1KICdLtCPHnYyyEA66WVghCPjequmklF/946C jV6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=EgRuRWn7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j33-20020a634a61000000b0050fa589bc9esi14096493pgl.592.2023.04.18.16.54.40; Tue, 18 Apr 2023 16:54:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=EgRuRWn7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231431AbjDRXkT (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Tue, 18 Apr 2023 19:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231566AbjDRXj7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Apr 2023 19:39:59 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [IPv6:2001:df5:b000:5::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7ED13859 for <linux-kernel@vger.kernel.org>; Tue, 18 Apr 2023 16:37:14 -0700 (PDT) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (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 gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id B8E562C0580; Wed, 19 Apr 2023 11:37:08 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1681861028; bh=y/ABsNUxwyuzEHBQbd2U/Nx2OtSkchcGJaNSSxnkzcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EgRuRWn7Em/KG/+WMhREGjchlxiy0rfMKIzak4XBJuxs8w0qR1Y/61yZDFabUYMtd Pdojb5s4G17HJhNnXRUQMEGkEUueDb7xvWP1P+6WTMpHgElEBs/ZLzK3tal+GJav29 yZe6JjfN59AGFIS7/GrET7OEgbCbxzgmNs9Xr+Qh5YcdaDwVEebW7cN4WnD1MtmhKa mYOQGjOxdFBtPaWTqgjF2VZnBgbI9DH6Dn4CCLtyo/V+CfZOfs0WGlzLaPKltXg6Xy sFpSsp/LLRKblv61r8CsmhIWJ91oHI/lZLKMQzlDCl3qtx2bKnQ6YzjoKlSZ9T0R75 2bL7YZjWQKOpg== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id <B643f29a40001>; Wed, 19 Apr 2023 11:37:08 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 03B5E13EE4D; Wed, 19 Apr 2023 11:37:08 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 073E7283BB6; Wed, 19 Apr 2023 11:37:08 +1200 (NZST) From: Chris Packham <chris.packham@alliedtelesis.co.nz> To: jdelvare@suse.com, linux@roeck-us.net, manio@skyboo.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham <chris.packham@alliedtelesis.co.nz> Subject: [PATCH v2 1/2] hwmon: (adt7475) Use device_property APIs when configuring polarity Date: Wed, 19 Apr 2023 11:36:55 +1200 Message-Id: <20230418233656.869055-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230418233656.869055-1-chris.packham@alliedtelesis.co.nz> References: <20230418233656.869055-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SEG-SpamProfiler-Analysis: v=2.3 cv=VfuJw2h9 c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=IkcTkHD0fZMA:10 a=dKHAf1wccvYA:10 a=GF2wAtdHAAAA:8 a=i0TjTk5wKnZJQiLDsWAA:9 a=QEXdDO2ut3YA:10 a=Vv19E3DM6UNVh-gFiZZL:22 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763560229087016450?= X-GMAIL-MSGID: =?utf-8?q?1763560229087016450?= |
Series |
hwmon: (adt7475) Handle DT unaware platforms
|
|
Commit Message
Chris Packham
April 18, 2023, 11:36 p.m. UTC
On DT unaware platforms of_property_read_u32_array() returns -ENOSYS
which wasn't handled by the code treating adi,pwm-active-state as
optional. Update the code to use device_property_read_u32_array() which
deals gracefully with DT unaware platforms.
Fixes: 86da28eed4fb ("hwmon: (adt7475) Add support for inverting pwm output")
Reported-by: Mariusz Białończyk <manio@skyboo.net>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Notes:
I've not currently got access to a DT unaware platform with an ADT7475
chip so I'm not 100% sure that this will fix the problem Mariusz
reported but looking at drivers I think this approach is correct.
Changes in v2:
- use device_property_read_u32_array instead of checking for -ENOSYS
drivers/hwmon/adt7475.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Wed, Apr 19, 2023 at 11:36:55AM +1200, Chris Packham wrote: > On DT unaware platforms of_property_read_u32_array() returns -ENOSYS > which wasn't handled by the code treating adi,pwm-active-state as > optional. Update the code to use device_property_read_u32_array() which > deals gracefully with DT unaware platforms. > > Fixes: 86da28eed4fb ("hwmon: (adt7475) Add support for inverting pwm output") > Reported-by: Mariusz Białończyk <manio@skyboo.net> > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > --- > > Notes: > I've not currently got access to a DT unaware platform with an ADT7475 > chip so I'm not 100% sure that this will fix the problem Mariusz > reported but looking at drivers I think this approach is correct. > What happens if there is no such property anywhere, neither in devicetree nor in acpi ? Guenter > Changes in v2: > - use device_property_read_u32_array instead of checking for -ENOSYS > > drivers/hwmon/adt7475.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c > index 6e4c92b500b8..6a6ebcc896b1 100644 > --- a/drivers/hwmon/adt7475.c > +++ b/drivers/hwmon/adt7475.c > @@ -1604,9 +1604,9 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client) > int ret, i; > u8 val; > > - ret = of_property_read_u32_array(client->dev.of_node, > - "adi,pwm-active-state", states, > - ARRAY_SIZE(states)); > + ret = device_property_read_u32_array(&client->dev, > + "adi,pwm-active-state", states, > + ARRAY_SIZE(states)); > if (ret) > return ret; > > -- > 2.40.0 >
On Wed, Apr 19, 2023 at 11:36:55AM +1200, Chris Packham wrote: > On DT unaware platforms of_property_read_u32_array() returns -ENOSYS > which wasn't handled by the code treating adi,pwm-active-state as > optional. Update the code to use device_property_read_u32_array() which > deals gracefully with DT unaware platforms. > > Fixes: 86da28eed4fb ("hwmon: (adt7475) Add support for inverting pwm output") > Reported-by: Mariusz Białończyk <manio@skyboo.net> > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Applied. Thanks, Guenter > --- > > Notes: > I've not currently got access to a DT unaware platform with an ADT7475 > chip so I'm not 100% sure that this will fix the problem Mariusz > reported but looking at drivers I think this approach is correct. > > Changes in v2: > - use device_property_read_u32_array instead of checking for -ENOSYS > > drivers/hwmon/adt7475.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c > index 6e4c92b500b8..6a6ebcc896b1 100644 > --- a/drivers/hwmon/adt7475.c > +++ b/drivers/hwmon/adt7475.c > @@ -1604,9 +1604,9 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client) > int ret, i; > u8 val; > > - ret = of_property_read_u32_array(client->dev.of_node, > - "adi,pwm-active-state", states, > - ARRAY_SIZE(states)); > + ret = device_property_read_u32_array(&client->dev, > + "adi,pwm-active-state", states, > + ARRAY_SIZE(states)); > if (ret) > return ret; >
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 6e4c92b500b8..6a6ebcc896b1 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -1604,9 +1604,9 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client) int ret, i; u8 val; - ret = of_property_read_u32_array(client->dev.of_node, - "adi,pwm-active-state", states, - ARRAY_SIZE(states)); + ret = device_property_read_u32_array(&client->dev, + "adi,pwm-active-state", states, + ARRAY_SIZE(states)); if (ret) return ret;