From patchwork Sat Sep 7 17:24:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13795238 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7EDB4EB64CD for ; Sat, 7 Sep 2024 17:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=HyvRImjoEj3AzyL98EjbHwe80miJso2YtX4UW8KcR7k=; b=rMzjC+8mmaLbGpMxLAw9Mv7M/r JbyMLoQ5SA0dvMWCVrIZqyX+T7lHwiomfYHeLdzfrFkt+BCo6MHQVVp3tEiu75ZYCD7ED+SkQ3oAi /TEqlSjOMBQ+bntekDghtCx7GRgxez+qdgns5Mo4z8JQG6zTll4Es9VXY0Sx4X0WBr/49e9wcRKuN 7LP1VGLXw4/MguK6l3bwHy02m8PFuM7HVYGKhVJSKoxqzFRbLKuPK/MkLhUYLLsVO9JRVaKGDEPZq t3QTB30QsepD6ejlyVXFcCFm4ezmVJECBfROwT0DwHEgXPzbGlsokjoSJNibORLIGPmsuDlTQLBqF tJc4IQ1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smzCT-0000000FMsX-1HPW; Sat, 07 Sep 2024 17:26:17 +0000 Received: from smtp-20.smtpout.orange.fr ([80.12.242.20] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smzBS-0000000FMl8-2zXU for linux-arm-kernel@lists.infradead.org; Sat, 07 Sep 2024 17:25:17 +0000 Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id mzBIscbar0aTdmzBJsLH0L; Sat, 07 Sep 2024 19:25:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1725729910; bh=HyvRImjoEj3AzyL98EjbHwe80miJso2YtX4UW8KcR7k=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=D7yZzign6bl3Ey/uxVMjlK1XwZgwlI/K+Sx5cP2PdRFJIjXlJCNcMkC4OoJX/fGP0 FxTBNejqOwxSrG8EfT4VhnxVEDEvaD822wHPCAX01kki7m6evzSz8/e0QiLbmuAV1i QP5EOLwVPZF0TZ9hDrb6ZmTaa2CV/YznxGo2w82cXmScU3tr4II+C0+PC2hwLrzFSv gHp/30YWZQbEe4+HTSzqU0FhRp7itnEJyo6PBGoImFHAJLGv7d8d+PosYbuouLaq9C yj6BZXn7ZOY3X2W86r4BBLD8Q5NedAyKh4BCuFXrUXSqnoYyAljyxoxceZ4jf0ac9t ctsp3dUiy5lPw== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 07 Sep 2024 19:25:10 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Hans de Goede , Support Opensource , Saravanan Sekar , Jernej Skrabec , Samuel Holland Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 1/2] iio: adc: Constify struct iio_map Date: Sat, 7 Sep 2024 19:24:46 +0200 Message-ID: <5729dc3cc3892ecf0d8ea28c5f7307b34e27493e.1725729801.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240907_102515_327316_A10F4495 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 'struct iio_map' are not modified in these drivers. Constifying this structure moves some data to a read-only section, so increase overall security. In order to do it, the prototype of iio_map_array_register() and devm_iio_map_array_register(), and a few structures that hold a "struct iio_map *" need to be adjusted. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 21086 760 0 21846 5556 drivers/iio/adc/axp20x_adc.o After: ===== text data bss dec hex filename 21470 360 0 21830 5546 drivers/iio/adc/axp20x_adc.o 33842 1697 384 35923 8c53 drivers/iio/addac/ad74413r.o Signed-off-by: Christophe JAILLET --- Compile tested only --- drivers/iio/adc/axp20x_adc.c | 6 +++--- drivers/iio/adc/axp288_adc.c | 2 +- drivers/iio/adc/da9150-gpadc.c | 2 +- drivers/iio/adc/intel_mrfld_adc.c | 2 +- drivers/iio/adc/lp8788_adc.c | 6 +++--- drivers/iio/adc/mp2629_adc.c | 2 +- drivers/iio/adc/rn5t618-adc.c | 2 +- drivers/iio/adc/sun4i-gpadc-iio.c | 2 +- drivers/iio/inkern.c | 7 ++++--- include/linux/iio/driver.h | 5 +++-- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index b487e577befb..cac3bacf2589 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -131,7 +131,7 @@ enum axp813_adc_channel_v { AXP813_BATT_V, }; -static struct iio_map axp20x_maps[] = { +static const struct iio_map axp20x_maps[] = { { .consumer_dev_name = "axp20x-usb-power-supply", .consumer_channel = "vbus_v", @@ -163,7 +163,7 @@ static struct iio_map axp20x_maps[] = { }, { /* sentinel */ } }; -static struct iio_map axp22x_maps[] = { +static const struct iio_map axp22x_maps[] = { { .consumer_dev_name = "axp20x-battery-power-supply", .consumer_channel = "batt_v", @@ -893,7 +893,7 @@ struct axp_data { unsigned long adc_en2_mask; int (*adc_rate)(struct axp20x_adc_iio *info, int rate); - struct iio_map *maps; + const struct iio_map *maps; }; static const struct axp_data axp192_data = { diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index f135cf2362df..a9f84253d4b1 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -103,7 +103,7 @@ static const struct iio_chan_spec axp288_adc_channels[] = { }; /* for consumer drivers */ -static struct iio_map axp288_adc_default_maps[] = { +static const struct iio_map axp288_adc_default_maps[] = { IIO_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"), IIO_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"), IIO_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"), diff --git a/drivers/iio/adc/da9150-gpadc.c b/drivers/iio/adc/da9150-gpadc.c index 8f0d3fb63b67..82628746ba8e 100644 --- a/drivers/iio/adc/da9150-gpadc.c +++ b/drivers/iio/adc/da9150-gpadc.c @@ -291,7 +291,7 @@ static const struct iio_chan_spec da9150_gpadc_channels[] = { }; /* Default maps used by da9150-charger */ -static struct iio_map da9150_gpadc_default_maps[] = { +static const struct iio_map da9150_gpadc_default_maps[] = { { .consumer_dev_name = "da9150-charger", .consumer_channel = "CHAN_IBUS", diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c index 0590a126f321..30c8c09e3716 100644 --- a/drivers/iio/adc/intel_mrfld_adc.c +++ b/drivers/iio/adc/intel_mrfld_adc.c @@ -164,7 +164,7 @@ static const struct iio_chan_spec mrfld_adc_channels[] = { BCOVE_ADC_CHANNEL(IIO_TEMP, 8, "CH8", 0xC6), }; -static struct iio_map iio_maps[] = { +static const struct iio_map iio_maps[] = { IIO_MAP("CH0", "bcove-battery", "VBATRSLT"), IIO_MAP("CH1", "bcove-battery", "BATTID"), IIO_MAP("CH2", "bcove-battery", "IBATRSLT"), diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index 6d9b354bc705..0d49be0061a2 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c @@ -26,7 +26,7 @@ struct lp8788_adc { struct lp8788 *lp; - struct iio_map *map; + const struct iio_map *map; struct mutex lock; }; @@ -149,7 +149,7 @@ static const struct iio_chan_spec lp8788_adc_channels[] = { }; /* default maps used by iio consumer (lp8788-charger driver) */ -static struct iio_map lp8788_default_iio_maps[] = { +static const struct iio_map lp8788_default_iio_maps[] = { { .consumer_dev_name = "lp8788-charger", .consumer_channel = "lp8788_vbatt_5p0", @@ -168,7 +168,7 @@ static int lp8788_iio_map_register(struct device *dev, struct lp8788_platform_data *pdata, struct lp8788_adc *adc) { - struct iio_map *map; + const struct iio_map *map; int ret; map = (!pdata || !pdata->adc_pdata) ? diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c index 5f672765d4a2..f114817601f2 100644 --- a/drivers/iio/adc/mp2629_adc.c +++ b/drivers/iio/adc/mp2629_adc.c @@ -52,7 +52,7 @@ static struct iio_chan_spec mp2629_channels[] = { MP2629_ADC_CHAN(INPUT_CURRENT, IIO_CURRENT) }; -static struct iio_map mp2629_adc_maps[] = { +static const struct iio_map mp2629_adc_maps[] = { MP2629_MAP(BATT_VOLT, "batt-volt"), MP2629_MAP(SYSTEM_VOLT, "system-volt"), MP2629_MAP(INPUT_VOLT, "input-volt"), diff --git a/drivers/iio/adc/rn5t618-adc.c b/drivers/iio/adc/rn5t618-adc.c index ce5f3011fe00..b33536157adc 100644 --- a/drivers/iio/adc/rn5t618-adc.c +++ b/drivers/iio/adc/rn5t618-adc.c @@ -185,7 +185,7 @@ static const struct iio_chan_spec rn5t618_adc_iio_channels[] = { RN5T618_ADC_CHANNEL(AIN0, IIO_VOLTAGE, "AIN0") }; -static struct iio_map rn5t618_maps[] = { +static const struct iio_map rn5t618_maps[] = { IIO_MAP("VADP", "rn5t618-power", "vadp"), IIO_MAP("VUSB", "rn5t618-power", "vusb"), { /* sentinel */ } diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 100ecced5fc1..5d459f050634 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -114,7 +114,7 @@ struct sun4i_gpadc_iio { .datasheet_name = _name, \ } -static struct iio_map sun4i_gpadc_hwmon_maps[] = { +static const struct iio_map sun4i_gpadc_hwmon_maps[] = { { .adc_channel_label = "temp_adc", .consumer_dev_name = "iio_hwmon.0", diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 151099be2863..7f325b3ed08f 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -20,7 +20,7 @@ struct iio_map_internal { struct iio_dev *indio_dev; - struct iio_map *map; + const struct iio_map *map; struct list_head l; }; @@ -42,7 +42,7 @@ static int iio_map_array_unregister_locked(struct iio_dev *indio_dev) return ret; } -int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) +int iio_map_array_register(struct iio_dev *indio_dev, const struct iio_map *maps) { struct iio_map_internal *mapi; int i = 0; @@ -86,7 +86,8 @@ static void iio_map_array_unregister_cb(void *indio_dev) iio_map_array_unregister(indio_dev); } -int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, struct iio_map *maps) +int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, + const struct iio_map *maps) { int ret; diff --git a/include/linux/iio/driver.h b/include/linux/iio/driver.h index 7a157ed218f6..7f8b55551ed0 100644 --- a/include/linux/iio/driver.h +++ b/include/linux/iio/driver.h @@ -18,7 +18,7 @@ struct iio_map; * @map: array of mappings specifying association of channel with client */ int iio_map_array_register(struct iio_dev *indio_dev, - struct iio_map *map); + const struct iio_map *map); /** * iio_map_array_unregister() - tell the core to remove consumer mappings for @@ -38,6 +38,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev); * handle de-registration of the IIO map object when the device's refcount goes to * zero. */ -int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, struct iio_map *maps); +int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, + const struct iio_map *maps); #endif From patchwork Sat Sep 7 17:24:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13795239 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69943EB64CA for ; Sat, 7 Sep 2024 17:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QqNd1qOb7nNU0uwNQowVVSCA68Q31RBB+cNS1Dla0LY=; b=rzeN55SoOJjR8+vP9Hh3NAWyzM CNrxIkZiwF9NjkW7kcMK8FO8+60WK46sbF2vODdmbTvnddsM5hKqq6dyDYHxSBenEtL3V9j0N+l5T tTv1GqvCc2OB7FZ0FVC/cw8X6O2MmUkZYri1CLdwmfpQC3OXJti4hVg1b2GIv1lT1zma+ECRpTv3s JNaAmtoq3iigsZWs3sanZJFcmZPDWDuePqNmGmXg66fYfrVKtar799yyQLdObljwXOtesszH4pu0V Mna7y6HGmxVnG38GBr8Y4K4qy1ppaJmSc4Y7Q0OOJ50pcBgbfZikBnbyLZlJbQuYp5M60hb8HOPbP yu3aj37Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smzDR-0000000FMyC-1sQE; Sat, 07 Sep 2024 17:27:17 +0000 Received: from msa-209.smtpout.orange.fr ([193.252.23.209] helo=msa.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smzBW-0000000FMlV-2QsX for linux-arm-kernel@lists.infradead.org; Sat, 07 Sep 2024 17:25:20 +0000 Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id mzBIscbar0aTdmzBTsLH7S; Sat, 07 Sep 2024 19:25:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1725729916; bh=QqNd1qOb7nNU0uwNQowVVSCA68Q31RBB+cNS1Dla0LY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=L3iY79qAD7iFw0HcamIQ0KNnfHVwnj6xPI+WJOE4FHwzVRXV64BuqwI3TAxROau4w Ca2QCl8ABng/ByMLP127VveQ3+zrE7I3ETPCgVm0oKtNhp/vvUlgTxITuxY+t5XMoo UgQ7og9DQLR9G80D3DgYB9kKTgmjjJLCyPmOdNv/Y+BXDm6+XGH0dCkMqx/fqCGL45 PDEA3wI4rcp4WaEIoVtBs6RqAcdx7K7PRRt+KD52qpBKRui+wkCuEG75NH2imwq1gt m35+LZPp6UeDRw/ab3ciNjzXw/w+p8qDmJ/HAIjBBRD8daFoy3ZtPX+yaSqAeg5xSu mvdMkpSdJK9Cw== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 07 Sep 2024 19:25:16 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Support Opensource , Jernej Skrabec , Samuel Holland Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 2/2] iio: adc: Convert to IIO_MAP() Date: Sat, 7 Sep 2024 19:24:47 +0200 Message-ID: <48f08224fab5a7595f650dbcef012d7cac3f972b.1725729801.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <5729dc3cc3892ecf0d8ea28c5f7307b34e27493e.1725729801.git.christophe.jaillet@wanadoo.fr> References: <5729dc3cc3892ecf0d8ea28c5f7307b34e27493e.1725729801.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240907_102518_912309_5AE751DD X-CRM114-Status: GOOD ( 10.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use IIO_MAP() instead of hand-writing it. It is much less verbose. The change has been do with the following coccinelle script: @@ identifier STRUCT_NAME; constant NAME, CHANNEL, LABEL; @@ static const struct iio_map STRUCT_NAME[] = { ..., - { - .consumer_dev_name = NAME, - .consumer_channel = CHANNEL, - .adc_channel_label = LABEL, - }, + IIO_MAP(LABEL, NAME, CHANNEL), ... }; @@ identifier STRUCT_NAME; constant NAME, LABEL; @@ static const struct iio_map STRUCT_NAME[] = { ..., - { - .consumer_dev_name = NAME, - .adc_channel_label = LABEL, - }, + IIO_MAP(LABEL, NAME, NULL), ... }; Signed-off-by: Christophe JAILLET --- Compile tested only --- drivers/iio/adc/axp20x_adc.c | 54 +++++++------------------------ drivers/iio/adc/da9150-gpadc.c | 24 +++----------- drivers/iio/adc/lp8788_adc.c | 12 ++----- drivers/iio/adc/sun4i-gpadc-iio.c | 5 +-- 4 files changed, 19 insertions(+), 76 deletions(-) diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index cac3bacf2589..9a935044833a 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -132,51 +132,21 @@ enum axp813_adc_channel_v { }; static const struct iio_map axp20x_maps[] = { - { - .consumer_dev_name = "axp20x-usb-power-supply", - .consumer_channel = "vbus_v", - .adc_channel_label = "vbus_v", - }, { - .consumer_dev_name = "axp20x-usb-power-supply", - .consumer_channel = "vbus_i", - .adc_channel_label = "vbus_i", - }, { - .consumer_dev_name = "axp20x-ac-power-supply", - .consumer_channel = "acin_v", - .adc_channel_label = "acin_v", - }, { - .consumer_dev_name = "axp20x-ac-power-supply", - .consumer_channel = "acin_i", - .adc_channel_label = "acin_i", - }, { - .consumer_dev_name = "axp20x-battery-power-supply", - .consumer_channel = "batt_v", - .adc_channel_label = "batt_v", - }, { - .consumer_dev_name = "axp20x-battery-power-supply", - .consumer_channel = "batt_chrg_i", - .adc_channel_label = "batt_chrg_i", - }, { - .consumer_dev_name = "axp20x-battery-power-supply", - .consumer_channel = "batt_dischrg_i", - .adc_channel_label = "batt_dischrg_i", - }, { /* sentinel */ } + IIO_MAP("vbus_v", "axp20x-usb-power-supply", "vbus_v"), + IIO_MAP("vbus_i", "axp20x-usb-power-supply", "vbus_i"), + IIO_MAP("acin_v", "axp20x-ac-power-supply", "acin_v"), + IIO_MAP("acin_i", "axp20x-ac-power-supply", "acin_i"), + IIO_MAP("batt_v", "axp20x-battery-power-supply", "batt_v"), + IIO_MAP("batt_chrg_i", "axp20x-battery-power-supply", "batt_chrg_i"), + IIO_MAP("batt_dischrg_i", "axp20x-battery-power-supply", "batt_dischrg_i"), + { /* sentinel */ } }; static const struct iio_map axp22x_maps[] = { - { - .consumer_dev_name = "axp20x-battery-power-supply", - .consumer_channel = "batt_v", - .adc_channel_label = "batt_v", - }, { - .consumer_dev_name = "axp20x-battery-power-supply", - .consumer_channel = "batt_chrg_i", - .adc_channel_label = "batt_chrg_i", - }, { - .consumer_dev_name = "axp20x-battery-power-supply", - .consumer_channel = "batt_dischrg_i", - .adc_channel_label = "batt_dischrg_i", - }, { /* sentinel */ } + IIO_MAP("batt_v", "axp20x-battery-power-supply", "batt_v"), + IIO_MAP("batt_chrg_i", "axp20x-battery-power-supply", "batt_chrg_i"), + IIO_MAP("batt_dischrg_i", "axp20x-battery-power-supply", "batt_dischrg_i"), + { /* sentinel */ } }; /* diff --git a/drivers/iio/adc/da9150-gpadc.c b/drivers/iio/adc/da9150-gpadc.c index 82628746ba8e..0290345ade84 100644 --- a/drivers/iio/adc/da9150-gpadc.c +++ b/drivers/iio/adc/da9150-gpadc.c @@ -292,26 +292,10 @@ static const struct iio_chan_spec da9150_gpadc_channels[] = { /* Default maps used by da9150-charger */ static const struct iio_map da9150_gpadc_default_maps[] = { - { - .consumer_dev_name = "da9150-charger", - .consumer_channel = "CHAN_IBUS", - .adc_channel_label = "IBUS", - }, - { - .consumer_dev_name = "da9150-charger", - .consumer_channel = "CHAN_VBUS", - .adc_channel_label = "VBUS", - }, - { - .consumer_dev_name = "da9150-charger", - .consumer_channel = "CHAN_TJUNC", - .adc_channel_label = "TJUNC_CORE", - }, - { - .consumer_dev_name = "da9150-charger", - .consumer_channel = "CHAN_VBAT", - .adc_channel_label = "VBAT", - }, + IIO_MAP("IBUS", "da9150-charger", "CHAN_IBUS"), + IIO_MAP("VBUS", "da9150-charger", "CHAN_VBUS"), + IIO_MAP("TJUNC_CORE", "da9150-charger", "CHAN_TJUNC"), + IIO_MAP("VBAT", "da9150-charger", "CHAN_VBAT"), {}, }; diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index 0d49be0061a2..33bf8aef79e3 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c @@ -150,16 +150,8 @@ static const struct iio_chan_spec lp8788_adc_channels[] = { /* default maps used by iio consumer (lp8788-charger driver) */ static const struct iio_map lp8788_default_iio_maps[] = { - { - .consumer_dev_name = "lp8788-charger", - .consumer_channel = "lp8788_vbatt_5p0", - .adc_channel_label = "VBATT_5P0", - }, - { - .consumer_dev_name = "lp8788-charger", - .consumer_channel = "lp8788_adc1", - .adc_channel_label = "ADC1", - }, + IIO_MAP("VBATT_5P0", "lp8788-charger", "lp8788_vbatt_5p0"), + IIO_MAP("ADC1", "lp8788-charger", "lp8788_adc1"), { } }; diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 5d459f050634..00a3a4db0fe0 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -115,10 +115,7 @@ struct sun4i_gpadc_iio { } static const struct iio_map sun4i_gpadc_hwmon_maps[] = { - { - .adc_channel_label = "temp_adc", - .consumer_dev_name = "iio_hwmon.0", - }, + IIO_MAP("temp_adc", "iio_hwmon.0", NULL), { /* sentinel */ }, };