From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jingoo Han <jg1.han@samsung.com>
Cc: "'Greg Kroah-Hartman'" <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-iio@vger.kernel.org,
Jonathan Cameron <jic23@cam.ac.uk>
Subject: Re: [PATCH 2/2] staging: iio: replace strict_strto*() with kstrto*()
Date: Tue, 23 Jul 2013 13:52:42 +0300 [thread overview]
Message-ID: <20130723105242.GP5585@mwanda> (raw)
In-Reply-To: <001d01ce878e$0e76b710$2b642530$@samsung.com>
On Tue, Jul 23, 2013 at 07:19:03PM +0900, Jingoo Han wrote:
> The usage of strict_strto*() is not preferred, because
> strict_strto*() is obsolete. Thus, kstrto*() should be
> used.
In olden times there was just strict_strtol() and strict_strtoul().
These days we have kstrtou8() and kstrtoint() and a bunch of others.
So when you do these patches you have to take more time to consider
what type we should be using and update the surrounding code.
I haven't reviewed all of these so please check everything again.
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 6330af6..afe191a 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -326,7 +326,7 @@ static ssize_t ad5933_store_frequency(struct device *dev,
> long val;
> int ret;
>
> - ret = strict_strtoul(buf, 10, &val);
> + ret = kstrtoul(buf, 10, &val);
This bug is in the original code as well. "val" is long but it
should be unsigned long. Later we check that:
if (val > AD5933_MAX_OUTPUT_FREQ_Hz) {
Forgetting that "val" could be a negative number.
> diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
> index e5943e2..fbb230a 100644
> --- a/drivers/staging/iio/meter/ade7753.c
> +++ b/drivers/staging/iio/meter/ade7753.c
> @@ -188,7 +188,7 @@ static ssize_t ade7753_write_8bit(struct device *dev,
> int ret;
> long val;
>
> - ret = strict_strtol(buf, 10, &val);
> + ret = kstrtol(buf, 10, &val);
For these we should be using the new kstrtou8() functions.
> if (ret)
> goto error_ret;
> ret = ade7753_spi_write_reg_8(dev, this_attr->address, val);
> @@ -206,7 +206,7 @@ static ssize_t ade7753_write_16bit(struct device *dev,
> int ret;
> long val;
>
> - ret = strict_strtol(buf, 10, &val);
> + ret = kstrtol(buf, 10, &val);
Same.
> if (ret)
> goto error_ret;
> ret = ade7753_spi_write_reg_16(dev, this_attr->address, val);
> @@ -418,7 +418,7 @@ static ssize_t ade7753_write_frequency(struct device *dev,
> int ret;
> u16 reg, t;
>
> - ret = strict_strtol(buf, 10, &val);
> + ret = kstrtol(buf, 10, &val);
> if (ret)
> return ret;
> if (val == 0)
> diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
> index 7b6503b..ea337c4 100644
> --- a/drivers/staging/iio/meter/ade7754.c
> +++ b/drivers/staging/iio/meter/ade7754.c
> @@ -188,7 +188,7 @@ static ssize_t ade7754_write_8bit(struct device *dev,
> int ret;
> long val;
>
> - ret = strict_strtol(buf, 10, &val);
> + ret = kstrtol(buf, 10, &val);
Same.
> if (ret)
> goto error_ret;
> ret = ade7754_spi_write_reg_8(dev, this_attr->address, val);
> @@ -206,7 +206,7 @@ static ssize_t ade7754_write_16bit(struct device *dev,
> int ret;
> long val;
>
> - ret = strict_strtol(buf, 10, &val);
> + ret = kstrtol(buf, 10, &val);
Same.
> if (ret)
> goto error_ret;
> ret = ade7754_spi_write_reg_16(dev, this_attr->address, val);
> --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> @@ -56,7 +56,7 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
> unsigned long val;
> int ret;
>
> - ret = strict_strtoul(buf, 10, &val);
> + ret = kstrtoul(buf, 10, &val);
For this one we should make "val" an int.
> if (ret)
> goto error_ret;
>
regards,
dan carpenter
next prev parent reply other threads:[~2013-07-23 10:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-23 10:19 [PATCH 2/2] staging: iio: replace strict_strto*() with kstrto*() Jingoo Han
2013-07-23 10:52 ` Dan Carpenter [this message]
2013-07-23 11:26 ` Dan Carpenter
2013-07-23 11:33 ` Lars-Peter Clausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130723105242.GP5585@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jg1.han@samsung.com \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.