* [PATCH v2 1/2] staging: iio: light: isl29018.c: obsolete use of strict_strtoul
2011-12-12 23:38 staging: iio: light: obsolete use of strict_strtoul v2 Johannes Tenschert
@ 2011-12-12 23:38 ` Johannes Tenschert
2011-12-12 23:38 ` [PATCH v2 2/2] staging: iio: light: tsl2583.c: " Johannes Tenschert
2011-12-13 6:33 ` staging: iio: light: obsolete use of strict_strtoul v2 Dan Carpenter
2 siblings, 0 replies; 5+ messages in thread
From: Johannes Tenschert @ 2011-12-12 23:38 UTC (permalink / raw)
To: devel; +Cc: jic23, gregkh, jbrenner, linux-iio, Johannes Tenschert
The function strict_strtoul is obsolete and replaced by kstrtoul
and kstrtoint.
If kstrto* fails its return code is returned instead of -EINVAL.
Signed-off-by: Johannes Tenschert <Johannes.Tenschert@informatik.stud.uni-erlangen.de>
---
drivers/staging/iio/light/isl29018.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 849d6a5..9806495 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -253,9 +253,11 @@ static ssize_t store_range(struct device *dev,
int status;
unsigned long lval;
unsigned int new_range;
+ int ret;
- if (strict_strtoul(buf, 10, &lval))
- return -EINVAL;
+ ret = kstrtoul(buf, 10, &lval);
+ if (ret)
+ return ret;
if (!(lval == 1000UL || lval == 4000UL ||
lval == 16000UL || lval == 64000UL)) {
@@ -295,9 +297,11 @@ static ssize_t store_resolution(struct device *dev,
int status;
unsigned long lval;
unsigned int new_adc_bit;
+ int ret;
- if (strict_strtoul(buf, 10, &lval))
- return -EINVAL;
+ ret = kstrtoul(buf, 10, &lval);
+ if (ret)
+ return ret;
if (!(lval == 4 || lval == 8 || lval == 12 || lval == 16)) {
dev_err(dev, "The resolution is not supported\n");
return -EINVAL;
@@ -333,11 +337,13 @@ static ssize_t store_prox_infrared_supression(struct device *dev,
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
- unsigned long lval;
+ int val;
+ int ret;
- if (strict_strtoul(buf, 10, &lval))
- return -EINVAL;
- if (!(lval == 0UL || lval == 1UL)) {
+ ret = kstrtoint(buf, 10, &val);
+ if (ret)
+ return ret;
+ if (!(val == 0 || val == 1)) {
dev_err(dev, "The mode is not supported\n");
return -EINVAL;
}
@@ -345,7 +351,7 @@ static ssize_t store_prox_infrared_supression(struct device *dev,
/* get the "proximity scheme" i.e. if the chip does on chip
infrared supression (1 means perform on chip supression) */
mutex_lock(&chip->lock);
- chip->prox_scheme = (int)lval;
+ chip->prox_scheme = val;
mutex_unlock(&chip->lock);
return count;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] staging: iio: light: tsl2583.c: obsolete use of strict_strtoul
2011-12-12 23:38 staging: iio: light: obsolete use of strict_strtoul v2 Johannes Tenschert
2011-12-12 23:38 ` [PATCH v2 1/2] staging: iio: light: isl29018.c: obsolete use of strict_strtoul Johannes Tenschert
@ 2011-12-12 23:38 ` Johannes Tenschert
2011-12-13 6:33 ` staging: iio: light: obsolete use of strict_strtoul v2 Dan Carpenter
2 siblings, 0 replies; 5+ messages in thread
From: Johannes Tenschert @ 2011-12-12 23:38 UTC (permalink / raw)
To: devel; +Cc: jic23, gregkh, jbrenner, linux-iio, Johannes Tenschert
The function strict_strtoul is obsolete and replaced by kstrtouint
and kstrtoint.
If kstrto* fails its return code is returned instead of -EINVAL.
Signed-off-by: Johannes Tenschert <Johannes.Tenschert@informatik.stud.uni-erlangen.de>
---
drivers/staging/iio/light/tsl2583.c | 48 +++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 5b6455a..8c751e0 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -493,10 +493,12 @@ static ssize_t taos_power_state_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
- unsigned long value;
+ unsigned int value;
+ int ret;
- if (strict_strtoul(buf, 0, &value))
- return -EINVAL;
+ ret = kstrtouint(buf, 0, &value);
+ if (ret)
+ return ret;
if (value == 0)
taos_chip_off(indio_dev);
@@ -536,10 +538,12 @@ static ssize_t taos_gain_store(struct device *dev,
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
- unsigned long value;
+ unsigned int value;
+ int ret;
- if (strict_strtoul(buf, 0, &value))
- return -EINVAL;
+ ret = kstrtouint(buf, 0, &value);
+ if (ret)
+ return ret;
switch (value) {
case 1:
@@ -582,10 +586,12 @@ static ssize_t taos_als_time_store(struct device *dev,
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
- unsigned long value;
+ int value;
+ int ret;
- if (strict_strtoul(buf, 0, &value))
- return -EINVAL;
+ ret = kstrtoint(buf, 0, &value);
+ if (ret)
+ return ret;
if ((value < 50) || (value > 650))
return -EINVAL;
@@ -619,10 +625,12 @@ static ssize_t taos_als_trim_store(struct device *dev,
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
- unsigned long value;
+ int value;
+ int ret;
- if (strict_strtoul(buf, 0, &value))
- return -EINVAL;
+ ret = kstrtoint(buf, 0, &value);
+ if (ret)
+ return ret;
if (value)
chip->taos_settings.als_gain_trim = value;
@@ -644,10 +652,12 @@ static ssize_t taos_als_cal_target_store(struct device *dev,
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
- unsigned long value;
+ int value;
+ int ret;
- if (strict_strtoul(buf, 0, &value))
- return -EINVAL;
+ ret = kstrtoint(buf, 0, &value);
+ if (ret)
+ return ret;
if (value)
chip->taos_settings.als_cal_target = value;
@@ -671,10 +681,12 @@ static ssize_t taos_do_calibrate(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
- unsigned long value;
+ unsigned int value;
+ int ret;
- if (strict_strtoul(buf, 0, &value))
- return -EINVAL;
+ ret = kstrtouint(buf, 0, &value);
+ if (ret)
+ return ret;
if (value == 1)
taos_als_calibrate(indio_dev);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: staging: iio: light: obsolete use of strict_strtoul v2
2011-12-12 23:38 staging: iio: light: obsolete use of strict_strtoul v2 Johannes Tenschert
2011-12-12 23:38 ` [PATCH v2 1/2] staging: iio: light: isl29018.c: obsolete use of strict_strtoul Johannes Tenschert
2011-12-12 23:38 ` [PATCH v2 2/2] staging: iio: light: tsl2583.c: " Johannes Tenschert
@ 2011-12-13 6:33 ` Dan Carpenter
2011-12-14 20:11 ` Jonathan Cameron
2 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2011-12-13 6:33 UTC (permalink / raw)
To: Johannes Tenschert; +Cc: devel, linux-iio, gregkh, jic23, jbrenner
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
On Tue, Dec 13, 2011 at 12:38:20AM +0100, Johannes Tenschert wrote:
> Hi,
>
> I changed the patch to use the right kstrto* as Dan Carpenter suggested, but
> I'm not familiar enough with the code to fix the divide by zero bug in a good
> way.
>
> I also didn't change taos_settings because I don't know it well enough and don't
> want to introduce new bugs. So kstrtoint was used provisional to set it.
Yah, yah. Neither of us know the code, so hopefully the iio people
can comment.
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread