Commit 7034ed13 authored by Namjae Jeon's avatar Namjae Jeon Committed by Fengguang Wu

backing-dev: use kstrto* in preference to simple_strtoul

Fix checkpatch warnings:

WARNING: consider using kstrto* in preference to simple_strtoul

for the below sys entry parsers:
/sys/block/<block device>/bdi/read_ahead_kb
/sys/block/<block device>/bdi/max_ratio
/sys/block/<block device>/bdi/min_ratio
Signed-off-by: default avatarNamjae Jeon <linkinjeon@gmail.com>
Signed-off-by: default avatarVivek Trivedi <vtrivedi018@gmail.com>
parent fea7a08a
...@@ -158,16 +158,16 @@ static ssize_t read_ahead_kb_store(struct device *dev, ...@@ -158,16 +158,16 @@ static ssize_t read_ahead_kb_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct backing_dev_info *bdi = dev_get_drvdata(dev); struct backing_dev_info *bdi = dev_get_drvdata(dev);
char *end;
unsigned long read_ahead_kb; unsigned long read_ahead_kb;
ssize_t ret = -EINVAL; ssize_t ret;
read_ahead_kb = simple_strtoul(buf, &end, 10); ret = kstrtoul(buf, 10, &read_ahead_kb);
if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) { if (ret < 0)
bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10); return ret;
ret = count;
} bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10);
return ret;
return count;
} }
#define K(pages) ((pages) << (PAGE_SHIFT - 10)) #define K(pages) ((pages) << (PAGE_SHIFT - 10))
...@@ -187,16 +187,17 @@ static ssize_t min_ratio_store(struct device *dev, ...@@ -187,16 +187,17 @@ static ssize_t min_ratio_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct backing_dev_info *bdi = dev_get_drvdata(dev); struct backing_dev_info *bdi = dev_get_drvdata(dev);
char *end;
unsigned int ratio; unsigned int ratio;
ssize_t ret = -EINVAL; ssize_t ret;
ret = kstrtouint(buf, 10, &ratio);
if (ret < 0)
return ret;
ret = bdi_set_min_ratio(bdi, ratio);
if (!ret)
ret = count;
ratio = simple_strtoul(buf, &end, 10);
if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) {
ret = bdi_set_min_ratio(bdi, ratio);
if (!ret)
ret = count;
}
return ret; return ret;
} }
BDI_SHOW(min_ratio, bdi->min_ratio) BDI_SHOW(min_ratio, bdi->min_ratio)
...@@ -205,16 +206,17 @@ static ssize_t max_ratio_store(struct device *dev, ...@@ -205,16 +206,17 @@ static ssize_t max_ratio_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct backing_dev_info *bdi = dev_get_drvdata(dev); struct backing_dev_info *bdi = dev_get_drvdata(dev);
char *end;
unsigned int ratio; unsigned int ratio;
ssize_t ret = -EINVAL; ssize_t ret;
ret = kstrtouint(buf, 10, &ratio);
if (ret < 0)
return ret;
ret = bdi_set_max_ratio(bdi, ratio);
if (!ret)
ret = count;
ratio = simple_strtoul(buf, &end, 10);
if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) {
ret = bdi_set_max_ratio(bdi, ratio);
if (!ret)
ret = count;
}
return ret; return ret;
} }
BDI_SHOW(max_ratio, bdi->max_ratio) BDI_SHOW(max_ratio, bdi->max_ratio)
......
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