Message ID | 20221115132324.1078169-1-linux@rasmusvillemoes.dk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2728052wru; Tue, 15 Nov 2022 05:31:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7k9u/+DZhFVbeQ9hpJPJGmijXY8BhCHaIHf1WQsUZs0s9/4aHsDD6+2yPjKzPdwxMXtHlb X-Received: by 2002:a63:ce04:0:b0:46b:2493:14ad with SMTP id y4-20020a63ce04000000b0046b249314admr16233423pgf.274.1668519059847; Tue, 15 Nov 2022 05:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668519059; cv=none; d=google.com; s=arc-20160816; b=YYBZ1Xz/IvfyxDs0+WhQlyXbYMLHbW0jHBaCnEnusV5FBJw2QAg+QPy/+/OKBMOw4b k1V6GKipoy+7OTC948zqet74ZEgB/kb6ArZXu/thmbRGoxyCcJ+BiCyVvaLVh5ltjbsa QXZK0elovrxSEzlEeOdliKK46i7j4sdYpByZ1HSaXWbKH0fFjT/Xj7E3dNRv7zyEF2lB 5SxWzTBb1FhRhYZs2YbhmUx4QZO34UTPyq3AWQj6gfqMPFCDKOuS+bPzMr+V0FhsQFV+ Oe9K+DilwbrNnFsQ+zTeRhoxTmphhImAZ7c7cHdyEtovcCUBgGklmxaXwv6kdp/ssr0D r1SQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=gjy2+mpCjTP8mfHF1OGdgEun8TSro32Otc7xp3Fdvvs=; b=yU3UQd/5ncB6yhy1htn7P255b1zwHLHHPx3mIDL6VqzuRejVNasf6xc5vPwE/EtOHC mp632t67BNQkCV7nW9qHtMionYJZnEiwhAMHp8ykiFYOcKdG91jSCnYIsyODEpkgcCna suo96stqamWJETRQyWMYLcDIwr/5O5/KcT58mSI2KEVYuMR4y/05CdrgCeXnhyLUwCQv SXEoa46JtelPwcwjgmV4MD8SftudafFrj2TVZ2huJISBf0DIsq3NA1aQXOWiBp9V7YM8 bOGm3IvKoNR6riGjTxb16b2PCWLOFZwMFqV1pW8j7NB53TPTDJyECFnKCcIMZuDSyHtV m+3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=SmwV9Cav; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p3-20020a170902e74300b00186ba4ba494si13433302plf.475.2022.11.15.05.30.46; Tue, 15 Nov 2022 05:30:59 -0800 (PST) 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=@rasmusvillemoes.dk header.s=google header.b=SmwV9Cav; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbiKONXf (ORCPT <rfc822;lkml4gm@gmail.com> + 99 others); Tue, 15 Nov 2022 08:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbiKONXe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 08:23:34 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E7CA5580 for <linux-kernel@vger.kernel.org>; Tue, 15 Nov 2022 05:23:32 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id be13so24400399lfb.4 for <linux-kernel@vger.kernel.org>; Tue, 15 Nov 2022 05:23:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gjy2+mpCjTP8mfHF1OGdgEun8TSro32Otc7xp3Fdvvs=; b=SmwV9CavWzAy5Xmpu8rbzU1RZqIJydT/n2irp88TN3z08Rpnl2sogkyE/0tfmepVae mFC8myPhZBFP/+teKFyk9lsRPqxC4AnTQZTjFzBPzFXyNwJxWoAicRGBfrYtvC9dqU9h /dDDqs+LXSxzuXgegsArT7EDlYQlCdJN6y31I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gjy2+mpCjTP8mfHF1OGdgEun8TSro32Otc7xp3Fdvvs=; b=Opv5jHTk3hjhe8DR3Tj3sxvm3Qd9pJ/iWvhHQjbofluOaEWUzUWhFrJ7WUZvLOzxMQ SAobS7yVuSoPGADMMxynTtLpbwWsh5/+ut/tFDc/qchjKUBSZwt/FtOdER5uCWBxYJ8W SvovGASE1xcP4DSvbE6aLcVK5WutrGsAeI0whCJGGcebmMy4F96l9g4bnySMMDG4+wVL mbeSabWgtLUP4PHhujvPzD2XPkigxpX64Zy/OmHN24m66h/iYVvumSuc4XKfJRWBLMPo yjfgaK9rN9s050jl5Kry3p53hMCoSK8OX2wytv2vzeJwsjdqB6MJ/MywDrA+J3uZWWn6 3etw== X-Gm-Message-State: ANoB5pmKlVC1bSes89+1V9ZvV2NhBkex4fAa0u2O1t0ZjKdZ43vM4V2E oabrp7zXcjF/ebdGxgMmDCdWFw== X-Received: by 2002:ac2:48b4:0:b0:497:ca2:4e74 with SMTP id u20-20020ac248b4000000b004970ca24e74mr5918104lfg.488.1668518610588; Tue, 15 Nov 2022 05:23:30 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id s13-20020a05651c048d00b0026fc79fd67dsm2503482ljc.74.2022.11.15.05.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 05:23:29 -0800 (PST) From: Rasmus Villemoes <linux@rasmusvillemoes.dk> To: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Javier Arteaga <javier@emutex.com>, "Dan O'Donovan" <dan@emutex.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Nicola Lunghi <nicola.lunghi@emutex.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>, Jonathan Cameron <Jonathan.Cameron@huawei.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table Date: Tue, 15 Nov 2022 14:23:23 +0100 Message-Id: <20221115132324.1078169-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1749569041413038834?= X-GMAIL-MSGID: =?utf-8?q?1749569041413038834?= |
Series |
iio: adc128s052: add proper .data members in adc128_of_match table
|
|
Commit Message
Rasmus Villemoes
Nov. 15, 2022, 1:23 p.m. UTC
Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID
AANT1280"), the driver unconditionally used spi_get_device_id() to get
the index into the adc128_config array.
However, with that commit, OF-based boards now incorrectly treat all
supported sensors as if they are an adc128s052, because all the .data
members of the adc128_of_match table are implicitly 0. Our board,
which has an adc122s021, thus exposes 8 channels whereas it really
only has two.
Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280")
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
I think the driver could be simplified somewhat by having just one
single adc_channels[] array with the 8 entries, unconditionally use
that as ->channels, with ->num_channels being taken from the match
data instead of having this indirection through the auxiliary config
array.
But this patch is properly more suited for -stable.
drivers/iio/adc/ti-adc128s052.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Comments
On Tue, Nov 15, 2022 at 02:23:23PM +0100, Rasmus Villemoes wrote: > Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID > AANT1280"), the driver unconditionally used spi_get_device_id() to get > the index into the adc128_config array. > > However, with that commit, OF-based boards now incorrectly treat all > supported sensors as if they are an adc128s052, because all the .data > members of the adc128_of_match table are implicitly 0. Our board, > which has an adc122s021, thus exposes 8 channels whereas it really > only has two. > > Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280") > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> > --- > > I think the driver could be simplified somewhat by having just one > single adc_channels[] array with the 8 entries, unconditionally use > that as ->channels, with ->num_channels being taken from the match > data instead of having this indirection through the auxiliary config > array. Hmm... I have a patch locally that changes this to take pointers instead of numbers and using spi_get_device_match_data() (but the latter is only available in Linux Next so far). > But this patch is properly more suited for -stable. LGTM for time being Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > drivers/iio/adc/ti-adc128s052.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c > index 622fd384983c..b3d5b9b7255b 100644 > --- a/drivers/iio/adc/ti-adc128s052.c > +++ b/drivers/iio/adc/ti-adc128s052.c > @@ -181,13 +181,13 @@ static int adc128_probe(struct spi_device *spi) > } > > static const struct of_device_id adc128_of_match[] = { > - { .compatible = "ti,adc128s052", }, > - { .compatible = "ti,adc122s021", }, > - { .compatible = "ti,adc122s051", }, > - { .compatible = "ti,adc122s101", }, > - { .compatible = "ti,adc124s021", }, > - { .compatible = "ti,adc124s051", }, > - { .compatible = "ti,adc124s101", }, > + { .compatible = "ti,adc128s052", .data = (void*)0L, }, > + { .compatible = "ti,adc122s021", .data = (void*)1L, }, > + { .compatible = "ti,adc122s051", .data = (void*)1L, }, > + { .compatible = "ti,adc122s101", .data = (void*)1L, }, > + { .compatible = "ti,adc124s021", .data = (void*)2L, }, > + { .compatible = "ti,adc124s051", .data = (void*)2L, }, > + { .compatible = "ti,adc124s101", .data = (void*)2L, }, > { /* sentinel */ }, > }; > MODULE_DEVICE_TABLE(of, adc128_of_match); > -- > 2.37.2 >
On 15/11/2022 14.23, Rasmus Villemoes wrote: > Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID > AANT1280"), the driver unconditionally used spi_get_device_id() to get > the index into the adc128_config array. > > However, with that commit, OF-based boards now incorrectly treat all > supported sensors as if they are an adc128s052, because all the .data > members of the adc128_of_match table are implicitly 0. Our board, > which has an adc122s021, thus exposes 8 channels whereas it really > only has two. > > Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280") > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> > --- Ping. Any chance this could be picked up before the merge window for 6.2 opens?
On Tue, 22 Nov 2022 15:41:21 +0100 Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote: > On 15/11/2022 14.23, Rasmus Villemoes wrote: > > Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID > > AANT1280"), the driver unconditionally used spi_get_device_id() to get > > the index into the adc128_config array. > > > > However, with that commit, OF-based boards now incorrectly treat all > > supported sensors as if they are an adc128s052, because all the .data > > members of the adc128_of_match table are implicitly 0. Our board, > > which has an adc122s021, thus exposes 8 channels whereas it really > > only has two. > > > > Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280") > > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> > > --- > > Ping. Any chance this could be picked up before the merge window for 6.2 > opens? Given it is a clear fix, but for an issue that is multiple versions old (so I'm not sneaking it in post rc6).. No actual rush on this, but meh I'm queuing a bunch of other stuff that will hopefully just make it this cycle so applied to the togreg branch of iio.git and marked for stable. Thanks, Jonathan
diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 622fd384983c..b3d5b9b7255b 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -181,13 +181,13 @@ static int adc128_probe(struct spi_device *spi) } static const struct of_device_id adc128_of_match[] = { - { .compatible = "ti,adc128s052", }, - { .compatible = "ti,adc122s021", }, - { .compatible = "ti,adc122s051", }, - { .compatible = "ti,adc122s101", }, - { .compatible = "ti,adc124s021", }, - { .compatible = "ti,adc124s051", }, - { .compatible = "ti,adc124s101", }, + { .compatible = "ti,adc128s052", .data = (void*)0L, }, + { .compatible = "ti,adc122s021", .data = (void*)1L, }, + { .compatible = "ti,adc122s051", .data = (void*)1L, }, + { .compatible = "ti,adc122s101", .data = (void*)1L, }, + { .compatible = "ti,adc124s021", .data = (void*)2L, }, + { .compatible = "ti,adc124s051", .data = (void*)2L, }, + { .compatible = "ti,adc124s101", .data = (void*)2L, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, adc128_of_match);