]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
bcache: Move couple of functions to sysfs.c
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 28 May 2018 07:37:43 +0000 (15:37 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1784665
There is couple of functions that are used exclusively in sysfs.c.
Move it to there and make them static.

Besides above, it will allow further clean up.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit ecb37ce9baac653cc09e2b631393dde3df82979f)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/md/bcache/sysfs.c
drivers/md/bcache/util.c
drivers/md/bcache/util.h

index f4150eba2101a472bfc44cf9212ff0dbe5d056e0..5507b21fadbd13f4f967e1dc07550e6c06ef6d79 100644 (file)
@@ -132,6 +132,41 @@ rw_attribute(btree_shrinker_disabled);
 rw_attribute(copy_gc_enabled);
 rw_attribute(size);
 
+static ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[],
+                           size_t selected)
+{
+       char *out = buf;
+       size_t i;
+
+       for (i = 0; list[i]; i++)
+               out += snprintf(out, buf + size - out,
+                               i == selected ? "[%s] " : "%s ", list[i]);
+
+       out[-1] = '\n';
+       return out - buf;
+}
+
+static ssize_t bch_read_string_list(const char *buf, const char * const list[])
+{
+       size_t i;
+       char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
+       if (!d)
+               return -ENOMEM;
+
+       s = strim(d);
+
+       for (i = 0; list[i]; i++)
+               if (!strcmp(list[i], s))
+                       break;
+
+       kfree(d);
+
+       if (!list[i])
+               return -EINVAL;
+
+       return i;
+}
+
 SHOW(__bch_cached_dev)
 {
        struct cached_dev *dc = container_of(kobj, struct cached_dev,
index 1e6b5fd763fef9bbfbf29ded0c28be7b39e2964d..8e85f46f58be92dc6d2b57d6a9478f6194e94663 100644 (file)
@@ -120,41 +120,6 @@ ssize_t bch_hprint(char *buf, int64_t v)
                return sprintf(buf, "%llu.%i%c", q, t * 10 / 1024, units[u]);
 }
 
-ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[],
-                           size_t selected)
-{
-       char *out = buf;
-       size_t i;
-
-       for (i = 0; list[i]; i++)
-               out += snprintf(out, buf + size - out,
-                               i == selected ? "[%s] " : "%s ", list[i]);
-
-       out[-1] = '\n';
-       return out - buf;
-}
-
-ssize_t bch_read_string_list(const char *buf, const char * const list[])
-{
-       size_t i;
-       char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
-       if (!d)
-               return -ENOMEM;
-
-       s = strim(d);
-
-       for (i = 0; list[i]; i++)
-               if (!strcmp(list[i], s))
-                       break;
-
-       kfree(d);
-
-       if (!list[i])
-               return -EINVAL;
-
-       return i;
-}
-
 bool bch_is_zero(const char *p, size_t n)
 {
        size_t i;
index 6920616610bd50b77d882bdc7b97bd47d93c2038..ecd80376fd9a34b7fe739971e6514d4109dae033 100644 (file)
@@ -365,11 +365,6 @@ ssize_t bch_hprint(char *buf, int64_t v);
 bool bch_is_zero(const char *p, size_t n);
 int bch_parse_uuid(const char *s, char *uuid);
 
-ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[],
-                           size_t selected);
-
-ssize_t bch_read_string_list(const char *buf, const char * const list[]);
-
 struct time_stats {
        spinlock_t      lock;
        /*