Skip to content

Commit

Permalink
Staging: iio/accel: Changed data type for val to unsigned long in wri…
Browse files Browse the repository at this point in the history
…te_frequency

In lis3102dq_write_frequency() we used a long variable to store the
value parsed from the char* buffer buf, as there only was a
strict_strtol() function to parse values.
Now we have got kstrto* which allows us to convert to the right data
type in most cases.

In this particular function we want to write a frequency value, and it
doesn't make sense to allow negative values here (as Dan Carpenter
pointed out in a previous email).
This means we can now parse the value into an unsigned long and get an
error for invalid (e.g. negative) values.

Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andreas Ruprecht authored and Greg Kroah-Hartman committed Nov 29, 2011
1 parent bae5b53 commit 359f9ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ static ssize_t lis3l02dq_write_frequency(struct device *dev,
size_t len)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
long val;
unsigned long val;
int ret;
u8 t;

ret = strict_strtol(buf, 10, &val);
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;

Expand Down

0 comments on commit 359f9ca

Please sign in to comment.