md, sysfs, LLVMLinux: Remove nested function from bcache sysfs
authorBernhard Rosenkränzer <bero@linaro.org>
Wed, 22 Feb 2017 23:20:49 +0000 (00:20 +0100)
committerStefan Agner <stefan@agner.ch>
Mon, 7 Aug 2017 06:21:11 +0000 (23:21 -0700)
Replace the use of nested functions where a normal function will suffice.

Nested functions are not liked by upstream kernel developers in general. Their
use breaks the use of clang as a compiler, and doesn't make the code any
better.

This code now works for both gcc and clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Forward-ported-by: Bernhard Rosenkränzer <bero@linaro.org>
Signed-off-by: Bernhard Rosenkränzer <bero@linaro.org>
drivers/md/bcache/sysfs.c

index f90f1361698080654ffe41778a4c637cbd40898b..0d513ece1b21220a4ebb2adf376a3de5df5db889 100644 (file)
@@ -732,6 +732,11 @@ static struct attribute *bch_cache_set_internal_files[] = {
 };
 KTYPE(bch_cache_set_internal);
 
+static int __bch_cache_cmp(const void *l, const void *r)
+{
+       return *((uint16_t *) r) - *((uint16_t *) l);
+}
+
 SHOW(__bch_cache)
 {
        struct cache *ca = container_of(kobj, struct cache, kobj);
@@ -756,9 +761,6 @@ SHOW(__bch_cache)
                                               CACHE_REPLACEMENT(&ca->sb));
 
        if (attr == &sysfs_priority_stats) {
-               int cmp(const void *l, const void *r)
-               {       return *((uint16_t *) r) - *((uint16_t *) l); }
-
                struct bucket *b;
                size_t n = ca->sb.nbuckets, i;
                size_t unused = 0, available = 0, dirty = 0, meta = 0;
@@ -787,7 +789,7 @@ SHOW(__bch_cache)
                        p[i] = ca->buckets[i].prio;
                mutex_unlock(&ca->set->bucket_lock);
 
-               sort(p, n, sizeof(uint16_t), cmp, NULL);
+               sort(p, n, sizeof(uint16_t), __bch_cache_cmp, NULL);
 
                while (n &&
                       !cached[n - 1])