Commit 1a0ddd56 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jens Axboe

pktcdvd: replace sscanf() by kstrtoul()

The checkpatch.pl warns: "Prefer kstrto<type> to single variable sscanf".
Fix the code accordingly.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230310164549.22133-3-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3a41db53
......@@ -237,15 +237,16 @@ static ssize_t congestion_off_store(struct device *dev,
const char *buf, size_t len)
{
struct pktcdvd_device *pd = dev_get_drvdata(dev);
int val;
int val, ret;
if (sscanf(buf, "%d", &val) == 1) {
spin_lock(&pd->lock);
pd->write_congestion_off = val;
init_write_congestion_marks(&pd->write_congestion_off,
&pd->write_congestion_on);
spin_unlock(&pd->lock);
}
ret = kstrtoint(buf, 10, &val);
if (ret)
return ret;
spin_lock(&pd->lock);
pd->write_congestion_off = val;
init_write_congestion_marks(&pd->write_congestion_off, &pd->write_congestion_on);
spin_unlock(&pd->lock);
return len;
}
static DEVICE_ATTR_RW(congestion_off);
......@@ -267,15 +268,16 @@ static ssize_t congestion_on_store(struct device *dev,
const char *buf, size_t len)
{
struct pktcdvd_device *pd = dev_get_drvdata(dev);
int val;
int val, ret;
if (sscanf(buf, "%d", &val) == 1) {
spin_lock(&pd->lock);
pd->write_congestion_on = val;
init_write_congestion_marks(&pd->write_congestion_off,
&pd->write_congestion_on);
spin_unlock(&pd->lock);
}
ret = kstrtoint(buf, 10, &val);
if (ret)
return ret;
spin_lock(&pd->lock);
pd->write_congestion_on = val;
init_write_congestion_marks(&pd->write_congestion_off, &pd->write_congestion_on);
spin_unlock(&pd->lock);
return len;
}
static DEVICE_ATTR_RW(congestion_on);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment