diff mbox series

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

Message ID 20200526210223.1672-5-rikard.falkeborn@gmail.com (mailing list archive)
State New, archived
Headers show
Series drivers/iio: Constify structs | expand

Commit Message

Rikard Falkeborn May 26, 2020, 9:02 p.m. UTC
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

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/iio/dac/ad5686.c | 8 ++++----
 drivers/iio/dac/ad5686.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Alexandru Ardelean May 27, 2020, 4:50 a.m. UTC | #1
On Tue, 2020-05-26 at 23:02 +0200, Rikard Falkeborn wrote:
> [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
> 

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> ---
>  drivers/iio/dac/ad5686.c | 8 ++++----
>  drivers/iio/dac/ad5686.h | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index 8dd67da0a7da..6de48f618c95 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -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),		\
> diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> index 52009b5eef88..a15f2970577e 100644
> --- a/drivers/iio/dac/ad5686.h
> +++ b/drivers/iio/dac/ad5686.h
> @@ -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;
>  };
>
Jonathan Cameron May 31, 2020, 1:47 p.m. UTC | #2
On Wed, 27 May 2020 04:50:46 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Tue, 2020-05-26 at 23:02 +0200, Rikard Falkeborn wrote:
> > [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
> >   
> 
> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> 
Applied.

thanks,

> > Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> > ---
> >  drivers/iio/dac/ad5686.c | 8 ++++----
> >  drivers/iio/dac/ad5686.h | 2 +-
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> > index 8dd67da0a7da..6de48f618c95 100644
> > --- a/drivers/iio/dac/ad5686.c
> > +++ b/drivers/iio/dac/ad5686.c
> > @@ -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),		\
> > diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> > index 52009b5eef88..a15f2970577e 100644
> > --- a/drivers/iio/dac/ad5686.h
> > +++ b/drivers/iio/dac/ad5686.h
> > @@ -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;
> >  };
> >
Rikard Falkeborn Aug. 18, 2020, 7:30 p.m. UTC | #3
On Sun, May 31, 2020 at 02:47:15PM +0100, Jonathan Cameron wrote:
> On Wed, 27 May 2020 04:50:46 +0000
> "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:
> 
> > On Tue, 2020-05-26 at 23:02 +0200, Rikard Falkeborn wrote:
> > > [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
> > >   
> > 
> > Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > 
> 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

> 
> > > Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> > > ---
> > >  drivers/iio/dac/ad5686.c | 8 ++++----
> > >  drivers/iio/dac/ad5686.h | 2 +-
> > >  2 files changed, 5 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> > > index 8dd67da0a7da..6de48f618c95 100644
> > > --- a/drivers/iio/dac/ad5686.c
> > > +++ b/drivers/iio/dac/ad5686.c
> > > @@ -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),		\
> > > diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> > > index 52009b5eef88..a15f2970577e 100644
> > > --- a/drivers/iio/dac/ad5686.h
> > > +++ b/drivers/iio/dac/ad5686.h
> > > @@ -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;
> > >  };
> > >    
>
Jonathan Cameron Aug. 22, 2020, 10:31 a.m. UTC | #4
On Tue, 18 Aug 2020 21:30:17 +0200
Rikard Falkeborn <rikard.falkeborn@gmail.com> wrote:

> On Sun, May 31, 2020 at 02:47:15PM +0100, Jonathan Cameron wrote:
> > On Wed, 27 May 2020 04:50:46 +0000
> > "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:
> >   
> > > On Tue, 2020-05-26 at 23:02 +0200, Rikard Falkeborn wrote:  
> > > > [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
> > > >     
> > > 
> > > Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > >   
> > 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

> Rikard
> 
> >   
> > > > Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> > > > ---
> > > >  drivers/iio/dac/ad5686.c | 8 ++++----
> > > >  drivers/iio/dac/ad5686.h | 2 +-
> > > >  2 files changed, 5 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> > > > index 8dd67da0a7da..6de48f618c95 100644
> > > > --- a/drivers/iio/dac/ad5686.c
> > > > +++ b/drivers/iio/dac/ad5686.c
> > > > @@ -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),		\
> > > > diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> > > > index 52009b5eef88..a15f2970577e 100644
> > > > --- a/drivers/iio/dac/ad5686.h
> > > > +++ b/drivers/iio/dac/ad5686.h
> > > > @@ -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;
> > > >  };
> > > >      
> >
diff mbox series

Patch

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 8dd67da0a7da..6de48f618c95 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -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),		\
diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
index 52009b5eef88..a15f2970577e 100644
--- a/drivers/iio/dac/ad5686.h
+++ b/drivers/iio/dac/ad5686.h
@@ -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;
 };