Message ID | 20221214114944.83790-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp166534wrn; Wed, 14 Dec 2022 03:50:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6YFkFtBq1j/ORXJLMTAHyq2bhvvngIIGEkP+0Un4KFgN20DIS6QlZ8hVaJhEVoE0DLINfn X-Received: by 2002:a05:6a20:8f14:b0:9d:efbf:6602 with SMTP id b20-20020a056a208f1400b0009defbf6602mr34565847pzk.16.1671018644336; Wed, 14 Dec 2022 03:50:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671018644; cv=none; d=google.com; s=arc-20160816; b=EKgSHdmNlT1EGKod36bKWniMDqv+3SIQiQyZg9afLddoaF9sYefKgsN4ogI4AOV05L U9Ka+QY7Kceg90S3izSoV2naL56tThlVlGKtvpztO6xKIBSlhxGDNUStQxtgy9YPyZew qgCSmyCXHkux/Tu2WRDy+njAxaJ1owqsEm3OHPvd/Aqef4TH6MFCgPNh7XS91y7QguSq B7Kpd+7MSsk4Nzxp0W7NMAQ90mme9eSmknYWk2La+JSIeZgjjhjA99C4fN0ZqHj+sWJP bM+UFH3ThT786hrFwyG7T7Cq0NOOJJZY/yaJQsZB7Qvng3CXPEv/OtKqWt86iQ5nmwGt tpIw== 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=9xkkrsWySL/Mr9t5JlwEbUAuNUz844RBRavqe7Jk314=; b=u+FATaatkP7i0Q9Q6rEKT+pqyN5XR3NvQwUkM7vSShPdLh3RAYLslp8I3BlvFbE7lR K0I51tJd3m3cBNhxVSEPr/ReeEVtDkNCKwmcXKNkI87JxYvO6LWboiiAphsMHEBSdqoc gi3QlzzaRNJAATqytUksRrqdyrHj3sfi7mAhDQrsnrxLFspF1LZ0IrK2++X/dO/hMo5H jwNuEkIBn7+EA8y1UgWJwm3dgN9yLRTzFHHNDAavFWikTCqyxqilas7f6VhNdobUfyiS 2DHM3ruZKLz5LYJHPyPCKwqIO3OE/n6ju0wjEIzm3lD4pLTCDNNnneQV3lmdYL4CkYRJ wQVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LVVlYe+8; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w126-20020a636284000000b0045d1aa2a589si15181641pgb.840.2022.12.14.03.50.29; Wed, 14 Dec 2022 03:50:44 -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=@intel.com header.s=Intel header.b=LVVlYe+8; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238078AbiLNLtX (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Wed, 14 Dec 2022 06:49:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiLNLtV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Dec 2022 06:49:21 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21A94313; Wed, 14 Dec 2022 03:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671018561; x=1702554561; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SVgFMAfjfuxrKEN25v+tJjLoBKU5Ql7lsjAKQ0yd+gs=; b=LVVlYe+8uTnb+ltN+WI8PNlXeO7OuaAwtQYpLhXRzdiS2JvWZ8clAo+J aAITRJUzzoAzf60+dYZqlFf84RWh5K6Y64JElWo43q8E+bnCK5R0mpLVO RBy931XLUdG2NcEEMFw0kwxgHs4EvzueruwgF65DwzsU3U+R5XXyKXKnt zoD7kNAJGo31Mn6HK2hYJIV5OrO8V1fnG+cVUt+TyRxt31hTKBirHQOcX tjJeUw8YEacY7kwan3uofGDDa/RRYSQQgjPRCOJCVnXeLnlaPjlmNgiNq 0FM+Ow8HIePM6oi1ni5oS7BGD5J9qS/O2X8L3VWq2W+v4/4fJnnd8KSCx A==; X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="316017147" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="316017147" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2022 03:49:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="977805633" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="977805633" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 14 Dec 2022 03:49:19 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 46BA5F7; Wed, 14 Dec 2022 13:49:48 +0200 (EET) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de> Subject: [PATCH v1 1/2] iio: adc: ti-adc128s052: Switch to use spi_get_device_match_data() Date: Wed, 14 Dec 2022 13:49:43 +0200 Message-Id: <20221214114944.83790-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE 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?1752190045968050149?= X-GMAIL-MSGID: =?utf-8?q?1752190045968050149?= |
Series |
[v1,1/2] iio: adc: ti-adc128s052: Switch to use spi_get_device_match_data()
|
|
Commit Message
Andy Shevchenko
Dec. 14, 2022, 11:49 a.m. UTC
The spi_get_device_match_data() helps to get driver data from the
firmware node or SPI ID table. Use it instead of open coding.
While at it, switch ID tables to provide an acrual pointers to
the configuration data.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Requires aea672d054a2 ("spi: Introduce spi_get_device_match_data()
helper") which is part of upstream as of today.
drivers/iio/adc/ti-adc128s052.c | 39 +++++++++++++++------------------
1 file changed, 18 insertions(+), 21 deletions(-)
Comments
Hi Andy, I love your patch! Perhaps something to improve: [auto build test WARNING on jic23-iio/togreg] [also build test WARNING on next-20221214] [cannot apply to linus/master v6.1] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/iio-adc-ti-adc128s052-Switch-to-use-spi_get_device_match_data/20221214-195107 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20221214114944.83790-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 1/2] iio: adc: ti-adc128s052: Switch to use spi_get_device_match_data() config: ia64-allyesconfig compiler: ia64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/bcf5eb0a92b2364ddde0d61a772ae31f2fbc4dae git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/iio-adc-ti-adc128s052-Switch-to-use-spi_get_device_match_data/20221214-195107 git checkout bcf5eb0a92b2364ddde0d61a772ae31f2fbc4dae # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/iio/adc/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/iio/adc/ti-adc128s052.c: In function 'adc128_probe': drivers/iio/adc/ti-adc128s052.c:158:18: error: implicit declaration of function 'spi_get_device_match_data'; did you mean 'spi_get_device_id'? [-Werror=implicit-function-declaration] 158 | config = spi_get_device_match_data(&spi->dev); | ^~~~~~~~~~~~~~~~~~~~~~~~~ | spi_get_device_id >> drivers/iio/adc/ti-adc128s052.c:158:16: warning: assignment to 'const struct adc128_configuration *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 158 | config = spi_get_device_match_data(&spi->dev); | ^ drivers/iio/adc/ti-adc128s052.c:160:44: error: array subscript is not an integer 160 | indio_dev->channels = adc128_config[config].channels; | ^ drivers/iio/adc/ti-adc128s052.c:161:48: error: array subscript is not an integer 161 | indio_dev->num_channels = adc128_config[config].num_channels; | ^ >> drivers/iio/adc/ti-adc128s052.c:142:44: warning: variable 'config' set but not used [-Wunused-but-set-variable] 142 | const struct adc128_configuration *config; | ^~~~~~ cc1: some warnings being treated as errors vim +158 drivers/iio/adc/ti-adc128s052.c 139 140 static int adc128_probe(struct spi_device *spi) 141 { > 142 const struct adc128_configuration *config; 143 struct iio_dev *indio_dev; 144 struct adc128 *adc; 145 int ret; 146 147 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); 148 if (!indio_dev) 149 return -ENOMEM; 150 151 adc = iio_priv(indio_dev); 152 adc->spi = spi; 153 154 indio_dev->name = spi_get_device_id(spi)->name; 155 indio_dev->modes = INDIO_DIRECT_MODE; 156 indio_dev->info = &adc128_info; 157 > 158 config = spi_get_device_match_data(&spi->dev); 159 160 indio_dev->channels = adc128_config[config].channels; 161 indio_dev->num_channels = adc128_config[config].num_channels; 162 163 adc->reg = devm_regulator_get(&spi->dev, "vref"); 164 if (IS_ERR(adc->reg)) 165 return PTR_ERR(adc->reg); 166 167 ret = regulator_enable(adc->reg); 168 if (ret < 0) 169 return ret; 170 ret = devm_add_action_or_reset(&spi->dev, adc128_disable_regulator, 171 adc->reg); 172 if (ret) 173 return ret; 174 175 mutex_init(&adc->lock); 176 177 return devm_iio_device_register(&spi->dev, indio_dev); 178 } 179
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on jic23-iio/togreg] [also build test ERROR on next-20221214] [cannot apply to linus/master v6.1] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/iio-adc-ti-adc128s052-Switch-to-use-spi_get_device_match_data/20221214-195107 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20221214114944.83790-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 1/2] iio: adc: ti-adc128s052: Switch to use spi_get_device_match_data() config: i386-randconfig-a002 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/bcf5eb0a92b2364ddde0d61a772ae31f2fbc4dae git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/iio-adc-ti-adc128s052-Switch-to-use-spi_get_device_match_data/20221214-195107 git checkout bcf5eb0a92b2364ddde0d61a772ae31f2fbc4dae # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/iio/adc/ti-adc128s052.c:158:11: error: implicit declaration of function 'spi_get_device_match_data' is invalid in C99 [-Werror,-Wimplicit-function-declaration] config = spi_get_device_match_data(&spi->dev); ^ drivers/iio/adc/ti-adc128s052.c:158:9: warning: incompatible integer to pointer conversion assigning to 'const struct adc128_configuration *' from 'int' [-Wint-conversion] config = spi_get_device_match_data(&spi->dev); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/iio/adc/ti-adc128s052.c:160:37: error: array subscript is not an integer indio_dev->channels = adc128_config[config].channels; ^~~~~~~ drivers/iio/adc/ti-adc128s052.c:161:41: error: array subscript is not an integer indio_dev->num_channels = adc128_config[config].num_channels; ^~~~~~~ 1 warning and 3 errors generated. vim +/spi_get_device_match_data +158 drivers/iio/adc/ti-adc128s052.c 139 140 static int adc128_probe(struct spi_device *spi) 141 { 142 const struct adc128_configuration *config; 143 struct iio_dev *indio_dev; 144 struct adc128 *adc; 145 int ret; 146 147 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); 148 if (!indio_dev) 149 return -ENOMEM; 150 151 adc = iio_priv(indio_dev); 152 adc->spi = spi; 153 154 indio_dev->name = spi_get_device_id(spi)->name; 155 indio_dev->modes = INDIO_DIRECT_MODE; 156 indio_dev->info = &adc128_info; 157 > 158 config = spi_get_device_match_data(&spi->dev); 159 > 160 indio_dev->channels = adc128_config[config].channels; 161 indio_dev->num_channels = adc128_config[config].num_channels; 162 163 adc->reg = devm_regulator_get(&spi->dev, "vref"); 164 if (IS_ERR(adc->reg)) 165 return PTR_ERR(adc->reg); 166 167 ret = regulator_enable(adc->reg); 168 if (ret < 0) 169 return ret; 170 ret = devm_add_action_or_reset(&spi->dev, adc128_disable_regulator, 171 adc->reg); 172 if (ret) 173 return ret; 174 175 mutex_init(&adc->lock); 176 177 return devm_iio_device_register(&spi->dev, indio_dev); 178 } 179
On Wed, 14 Dec 2022 13:49:43 +0200 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > The spi_get_device_match_data() helps to get driver data from the > firmware node or SPI ID table. Use it instead of open coding. > > While at it, switch ID tables to provide an acrual pointers to > the configuration data. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > > Requires aea672d054a2 ("spi: Introduce spi_get_device_match_data() > helper") which is part of upstream as of today. I rebased to get that (will rebase again on rc1). Applied to the togreg branch of iio.git and pushed out as testing to keep 0-day busy over my holidays. Jonathan > > drivers/iio/adc/ti-adc128s052.c | 39 +++++++++++++++------------------ > 1 file changed, 18 insertions(+), 21 deletions(-) > > diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c > index b3d5b9b7255b..9dfc625100b6 100644 > --- a/drivers/iio/adc/ti-adc128s052.c > +++ b/drivers/iio/adc/ti-adc128s052.c > @@ -139,16 +139,11 @@ static void adc128_disable_regulator(void *reg) > > static int adc128_probe(struct spi_device *spi) > { > + const struct adc128_configuration *config; > struct iio_dev *indio_dev; > - unsigned int config; > struct adc128 *adc; > int ret; > > - if (dev_fwnode(&spi->dev)) > - config = (unsigned long) device_get_match_data(&spi->dev); > - else > - config = spi_get_device_id(spi)->driver_data; > - > indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); > if (!indio_dev) > return -ENOMEM; > @@ -160,6 +155,8 @@ static int adc128_probe(struct spi_device *spi) > indio_dev->modes = INDIO_DIRECT_MODE; > indio_dev->info = &adc128_info; > > + config = spi_get_device_match_data(&spi->dev); > + > indio_dev->channels = adc128_config[config].channels; > indio_dev->num_channels = adc128_config[config].num_channels; > > @@ -181,32 +178,32 @@ static int adc128_probe(struct spi_device *spi) > } > > static const struct of_device_id adc128_of_match[] = { > - { .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, }, > + { .compatible = "ti,adc128s052", .data = &adc128_config[0] }, > + { .compatible = "ti,adc122s021", .data = &adc128_config[1] }, > + { .compatible = "ti,adc122s051", .data = &adc128_config[1] }, > + { .compatible = "ti,adc122s101", .data = &adc128_config[1] }, > + { .compatible = "ti,adc124s021", .data = &adc128_config[2] }, > + { .compatible = "ti,adc124s051", .data = &adc128_config[2] }, > + { .compatible = "ti,adc124s101", .data = &adc128_config[2] }, > { /* sentinel */ }, > }; > MODULE_DEVICE_TABLE(of, adc128_of_match); > > static const struct spi_device_id adc128_id[] = { > - { "adc128s052", 0 }, /* index into adc128_config */ > - { "adc122s021", 1 }, > - { "adc122s051", 1 }, > - { "adc122s101", 1 }, > - { "adc124s021", 2 }, > - { "adc124s051", 2 }, > - { "adc124s101", 2 }, > + { "adc128s052", (kernel_ulong_t)&adc128_config[0] }, > + { "adc122s021", (kernel_ulong_t)&adc128_config[1] }, > + { "adc122s051", (kernel_ulong_t)&adc128_config[1] }, > + { "adc122s101", (kernel_ulong_t)&adc128_config[1] }, > + { "adc124s021", (kernel_ulong_t)&adc128_config[2] }, > + { "adc124s051", (kernel_ulong_t)&adc128_config[2] }, > + { "adc124s101", (kernel_ulong_t)&adc128_config[2] }, > { } > }; > MODULE_DEVICE_TABLE(spi, adc128_id); > > #ifdef CONFIG_ACPI > static const struct acpi_device_id adc128_acpi_match[] = { > - { "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */ > + { "AANT1280", (kernel_ulong_t)&adc128_config[2] }, > { } > }; > MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
On Fri, 23 Dec 2022 15:22:42 +0000 Jonathan Cameron <jic23@kernel.org> wrote: > On Wed, 14 Dec 2022 13:49:43 +0200 > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > > The spi_get_device_match_data() helps to get driver data from the > > firmware node or SPI ID table. Use it instead of open coding. > > > > While at it, switch ID tables to provide an acrual pointers to > > the configuration data. > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > --- > > > > Requires aea672d054a2 ("spi: Introduce spi_get_device_match_data() > > helper") which is part of upstream as of today. > > I rebased to get that (will rebase again on rc1). > > Applied to the togreg branch of iio.git and pushed out as testing > to keep 0-day busy over my holidays. I take it back... Build test failed... > > Jonathan > > > > > drivers/iio/adc/ti-adc128s052.c | 39 +++++++++++++++------------------ > > 1 file changed, 18 insertions(+), 21 deletions(-) > > > > diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c > > index b3d5b9b7255b..9dfc625100b6 100644 > > --- a/drivers/iio/adc/ti-adc128s052.c > > +++ b/drivers/iio/adc/ti-adc128s052.c > > @@ -139,16 +139,11 @@ static void adc128_disable_regulator(void *reg) > > > > static int adc128_probe(struct spi_device *spi) > > { > > + const struct adc128_configuration *config; > > struct iio_dev *indio_dev; > > - unsigned int config; > > struct adc128 *adc; > > int ret; > > > > - if (dev_fwnode(&spi->dev)) > > - config = (unsigned long) device_get_match_data(&spi->dev); > > - else > > - config = spi_get_device_id(spi)->driver_data; > > - > > indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); > > if (!indio_dev) > > return -ENOMEM; > > @@ -160,6 +155,8 @@ static int adc128_probe(struct spi_device *spi) > > indio_dev->modes = INDIO_DIRECT_MODE; > > indio_dev->info = &adc128_info; > > > > + config = spi_get_device_match_data(&spi->dev); Takes a struct spi_device* Also, having opened code up to fix this, we have a spi_get_device_id() left just above that needs dealing with. And a lot of uses of config below that need fixing. I'm dropping this series until that's all fixed up. Jonathan > > + > > indio_dev->channels = adc128_config[config].channels; > > indio_dev->num_channels = adc128_config[config].num_channels; > > > > @@ -181,32 +178,32 @@ static int adc128_probe(struct spi_device *spi) > > } > > > > static const struct of_device_id adc128_of_match[] = { > > - { .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, }, > > + { .compatible = "ti,adc128s052", .data = &adc128_config[0] }, > > + { .compatible = "ti,adc122s021", .data = &adc128_config[1] }, > > + { .compatible = "ti,adc122s051", .data = &adc128_config[1] }, > > + { .compatible = "ti,adc122s101", .data = &adc128_config[1] }, > > + { .compatible = "ti,adc124s021", .data = &adc128_config[2] }, > > + { .compatible = "ti,adc124s051", .data = &adc128_config[2] }, > > + { .compatible = "ti,adc124s101", .data = &adc128_config[2] }, > > { /* sentinel */ }, > > }; > > MODULE_DEVICE_TABLE(of, adc128_of_match); > > > > static const struct spi_device_id adc128_id[] = { > > - { "adc128s052", 0 }, /* index into adc128_config */ > > - { "adc122s021", 1 }, > > - { "adc122s051", 1 }, > > - { "adc122s101", 1 }, > > - { "adc124s021", 2 }, > > - { "adc124s051", 2 }, > > - { "adc124s101", 2 }, > > + { "adc128s052", (kernel_ulong_t)&adc128_config[0] }, > > + { "adc122s021", (kernel_ulong_t)&adc128_config[1] }, > > + { "adc122s051", (kernel_ulong_t)&adc128_config[1] }, > > + { "adc122s101", (kernel_ulong_t)&adc128_config[1] }, > > + { "adc124s021", (kernel_ulong_t)&adc128_config[2] }, > > + { "adc124s051", (kernel_ulong_t)&adc128_config[2] }, > > + { "adc124s101", (kernel_ulong_t)&adc128_config[2] }, > > { } > > }; > > MODULE_DEVICE_TABLE(spi, adc128_id); > > > > #ifdef CONFIG_ACPI > > static const struct acpi_device_id adc128_acpi_match[] = { > > - { "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */ > > + { "AANT1280", (kernel_ulong_t)&adc128_config[2] }, > > { } > > }; > > MODULE_DEVICE_TABLE(acpi, adc128_acpi_match); >
On Fri, Dec 23, 2022 at 03:44:50PM +0000, Jonathan Cameron wrote: > On Fri, 23 Dec 2022 15:22:42 +0000 > Jonathan Cameron <jic23@kernel.org> wrote: > > > On Wed, 14 Dec 2022 13:49:43 +0200 > > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > > > > The spi_get_device_match_data() helps to get driver data from the > > > firmware node or SPI ID table. Use it instead of open coding. > > > > > > While at it, switch ID tables to provide an acrual pointers to > > > the configuration data. > > > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > > --- > > > > > > Requires aea672d054a2 ("spi: Introduce spi_get_device_match_data() > > > helper") which is part of upstream as of today. > > > > I rebased to get that (will rebase again on rc1). > > > > Applied to the togreg branch of iio.git and pushed out as testing > > to keep 0-day busy over my holidays. > > I take it back... Build test failed... As comment on the first patch stays this requires an SPI core patch, which is now the part of the v6.2-rc1. Can you reapply it taking the above into consideration?
On Wed, 28 Dec 2022 11:59:53 +0200 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > On Fri, Dec 23, 2022 at 03:44:50PM +0000, Jonathan Cameron wrote: > > On Fri, 23 Dec 2022 15:22:42 +0000 > > Jonathan Cameron <jic23@kernel.org> wrote: > > > > > On Wed, 14 Dec 2022 13:49:43 +0200 > > > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > > > > > > The spi_get_device_match_data() helps to get driver data from the > > > > firmware node or SPI ID table. Use it instead of open coding. > > > > > > > > While at it, switch ID tables to provide an acrual pointers to > > > > the configuration data. > > > > > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > > > --- > > > > > > > > Requires aea672d054a2 ("spi: Introduce spi_get_device_match_data() > > > > helper") which is part of upstream as of today. > > > > > > I rebased to get that (will rebase again on rc1). > > > > > > Applied to the togreg branch of iio.git and pushed out as testing > > > to keep 0-day busy over my holidays. > > > > I take it back... Build test failed... > > As comment on the first patch stays this requires an SPI core patch, which is > now the part of the v6.2-rc1. > > Can you reapply it taking the above into consideration? > I should have been more specific though I do mention rebasing to get the patch above.. Doesn't build with it. Signature of spi_get_device_match_data is: extern const void * spi_get_device_match_data(const struct spi_device *sdev); and you are passing it a struct device * which rather implies you didn't successfully build test this. Jonathan
On Sat, Dec 31, 2022 at 02:45:58PM +0000, Jonathan Cameron wrote: > On Wed, 28 Dec 2022 11:59:53 +0200 > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: ... > I should have been more specific though I do mention rebasing to get the > patch above.. Doesn't build with it. > > Signature of spi_get_device_match_data is: > extern const void * > spi_get_device_match_data(const struct spi_device *sdev); > > and you are passing it a struct device * which rather implies you didn't > successfully build test this. Definitely. Thanks for spotting this, I'll investigate what happened on my side that it wasn't built.
diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index b3d5b9b7255b..9dfc625100b6 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -139,16 +139,11 @@ static void adc128_disable_regulator(void *reg) static int adc128_probe(struct spi_device *spi) { + const struct adc128_configuration *config; struct iio_dev *indio_dev; - unsigned int config; struct adc128 *adc; int ret; - if (dev_fwnode(&spi->dev)) - config = (unsigned long) device_get_match_data(&spi->dev); - else - config = spi_get_device_id(spi)->driver_data; - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); if (!indio_dev) return -ENOMEM; @@ -160,6 +155,8 @@ static int adc128_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &adc128_info; + config = spi_get_device_match_data(&spi->dev); + indio_dev->channels = adc128_config[config].channels; indio_dev->num_channels = adc128_config[config].num_channels; @@ -181,32 +178,32 @@ static int adc128_probe(struct spi_device *spi) } static const struct of_device_id adc128_of_match[] = { - { .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, }, + { .compatible = "ti,adc128s052", .data = &adc128_config[0] }, + { .compatible = "ti,adc122s021", .data = &adc128_config[1] }, + { .compatible = "ti,adc122s051", .data = &adc128_config[1] }, + { .compatible = "ti,adc122s101", .data = &adc128_config[1] }, + { .compatible = "ti,adc124s021", .data = &adc128_config[2] }, + { .compatible = "ti,adc124s051", .data = &adc128_config[2] }, + { .compatible = "ti,adc124s101", .data = &adc128_config[2] }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, adc128_of_match); static const struct spi_device_id adc128_id[] = { - { "adc128s052", 0 }, /* index into adc128_config */ - { "adc122s021", 1 }, - { "adc122s051", 1 }, - { "adc122s101", 1 }, - { "adc124s021", 2 }, - { "adc124s051", 2 }, - { "adc124s101", 2 }, + { "adc128s052", (kernel_ulong_t)&adc128_config[0] }, + { "adc122s021", (kernel_ulong_t)&adc128_config[1] }, + { "adc122s051", (kernel_ulong_t)&adc128_config[1] }, + { "adc122s101", (kernel_ulong_t)&adc128_config[1] }, + { "adc124s021", (kernel_ulong_t)&adc128_config[2] }, + { "adc124s051", (kernel_ulong_t)&adc128_config[2] }, + { "adc124s101", (kernel_ulong_t)&adc128_config[2] }, { } }; MODULE_DEVICE_TABLE(spi, adc128_id); #ifdef CONFIG_ACPI static const struct acpi_device_id adc128_acpi_match[] = { - { "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */ + { "AANT1280", (kernel_ulong_t)&adc128_config[2] }, { } }; MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);