* [PATCH 0/2] hwmon: (ina2xx) code clean-up and minor fixes
@ 2015-01-12 13:47 ` Bartosz Golaszewski
0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2015-01-12 13:47 UTC (permalink / raw)
To: Guenter Roeck
Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors, Bartosz Golaszewski
This small series fixes two minor issues in the driver after recent
implementation of new attributes. The first patch removes an unnecessary
result check after calling dev_get_drvdata() and the second one adds
calls to DIV_ROUND_CLOSEST() to avoid rounding errors.
This series is rebased against current hwmon-next.
Bartosz Golaszewski (2):
hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
drivers/hwmon/ina2xx.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
--
2.1.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [lm-sensors] [PATCH 0/2] hwmon: (ina2xx) code clean-up and minor fixes
@ 2015-01-12 13:47 ` Bartosz Golaszewski
0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2015-01-12 13:47 UTC (permalink / raw)
To: Guenter Roeck
Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors, Bartosz Golaszewski
This small series fixes two minor issues in the driver after recent
implementation of new attributes. The first patch removes an unnecessary
result check after calling dev_get_drvdata() and the second one adds
calls to DIV_ROUND_CLOSEST() to avoid rounding errors.
This series is rebased against current hwmon-next.
Bartosz Golaszewski (2):
hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
drivers/hwmon/ina2xx.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
--
2.1.3
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
2015-01-12 13:47 ` [lm-sensors] " Bartosz Golaszewski
@ 2015-01-12 13:47 ` Bartosz Golaszewski
-1 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2015-01-12 13:47 UTC (permalink / raw)
To: Guenter Roeck
Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors, Bartosz Golaszewski
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/hwmon/ina2xx.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index a16d6a2..ae110c5 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -370,9 +370,6 @@ static ssize_t ina226_set_interval(struct device *dev,
unsigned long val;
int status;
- if (IS_ERR(data))
- return PTR_ERR(data);
-
status = kstrtoul(buf, 10, &val);
if (status < 0)
return status;
--
2.1.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [lm-sensors] [PATCH 1/2] hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
@ 2015-01-12 13:47 ` Bartosz Golaszewski
0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2015-01-12 13:47 UTC (permalink / raw)
To: Guenter Roeck
Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors, Bartosz Golaszewski
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/hwmon/ina2xx.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index a16d6a2..ae110c5 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -370,9 +370,6 @@ static ssize_t ina226_set_interval(struct device *dev,
unsigned long val;
int status;
- if (IS_ERR(data))
- return PTR_ERR(data);
-
status = kstrtoul(buf, 10, &val);
if (status < 0)
return status;
--
2.1.3
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
2015-01-12 13:47 ` [lm-sensors] " Bartosz Golaszewski
@ 2015-01-12 13:47 ` Bartosz Golaszewski
-1 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2015-01-12 13:47 UTC (permalink / raw)
To: Guenter Roeck
Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors, Bartosz Golaszewski
Use DIV_ROUND_CLOSEST() when dealing with the calibration values to make the
calculations less error prone.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/hwmon/ina2xx.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index ae110c5..611ec4e 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -186,8 +186,11 @@ static void ina226_set_update_interval(struct ina2xx_data *data)
static int ina2xx_calibrate(struct ina2xx_data *data)
{
- return i2c_smbus_write_word_swapped(data->client, INA2XX_CALIBRATION,
- data->config->calibration_factor / data->rshunt);
+ u16 val = DIV_ROUND_CLOSEST(data->config->calibration_factor,
+ data->rshunt);
+
+ return i2c_smbus_write_word_swapped(data->client,
+ INA2XX_CALIBRATION, val);
}
/*
@@ -307,7 +310,8 @@ static int ina2xx_get_value(struct ina2xx_data *data, u8 reg)
val = (s16)data->regs[reg];
break;
case INA2XX_CALIBRATION:
- val = data->config->calibration_factor / data->regs[reg];
+ val = DIV_ROUND_CLOSEST(data->config->calibration_factor,
+ data->regs[reg]);
break;
default:
/* programmer goofed */
--
2.1.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [lm-sensors] [PATCH 2/2] hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
@ 2015-01-12 13:47 ` Bartosz Golaszewski
0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2015-01-12 13:47 UTC (permalink / raw)
To: Guenter Roeck
Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors, Bartosz Golaszewski
Use DIV_ROUND_CLOSEST() when dealing with the calibration values to make the
calculations less error prone.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/hwmon/ina2xx.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index ae110c5..611ec4e 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -186,8 +186,11 @@ static void ina226_set_update_interval(struct ina2xx_data *data)
static int ina2xx_calibrate(struct ina2xx_data *data)
{
- return i2c_smbus_write_word_swapped(data->client, INA2XX_CALIBRATION,
- data->config->calibration_factor / data->rshunt);
+ u16 val = DIV_ROUND_CLOSEST(data->config->calibration_factor,
+ data->rshunt);
+
+ return i2c_smbus_write_word_swapped(data->client,
+ INA2XX_CALIBRATION, val);
}
/*
@@ -307,7 +310,8 @@ static int ina2xx_get_value(struct ina2xx_data *data, u8 reg)
val = (s16)data->regs[reg];
break;
case INA2XX_CALIBRATION:
- val = data->config->calibration_factor / data->regs[reg];
+ val = DIV_ROUND_CLOSEST(data->config->calibration_factor,
+ data->regs[reg]);
break;
default:
/* programmer goofed */
--
2.1.3
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] hwmon: (ina2xx) code clean-up and minor fixes
2015-01-12 13:47 ` [lm-sensors] " Bartosz Golaszewski
@ 2015-01-12 14:23 ` Guenter Roeck
-1 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2015-01-12 14:23 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors
On 01/12/2015 05:47 AM, Bartosz Golaszewski wrote:
> This small series fixes two minor issues in the driver after recent
> implementation of new attributes. The first patch removes an unnecessary
> result check after calling dev_get_drvdata() and the second one adds
> calls to DIV_ROUND_CLOSEST() to avoid rounding errors.
>
> This series is rebased against current hwmon-next.
>
> Bartosz Golaszewski (2):
> hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
> hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
>
Both applied to -next.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] [PATCH 0/2] hwmon: (ina2xx) code clean-up and minor fixes
@ 2015-01-12 14:23 ` Guenter Roeck
0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2015-01-12 14:23 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: LKML, Benoit Cousson, Patrick Titiano, LM Sensors
On 01/12/2015 05:47 AM, Bartosz Golaszewski wrote:
> This small series fixes two minor issues in the driver after recent
> implementation of new attributes. The first patch removes an unnecessary
> result check after calling dev_get_drvdata() and the second one adds
> calls to DIV_ROUND_CLOSEST() to avoid rounding errors.
>
> This series is rebased against current hwmon-next.
>
> Bartosz Golaszewski (2):
> hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
> hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
>
Both applied to -next.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-01-12 14:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12 13:47 [PATCH 0/2] hwmon: (ina2xx) code clean-up and minor fixes Bartosz Golaszewski
2015-01-12 13:47 ` [lm-sensors] " Bartosz Golaszewski
2015-01-12 13:47 ` [PATCH 1/2] hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check Bartosz Golaszewski
2015-01-12 13:47 ` [lm-sensors] " Bartosz Golaszewski
2015-01-12 13:47 ` [PATCH 2/2] hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors Bartosz Golaszewski
2015-01-12 13:47 ` [lm-sensors] " Bartosz Golaszewski
2015-01-12 14:23 ` [PATCH 0/2] hwmon: (ina2xx) code clean-up and minor fixes Guenter Roeck
2015-01-12 14:23 ` [lm-sensors] " Guenter Roeck
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.