iio: adc: max9611: Make enum relations more future proof
diff mbox series

Message ID 20191113100938.27604-1-geert+renesas@glider.be
State New
Headers show
Series
  • iio: adc: max9611: Make enum relations more future proof
Related show

Commit Message

Geert Uytterhoeven Nov. 13, 2019, 10:09 a.m. UTC
The relations between enum values and array indices values are currently
not enforced by the code, which makes them fragile w.r.t. future
changes.

Fix this by:
  1. Using designated array initializers, to make sure array indices and
     enums values match,
  2. Linking max9611_csa_gain enum values to the corresponding
     max9611_conf_ids enum values, as the latter is cast to the former
     in max9611_read_csa_voltage().

No change in generated code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/iio/adc/max9611.c | 36 +++++++++++-------------------------
 1 file changed, 11 insertions(+), 25 deletions(-)

Comments

Niklas Söderlund Nov. 14, 2019, 7:28 a.m. UTC | #1
Hi Geert,

Looks good.

On 2019-11-13 11:09:38 +0100, Geert Uytterhoeven wrote:
> The relations between enum values and array indices values are currently
> not enforced by the code, which makes them fragile w.r.t. future
> changes.
> 
> Fix this by:
>   1. Using designated array initializers, to make sure array indices and
>      enums values match,
>   2. Linking max9611_csa_gain enum values to the corresponding
>      max9611_conf_ids enum values, as the latter is cast to the former
>      in max9611_read_csa_voltage().
> 
> No change in generated code.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/iio/adc/max9611.c | 36 +++++++++++-------------------------
>  1 file changed, 11 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> index b0755f25356d700d..cb306ff1a5d6a0b2 100644
> --- a/drivers/iio/adc/max9611.c
> +++ b/drivers/iio/adc/max9611.c
> @@ -114,22 +114,17 @@ enum max9611_conf_ids {
>   *		      where data shall be read from
>   */
>  static const unsigned int max9611_mux_conf[][2] = {
> -	/* CONF_SENSE_1x */
> -	{ MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> -	/* CONF_SENSE_4x */
> -	{ MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> -	/* CONF_SENSE_8x */
> -	{ MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> -	/* CONF_IN_VOLT */
> -	{ MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> -	/* CONF_TEMP */
> -	{ MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> +	[CONF_SENSE_1x]	= { MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> +	[CONF_SENSE_4x]	= { MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> +	[CONF_SENSE_8x]	= { MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> +	[CONF_IN_VOLT]	= { MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> +	[CONF_TEMP]	= { MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
>  };
>  
>  enum max9611_csa_gain {
> -	CSA_GAIN_1x,
> -	CSA_GAIN_4x,
> -	CSA_GAIN_8x,
> +	CSA_GAIN_1x = CONF_SENSE_1x,
> +	CSA_GAIN_4x = CONF_SENSE_4x,
> +	CSA_GAIN_8x = CONF_SENSE_8x,
>  };
>  
>  enum max9611_csa_gain_params {
> @@ -147,18 +142,9 @@ enum max9611_csa_gain_params {
>   * value; use this structure to retrieve the correct LSB and offset values.
>   */
>  static const unsigned int max9611_gain_conf[][2] = {
> -	{ /* [0] CSA_GAIN_1x */
> -		MAX9611_CSA_1X_LSB_nV,
> -		MAX9611_CSA_1X_OFFS_RAW,
> -	},
> -	{ /* [1] CSA_GAIN_4x */
> -		MAX9611_CSA_4X_LSB_nV,
> -		MAX9611_CSA_4X_OFFS_RAW,
> -	},
> -	{ /* [2] CSA_GAIN_8x */
> -		MAX9611_CSA_8X_LSB_nV,
> -		MAX9611_CSA_8X_OFFS_RAW,
> -	},
> +	[CSA_GAIN_1x] = { MAX9611_CSA_1X_LSB_nV, MAX9611_CSA_1X_OFFS_RAW, },
> +	[CSA_GAIN_4x] = { MAX9611_CSA_4X_LSB_nV, MAX9611_CSA_4X_OFFS_RAW, },
> +	[CSA_GAIN_8x] = { MAX9611_CSA_8X_LSB_nV, MAX9611_CSA_8X_OFFS_RAW, },
>  };
>  
>  enum max9611_chan_addrs {
> -- 
> 2.17.1
>
Jonathan Cameron Nov. 16, 2019, 4:25 p.m. UTC | #2
On Thu, 14 Nov 2019 08:28:03 +0100
Niklas Söderlund <niklas.soderlund@ragnatech.se> wrote:

> Hi Geert,
> 
> Looks good.
> 
> On 2019-11-13 11:09:38 +0100, Geert Uytterhoeven wrote:
> > The relations between enum values and array indices values are currently
> > not enforced by the code, which makes them fragile w.r.t. future
> > changes.
> > 
> > Fix this by:
> >   1. Using designated array initializers, to make sure array indices and
> >      enums values match,
> >   2. Linking max9611_csa_gain enum values to the corresponding
> >      max9611_conf_ids enum values, as the latter is cast to the former
> >      in max9611_read_csa_voltage().
> > 
> > No change in generated code.
> > 
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>  
> 
> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Looks good to me, but I'd like to leave a little longer for any
feedback from Jacopo as author of the driver.

Thanks,

Jonathan
> 
> > ---
> >  drivers/iio/adc/max9611.c | 36 +++++++++++-------------------------
> >  1 file changed, 11 insertions(+), 25 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > index b0755f25356d700d..cb306ff1a5d6a0b2 100644
> > --- a/drivers/iio/adc/max9611.c
> > +++ b/drivers/iio/adc/max9611.c
> > @@ -114,22 +114,17 @@ enum max9611_conf_ids {
> >   *		      where data shall be read from
> >   */
> >  static const unsigned int max9611_mux_conf[][2] = {
> > -	/* CONF_SENSE_1x */
> > -	{ MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> > -	/* CONF_SENSE_4x */
> > -	{ MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> > -	/* CONF_SENSE_8x */
> > -	{ MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> > -	/* CONF_IN_VOLT */
> > -	{ MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> > -	/* CONF_TEMP */
> > -	{ MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> > +	[CONF_SENSE_1x]	= { MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> > +	[CONF_SENSE_4x]	= { MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> > +	[CONF_SENSE_8x]	= { MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> > +	[CONF_IN_VOLT]	= { MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> > +	[CONF_TEMP]	= { MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> >  };
> >  
> >  enum max9611_csa_gain {
> > -	CSA_GAIN_1x,
> > -	CSA_GAIN_4x,
> > -	CSA_GAIN_8x,
> > +	CSA_GAIN_1x = CONF_SENSE_1x,
> > +	CSA_GAIN_4x = CONF_SENSE_4x,
> > +	CSA_GAIN_8x = CONF_SENSE_8x,
> >  };
> >  
> >  enum max9611_csa_gain_params {
> > @@ -147,18 +142,9 @@ enum max9611_csa_gain_params {
> >   * value; use this structure to retrieve the correct LSB and offset values.
> >   */
> >  static const unsigned int max9611_gain_conf[][2] = {
> > -	{ /* [0] CSA_GAIN_1x */
> > -		MAX9611_CSA_1X_LSB_nV,
> > -		MAX9611_CSA_1X_OFFS_RAW,
> > -	},
> > -	{ /* [1] CSA_GAIN_4x */
> > -		MAX9611_CSA_4X_LSB_nV,
> > -		MAX9611_CSA_4X_OFFS_RAW,
> > -	},
> > -	{ /* [2] CSA_GAIN_8x */
> > -		MAX9611_CSA_8X_LSB_nV,
> > -		MAX9611_CSA_8X_OFFS_RAW,
> > -	},
> > +	[CSA_GAIN_1x] = { MAX9611_CSA_1X_LSB_nV, MAX9611_CSA_1X_OFFS_RAW, },
> > +	[CSA_GAIN_4x] = { MAX9611_CSA_4X_LSB_nV, MAX9611_CSA_4X_OFFS_RAW, },
> > +	[CSA_GAIN_8x] = { MAX9611_CSA_8X_LSB_nV, MAX9611_CSA_8X_OFFS_RAW, },
> >  };
> >  
> >  enum max9611_chan_addrs {
> > -- 
> > 2.17.1
> >   
>
Jacopo Mondi Nov. 16, 2019, 4:54 p.m. UTC | #3
Hello,

On Sat, Nov 16, 2019 at 04:25:22PM +0000, Jonathan Cameron wrote:
> On Thu, 14 Nov 2019 08:28:03 +0100
> Niklas Söderlund <niklas.soderlund@ragnatech.se> wrote:
>
> > Hi Geert,
> >
> > Looks good.
> >
> > On 2019-11-13 11:09:38 +0100, Geert Uytterhoeven wrote:
> > > The relations between enum values and array indices values are currently
> > > not enforced by the code, which makes them fragile w.r.t. future
> > > changes.
> > >
> > > Fix this by:
> > >   1. Using designated array initializers, to make sure array indices and
> > >      enums values match,
> > >   2. Linking max9611_csa_gain enum values to the corresponding
> > >      max9611_conf_ids enum values, as the latter is cast to the former
> > >      in max9611_read_csa_voltage().
> > >
> > > No change in generated code.
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> Looks good to me, but I'd like to leave a little longer for any
> feedback from Jacopo as author of the driver.

yeah, sorry I've been sloppy.. I meant to give the patches a run, but
it seems there are only syntactic changes here, which indeed make the
code more robust.

Even if not tested, please add
Acked-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>
> Thanks,
>
> Jonathan
> >
> > > ---
> > >  drivers/iio/adc/max9611.c | 36 +++++++++++-------------------------
> > >  1 file changed, 11 insertions(+), 25 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > > index b0755f25356d700d..cb306ff1a5d6a0b2 100644
> > > --- a/drivers/iio/adc/max9611.c
> > > +++ b/drivers/iio/adc/max9611.c
> > > @@ -114,22 +114,17 @@ enum max9611_conf_ids {
> > >   *		      where data shall be read from
> > >   */
> > >  static const unsigned int max9611_mux_conf[][2] = {
> > > -	/* CONF_SENSE_1x */
> > > -	{ MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> > > -	/* CONF_SENSE_4x */
> > > -	{ MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> > > -	/* CONF_SENSE_8x */
> > > -	{ MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> > > -	/* CONF_IN_VOLT */
> > > -	{ MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> > > -	/* CONF_TEMP */
> > > -	{ MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> > > +	[CONF_SENSE_1x]	= { MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> > > +	[CONF_SENSE_4x]	= { MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> > > +	[CONF_SENSE_8x]	= { MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> > > +	[CONF_IN_VOLT]	= { MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> > > +	[CONF_TEMP]	= { MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> > >  };
> > >
> > >  enum max9611_csa_gain {
> > > -	CSA_GAIN_1x,
> > > -	CSA_GAIN_4x,
> > > -	CSA_GAIN_8x,
> > > +	CSA_GAIN_1x = CONF_SENSE_1x,
> > > +	CSA_GAIN_4x = CONF_SENSE_4x,
> > > +	CSA_GAIN_8x = CONF_SENSE_8x,
> > >  };
> > >
> > >  enum max9611_csa_gain_params {
> > > @@ -147,18 +142,9 @@ enum max9611_csa_gain_params {
> > >   * value; use this structure to retrieve the correct LSB and offset values.
> > >   */
> > >  static const unsigned int max9611_gain_conf[][2] = {
> > > -	{ /* [0] CSA_GAIN_1x */
> > > -		MAX9611_CSA_1X_LSB_nV,
> > > -		MAX9611_CSA_1X_OFFS_RAW,
> > > -	},
> > > -	{ /* [1] CSA_GAIN_4x */
> > > -		MAX9611_CSA_4X_LSB_nV,
> > > -		MAX9611_CSA_4X_OFFS_RAW,
> > > -	},
> > > -	{ /* [2] CSA_GAIN_8x */
> > > -		MAX9611_CSA_8X_LSB_nV,
> > > -		MAX9611_CSA_8X_OFFS_RAW,
> > > -	},
> > > +	[CSA_GAIN_1x] = { MAX9611_CSA_1X_LSB_nV, MAX9611_CSA_1X_OFFS_RAW, },
> > > +	[CSA_GAIN_4x] = { MAX9611_CSA_4X_LSB_nV, MAX9611_CSA_4X_OFFS_RAW, },
> > > +	[CSA_GAIN_8x] = { MAX9611_CSA_8X_LSB_nV, MAX9611_CSA_8X_OFFS_RAW, },
> > >  };
> > >
> > >  enum max9611_chan_addrs {
> > > --
> > > 2.17.1
> > >
> >
>
Jonathan Cameron Nov. 16, 2019, 5:32 p.m. UTC | #4
On Sat, 16 Nov 2019 17:54:44 +0100
Jacopo Mondi <jacopo@jmondi.org> wrote:

> Hello,
> 
> On Sat, Nov 16, 2019 at 04:25:22PM +0000, Jonathan Cameron wrote:
> > On Thu, 14 Nov 2019 08:28:03 +0100
> > Niklas Söderlund <niklas.soderlund@ragnatech.se> wrote:
> >  
> > > Hi Geert,
> > >
> > > Looks good.
> > >
> > > On 2019-11-13 11:09:38 +0100, Geert Uytterhoeven wrote:  
> > > > The relations between enum values and array indices values are currently
> > > > not enforced by the code, which makes them fragile w.r.t. future
> > > > changes.
> > > >
> > > > Fix this by:
> > > >   1. Using designated array initializers, to make sure array indices and
> > > >      enums values match,
> > > >   2. Linking max9611_csa_gain enum values to the corresponding
> > > >      max9611_conf_ids enum values, as the latter is cast to the former
> > > >      in max9611_read_csa_voltage().
> > > >
> > > > No change in generated code.
> > > >
> > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>  
> > >
> > > Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>  
> >
> > Looks good to me, but I'd like to leave a little longer for any
> > feedback from Jacopo as author of the driver.  
> 
> yeah, sorry I've been sloppy.. I meant to give the patches a run, but
> it seems there are only syntactic changes here, which indeed make the
> code more robust.
> 
> Even if not tested, please add
> Acked-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks!

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

Thanks,

J
> 
> Thanks
>   j
> 
> >
> > Thanks,
> >
> > Jonathan  
> > >  
> > > > ---
> > > >  drivers/iio/adc/max9611.c | 36 +++++++++++-------------------------
> > > >  1 file changed, 11 insertions(+), 25 deletions(-)
> > > >
> > > > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > > > index b0755f25356d700d..cb306ff1a5d6a0b2 100644
> > > > --- a/drivers/iio/adc/max9611.c
> > > > +++ b/drivers/iio/adc/max9611.c
> > > > @@ -114,22 +114,17 @@ enum max9611_conf_ids {
> > > >   *		      where data shall be read from
> > > >   */
> > > >  static const unsigned int max9611_mux_conf[][2] = {
> > > > -	/* CONF_SENSE_1x */
> > > > -	{ MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> > > > -	/* CONF_SENSE_4x */
> > > > -	{ MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> > > > -	/* CONF_SENSE_8x */
> > > > -	{ MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> > > > -	/* CONF_IN_VOLT */
> > > > -	{ MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> > > > -	/* CONF_TEMP */
> > > > -	{ MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> > > > +	[CONF_SENSE_1x]	= { MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
> > > > +	[CONF_SENSE_4x]	= { MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
> > > > +	[CONF_SENSE_8x]	= { MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
> > > > +	[CONF_IN_VOLT]	= { MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
> > > > +	[CONF_TEMP]	= { MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
> > > >  };
> > > >
> > > >  enum max9611_csa_gain {
> > > > -	CSA_GAIN_1x,
> > > > -	CSA_GAIN_4x,
> > > > -	CSA_GAIN_8x,
> > > > +	CSA_GAIN_1x = CONF_SENSE_1x,
> > > > +	CSA_GAIN_4x = CONF_SENSE_4x,
> > > > +	CSA_GAIN_8x = CONF_SENSE_8x,
> > > >  };
> > > >
> > > >  enum max9611_csa_gain_params {
> > > > @@ -147,18 +142,9 @@ enum max9611_csa_gain_params {
> > > >   * value; use this structure to retrieve the correct LSB and offset values.
> > > >   */
> > > >  static const unsigned int max9611_gain_conf[][2] = {
> > > > -	{ /* [0] CSA_GAIN_1x */
> > > > -		MAX9611_CSA_1X_LSB_nV,
> > > > -		MAX9611_CSA_1X_OFFS_RAW,
> > > > -	},
> > > > -	{ /* [1] CSA_GAIN_4x */
> > > > -		MAX9611_CSA_4X_LSB_nV,
> > > > -		MAX9611_CSA_4X_OFFS_RAW,
> > > > -	},
> > > > -	{ /* [2] CSA_GAIN_8x */
> > > > -		MAX9611_CSA_8X_LSB_nV,
> > > > -		MAX9611_CSA_8X_OFFS_RAW,
> > > > -	},
> > > > +	[CSA_GAIN_1x] = { MAX9611_CSA_1X_LSB_nV, MAX9611_CSA_1X_OFFS_RAW, },
> > > > +	[CSA_GAIN_4x] = { MAX9611_CSA_4X_LSB_nV, MAX9611_CSA_4X_OFFS_RAW, },
> > > > +	[CSA_GAIN_8x] = { MAX9611_CSA_8X_LSB_nV, MAX9611_CSA_8X_OFFS_RAW, },
> > > >  };
> > > >
> > > >  enum max9611_chan_addrs {
> > > > --
> > > > 2.17.1
> > > >  
> > >  
> >

Patch
diff mbox series

diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
index b0755f25356d700d..cb306ff1a5d6a0b2 100644
--- a/drivers/iio/adc/max9611.c
+++ b/drivers/iio/adc/max9611.c
@@ -114,22 +114,17 @@  enum max9611_conf_ids {
  *		      where data shall be read from
  */
 static const unsigned int max9611_mux_conf[][2] = {
-	/* CONF_SENSE_1x */
-	{ MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
-	/* CONF_SENSE_4x */
-	{ MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
-	/* CONF_SENSE_8x */
-	{ MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
-	/* CONF_IN_VOLT */
-	{ MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
-	/* CONF_TEMP */
-	{ MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
+	[CONF_SENSE_1x]	= { MAX9611_MUX_SENSE_1x, MAX9611_REG_CSA_DATA },
+	[CONF_SENSE_4x]	= { MAX9611_MUX_SENSE_4x, MAX9611_REG_CSA_DATA },
+	[CONF_SENSE_8x]	= { MAX9611_MUX_SENSE_8x, MAX9611_REG_CSA_DATA },
+	[CONF_IN_VOLT]	= { MAX9611_INPUT_VOLT, MAX9611_REG_RS_DATA },
+	[CONF_TEMP]	= { MAX9611_MUX_TEMP, MAX9611_REG_TEMP_DATA },
 };
 
 enum max9611_csa_gain {
-	CSA_GAIN_1x,
-	CSA_GAIN_4x,
-	CSA_GAIN_8x,
+	CSA_GAIN_1x = CONF_SENSE_1x,
+	CSA_GAIN_4x = CONF_SENSE_4x,
+	CSA_GAIN_8x = CONF_SENSE_8x,
 };
 
 enum max9611_csa_gain_params {
@@ -147,18 +142,9 @@  enum max9611_csa_gain_params {
  * value; use this structure to retrieve the correct LSB and offset values.
  */
 static const unsigned int max9611_gain_conf[][2] = {
-	{ /* [0] CSA_GAIN_1x */
-		MAX9611_CSA_1X_LSB_nV,
-		MAX9611_CSA_1X_OFFS_RAW,
-	},
-	{ /* [1] CSA_GAIN_4x */
-		MAX9611_CSA_4X_LSB_nV,
-		MAX9611_CSA_4X_OFFS_RAW,
-	},
-	{ /* [2] CSA_GAIN_8x */
-		MAX9611_CSA_8X_LSB_nV,
-		MAX9611_CSA_8X_OFFS_RAW,
-	},
+	[CSA_GAIN_1x] = { MAX9611_CSA_1X_LSB_nV, MAX9611_CSA_1X_OFFS_RAW, },
+	[CSA_GAIN_4x] = { MAX9611_CSA_4X_LSB_nV, MAX9611_CSA_4X_OFFS_RAW, },
+	[CSA_GAIN_8x] = { MAX9611_CSA_8X_LSB_nV, MAX9611_CSA_8X_OFFS_RAW, },
 };
 
 enum max9611_chan_addrs {