From: Jonathan Cameron <jic23@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Chen-Yu Tsai <wens@csie.org>, Hans de Goede <hdegoede@redhat.com>,
Support Opensource <support.opensource@diasemi.com>,
Saravanan Sekar <sravanhome@gmail.com>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 1/2] iio: adc: Constify struct iio_map
Date: Sun, 8 Sep 2024 11:45:46 +0100 [thread overview]
Message-ID: <20240908114546.395661ef@jic23-huawei> (raw)
In-Reply-To: <5729dc3cc3892ecf0d8ea28c5f7307b34e27493e.1725729801.git.christophe.jaillet@wanadoo.fr>
On Sat, 7 Sep 2024 19:24:46 +0200
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> '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
Cropping was a bit random, given before and after have different files.
Anyhow, doesn't matter much, so applied as is.
Note this is 6.13 material now.
Thanks,
Jonathan
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> --
> 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
next prev parent reply other threads:[~2024-09-08 10:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-07 17:24 Christophe JAILLET
2024-09-07 17:24 ` [PATCH 2/2] iio: adc: Convert to IIO_MAP() Christophe JAILLET
2024-09-08 10:45 ` Jonathan Cameron [this message]
2024-09-08 11:44 ` [PATCH 1/2] iio: adc: Constify struct iio_map Christophe JAILLET
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240908114546.395661ef@jic23-huawei \
--to=jic23@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=hdegoede@redhat.com \
--cc=jernej.skrabec@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=samuel@sholland.org \
--cc=sravanhome@gmail.com \
--cc=support.opensource@diasemi.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®