diff for duplicates of <20181125110839.4a3aecf9@archlinux> diff --git a/a/1.txt b/N1/1.txt index 3af3895..0225f38 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -3,81 +3,77 @@ On Thu, 22 Nov 2018 11:01:00 +0000 > On Mi, 2018-11-21 at 16:04 -0200, Giuliano Belinassi wrote: > > Previously, the AD7780 driver only supported gpio for the 'powerdown' -> > pin. This commit adds suppport for the 'gain' and 'filter' pin. =20 +> > pin. This commit adds suppport for the 'gain' and 'filter' pin. > Hey, ->=20 +> > Comments inline. -> >=20 +> > > > Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br> > > --- -> > =C2=A0drivers/staging/iio/adc/ad7780.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= -=A0=C2=A0| 61 ++++++++++++++++++++++++-- -> > =C2=A0include/linux/iio/adc/ad_sigma_delta.h |=C2=A0=C2=A05 +++ -> > =C2=A02 files changed, 62 insertions(+), 4 deletions(-) -> >=20 +> > drivers/staging/iio/adc/ad7780.c | 61 ++++++++++++++++++++++++-- +> > include/linux/iio/adc/ad_sigma_delta.h | 5 +++ +> > 2 files changed, 62 insertions(+), 4 deletions(-) +> > > > diff --git a/drivers/staging/iio/adc/ad7780.c > > b/drivers/staging/iio/adc/ad7780.c > > index c4a85789c2db..69794f06dbcd 100644 > > --- a/drivers/staging/iio/adc/ad7780.c > > +++ b/drivers/staging/iio/adc/ad7780.c > > @@ -39,6 +39,9 @@ -> > =C2=A0#define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2) -> > =C2=A0#define AD7170_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1 | +> > #define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2) +> > #define AD7170_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1 | > > AD7170_PAT2) -> > =C2=A0 +> > > > +#define AD7780_GAIN_GPIO 0 > > +#define AD7780_FILTER_GPIO 1 > > + -> > =C2=A0struct ad7780_chip_info { -> > =C2=A0 struct iio_chan_spec channel; -> > =C2=A0 unsigned int pattern_mask; +> > struct ad7780_chip_info { +> > struct iio_chan_spec channel; +> > unsigned int pattern_mask; > > @@ -50,6 +53,8 @@ struct ad7780_state { -> > =C2=A0 const struct ad7780_chip_info *chip_info; -> > =C2=A0 struct regulator *reg; -> > =C2=A0 struct gpio_desc *powerdown_gpio; +> > const struct ad7780_chip_info *chip_info; +> > struct regulator *reg; +> > struct gpio_desc *powerdown_gpio; > > + struct gpio_desc *gain_gpio; > > + struct gpio_desc *filter_gpio; -> > =C2=A0 unsigned int gain; -> > =C2=A0 -> > =C2=A0 struct ad_sigma_delta sd; +> > unsigned int gain; +> > +> > struct ad_sigma_delta sd; > > @@ -115,18 +120,51 @@ static int ad7780_read_raw(struct iio_dev > > *indio_dev, -> > =C2=A0 return -EINVAL; -> > =C2=A0} -> > =C2=A0 +> > return -EINVAL; +> > } +> > > > +static int ad7780_write_raw(struct iio_dev *indio_dev, -> > + =C2=A0=C2=A0=C2=A0=C2=A0struct iio_chan_spec const *chan, -> > + =C2=A0=C2=A0=C2=A0=C2=A0int val, -> > + =C2=A0=C2=A0=C2=A0=C2=A0int val2, -> > + =C2=A0=C2=A0=C2=A0=C2=A0long m) +> > + struct iio_chan_spec const *chan, +> > + int val, +> > + int val2, +> > + long m) > > +{ -> > + struct ad7780_state *st =3D iio_priv(indio_dev); +> > + struct ad7780_state *st = iio_priv(indio_dev); > > + -> > + if (m !=3D IIO_CHAN_INFO_RAW) +> > + if (m != IIO_CHAN_INFO_RAW) > > + return -EINVAL; > > + > > + if (st->chip_info->is_ad778x) { > > + switch(val) { -> > + case AD7780_GAIN_GPIO: =20 ->=20 +> > + case AD7780_GAIN_GPIO: +> > I think that instead of setting the gain directly, we should use -> the=C2=A0IIO_CHAN_INFO_SCALE attribute. At page 12 of the ad7780 datashee= -t there +> the IIO_CHAN_INFO_SCALE attribute. At page 12 of the ad7780 datasheet there > is a formula from which the output code can be calculated: -> Code =3D 2^(N =E2=88=92 1) -> =C3=97 [(AIN =C3=97 Gain /VREF) + 1]. So, by setting the scale from user = -space, the +> Code = 2^(N − 1) +> × [(AIN × Gain /VREF) + 1]. So, by setting the scale from user space, the > driver can calculate the correct gain by using the formula above. Also, it > would be useful to introduce scale available. > Furthermore, there is a new -> ad7124 adc driver which does this exact thing. Take a look here:=C2=A0htt= -ps://gi +> ad7124 adc driver which does this exact thing. Take a look here: https://gi > thub.com/analogdevicesinc/linux/blob/master/drivers/iio/adc/ad7124.c#L337. ->=20 +> > > + gpiod_set_value(st->gain_gpio, val2); > > + break; -> > + case AD7780_FILTER_GPIO: =20 ->=20 +> > + case AD7780_FILTER_GPIO: +> > The attribute that should be used to configure the filter gpio is > IIO_CHAN_INFO_SAMP_FREQ. So, we should have 10 Hz and 16.7 Hz available > sampling frequencies. If from user space the 10 Hz sampling freq is @@ -106,7 +102,7 @@ Jonathan ->=20 +> > > + gpiod_set_value(st->filter_gpio, val2); > > + break; > > + default: @@ -117,76 +113,73 @@ Jonathan > > + return 0; > > +} > > + -> > =C2=A0static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma= -_delta, -> > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0unsigned int raw_sample) -> > =C2=A0{ -> > =C2=A0 struct ad7780_state *st =3D ad_sigma_delta_to_ad7780(sigma_delta= -); -> > =C2=A0 const struct ad7780_chip_info *chip_info =3D st->chip_info; +> > static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, +> > unsigned int raw_sample) +> > { +> > struct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta); +> > const struct ad7780_chip_info *chip_info = st->chip_info; > > + int val; -> > =C2=A0 -> > =C2=A0 if ((raw_sample & AD7780_ERR) || -> > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0((raw_sample & chip_info->pattern_mask) = -!=3D chip_info- =20 -> > >pattern)) =20 -> > =C2=A0 return -EIO; -> > =C2=A0 -> > =C2=A0 if (chip_info->is_ad778x) { +> > +> > if ((raw_sample & AD7780_ERR) || +> > ((raw_sample & chip_info->pattern_mask) != chip_info- +> > >pattern)) +> > return -EIO; +> > +> > if (chip_info->is_ad778x) { > > - if (raw_sample & AD7780_GAIN) -> > + val =3D raw_sample & AD7780_GAIN; +> > + val = raw_sample & AD7780_GAIN; > > + -> > + if (val !=3D gpiod_get_value(st->gain_gpio)) +> > + if (val != gpiod_get_value(st->gain_gpio)) > > + return -EIO; > > + > > + if (val) -> > =C2=A0 st->gain =3D 1; -> > =C2=A0 else -> > =C2=A0 st->gain =3D 128; +> > st->gain = 1; +> > else +> > st->gain = 128; > > @@ -141,18 +179,20 @@ static const struct ad_sigma_delta_info -> > ad7780_sigma_delta_info =3D { -> > =C2=A0 .has_registers =3D false, -> > =C2=A0}; -> > =C2=A0 +> > ad7780_sigma_delta_info = { +> > .has_registers = false, +> > }; +> > > > -#define AD7780_CHANNEL(bits, wordsize) \ > > +#define AD7170_CHANNEL(bits, wordsize) \ -> > =C2=A0 AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits) +> > AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits) > > +#define AD7780_CHANNEL(bits, wordsize) \ > > + AD_SD_CHANNEL_GAIN_FILTER(1, 0, 0, bits, 32, wordsize - bits) -> > =C2=A0 -> > =C2=A0static const struct ad7780_chip_info ad7780_chip_info_tbl[] =3D { -> > =C2=A0 [ID_AD7170] =3D { -> > - .channel =3D AD7780_CHANNEL(12, 24), -> > + .channel =3D AD7170_CHANNEL(12, 24), -> > =C2=A0 .pattern =3D AD7170_PATTERN, -> > =C2=A0 .pattern_mask =3D AD7170_PATTERN_MASK, -> > =C2=A0 .is_ad778x =3D false, -> > =C2=A0 }, -> > =C2=A0 [ID_AD7171] =3D { -> > - .channel =3D AD7780_CHANNEL(16, 24), -> > + .channel =3D AD7170_CHANNEL(16, 24), -> > =C2=A0 .pattern =3D AD7170_PATTERN, -> > =C2=A0 .pattern_mask =3D AD7170_PATTERN_MASK, -> > =C2=A0 .is_ad778x =3D false, +> > +> > static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { +> > [ID_AD7170] = { +> > - .channel = AD7780_CHANNEL(12, 24), +> > + .channel = AD7170_CHANNEL(12, 24), +> > .pattern = AD7170_PATTERN, +> > .pattern_mask = AD7170_PATTERN_MASK, +> > .is_ad778x = false, +> > }, +> > [ID_AD7171] = { +> > - .channel = AD7780_CHANNEL(16, 24), +> > + .channel = AD7170_CHANNEL(16, 24), +> > .pattern = AD7170_PATTERN, +> > .pattern_mask = AD7170_PATTERN_MASK, +> > .is_ad778x = false, > > @@ -173,6 +213,7 @@ static const struct ad7780_chip_info -> > ad7780_chip_info_tbl[] =3D { -> > =C2=A0 -> > =C2=A0static const struct iio_info ad7780_info =3D { -> > =C2=A0 .read_raw =3D ad7780_read_raw, -> > + .write_raw =3D ad7780_write_raw, -> > =C2=A0}; -> > =C2=A0 -> > =C2=A0static int ad7780_probe(struct spi_device *spi) +> > ad7780_chip_info_tbl[] = { +> > +> > static const struct iio_info ad7780_info = { +> > .read_raw = ad7780_read_raw, +> > + .write_raw = ad7780_write_raw, +> > }; +> > +> > static int ad7780_probe(struct spi_device *spi) > > @@ -222,6 +263,18 @@ static int ad7780_probe(struct spi_device *spi) -> > =C2=A0 goto error_disable_reg; -> > =C2=A0 } -> > =C2=A0 +> > goto error_disable_reg; +> > } +> > > > + if (st->chip_info->is_ad778x) { -> > + st->gain_gpio =3D devm_gpiod_get_optional(&spi->dev, +> > + st->gain_gpio = devm_gpiod_get_optional(&spi->dev, > > + "gain", > > + GPIOD_OUT_HIGH); > > + if (IS_ERR(st->gain_gpio)) { -> > + ret =3D PTR_ERR(st->gain_gpio); +> > + ret = PTR_ERR(st->gain_gpio); > > + dev_err(&spi->dev, "Failed to request gain GPIO: > > %d\n", > > + ret); @@ -194,9 +187,9 @@ _delta, > > + } > > + } > > + -> > =C2=A0 ret =3D ad_sd_setup_buffer_and_trigger(indio_dev); -> > =C2=A0 if (ret) -> > =C2=A0 goto error_disable_reg; +> > ret = ad_sd_setup_buffer_and_trigger(indio_dev); +> > if (ret) +> > goto error_disable_reg; > > diff --git a/include/linux/iio/adc/ad_sigma_delta.h > > b/include/linux/iio/adc/ad_sigma_delta.h > > index 730ead1a46df..6cadab6fd5fd 100644 @@ -204,16 +197,15 @@ _delta, > > +++ b/include/linux/iio/adc/ad_sigma_delta.h > > @@ -173,6 +173,11 @@ int ad_sd_validate_trigger(struct iio_dev > > *indio_dev, struct iio_trigger *trig); -> > =C2=A0 __AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \ -> > =C2=A0 _storagebits, _shift, NULL, IIO_VOLTAGE, 0) -> > =C2=A0 +> > __AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \ +> > _storagebits, _shift, NULL, IIO_VOLTAGE, 0) +> > > > +#define AD_SD_CHANNEL_GAIN_FILTER(_si, _channel, _address, _bits, \ > > + _storagebits, _shift) \ > > + __AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \ > > + _storagebits, _shift, NULL, IIO_VOLTAGE, > > BIT(IIO_CHAN_INFO_RAW)) > > + -> > =C2=A0#define AD_SD_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _s= -hift) \ -> > =C2=A0 __AD_SD_CHANNEL(_si, 0, -1, _address, _bits, \ -> > =C2=A0 _storagebits, _shift, NULL, IIO_TEMP, =20 +> > #define AD_SD_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _shift) \ +> > __AD_SD_CHANNEL(_si, 0, -1, _address, _bits, \ +> > _storagebits, _shift, NULL, IIO_TEMP, diff --git a/a/content_digest b/N1/content_digest index 5dc0fe3..8e00e90 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -25,81 +25,77 @@ "\n" "> On Mi, 2018-11-21 at 16:04 -0200, Giuliano Belinassi wrote:\n" "> > Previously, the AD7780 driver only supported gpio for the 'powerdown'\n" - "> > pin. This commit adds suppport for the 'gain' and 'filter' pin. =20\n" + "> > pin. This commit adds suppport for the 'gain' and 'filter' pin. \n" "> Hey,\n" - ">=20\n" + "> \n" "> Comments inline.\n" - "> >=20\n" + "> > \n" "> > Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br>\n" "> > ---\n" - "> > =C2=A0drivers/staging/iio/adc/ad7780.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=\n" - "=A0=C2=A0| 61 ++++++++++++++++++++++++--\n" - "> > =C2=A0include/linux/iio/adc/ad_sigma_delta.h |=C2=A0=C2=A05 +++\n" - "> > =C2=A02 files changed, 62 insertions(+), 4 deletions(-)\n" - "> >=20\n" + "> > \302\240drivers/staging/iio/adc/ad7780.c\302\240\302\240\302\240\302\240\302\240\302\240\302\240| 61 ++++++++++++++++++++++++--\n" + "> > \302\240include/linux/iio/adc/ad_sigma_delta.h |\302\240\302\2405 +++\n" + "> > \302\2402 files changed, 62 insertions(+), 4 deletions(-)\n" + "> > \n" "> > diff --git a/drivers/staging/iio/adc/ad7780.c\n" "> > b/drivers/staging/iio/adc/ad7780.c\n" "> > index c4a85789c2db..69794f06dbcd 100644\n" "> > --- a/drivers/staging/iio/adc/ad7780.c\n" "> > +++ b/drivers/staging/iio/adc/ad7780.c\n" "> > @@ -39,6 +39,9 @@\n" - "> > =C2=A0#define AD7170_PATTERN\t\t(AD7780_PAT0 | AD7170_PAT2)\n" - "> > =C2=A0#define AD7170_PATTERN_MASK\t(AD7780_PAT0 | AD7780_PAT1 |\n" + "> > \302\240#define AD7170_PATTERN\t\t(AD7780_PAT0 | AD7170_PAT2)\n" + "> > \302\240#define AD7170_PATTERN_MASK\t(AD7780_PAT0 | AD7780_PAT1 |\n" "> > AD7170_PAT2)\n" - "> > =C2=A0\n" + "> > \302\240\n" "> > +#define AD7780_GAIN_GPIO\t0\n" "> > +#define AD7780_FILTER_GPIO\t1\n" "> > +\n" - "> > =C2=A0struct ad7780_chip_info {\n" - "> > =C2=A0\tstruct iio_chan_spec\tchannel;\n" - "> > =C2=A0\tunsigned int\t\tpattern_mask;\n" + "> > \302\240struct ad7780_chip_info {\n" + "> > \302\240\tstruct iio_chan_spec\tchannel;\n" + "> > \302\240\tunsigned int\t\tpattern_mask;\n" "> > @@ -50,6 +53,8 @@ struct ad7780_state {\n" - "> > =C2=A0\tconst struct ad7780_chip_info\t*chip_info;\n" - "> > =C2=A0\tstruct regulator\t\t*reg;\n" - "> > =C2=A0\tstruct gpio_desc\t\t*powerdown_gpio;\n" + "> > \302\240\tconst struct ad7780_chip_info\t*chip_info;\n" + "> > \302\240\tstruct regulator\t\t*reg;\n" + "> > \302\240\tstruct gpio_desc\t\t*powerdown_gpio;\n" "> > +\tstruct gpio_desc\t\t*gain_gpio;\n" "> > +\tstruct gpio_desc\t\t*filter_gpio;\n" - "> > =C2=A0\tunsigned int\tgain;\n" - "> > =C2=A0\n" - "> > =C2=A0\tstruct ad_sigma_delta sd;\n" + "> > \302\240\tunsigned int\tgain;\n" + "> > \302\240\n" + "> > \302\240\tstruct ad_sigma_delta sd;\n" "> > @@ -115,18 +120,51 @@ static int ad7780_read_raw(struct iio_dev\n" "> > *indio_dev,\n" - "> > =C2=A0\treturn -EINVAL;\n" - "> > =C2=A0}\n" - "> > =C2=A0\n" + "> > \302\240\treturn -EINVAL;\n" + "> > \302\240}\n" + "> > \302\240\n" "> > +static int ad7780_write_raw(struct iio_dev *indio_dev,\n" - "> > +\t\t\t=C2=A0=C2=A0=C2=A0=C2=A0struct iio_chan_spec const *chan,\n" - "> > +\t\t\t=C2=A0=C2=A0=C2=A0=C2=A0int val,\n" - "> > +\t\t\t=C2=A0=C2=A0=C2=A0=C2=A0int val2,\n" - "> > +\t\t\t=C2=A0=C2=A0=C2=A0=C2=A0long m)\n" + "> > +\t\t\t\302\240\302\240\302\240\302\240struct iio_chan_spec const *chan,\n" + "> > +\t\t\t\302\240\302\240\302\240\302\240int val,\n" + "> > +\t\t\t\302\240\302\240\302\240\302\240int val2,\n" + "> > +\t\t\t\302\240\302\240\302\240\302\240long m)\n" "> > +{\n" - "> > +\tstruct ad7780_state *st =3D iio_priv(indio_dev);\n" + "> > +\tstruct ad7780_state *st = iio_priv(indio_dev);\n" "> > +\n" - "> > +\tif (m !=3D IIO_CHAN_INFO_RAW)\n" + "> > +\tif (m != IIO_CHAN_INFO_RAW)\n" "> > +\t\treturn -EINVAL;\n" "> > +\n" "> > +\tif (st->chip_info->is_ad778x) {\n" "> > +\t\tswitch(val) {\n" - "> > +\t\tcase AD7780_GAIN_GPIO: =20\n" - ">=20\n" + "> > +\t\tcase AD7780_GAIN_GPIO: \n" + "> \n" "> I think that instead of setting the gain directly, we should use\n" - "> the=C2=A0IIO_CHAN_INFO_SCALE attribute. At page 12 of the ad7780 datashee=\n" - "t there\n" + "> the\302\240IIO_CHAN_INFO_SCALE attribute. At page 12 of the ad7780 datasheet there\n" "> is a formula from which the output code can be calculated:\n" - "> Code =3D 2^(N =E2=88=92 1)\n" - "> =C3=97 [(AIN =C3=97 Gain /VREF) + 1]. So, by setting the scale from user =\n" - "space, the\n" + "> Code = 2^(N \342\210\222 1)\n" + "> \303\227 [(AIN \303\227 Gain /VREF) + 1]. So, by setting the scale from user space, the\n" "> driver can calculate the correct gain by using the formula above. Also, it\n" "> would be useful to introduce scale available.\n" "> Furthermore, there is a new\n" - "> ad7124 adc driver which does this exact thing. Take a look here:=C2=A0htt=\n" - "ps://gi\n" + "> ad7124 adc driver which does this exact thing. Take a look here:\302\240https://gi\n" "> thub.com/analogdevicesinc/linux/blob/master/drivers/iio/adc/ad7124.c#L337.\n" - ">=20\n" + "> \n" "> > +\t\t\tgpiod_set_value(st->gain_gpio, val2);\n" "> > +\t\tbreak;\n" - "> > +\t\tcase AD7780_FILTER_GPIO: =20\n" - ">=20\n" + "> > +\t\tcase AD7780_FILTER_GPIO: \n" + "> \n" "> The attribute that should be used to configure the filter gpio is\n" "> IIO_CHAN_INFO_SAMP_FREQ. So, we should have 10 Hz and 16.7 Hz available\n" "> sampling frequencies. If from user space the 10 Hz sampling freq is\n" @@ -128,7 +124,7 @@ "\n" "\n" "\n" - ">=20\n" + "> \n" "> > +\t\t\tgpiod_set_value(st->filter_gpio, val2);\n" "> > +\t\tbreak;\n" "> > +\t\tdefault:\n" @@ -139,76 +135,73 @@ "> > +\treturn 0;\n" "> > +}\n" "> > +\n" - "> > =C2=A0static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma=\n" - "_delta,\n" - "> > =C2=A0\t\t\t\t=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0unsigned int raw_sample)\n" - "> > =C2=A0{\n" - "> > =C2=A0\tstruct ad7780_state *st =3D ad_sigma_delta_to_ad7780(sigma_delta=\n" - ");\n" - "> > =C2=A0\tconst struct ad7780_chip_info *chip_info =3D st->chip_info;\n" + "> > \302\240static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta,\n" + "> > \302\240\t\t\t\t\302\240\302\240\302\240\302\240\302\240unsigned int raw_sample)\n" + "> > \302\240{\n" + "> > \302\240\tstruct ad7780_state *st = ad_sigma_delta_to_ad7780(sigma_delta);\n" + "> > \302\240\tconst struct ad7780_chip_info *chip_info = st->chip_info;\n" "> > +\tint val;\n" - "> > =C2=A0\n" - "> > =C2=A0\tif ((raw_sample & AD7780_ERR) ||\n" - "> > =C2=A0\t=C2=A0=C2=A0=C2=A0=C2=A0((raw_sample & chip_info->pattern_mask) =\n" - "!=3D chip_info- =20\n" - "> > >pattern)) =20\n" - "> > =C2=A0\t\treturn -EIO;\n" - "> > =C2=A0\n" - "> > =C2=A0\tif (chip_info->is_ad778x) {\n" + "> > \302\240\n" + "> > \302\240\tif ((raw_sample & AD7780_ERR) ||\n" + "> > \302\240\t\302\240\302\240\302\240\302\240((raw_sample & chip_info->pattern_mask) != chip_info- \n" + "> > >pattern)) \n" + "> > \302\240\t\treturn -EIO;\n" + "> > \302\240\n" + "> > \302\240\tif (chip_info->is_ad778x) {\n" "> > -\t\tif (raw_sample & AD7780_GAIN)\n" - "> > +\t\tval =3D raw_sample & AD7780_GAIN;\n" + "> > +\t\tval = raw_sample & AD7780_GAIN;\n" "> > +\n" - "> > +\t\tif (val !=3D gpiod_get_value(st->gain_gpio))\n" + "> > +\t\tif (val != gpiod_get_value(st->gain_gpio))\n" "> > +\t\t\treturn -EIO;\n" "> > +\n" "> > +\t\tif (val)\n" - "> > =C2=A0\t\t\tst->gain =3D 1;\n" - "> > =C2=A0\t\telse\n" - "> > =C2=A0\t\t\tst->gain =3D 128;\n" + "> > \302\240\t\t\tst->gain = 1;\n" + "> > \302\240\t\telse\n" + "> > \302\240\t\t\tst->gain = 128;\n" "> > @@ -141,18 +179,20 @@ static const struct ad_sigma_delta_info\n" - "> > ad7780_sigma_delta_info =3D {\n" - "> > =C2=A0\t.has_registers =3D false,\n" - "> > =C2=A0};\n" - "> > =C2=A0\n" + "> > ad7780_sigma_delta_info = {\n" + "> > \302\240\t.has_registers = false,\n" + "> > \302\240};\n" + "> > \302\240\n" "> > -#define AD7780_CHANNEL(bits, wordsize) \\\n" "> > +#define AD7170_CHANNEL(bits, wordsize) \\\n" - "> > =C2=A0\tAD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)\n" + "> > \302\240\tAD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)\n" "> > +#define AD7780_CHANNEL(bits, wordsize) \\\n" "> > +\tAD_SD_CHANNEL_GAIN_FILTER(1, 0, 0, bits, 32, wordsize - bits)\n" - "> > =C2=A0\n" - "> > =C2=A0static const struct ad7780_chip_info ad7780_chip_info_tbl[] =3D {\n" - "> > =C2=A0\t[ID_AD7170] =3D {\n" - "> > -\t\t.channel =3D AD7780_CHANNEL(12, 24),\n" - "> > +\t\t.channel =3D AD7170_CHANNEL(12, 24),\n" - "> > =C2=A0\t\t.pattern =3D AD7170_PATTERN,\n" - "> > =C2=A0\t\t.pattern_mask =3D AD7170_PATTERN_MASK,\n" - "> > =C2=A0\t\t.is_ad778x =3D false,\n" - "> > =C2=A0\t},\n" - "> > =C2=A0\t[ID_AD7171] =3D {\n" - "> > -\t\t.channel =3D AD7780_CHANNEL(16, 24),\n" - "> > +\t\t.channel =3D AD7170_CHANNEL(16, 24),\n" - "> > =C2=A0\t\t.pattern =3D AD7170_PATTERN,\n" - "> > =C2=A0\t\t.pattern_mask =3D AD7170_PATTERN_MASK,\n" - "> > =C2=A0\t\t.is_ad778x =3D false,\n" + "> > \302\240\n" + "> > \302\240static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {\n" + "> > \302\240\t[ID_AD7170] = {\n" + "> > -\t\t.channel = AD7780_CHANNEL(12, 24),\n" + "> > +\t\t.channel = AD7170_CHANNEL(12, 24),\n" + "> > \302\240\t\t.pattern = AD7170_PATTERN,\n" + "> > \302\240\t\t.pattern_mask = AD7170_PATTERN_MASK,\n" + "> > \302\240\t\t.is_ad778x = false,\n" + "> > \302\240\t},\n" + "> > \302\240\t[ID_AD7171] = {\n" + "> > -\t\t.channel = AD7780_CHANNEL(16, 24),\n" + "> > +\t\t.channel = AD7170_CHANNEL(16, 24),\n" + "> > \302\240\t\t.pattern = AD7170_PATTERN,\n" + "> > \302\240\t\t.pattern_mask = AD7170_PATTERN_MASK,\n" + "> > \302\240\t\t.is_ad778x = false,\n" "> > @@ -173,6 +213,7 @@ static const struct ad7780_chip_info\n" - "> > ad7780_chip_info_tbl[] =3D {\n" - "> > =C2=A0\n" - "> > =C2=A0static const struct iio_info ad7780_info =3D {\n" - "> > =C2=A0\t.read_raw =3D ad7780_read_raw,\n" - "> > +\t.write_raw =3D ad7780_write_raw,\n" - "> > =C2=A0};\n" - "> > =C2=A0\n" - "> > =C2=A0static int ad7780_probe(struct spi_device *spi)\n" + "> > ad7780_chip_info_tbl[] = {\n" + "> > \302\240\n" + "> > \302\240static const struct iio_info ad7780_info = {\n" + "> > \302\240\t.read_raw = ad7780_read_raw,\n" + "> > +\t.write_raw = ad7780_write_raw,\n" + "> > \302\240};\n" + "> > \302\240\n" + "> > \302\240static int ad7780_probe(struct spi_device *spi)\n" "> > @@ -222,6 +263,18 @@ static int ad7780_probe(struct spi_device *spi)\n" - "> > =C2=A0\t\tgoto error_disable_reg;\n" - "> > =C2=A0\t}\n" - "> > =C2=A0\n" + "> > \302\240\t\tgoto error_disable_reg;\n" + "> > \302\240\t}\n" + "> > \302\240\n" "> > +\tif (st->chip_info->is_ad778x) {\n" - "> > +\t\tst->gain_gpio =3D devm_gpiod_get_optional(&spi->dev,\n" + "> > +\t\tst->gain_gpio = devm_gpiod_get_optional(&spi->dev,\n" "> > +\t\t\t\t\t\t\t\"gain\",\n" "> > +\t\t\t\t\t\t\tGPIOD_OUT_HIGH);\n" "> > +\t\tif (IS_ERR(st->gain_gpio)) {\n" - "> > +\t\t\tret =3D PTR_ERR(st->gain_gpio);\n" + "> > +\t\t\tret = PTR_ERR(st->gain_gpio);\n" "> > +\t\t\tdev_err(&spi->dev, \"Failed to request gain GPIO:\n" "> > %d\\n\",\n" "> > +\t\t\t\tret);\n" @@ -216,9 +209,9 @@ "> > +\t\t}\n" "> > +\t}\n" "> > +\n" - "> > =C2=A0\tret =3D ad_sd_setup_buffer_and_trigger(indio_dev);\n" - "> > =C2=A0\tif (ret)\n" - "> > =C2=A0\t\tgoto error_disable_reg;\n" + "> > \302\240\tret = ad_sd_setup_buffer_and_trigger(indio_dev);\n" + "> > \302\240\tif (ret)\n" + "> > \302\240\t\tgoto error_disable_reg;\n" "> > diff --git a/include/linux/iio/adc/ad_sigma_delta.h\n" "> > b/include/linux/iio/adc/ad_sigma_delta.h\n" "> > index 730ead1a46df..6cadab6fd5fd 100644\n" @@ -226,18 +219,17 @@ "> > +++ b/include/linux/iio/adc/ad_sigma_delta.h\n" "> > @@ -173,6 +173,11 @@ int ad_sd_validate_trigger(struct iio_dev\n" "> > *indio_dev, struct iio_trigger *trig);\n" - "> > =C2=A0\t__AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \\\n" - "> > =C2=A0\t\t_storagebits, _shift, NULL, IIO_VOLTAGE, 0)\n" - "> > =C2=A0\n" + "> > \302\240\t__AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \\\n" + "> > \302\240\t\t_storagebits, _shift, NULL, IIO_VOLTAGE, 0)\n" + "> > \302\240\n" "> > +#define AD_SD_CHANNEL_GAIN_FILTER(_si, _channel, _address, _bits, \\\n" "> > +\t_storagebits, _shift) \\\n" "> > +\t__AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \\\n" "> > +\t\t_storagebits, _shift, NULL, IIO_VOLTAGE,\n" "> > BIT(IIO_CHAN_INFO_RAW))\n" "> > +\n" - "> > =C2=A0#define AD_SD_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _s=\n" - "hift) \\\n" - "> > =C2=A0\t__AD_SD_CHANNEL(_si, 0, -1, _address, _bits, \\\n" - "> > =C2=A0\t\t_storagebits, _shift, NULL, IIO_TEMP, =20" + "> > \302\240#define AD_SD_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _shift) \\\n" + "> > \302\240\t__AD_SD_CHANNEL(_si, 0, -1, _address, _bits, \\\n" + "> > \302\240\t\t_storagebits, _shift, NULL, IIO_TEMP," -fdf01f4f969f1276ce0e155b30ee2464846df4aba8262d3f0495190869eaf66d +bb49858cee2095c053e279c9ba63412d01a3bbd6f20ccb3cde403d53d55d15e3
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.