diff options
Diffstat (limited to 'mm/backing-dev.c')
| -rw-r--r-- | mm/backing-dev.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c index b41823cc05e6..d3ca2b3ee176 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c | |||
| @@ -158,16 +158,16 @@ static ssize_t read_ahead_kb_store(struct device *dev, | |||
| 158 | const char *buf, size_t count) | 158 | const char *buf, size_t count) |
| 159 | { | 159 | { |
| 160 | struct backing_dev_info *bdi = dev_get_drvdata(dev); | 160 | struct backing_dev_info *bdi = dev_get_drvdata(dev); |
| 161 | char *end; | ||
| 162 | unsigned long read_ahead_kb; | 161 | unsigned long read_ahead_kb; |
| 163 | ssize_t ret = -EINVAL; | 162 | ssize_t ret; |
| 164 | 163 | ||
| 165 | read_ahead_kb = simple_strtoul(buf, &end, 10); | 164 | ret = kstrtoul(buf, 10, &read_ahead_kb); |
| 166 | if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) { | 165 | if (ret < 0) |
| 167 | bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10); | 166 | return ret; |
| 168 | ret = count; | 167 | |
| 169 | } | 168 | bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10); |
| 170 | return ret; | 169 | |
| 170 | return count; | ||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | #define K(pages) ((pages) << (PAGE_SHIFT - 10)) | 173 | #define K(pages) ((pages) << (PAGE_SHIFT - 10)) |
| @@ -187,16 +187,17 @@ static ssize_t min_ratio_store(struct device *dev, | |||
| 187 | struct device_attribute *attr, const char *buf, size_t count) | 187 | struct device_attribute *attr, const char *buf, size_t count) |
| 188 | { | 188 | { |
| 189 | struct backing_dev_info *bdi = dev_get_drvdata(dev); | 189 | struct backing_dev_info *bdi = dev_get_drvdata(dev); |
| 190 | char *end; | ||
| 191 | unsigned int ratio; | 190 | unsigned int ratio; |
| 192 | ssize_t ret = -EINVAL; | 191 | ssize_t ret; |
| 192 | |||
| 193 | ret = kstrtouint(buf, 10, &ratio); | ||
| 194 | if (ret < 0) | ||
| 195 | return ret; | ||
| 196 | |||
| 197 | ret = bdi_set_min_ratio(bdi, ratio); | ||
| 198 | if (!ret) | ||
| 199 | ret = count; | ||
| 193 | 200 | ||
| 194 | ratio = simple_strtoul(buf, &end, 10); | ||
| 195 | if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) { | ||
| 196 | ret = bdi_set_min_ratio(bdi, ratio); | ||
| 197 | if (!ret) | ||
| 198 | ret = count; | ||
| 199 | } | ||
| 200 | return ret; | 201 | return ret; |
| 201 | } | 202 | } |
| 202 | BDI_SHOW(min_ratio, bdi->min_ratio) | 203 | BDI_SHOW(min_ratio, bdi->min_ratio) |
| @@ -205,16 +206,17 @@ static ssize_t max_ratio_store(struct device *dev, | |||
| 205 | struct device_attribute *attr, const char *buf, size_t count) | 206 | struct device_attribute *attr, const char *buf, size_t count) |
| 206 | { | 207 | { |
| 207 | struct backing_dev_info *bdi = dev_get_drvdata(dev); | 208 | struct backing_dev_info *bdi = dev_get_drvdata(dev); |
| 208 | char *end; | ||
| 209 | unsigned int ratio; | 209 | unsigned int ratio; |
| 210 | ssize_t ret = -EINVAL; | 210 | ssize_t ret; |
| 211 | |||
| 212 | ret = kstrtouint(buf, 10, &ratio); | ||
| 213 | if (ret < 0) | ||
| 214 | return ret; | ||
| 215 | |||
| 216 | ret = bdi_set_max_ratio(bdi, ratio); | ||
| 217 | if (!ret) | ||
| 218 | ret = count; | ||
| 211 | 219 | ||
| 212 | ratio = simple_strtoul(buf, &end, 10); | ||
| 213 | if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) { | ||
| 214 | ret = bdi_set_max_ratio(bdi, ratio); | ||
| 215 | if (!ret) | ||
| 216 | ret = count; | ||
| 217 | } | ||
| 218 | return ret; | 220 | return ret; |
| 219 | } | 221 | } |
| 220 | BDI_SHOW(max_ratio, bdi->max_ratio) | 222 | BDI_SHOW(max_ratio, bdi->max_ratio) |
