mm/ksm.c: use new hashtable implementation
[platform/adaptation/renesas_rcar/renesas_kernel.git] / mm / backing-dev.c
index b41823c..41733c5 100644 (file)
@@ -158,16 +158,16 @@ static ssize_t read_ahead_kb_store(struct device *dev,
                                  const char *buf, size_t count)
 {
        struct backing_dev_info *bdi = dev_get_drvdata(dev);
-       char *end;
        unsigned long read_ahead_kb;
-       ssize_t ret = -EINVAL;
+       ssize_t ret;
 
-       read_ahead_kb = simple_strtoul(buf, &end, 10);
-       if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) {
-               bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10);
-               ret = count;
-       }
-       return ret;
+       ret = kstrtoul(buf, 10, &read_ahead_kb);
+       if (ret < 0)
+               return ret;
+
+       bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10);
+
+       return count;
 }
 
 #define K(pages) ((pages) << (PAGE_SHIFT - 10))
@@ -187,16 +187,17 @@ static ssize_t min_ratio_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t count)
 {
        struct backing_dev_info *bdi = dev_get_drvdata(dev);
-       char *end;
        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;
 }
 BDI_SHOW(min_ratio, bdi->min_ratio)
@@ -205,26 +206,38 @@ static ssize_t max_ratio_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t count)
 {
        struct backing_dev_info *bdi = dev_get_drvdata(dev);
-       char *end;
        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;
 }
 BDI_SHOW(max_ratio, bdi->max_ratio)
 
+static ssize_t stable_pages_required_show(struct device *dev,
+                                         struct device_attribute *attr,
+                                         char *page)
+{
+       struct backing_dev_info *bdi = dev_get_drvdata(dev);
+
+       return snprintf(page, PAGE_SIZE-1, "%d\n",
+                       bdi_cap_stable_pages_required(bdi) ? 1 : 0);
+}
+
 #define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
 
 static struct device_attribute bdi_dev_attrs[] = {
        __ATTR_RW(read_ahead_kb),
        __ATTR_RW(min_ratio),
        __ATTR_RW(max_ratio),
+       __ATTR_RO(stable_pages_required),
        __ATTR_NULL,
 };