From patchwork Mon Jan 2 17:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13086889 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 DFD81C4708E for ; Mon, 2 Jan 2023 17:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235935AbjABReZ (ORCPT ); Mon, 2 Jan 2023 12:34:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232634AbjABReY (ORCPT ); Mon, 2 Jan 2023 12:34:24 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD815A0; Mon, 2 Jan 2023 09:34:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672680863; x=1704216863; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MJGT5Ng6SxRubq/uFYarUZ2wwevXbyU19KA8rQmlL2U=; b=KQuYz9ODOuLPtayNqwNfI3M24KQp0XlqtWiLfpdok8JVUviHaLinaaZJ P2X7VfLY+4V1Xryc7AF14O7BosVGFfTNh3Q9e04Vx+XP3f44N6w1+R+s1 yh7rnFDFI3+ygEFFe/qHWvaJJlMdrzeUlDZKVQA2Qp2cou9SK8ca4pCwa Ua1WYRMdE9OU9C1H5HQC7GVCMi0g2UmWxT5JnTQ9ZuXoYzee98D0pKAxD G/RQKIODe4rRW8CPflwiDMdDGtGO//fVfu1iKX7S7ETLRY7iywkNiC4Dt sHbrMZDBWO8hNJWpTPWsaQkVjiz34iUiLjWShLMLA7I8B3afzZLK/+wVS g==; X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="321583641" X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="321583641" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2023 09:34:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="717862167" X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="717862167" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Jan 2023 09:34:21 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AC96C84; Mon, 2 Jan 2023 19:34:53 +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 v2 1/3] iio: adc: ti-adc128s052: Switch to use spi_get_device_match_data() Date: Mon, 2 Jan 2023 19:34:48 +0200 Message-Id: <20230102173450.29882-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230102173450.29882-1-andriy.shevchenko@linux.intel.com> References: <20230102173450.29882-1-andriy.shevchenko@linux.intel.com> 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 --- drivers/iio/adc/ti-adc128s052.c | 43 +++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index b3d5b9b7255b..4a15b6bea310 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,8 +155,10 @@ static int adc128_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &adc128_info; - indio_dev->channels = adc128_config[config].channels; - indio_dev->num_channels = adc128_config[config].num_channels; + config = spi_get_device_match_data(spi); + + indio_dev->channels = config->channels; + indio_dev->num_channels = config->num_channels; adc->reg = devm_regulator_get(&spi->dev, "vref"); if (IS_ERR(adc->reg)) @@ -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 Mon Jan 2 17:34:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13086890 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 E8736C4708D for ; Mon, 2 Jan 2023 17:34:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236085AbjABRe1 (ORCPT ); Mon, 2 Jan 2023 12:34:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234924AbjABReZ (ORCPT ); Mon, 2 Jan 2023 12:34:25 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131A3BCA; Mon, 2 Jan 2023 09:34:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672680864; x=1704216864; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SCU7ycnxB3zii0W95wguPLD/q5qBT1vuhKpdekHvQos=; b=VpCQDURFf78y1snCyVGS5MtsdFHqkBZqj2RykeK89ksYwBbU+siqYXno LI++/NZ33eWgYyOx8y5F+RsIO28HnqSJg4NMJMs73LxC2iasYK1ufWaBk Ksd6NZQw54VC8FEyt27k9r4SFWKeBOjDvxowWy73xaY4ObpaeUogATPb0 Fr6DbcC3Tr+MgkPP3rU7tZH+mUG4NHi6nSG+kWt+XtbiFioDEw5xEalMX BqBGUY12OTlsz01alBHPwRnqAlLoY87VwFiEtMShfEPljFzo95HN2BlkB VsB/RJCPN9Zsi79ilGc9D7EB5qHBPoXOZiRZaw1zkDWIIMN1H+BGpvdgv w==; X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="322752810" X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="322752810" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2023 09:34:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="686951024" X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="686951024" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 02 Jan 2023 09:34:21 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BB051162; Mon, 2 Jan 2023 19:34:53 +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 v2 2/3] iio: adc: ti-adc128s052: Drop anti-pattern of ACPI_PTR() use Date: Mon, 2 Jan 2023 19:34:49 +0200 Message-Id: <20230102173450.29882-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230102173450.29882-1-andriy.shevchenko@linux.intel.com> References: <20230102173450.29882-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 4a15b6bea310..0f737e9df0fa 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, From patchwork Mon Jan 2 17:34:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13086891 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 9F298C3DA7A for ; Mon, 2 Jan 2023 17:34:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236193AbjABRe2 (ORCPT ); Mon, 2 Jan 2023 12:34:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236072AbjABRe0 (ORCPT ); Mon, 2 Jan 2023 12:34:26 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DB7CA0; Mon, 2 Jan 2023 09:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672680865; x=1704216865; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yTeQ4iXOCmX4eH04kZmPkFyCtQ2mz03AnPemoHb9ccg=; b=D8cbZKdFFT9iUGqF62e72mRInrDi3KfBJQnLreqIdifFzddVEOo61quz zSdw6CUj33ceOp3Gt+ja/6qBVjzROh8ABHJ6AlOmBZFFz3LGg+/LVLmhl 9WfR8oNg9lir+CS+gWRW3Hbc1/VktzyzcMnSGameU2rz/JNeoDPBcGB1y A9FzDzkDx6jGAAB2bxcoKZTgn1Zx/cHOJ+7MWO1z1H2wy4JPVDXv2Y6EZ mcYiXRjr19pt26CWDJwMarwNZXSiGVDgINh9HvcSfwvHVWaY6JQ7aVDOg EYRX0ZXbmaaj4H5sjLav6rg5OeBiJTap+OfU/Hpy7vI29BuD6qsbOQ2y9 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="322752807" X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="322752807" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2023 09:34:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="686951025" X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="686951025" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 02 Jan 2023 09:34:21 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CE22E1CA; Mon, 2 Jan 2023 19:34:53 +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 v2 3/3] iio: adc: ti-adc128s052: Sort headers Date: Mon, 2 Jan 2023 19:34:50 +0200 Message-Id: <20230102173450.29882-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230102173450.29882-1-andriy.shevchenko@linux.intel.com> References: <20230102173450.29882-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Sort the headers in alphabetic order in order to ease the maintenance for this part. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/ti-adc128s052.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 0f737e9df0fa..a456ea78462f 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -10,12 +10,12 @@ */ #include -#include -#include -#include #include +#include +#include #include #include +#include struct adc128_configuration { const struct iio_chan_spec *channels;