From patchwork Wed Dec 14 11:49:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13073012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8352C4332F for ; Wed, 14 Dec 2022 11:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238024AbiLNLtX (ORCPT ); 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 ); 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 To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen 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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 --- 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(-) 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); From patchwork Wed Dec 14 11:49:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13073013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F3DC4167B for ; Wed, 14 Dec 2022 11:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238010AbiLNLtX (ORCPT ); Wed, 14 Dec 2022 06:49:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238006AbiLNLtW (ORCPT ); Wed, 14 Dec 2022 06:49:22 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC9D63AF; 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:in-reply-to: references:mime-version:content-transfer-encoding; bh=r188qz47hPmbr6r5XbBcOdNISw/RCExFeHfQbTTAWVA=; b=bmpIVk2hvGOz9ftiG/2sp3uVh3GtvtHNR1aQv7JB1Dtub5ukUtvuDkKo X8/oHGH14orY9Y8cdCvLn1MfpPdgXBsmFJJ4vsNbeuqqr+WFA7CMaaxkg urHHtPyWDEPf7u3pgnl2drSXrUW/mVLyfbKSJPE5A+nbPAKIVnHrF+J7b apTquz1juGExfOMIIO5LnF0aOqg58wwacFqmUATnMOKuvNudjOR5ViKtO JisVr9CwJutOHXUA/JYwo4q+1QkZg73ISTBco+Uv1zAvk/jOExJ34J4VW XPdQaYTm61Uxy0MkyMHGDhpJQn54/tg5u+3jLZe1pEGKJbAG/c7ajRg8R Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="316017144" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="316017144" 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="977805631" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="977805631" 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 5189BF4; Wed, 14 Dec 2022 13:49:48 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 2/2] iio: adc: ti-adc128s052: Drop anti-pattern of ACPI_PTR() use Date: Wed, 14 Dec 2022 13:49:44 +0200 Message-Id: <20221214114944.83790-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221214114944.83790-1-andriy.shevchenko@linux.intel.com> References: <20221214114944.83790-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org ACPI_PTR() is more harmful than helpful. For example, in this case if CONFIG_ACPI=n, the ID table left unused and code is obfuscated by ifdeffery. Drop anti-pattern of ACPI_PTR() use. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/ti-adc128s052.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 9dfc625100b6..fc09ee6bb174 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -9,7 +9,6 @@ * https://www.ti.com/lit/ds/symlink/adc124s021.pdf */ -#include #include #include #include @@ -201,19 +200,17 @@ static const struct spi_device_id adc128_id[] = { }; MODULE_DEVICE_TABLE(spi, adc128_id); -#ifdef CONFIG_ACPI static const struct acpi_device_id adc128_acpi_match[] = { { "AANT1280", (kernel_ulong_t)&adc128_config[2] }, { } }; MODULE_DEVICE_TABLE(acpi, adc128_acpi_match); -#endif static struct spi_driver adc128_driver = { .driver = { .name = "adc128s052", .of_match_table = adc128_of_match, - .acpi_match_table = ACPI_PTR(adc128_acpi_match), + .acpi_match_table = adc128_acpi_match, }, .probe = adc128_probe, .id_table = adc128_id,