Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: max9611: Fix attribute measure unit
@ 2017-05-09  7:57 Jacopo Mondi
  2017-05-09 11:53 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Jacopo Mondi @ 2017-05-09  7:57 UTC (permalink / raw)
  To: geert, jic23, knaack.h, lars, pmeerw; +Cc: linux-iio, linux-renesas-soc

The power and current "shunt-resistor" attribute's 'show' function
displays the resistor value in milli-Ohms, while the ABI description
specifies it should be displayed in Ohms. Fix it.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/iio/adc/max9611.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
index ec82106..4580ebd 100644
--- a/drivers/iio/adc/max9611.c
+++ b/drivers/iio/adc/max9611.c
@@ -438,10 +438,10 @@ static ssize_t max9611_shunt_resistor_show(struct device *dev,
 	struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev));
 	unsigned int i, r;
 
-	i = max9611->shunt_resistor_uohm / 1000;
-	r = max9611->shunt_resistor_uohm % 1000;
+	i = max9611->shunt_resistor_uohm / 1000000;
+	r = max9611->shunt_resistor_uohm % 1000000;
 
-	return sprintf(buf, "%u.%03u\n", i, r);
+	return sprintf(buf, "%u.%06u\n", i, r);
 }
 
 static IIO_DEVICE_ATTR(in_power_shunt_resistor, 0444,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: adc: max9611: Fix attribute measure unit
  2017-05-09  7:57 [PATCH] iio: adc: max9611: Fix attribute measure unit Jacopo Mondi
@ 2017-05-09 11:53 ` Geert Uytterhoeven
  2017-05-14 15:39   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2017-05-09 11:53 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Linux-Renesas

Hi Jacopo,

On Tue, May 9, 2017 at 9:57 AM, Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
> The power and current "shunt-resistor" attribute's 'show' function
> displays the resistor value in milli-Ohms, while the ABI description
> specifies it should be displayed in Ohms. Fix it.
>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

# cat /sys/bus/iio/devices/iio:device*/in_*_shunt_resistor
0.005000
0.005000
0.005000
0.005000
#

$ grep shunt-resistor -- arch/arm64/boot/dts/renesas/salvator-x.dtsi
shunt-resistor-micro-ohms = <5000>;
shunt-resistor-micro-ohms = <5000>;
$

Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

> ---
>  drivers/iio/adc/max9611.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> index ec82106..4580ebd 100644
> --- a/drivers/iio/adc/max9611.c
> +++ b/drivers/iio/adc/max9611.c
> @@ -438,10 +438,10 @@ static ssize_t max9611_shunt_resistor_show(struct device *dev,
>         struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev));
>         unsigned int i, r;
>
> -       i = max9611->shunt_resistor_uohm / 1000;
> -       r = max9611->shunt_resistor_uohm % 1000;
> +       i = max9611->shunt_resistor_uohm / 1000000;
> +       r = max9611->shunt_resistor_uohm % 1000000;
>
> -       return sprintf(buf, "%u.%03u\n", i, r);
> +       return sprintf(buf, "%u.%06u\n", i, r);
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: adc: max9611: Fix attribute measure unit
  2017-05-09 11:53 ` Geert Uytterhoeven
@ 2017-05-14 15:39   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2017-05-14 15:39 UTC (permalink / raw)
  To: Geert Uytterhoeven, Jacopo Mondi
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, linux-iio,
	Linux-Renesas

On 09/05/17 12:53, Geert Uytterhoeven wrote:
> Hi Jacopo,
> 
> On Tue, May 9, 2017 at 9:57 AM, Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
>> The power and current "shunt-resistor" attribute's 'show' function
>> displays the resistor value in milli-Ohms, while the ABI description
>> specifies it should be displayed in Ohms. Fix it.
>>
>> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> 
> # cat /sys/bus/iio/devices/iio:device*/in_*_shunt_resistor
> 0.005000
> 0.005000
> 0.005000
> 0.005000
> #
> 
> $ grep shunt-resistor -- arch/arm64/boot/dts/renesas/salvator-x.dtsi
> shunt-resistor-micro-ohms = <5000>;
> shunt-resistor-micro-ohms = <5000>;
> $
> 
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> 
>> ---
>>   drivers/iio/adc/max9611.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
>> index ec82106..4580ebd 100644
>> --- a/drivers/iio/adc/max9611.c
>> +++ b/drivers/iio/adc/max9611.c
>> @@ -438,10 +438,10 @@ static ssize_t max9611_shunt_resistor_show(struct device *dev,
>>          struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev));
>>          unsigned int i, r;
>>
>> -       i = max9611->shunt_resistor_uohm / 1000;
>> -       r = max9611->shunt_resistor_uohm % 1000;
>> +       i = max9611->shunt_resistor_uohm / 1000000;
>> +       r = max9611->shunt_resistor_uohm % 1000000;
>>
>> -       return sprintf(buf, "%u.%03u\n", i, r);
>> +       return sprintf(buf, "%u.%06u\n", i, r);
>>   }
> 
> Gr{oetje,eeting}s,
> 
>                          Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                  -- Linus Torvalds
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-14 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-09  7:57 [PATCH] iio: adc: max9611: Fix attribute measure unit Jacopo Mondi
2017-05-09 11:53 ` Geert Uytterhoeven
2017-05-14 15:39   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox