* [PATCH v3 0/3] staging: iio: ad7780: correct driver read @ 2018-11-01 14:42 Renato Lui Geh 2018-11-01 14:43 ` [PATCH v3 1/3] staging: iio: ad7780: fix offset read value Renato Lui Geh ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Renato Lui Geh @ 2018-11-01 14:42 UTC (permalink / raw) To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh, giuliano.belinassi Cc: linux-iio, devel, linux-kernel, kernel-usp The purpose of this series is to correct two issues in the driver's raw read function and remove unnecessary struct fields. Changelog: *v2 - separated original patch into two patches (https://marc.info/?l=linux-iio&m=154047435605492) *v3 - reordered patches so that fixes go first - removed unnecessary initialization - removed unnecessary voltage field variable - dropped reading voltage on probe - returns -EINVAL error on null voltage Renato Lui Geh (3): staging: iio: ad7780: fix offset read value staging: iio: ad7780: update voltage on read staging: iio: ad7780: remove unnecessary stashed voltage value drivers/staging/iio/adc/ad7780.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.19.1 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 1/3] staging: iio: ad7780: fix offset read value 2018-11-01 14:42 [PATCH v3 0/3] staging: iio: ad7780: correct driver read Renato Lui Geh @ 2018-11-01 14:43 ` Renato Lui Geh 2018-11-01 15:02 ` Ardelean, Alexandru 2018-11-01 14:43 ` [PATCH v3 2/3] staging: iio: ad7780: update voltage on read Renato Lui Geh 2018-11-01 14:43 ` [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value Renato Lui Geh 2 siblings, 1 reply; 14+ messages in thread From: Renato Lui Geh @ 2018-11-01 14:43 UTC (permalink / raw) To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh, giuliano.belinassi Cc: linux-iio, devel, linux-kernel, kernel-usp Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET. This was fixed by assigning the correct value instead. Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> --- drivers/staging/iio/adc/ad7780.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b67412db0318..91e016d534ed 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -96,7 +96,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: - *val -= (1 << (chan->scan_type.realbits - 1)); + *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; } -- 2.19.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v3 1/3] staging: iio: ad7780: fix offset read value 2018-11-01 14:43 ` [PATCH v3 1/3] staging: iio: ad7780: fix offset read value Renato Lui Geh @ 2018-11-01 15:02 ` Ardelean, Alexandru 2018-11-03 13:07 ` Jonathan Cameron 0 siblings, 1 reply; 14+ messages in thread From: Ardelean, Alexandru @ 2018-11-01 15:02 UTC (permalink / raw) To: lars@metafoo.de, knaack.h@gmx.de, jic23@kernel.org, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com R29vZCBjYXRjaC4NCg0KQWNrZWQtYnk6IEFsZXhhbmRydSBBcmRlbGVhbiA8YWxleGFuZHJ1LmFy ZGVsZWFuQGFuYWxvZy5jb20+DQoNCk9uIFRodSwgMjAxOC0xMS0wMSBhdCAxMTo0MyAtMDMwMCwg UmVuYXRvIEx1aSBHZWggd3JvdGU6DQo+IFZhcmlhYmxlIHZhbCBzdWJ0cmFjdGVkIGFuIHVuaW5p dGlhbGl6ZWQgdmFsdWUgb24gSUlPX0NIQU5fSU5GT19PRkZTRVQuDQo+IFRoaXMgd2FzIGZpeGVk IGJ5IGFzc2lnbmlu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ix offset read value 2018-11-01 15:02 ` Ardelean, Alexandru @ 2018-11-03 13:07 ` Jonathan Cameron 2018-11-03 15:59 ` Renato Lui Geh 0 siblings, 1 reply; 14+ messages in thread From: Jonathan Cameron @ 2018-11-03 13:07 UTC (permalink / raw) To: Ardelean, Alexandru Cc: lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com On Thu, 1 Nov 2018 15:02:32 +0000 "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > Good catch. > > Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com> On the basis this has been broken for a long time, and you are clearly doing other nearby not fix work, I'm going to take this through the togreg tree rather than via the quicker fix path. It makes my life easier :) Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > > On Thu, 2018-11-01 at 11:43 -0300, Renato Lui Geh wrote: > > Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET. > > This was fixed by assigning the correct value instead. > > > > Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> > > --- > > drivers/staging/iio/adc/ad7780.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/iio/adc/ad7780.c > > b/drivers/staging/iio/adc/ad7780.c > > index b67412db0318..91e016d534ed 100644 > > --- a/drivers/staging/iio/adc/ad7780.c > > +++ b/drivers/staging/iio/adc/ad7780.c > > @@ -96,7 +96,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, > > *val2 = chan->scan_type.realbits - 1; > > return IIO_VAL_FRACTIONAL_LOG2; > > case IIO_CHAN_INFO_OFFSET: > > - *val -= (1 << (chan->scan_type.realbits - 1)); > > + *val = -(1 << (chan->scan_type.realbits - 1)); > > return IIO_VAL_INT; > > } > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 1/3] staging: iio: ad7780: fix offset read value 2018-11-03 13:07 ` Jonathan Cameron @ 2018-11-03 15:59 ` Renato Lui Geh 2018-11-03 17:23 ` Jonathan Cameron 0 siblings, 1 reply; 14+ messages in thread From: Renato Lui Geh @ 2018-11-03 15:59 UTC (permalink / raw) To: Jonathan Cameron Cc: Ardelean, Alexandru, lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com Hi, >On Thu, 1 Nov 2018 15:02:32 +0000 >"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > >> Good catch. That was actually Jonathan's catch. :) >> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com> I read up on Acked-by on the kernel docs, as I didn't know exactly what it meant, but I'm not so sure on how to proceed once the patch has been acked. For future patches, do I add this Acked-by line on the patch's message body? Or is this just an informal way of approval? >On the basis this has been broken for a long time, and you are clearly >doing other nearby not fix work, I'm going to take this through the togreg >tree rather than via the quicker fix path. It makes my life >easier :) > >Applied to the togreg branch of iio.git and pushed out as testing for >the autobuilders to play with it. So this means I should skip this patch on v4, right? Thanks, Renato ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 1/3] staging: iio: ad7780: fix offset read value 2018-11-03 15:59 ` Renato Lui Geh @ 2018-11-03 17:23 ` Jonathan Cameron 0 siblings, 0 replies; 14+ messages in thread From: Jonathan Cameron @ 2018-11-03 17:23 UTC (permalink / raw) To: Renato Lui Geh Cc: Ardelean, Alexandru, lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com On Sat, 3 Nov 2018 12:59:16 -0300 Renato Lui Geh <renatogeh@gmail.com> wrote: > Hi, > > >On Thu, 1 Nov 2018 15:02:32 +0000 > >"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > > > >> Good catch. > > That was actually Jonathan's catch. :) > > >> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com> > > I read up on Acked-by on the kernel docs, as I didn't know exactly what > it meant, but I'm not so sure on how to proceed once the patch has been > acked. For future patches, do I add this Acked-by line on the patch's > message body? Or is this just an informal way of approval? It's formal. You put the line directly below your Signed-off-by: line if you are resending. If I pick up the patch I paste it in there whilst applying. > > >On the basis this has been broken for a long time, and you are clearly > >doing other nearby not fix work, I'm going to take this through the togreg > >tree rather than via the quicker fix path. It makes my life > >easier :) > > > >Applied to the togreg branch of iio.git and pushed out as testing for > >the autobuilders to play with it. > > So this means I should skip this patch on v4, right? Yes. Already in the tree so don't send it again. Thanks Jonathan > > Thanks, > Renato > ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 2/3] staging: iio: ad7780: update voltage on read 2018-11-01 14:42 [PATCH v3 0/3] staging: iio: ad7780: correct driver read Renato Lui Geh 2018-11-01 14:43 ` [PATCH v3 1/3] staging: iio: ad7780: fix offset read value Renato Lui Geh @ 2018-11-01 14:43 ` Renato Lui Geh 2018-11-01 15:20 ` Ardelean, Alexandru 2018-11-01 14:43 ` [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value Renato Lui Geh 2 siblings, 1 reply; 14+ messages in thread From: Renato Lui Geh @ 2018-11-01 14:43 UTC (permalink / raw) To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh, giuliano.belinassi Cc: linux-iio, devel, linux-kernel, kernel-usp The ad7780 driver previously did not read the correct device output, as it read an outdated value set at initialization. It now updates its voltage on read. Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> --- Changes in v3: - removed initialization (int voltage_uv = 0) - returns error when voltage_uv is null drivers/staging/iio/adc/ad7780.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 91e016d534ed..f2a11e9424cd 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: - *val = st->int_vref_mv * st->gain; + voltage_uv = regulator_get_voltage(st->reg); + if (!voltage_uv) + return -EINVAL; + *val = (voltage_uv / 1000) * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: -- 2.19.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/3] staging: iio: ad7780: update voltage on read 2018-11-01 14:43 ` [PATCH v3 2/3] staging: iio: ad7780: update voltage on read Renato Lui Geh @ 2018-11-01 15:20 ` Ardelean, Alexandru 2018-11-03 13:10 ` Jonathan Cameron 0 siblings, 1 reply; 14+ messages in thread From: Ardelean, Alexandru @ 2018-11-01 15:20 UTC (permalink / raw) To: lars@metafoo.de, knaack.h@gmx.de, jic23@kernel.org, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com T24gVGh1LCAyMDE4LTExLTAxIGF0IDExOjQzIC0wMzAwLCBSZW5hdG8gTHVpIEdlaCB3cm90ZToN Cj4gVGhlIGFkNzc4MCBkcml2ZXIgcHJldmlvdXNseSBkaWQgbm90IHJlYWQgdGhlIGNvcnJlY3Qg ZGV2aWNlIG91dHB1dCwgYXMNCj4gaXQgcmVh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7DQo+ICAJY2Fz ZSBJSU9fQ0hBTl9JTkZPX09GRlNFVDoNCg== ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/3] staging: iio: ad7780: update voltage on read 2018-11-01 15:20 ` Ardelean, Alexandru @ 2018-11-03 13:10 ` Jonathan Cameron 2018-11-03 16:06 ` Renato Lui Geh 0 siblings, 1 reply; 14+ messages in thread From: Jonathan Cameron @ 2018-11-03 13:10 UTC (permalink / raw) To: Ardelean, Alexandru Cc: lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com On Thu, 1 Nov 2018 15:20:55 +0000 "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > On Thu, 2018-11-01 at 11:43 -0300, Renato Lui Geh wrote: > > The ad7780 driver previously did not read the correct device output, as > > it read an outdated value set at initialization. It now updates its > > voltage on read. > > > > Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> > > --- > > Changes in v3: > > - removed initialization (int voltage_uv = 0) > > - returns error when voltage_uv is null > > > > drivers/staging/iio/adc/ad7780.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/staging/iio/adc/ad7780.c > > b/drivers/staging/iio/adc/ad7780.c > > index 91e016d534ed..f2a11e9424cd 100644 > > --- a/drivers/staging/iio/adc/ad7780.c > > +++ b/drivers/staging/iio/adc/ad7780.c > > @@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, > > long m) > > { > > struct ad7780_state *st = iio_priv(indio_dev); > > + int voltage_uv; > > > > switch (m) { > > case IIO_CHAN_INFO_RAW: > > return ad_sigma_delta_single_conversion(indio_dev, chan, > > val); > > case IIO_CHAN_INFO_SCALE: > > - *val = st->int_vref_mv * st->gain; > > + voltage_uv = regulator_get_voltage(st->reg); > > + if (!voltage_uv) > > This looks wrong. > I admit this was done in the same way in the probe function, but that looks > a bit wrong as well. > > Typically, the return value of `regulator_get_voltage()` would get checked > with: > > ret = regulator_get_voltage(st->reg); > if (ret < 0) > return ret; > *val = ret / 1000; > > So, negative values are errors and zero & positive values are valid voltage > values. This one is a stylistic choice for readability. I ever so slightly prefer how Alex has it but don't care enough that I'd have commented on it ;) However, nice to tidy up as you'll be respinning patch 3 anyway! Thanks, Jonathan > > > + return -EINVAL; > > + *val = (voltage_uv / 1000) * st->gain; > > *val2 = chan->scan_type.realbits - 1; > > return IIO_VAL_FRACTIONAL_LOG2; > > case IIO_CHAN_INFO_OFFSET: ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/3] staging: iio: ad7780: update voltage on read 2018-11-03 13:10 ` Jonathan Cameron @ 2018-11-03 16:06 ` Renato Lui Geh 2018-11-03 17:21 ` Jonathan Cameron 0 siblings, 1 reply; 14+ messages in thread From: Renato Lui Geh @ 2018-11-03 16:06 UTC (permalink / raw) To: Jonathan Cameron Cc: Ardelean, Alexandru, lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com On Thu, 1 Nov 2018 15:20:55 +0000 "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > > This looks wrong. > I admit this was done in the same way in the probe function, but that looks > a bit wrong as well. > > Typically, the return value of `regulator_get_voltage()` would get checked > with: > > ret = regulator_get_voltage(st->reg); > if (ret < 0) > return ret; > *val = ret / 1000; > > So, negative values are errors and zero & positive values are valid voltage > values. I see. So -EINVAL is only used when sent the wrong info type? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/3] staging: iio: ad7780: update voltage on read 2018-11-03 16:06 ` Renato Lui Geh @ 2018-11-03 17:21 ` Jonathan Cameron 0 siblings, 0 replies; 14+ messages in thread From: Jonathan Cameron @ 2018-11-03 17:21 UTC (permalink / raw) To: Renato Lui Geh Cc: Ardelean, Alexandru, lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com On Sat, 3 Nov 2018 13:06:19 -0300 Renato Lui Geh <renatogeh@gmail.com> wrote: > On Thu, 1 Nov 2018 15:20:55 +0000 > "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > > > > This looks wrong. > > I admit this was done in the same way in the probe function, but that looks > > a bit wrong as well. > > > > Typically, the return value of `regulator_get_voltage()` would get checked > > with: > > > > ret = regulator_get_voltage(st->reg); > > if (ret < 0) > > return ret; > > *val = ret / 1000; > > > > So, negative values are errors and zero & positive values are valid voltage > > values. > > I see. So -EINVAL is only used when sent the wrong info type? yes. I actually misread what was there and thought we were just talking about using a ret variable rather than returning the error via your local variable. Definitely want to pass on the error from regulator_get_voltage as it may have more meaning than a simple -EINVAL. Thanks, Jonathan ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value 2018-11-01 14:42 [PATCH v3 0/3] staging: iio: ad7780: correct driver read Renato Lui Geh 2018-11-01 14:43 ` [PATCH v3 1/3] staging: iio: ad7780: fix offset read value Renato Lui Geh 2018-11-01 14:43 ` [PATCH v3 2/3] staging: iio: ad7780: update voltage on read Renato Lui Geh @ 2018-11-01 14:43 ` Renato Lui Geh 2018-11-01 15:28 ` Ardelean, Alexandru 2 siblings, 1 reply; 14+ messages in thread From: Renato Lui Geh @ 2018-11-01 14:43 UTC (permalink / raw) To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh, giuliano.belinassi Cc: linux-iio, devel, linux-kernel, kernel-usp This patch removes the unnecessary field int_vref_mv in ad7780_state referring to the device's voltage. Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> --- Changes in v3: - removed unnecessary int_vref_mv from ad7780_state drivers/staging/iio/adc/ad7780.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index f2a11e9424cd..f250370efcf7 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -42,7 +42,6 @@ struct ad7780_state { struct regulator *reg; struct gpio_desc *powerdown_gpio; unsigned int gain; - u16 int_vref_mv; struct ad_sigma_delta sd; }; @@ -190,9 +189,7 @@ static int ad7780_probe(struct spi_device *spi) st->chip_info = &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; - if (voltage_uv) - st->int_vref_mv = voltage_uv / 1000; - else + if (!voltage_uv) dev_warn(&spi->dev, "Reference voltage unspecified\n"); spi_set_drvdata(spi, indio_dev); -- 2.19.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value 2018-11-01 14:43 ` [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value Renato Lui Geh @ 2018-11-01 15:28 ` Ardelean, Alexandru 2018-11-03 13:10 ` Jonathan Cameron 0 siblings, 1 reply; 14+ messages in thread From: Ardelean, Alexandru @ 2018-11-01 15:28 UTC (permalink / raw) To: lars@metafoo.de, knaack.h@gmx.de, jic23@kernel.org, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com T24gVGh1LCAyMDE4LTExLTAxIGF0IDExOjQzIC0wMzAwLCBSZW5hdG8gTHVpIEdlaCB3cm90ZToN Cj4gVGhpcyBwYXRjaCByZ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z dGF0aWMgaW50IGFkNzc4MF9wcm9iZShzdHJ1Y3Qgc3BpX2RldmljZSAqc3BpKQ0KPiAgCXN0LT5j aGlwX2luZm8gPQ0KPiAgCQkmYWQ3NzgwX2NoaXBfaW5mb190Ymxbc3BpX2dldF9kZXZpY2VfaWQo c3BpKS0+ZHJpdmVyX2RhdGFdOw0KPiAgDQo+IC0JaWYgKHZvbHRhZ2VfdXYpDQo+IC0JCXN0LT5p bnRfdnJlZl9tdiA9IHZvbHRhZ2VfdXYgLyAxMDAwOw0KPiAtCWVsc2UNCj4gKwlpZiAoIXZvbHRh Z2VfdXYpDQo+ICAJCWRldl93YXJuKCZzcGktPmRldiwgIlJlZmVyZW5jZSB2b2x0YWdlIHVuc3Bl Y2lmaWVkXG4iKTsNCg0KSSB0aGluayB5b3UgY291bGQgcmVtb3ZlIHRoaXMgYWx0b2dldGhlciwg YW5kIGFsc28gcmVtb3ZlIHRoZSBlbnRpcmUNCmB2b2x0YWdlX3V2ID0gcmVndWxhdG9yX2dldF92 b2x0YWdlKHN0LT5yZWcpO2AgYXNzaWdubWVudC4NCg0KSXQgZG9lc24ndCBtYWtlIG11Y2ggc2Vu c2UgdG8gcmVhZCB0aGUgdm9sdGFnZSBoZXJlLCBzaW5jZSBpdCB3b24ndCBiZSB1c2VkDQppbiB0 aGUgcHJvYmUgcGFydCBhbnltb3JlLg0KDQo+ICANCj4gIAlzcGlfc2V0X2RydmRhdGEoc3BpLCBp bmRpb19kZXYpOw0K ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value 2018-11-01 15:28 ` Ardelean, Alexandru @ 2018-11-03 13:10 ` Jonathan Cameron 0 siblings, 0 replies; 14+ messages in thread From: Jonathan Cameron @ 2018-11-03 13:10 UTC (permalink / raw) To: Ardelean, Alexandru Cc: lars@metafoo.de, knaack.h@gmx.de, Hennerich, Michael, renatogeh@gmail.com, giuliano.belinassi@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com On Thu, 1 Nov 2018 15:28:19 +0000 "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > On Thu, 2018-11-01 at 11:43 -0300, Renato Lui Geh wrote: > > This patch removes the unnecessary field int_vref_mv in ad7780_state > > referring to the device's voltage. > > > > Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> > > --- > > Changes in v3: > > - removed unnecessary int_vref_mv from ad7780_state > > > > drivers/staging/iio/adc/ad7780.c | 5 +---- > > 1 file changed, 1 insertion(+), 4 deletions(-) > > > > diff --git a/drivers/staging/iio/adc/ad7780.c > > b/drivers/staging/iio/adc/ad7780.c > > index f2a11e9424cd..f250370efcf7 100644 > > --- a/drivers/staging/iio/adc/ad7780.c > > +++ b/drivers/staging/iio/adc/ad7780.c > > @@ -42,7 +42,6 @@ struct ad7780_state { > > struct regulator *reg; > > struct gpio_desc *powerdown_gpio; > > unsigned int gain; > > - u16 int_vref_mv; > > > > struct ad_sigma_delta sd; > > }; > > @@ -190,9 +189,7 @@ static int ad7780_probe(struct spi_device *spi) > > st->chip_info = > > &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; > > > > - if (voltage_uv) > > - st->int_vref_mv = voltage_uv / 1000; > > - else > > + if (!voltage_uv) > > dev_warn(&spi->dev, "Reference voltage unspecified\n"); > > I think you could remove this altogether, and also remove the entire > `voltage_uv = regulator_get_voltage(st->reg);` assignment. > > It doesn't make much sense to read the voltage here, since it won't be used > in the probe part anymore. > Absolutely agree on this. There is no point in reading here at all. Jonathan > > > > spi_set_drvdata(spi, indio_dev); ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-11-04 2:35 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-11-01 14:42 [PATCH v3 0/3] staging: iio: ad7780: correct driver read Renato Lui Geh 2018-11-01 14:43 ` [PATCH v3 1/3] staging: iio: ad7780: fix offset read value Renato Lui Geh 2018-11-01 15:02 ` Ardelean, Alexandru 2018-11-03 13:07 ` Jonathan Cameron 2018-11-03 15:59 ` Renato Lui Geh 2018-11-03 17:23 ` Jonathan Cameron 2018-11-01 14:43 ` [PATCH v3 2/3] staging: iio: ad7780: update voltage on read Renato Lui Geh 2018-11-01 15:20 ` Ardelean, Alexandru 2018-11-03 13:10 ` Jonathan Cameron 2018-11-03 16:06 ` Renato Lui Geh 2018-11-03 17:21 ` Jonathan Cameron 2018-11-01 14:43 ` [PATCH v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage value Renato Lui Geh 2018-11-01 15:28 ` Ardelean, Alexandru 2018-11-03 13:10 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).