Skip to contentSkip to conversation

drivers/iio: Constify structs

PATCH Applied Rikard Falkeborn 3 participants 18 messages May 26, 2020 – Aug 22, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drivers/iio: Constify structs

Constify a number of static structs to allow the compiler to put them in read-only memory. The patches are independent.

Rikard Falkeborn (6):
iio: adc: max11100: Constify struct iio_chan_spec
iio: dac: ad5380: Constify struct iio_chan_spec_ext_info
iio: dac: ad5592r-base: Constify struct iio_chan_spec_ext_info
iio: dac: ad5686: Constify static struct iio_chan_spec
iio: light: stk3310: Constify regmap_config
iio: magnetometer: mmc35240: Constify struct reg_default

 drivers/iio/adc/max11100.c          | 2 +-
 drivers/iio/dac/ad5380.c            | 2 +-
 drivers/iio/dac/ad5592r-base.c      | 2 +-
 drivers/iio/dac/ad5686.c            | 8 ++++----
 drivers/iio/dac/ad5686.h            | 2 +-
 drivers/iio/light/stk3310.c         | 2 +-
 drivers/iio/magnetometer/mmc35240.c | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/6 iio: adc: max11100: Constify struct iio_chan_spec

max11100_channels is not modified and can therefore be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
3776 1168 0 4944 1350 drivers/iio/adc/max11100.o

After:
text data bss dec hex filename
3968 976 0 4944 1350 drivers/iio/adc/max11100.o

---
 drivers/iio/adc/max11100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/max11100.c +1 -1
index 3440539cfdba..b121ca78f851 100644
@@ -37,7 +37,7 @@ struct max11100_state {
 	u8 buffer[3] ____cacheline_aligned;
 };
 
-static struct iio_chan_spec max11100_channels[] = {
+static const struct iio_chan_spec max11100_channels[] = {
 	{ /* [0] */
 		.type = IIO_VOLTAGE,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
Signature · 1 line
2.26.2
maintainer
#2 lore raw

Re: [PATCH 1/6] iio: adc: max11100: Constify struct iio_chan_spec

Quoted 7 lines · On Tue, 26 May 2020 23:02:18 +0200 Rikard Falkeborn…

max11100_channels is not modified and can therefore be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
3776 1168 0 4944 1350 drivers/iio/adc/max11100.o

Quoted 5 lines

After:
text data bss dec hex filename
3968 976 0 4944 1350 drivers/iio/adc/max11100.o

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/adc/max11100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/max11100.c +1 -1
index 3440539cfdba..b121ca78f851 100644
@@ -37,7 +37,7 @@ struct max11100_state {
 	u8 buffer[3] ____cacheline_aligned;
 };
 
-static struct iio_chan_spec max11100_channels[] = {
+static const struct iio_chan_spec max11100_channels[] = {
 	{ /* [0] */
 		.type = IIO_VOLTAGE,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
#3 lore raw

PATCH 2/6 iio: dac: ad5380: Constify struct iio_chan_spec_ext_info

In reply to Rikard Falkeborn

ad5380_ext_info is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

   text    data     bss     dec     hex filename
  12060    3280     192   15532    3cac drivers/iio/dac/ad5380.o

After:

   text    data     bss     dec     hex filename
  12252    3088     192   15532    3cac drivers/iio/dac/ad5380.o
---
 drivers/iio/dac/ad5380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5380.c +1 -1
index b37e5675f716..04c74cc1a4ec 100644
@@ -240,7 +240,7 @@ static const struct iio_info ad5380_info = {
 	.write_raw = ad5380_write_raw,
 };
 
-static struct iio_chan_spec_ext_info ad5380_ext_info[] = {
+static const struct iio_chan_spec_ext_info ad5380_ext_info[] = {
 	{
 		.name = "powerdown",
 		.read = ad5380_read_dac_powerdown,
Signature · 1 line
2.26.2
Acked-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] iio: dac: ad5380: Constify struct iio_chan_spec_ext_info

Quoted 5 lines · Rikard Falkeborn

[External]

ad5380_ext_info is not modified and can be made const to allow the compiler to put it in read-only memory.

Quoted 8 lines

Before:

   text    data     bss     dec     hex filename
  12060    3280     192   15532    3cac drivers/iio/dac/ad5380.o

After:

   text    data     bss     dec     hex filename
  12252    3088     192   15532    3cac drivers/iio/dac/ad5380.o
Quoted 18 lines
---
 drivers/iio/dac/ad5380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5380.c +1 -1
index b37e5675f716..04c74cc1a4ec 100644
@@ -240,7 +240,7 @@ static const struct iio_info ad5380_info = {
 	.write_raw = ad5380_write_raw,
 };
 
-static struct iio_chan_spec_ext_info ad5380_ext_info[] = {
+static const struct iio_chan_spec_ext_info ad5380_ext_info[] = {
 	{
 		.name = "powerdown",
 		.read = ad5380_read_dac_powerdown,
maintainer Applied
#5 lore raw

Re: [PATCH 2/6] iio: dac: ad5380: Constify struct iio_chan_spec_ext_info

Quoted 10 lines · Alexandru
Quoted 9 lines · Rikard Falkeborn

[External]

ad5380_ext_info is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

   text    data     bss     dec     hex filename
  12060    3280     192   15532    3cac drivers/iio/dac/ad5380.o
Quoted 7 lines
Quoted 4 lines

After:

   text    data     bss     dec     hex filename
  12252    3088     192   15532    3cac drivers/iio/dac/ad5380.o

Applied.

Quoted 18 lines
Quoted 18 lines
---
 drivers/iio/dac/ad5380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5380.c +1 -1
index b37e5675f716..04c74cc1a4ec 100644
@@ -240,7 +240,7 @@ static const struct iio_info ad5380_info = {
 	.write_raw = ad5380_write_raw,
 };
 
-static struct iio_chan_spec_ext_info ad5380_ext_info[] = {
+static const struct iio_chan_spec_ext_info ad5380_ext_info[] = {
 	{
 		.name = "powerdown",
 		.read = ad5380_read_dac_powerdown,  
#6 lore raw

PATCH 3/6 iio: dac: ad5592r-base: Constify struct iio_chan_spec_ext_info

In reply to Rikard Falkeborn

ad5592r_ext_info is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

   text    data     bss     dec     hex filename
  13293    2088     256   15637    3d15 drivers/iio/dac/ad5592r-base.o

After:

   text    data     bss     dec     hex filename
  13421    1960     256   15637    3d15 drivers/iio/dac/ad5592r-base.o
---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r-base.c +1 -1
index 410e90e5f75f..7402f67a551d 100644
@@ -484,7 +484,7 @@ static ssize_t ad5592r_show_scale_available(struct iio_dev *iio_dev,
 		st->scale_avail[1][0], st->scale_avail[1][1]);
 }
 
-static struct iio_chan_spec_ext_info ad5592r_ext_info[] = {
+static const struct iio_chan_spec_ext_info ad5592r_ext_info[] = {
 	{
 	 .name = "scale_available",
 	 .read = ad5592r_show_scale_available,
Signature · 1 line
2.26.2
Acked-by on v1 3/6
#7 lore raw

Re: [PATCH 3/6] iio: dac: ad5592r-base: Constify struct iio_chan_spec_ext_info

Quoted 5 lines · Rikard Falkeborn

[External]

ad5592r_ext_info is not modified and can be made const to allow the compiler to put it in read-only memory.

Quoted 8 lines

Before:

   text    data     bss     dec     hex filename
  13293    2088     256   15637    3d15 drivers/iio/dac/ad5592r-base.o

After:

   text    data     bss     dec     hex filename
  13421    1960     256   15637    3d15 drivers/iio/dac/ad5592r-base.o
Quoted 20 lines
---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r- renamed from drivers/iio/dac/ad5592r-base.c +0 -0

base.c
index 410e90e5f75f..7402f67a551d 100644

drivers/iio/dac/ad5592r-base.c +1 -1
@@ -484,7 +484,7 @@ static ssize_t ad5592r_show_scale_available(struct
 iio_dev *iio_dev,
 		st->scale_avail[1][0], st->scale_avail[1][1]);
 }
 
-static struct iio_chan_spec_ext_info ad5592r_ext_info[] = {
+static const struct iio_chan_spec_ext_info ad5592r_ext_info[] = {
 	{
 	 .name = "scale_available",

.read = ad5592r_show_scale_available,

maintainer Applied
#8 lore raw

Re: [PATCH 3/6] iio: dac: ad5592r-base: Constify struct iio_chan_spec_ext_info

Quoted 10 lines · Alexandru
Quoted 9 lines · Rikard Falkeborn

[External]

ad5592r_ext_info is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

   text    data     bss     dec     hex filename
  13293    2088     256   15637    3d15 drivers/iio/dac/ad5592r-base.o
Quoted 6 lines
Quoted 4 lines

After:

   text    data     bss     dec     hex filename
  13421    1960     256   15637    3d15 drivers/iio/dac/ad5592r-base.o

Applied.

Thanks

Quoted 20 lines
Quoted 20 lines
---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r- renamed from drivers/iio/dac/ad5592r-base.c +0 -0

base.c
index 410e90e5f75f..7402f67a551d 100644

drivers/iio/dac/ad5592r-base.c +1 -1
@@ -484,7 +484,7 @@ static ssize_t ad5592r_show_scale_available(struct
 iio_dev *iio_dev,
 		st->scale_avail[1][0], st->scale_avail[1][1]);
 }
 
-static struct iio_chan_spec_ext_info ad5592r_ext_info[] = {
+static const struct iio_chan_spec_ext_info ad5592r_ext_info[] = {
 	{
 	 .name = "scale_available",

.read = ad5592r_show_scale_available,

#9 lore raw

PATCH 4/6 iio: dac: ad5686: Constify static struct iio_chan_spec

In reply to Rikard Falkeborn

These are never modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
6642 12608 64 19314 4b72 drivers/iio/dac/ad5686.o

After:
text data bss dec hex filename
16946 2304 64 19314 4b72 drivers/iio/dac/ad5686.o

---
 drivers/iio/dac/ad5686.c | 8 ++++----
 drivers/iio/dac/ad5686.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/iio/dac/ad5686.c +4 -4
index 8dd67da0a7da..6de48f618c95 100644
@@ -206,12 +206,12 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
 }
 
 #define DECLARE_AD5693_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 }
 
 #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 1, bits, _shift),		\
 		AD5868_CHANNEL(1, 2, bits, _shift),		\
 		AD5868_CHANNEL(2, 4, bits, _shift),		\
@@ -219,7 +219,7 @@ static struct iio_chan_spec name[] = {				\
 }
 
 #define DECLARE_AD5676_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
@@ -231,7 +231,7 @@ static struct iio_chan_spec name[] = {				\
 }
 
 #define DECLARE_AD5679_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
drivers/iio/dac/ad5686.h +1 -1
index 52009b5eef88..a15f2970577e 100644
@@ -104,7 +104,7 @@ typedef int (*ad5686_read_func)(struct ad5686_state *st, u8 addr);
 struct ad5686_chip_info {
 	u16				int_vref_mv;
 	unsigned int			num_channels;
-	struct iio_chan_spec		*channels;
+	const struct iio_chan_spec	*channels;
 	enum ad5686_regmap_type		regmap_type;
 };
 
Signature · 1 line
2.26.2
Acked-by on v1 4/6
#10 lore raw

Re: [PATCH 4/6] iio: dac: ad5686: Constify static struct iio_chan_spec

Quoted 5 lines · Rikard Falkeborn

[External]

These are never modified and can be made const to allow the compiler to put it in read-only memory.

Quoted 8 lines

Before:
text data bss dec hex filename
6642 12608 64 19314 4b72 drivers/iio/dac/ad5686.o

After:
text data bss dec hex filename
16946 2304 64 19314 4b72 drivers/iio/dac/ad5686.o

Quoted 60 lines
---
 drivers/iio/dac/ad5686.c | 8 ++++----
 drivers/iio/dac/ad5686.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/iio/dac/ad5686.c +2 -2
index 8dd67da0a7da..6de48f618c95 100644
@@ -206,12 +206,12 @@ static const struct iio_chan_spec_ext_info
 ad5686_ext_info[] = {
 }
 
 #define DECLARE_AD5693_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 }
 
 #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 1, bits, _shift),		\
 		AD5868_CHANNEL(1, 2, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 4, bits, _shift),		\
@@ -219,7 +219,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5676_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
@@ -231,7 +231,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5679_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +0 -0
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
drivers/iio/dac/ad5686.h +1 -1
index 52009b5eef88..a15f2970577e 100644
@@ -104,7 +104,7 @@ typedef int (*ad5686_read_func)(struct ad5686_state
 *st, u8 addr);
 struct ad5686_chip_info {
 	u16				int_vref_mv;
 	unsigned int			num_channels;
-	struct iio_chan_spec		*channels;
+	const struct iio_chan_spec	*channels;
 	enum ad5686_regmap_type		regmap_type;
 };
maintainer Applied
#11 lore raw

Re: [PATCH 4/6] iio: dac: ad5686: Constify static struct iio_chan_spec

Quoted 10 lines · Alexandru
Quoted 9 lines · Rikard Falkeborn

[External]

These are never modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
6642 12608 64 19314 4b72 drivers/iio/dac/ad5686.o

Quoted 7 lines
Quoted 4 lines

After:
text data bss dec hex filename
16946 2304 64 19314 4b72 drivers/iio/dac/ad5686.o

Applied.

thanks,

Quoted 60 lines
Quoted 60 lines
---
 drivers/iio/dac/ad5686.c | 8 ++++----
 drivers/iio/dac/ad5686.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/iio/dac/ad5686.c +2 -2
index 8dd67da0a7da..6de48f618c95 100644
@@ -206,12 +206,12 @@ static const struct iio_chan_spec_ext_info
 ad5686_ext_info[] = {
 }
 
 #define DECLARE_AD5693_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 }
 
 #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 1, bits, _shift),		\
 		AD5868_CHANNEL(1, 2, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 4, bits, _shift),		\
@@ -219,7 +219,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5676_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
@@ -231,7 +231,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5679_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +0 -0
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
drivers/iio/dac/ad5686.h +1 -1
index 52009b5eef88..a15f2970577e 100644
@@ -104,7 +104,7 @@ typedef int (*ad5686_read_func)(struct ad5686_state
 *st, u8 addr);
 struct ad5686_chip_info {
 	u16				int_vref_mv;
 	unsigned int			num_channels;
-	struct iio_chan_spec		*channels;
+	const struct iio_chan_spec	*channels;
 	enum ad5686_regmap_type		regmap_type;
 };
#12 lore raw

Re: [PATCH 4/6] iio: dac: ad5686: Constify static struct iio_chan_spec

Quoted 18 lines · Jonathan Cameron
Quoted 15 lines · Alexandru
Quoted 13 lines · Rikard Falkeborn

[External]

These are never modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
6642 12608 64 19314 4b72 drivers/iio/dac/ad5686.o

After:
text data bss dec hex filename
16946 2304 64 19314 4b72 drivers/iio/dac/ad5686.o

Quoted 5 lines
Quoted 2 lines

Applied.

thanks,

Was this one really applied? I can't see it anywhere? The rest of the patches in the series are in Linus' tree.

Rikard

Quoted 62 lines
Quoted 61 lines
Quoted 61 lines
---
 drivers/iio/dac/ad5686.c | 8 ++++----
 drivers/iio/dac/ad5686.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/iio/dac/ad5686.c +2 -2
index 8dd67da0a7da..6de48f618c95 100644
@@ -206,12 +206,12 @@ static const struct iio_chan_spec_ext_info
 ad5686_ext_info[] = {
 }
 
 #define DECLARE_AD5693_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 }
 
 #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 1, bits, _shift),		\
 		AD5868_CHANNEL(1, 2, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 4, bits, _shift),		\
@@ -219,7 +219,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5676_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
@@ -231,7 +231,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5679_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +0 -0
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
drivers/iio/dac/ad5686.h +1 -1
index 52009b5eef88..a15f2970577e 100644
@@ -104,7 +104,7 @@ typedef int (*ad5686_read_func)(struct ad5686_state
 *st, u8 addr);
 struct ad5686_chip_info {
 	u16				int_vref_mv;
 	unsigned int			num_channels;
-	struct iio_chan_spec		*channels;
+	const struct iio_chan_spec	*channels;
 	enum ad5686_regmap_type		regmap_type;
 };
maintainer
#13 lore raw

Re: [PATCH 4/6] iio: dac: ad5686: Constify static struct iio_chan_spec

Quoted 19 lines · On Tue, 18 Aug 2020 21:30:17 +0200 Rikard Falkeborn…
Quoted 18 lines · Jonathan Cameron
Quoted 15 lines · Alexandru
Quoted 13 lines · Rikard Falkeborn

[External]

These are never modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
6642 12608 64 19314 4b72 drivers/iio/dac/ad5686.o

After:
text data bss dec hex filename
16946 2304 64 19314 4b72 drivers/iio/dac/ad5686.o

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Applied.

thanks,

Was this one really applied? I can't see it anywhere? The rest of the patches in the series are in Linus' tree.

No idea what happened here. Now applied to the togreg branch of iio.git and pushed out as testing. Sorry about that!

Jonathan

Quoted 64 lines

Rikard

Quoted 62 lines
Quoted 61 lines
Quoted 61 lines
---
 drivers/iio/dac/ad5686.c | 8 ++++----
 drivers/iio/dac/ad5686.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/iio/dac/ad5686.c +2 -2
index 8dd67da0a7da..6de48f618c95 100644
@@ -206,12 +206,12 @@ static const struct iio_chan_spec_ext_info
 ad5686_ext_info[] = {
 }
 
 #define DECLARE_AD5693_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 }
 
 #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 1, bits, _shift),		\
 		AD5868_CHANNEL(1, 2, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 4, bits, _shift),		\
@@ -219,7 +219,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5676_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +1 -1
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
@@ -231,7 +231,7 @@ static struct iio_chan_spec name[] = {			
 	\
 }
 
 #define DECLARE_AD5679_CHANNELS(name, bits, _shift)		\
-static struct iio_chan_spec name[] = {				\
+static const struct iio_chan_spec name[] = {			\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 		AD5868_CHANNEL(1, 1, bits, _shift),		\
drivers/iio/dac/ad5686.c +0 -0
 		AD5868_CHANNEL(2, 2, bits, _shift),		\
drivers/iio/dac/ad5686.h +1 -1
index 52009b5eef88..a15f2970577e 100644
@@ -104,7 +104,7 @@ typedef int (*ad5686_read_func)(struct ad5686_state
 *st, u8 addr);
 struct ad5686_chip_info {
 	u16				int_vref_mv;
 	unsigned int			num_channels;
-	struct iio_chan_spec		*channels;
+	const struct iio_chan_spec	*channels;
 	enum ad5686_regmap_type		regmap_type;
 };
#14 lore raw

PATCH 5/6 iio: light: stk3310: Constify regmap_config

In reply to Rikard Falkeborn

stk3310_regmap_config is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

   text    data     bss     dec     hex filename
  16027    5424     128   21579    544b drivers/iio/light/stk3310.o

After:

   text    data     bss     dec     hex filename
  16347    5104     128   21579    544b drivers/iio/light/stk3310.o
---
 drivers/iio/light/stk3310.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/stk3310.c +1 -1
index 185c24a75ae6..9d1e503bc958 100644
@@ -487,7 +487,7 @@ static bool stk3310_is_volatile_reg(struct device *dev, unsigned int reg)
 	}
 }
 
-static struct regmap_config stk3310_regmap_config = {
+static const struct regmap_config stk3310_regmap_config = {
 	.name = STK3310_REGMAP_NAME,
 	.reg_bits = 8,
 	.val_bits = 8,
Signature · 1 line
2.26.2
maintainer Applied
#15 lore raw

Re: [PATCH 5/6] iio: light: stk3310: Constify regmap_config

Quoted 4 lines · On Tue, 26 May 2020 23:02:22 +0200 Rikard Falkeborn…

stk3310_regmap_config is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

Quoted 8 lines
   text    data     bss     dec     hex filename
  16027    5424     128   21579    544b drivers/iio/light/stk3310.o

After:

   text    data     bss     dec     hex filename
  16347    5104     128   21579    544b drivers/iio/light/stk3310.o

Applied.

thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/light/stk3310.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/stk3310.c +1 -1
index 185c24a75ae6..9d1e503bc958 100644
@@ -487,7 +487,7 @@ static bool stk3310_is_volatile_reg(struct device *dev, unsigned int reg)
 	}
 }
 
-static struct regmap_config stk3310_regmap_config = {
+static const struct regmap_config stk3310_regmap_config = {
 	.name = STK3310_REGMAP_NAME,
 	.reg_bits = 8,
 	.val_bits = 8,
#16 lore raw

PATCH 6/6 iio: magnetometer: mmc35240: Constify struct reg_default

In reply to Rikard Falkeborn

mmc35240_reg_defaults is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

   text    data     bss     dec     hex filename
   9759    3288     128   13175    3377 drivers/iio/magnetometer/mmc35240.o

After:

   text    data     bss     dec     hex filename
   9823    3224     128   13175    3377 drivers/iio/magnetometer/mmc35240.o
---
 drivers/iio/magnetometer/mmc35240.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/mmc35240.c +1 -1
index 1787d656d009..f27586716b5c 100644
@@ -459,7 +459,7 @@ static bool mmc35240_is_volatile_reg(struct device *dev, unsigned int reg)
 	}
 }
 
-static struct reg_default mmc35240_reg_defaults[] = {
+static const struct reg_default mmc35240_reg_defaults[] = {
 	{ MMC35240_REG_CTRL0,  0x00 },
 	{ MMC35240_REG_CTRL1,  0x00 },
 };
Signature · 1 line
2.26.2
maintainer
#17 lore raw

Re: [PATCH 6/6] iio: magnetometer: mmc35240: Constify struct reg_default

Quoted 4 lines · On Tue, 26 May 2020 23:02:23 +0200 Rikard Falkeborn…

mmc35240_reg_defaults is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:

Quoted 8 lines
   text    data     bss     dec     hex filename
   9759    3288     128   13175    3377 drivers/iio/magnetometer/mmc35240.o

After:

   text    data     bss     dec     hex filename
   9823    3224     128   13175    3377 drivers/iio/magnetometer/mmc35240.o

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/magnetometer/mmc35240.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/mmc35240.c +1 -1
index 1787d656d009..f27586716b5c 100644
@@ -459,7 +459,7 @@ static bool mmc35240_is_volatile_reg(struct device *dev, unsigned int reg)
 	}
 }
 
-static struct reg_default mmc35240_reg_defaults[] = {
+static const struct reg_default mmc35240_reg_defaults[] = {
 	{ MMC35240_REG_CTRL0,  0x00 },
 	{ MMC35240_REG_CTRL1,  0x00 },
 };