firmware: google: memconsole: Drop global func pointer
authorStephen Boyd <swboyd@chromium.org>
Fri, 10 May 2019 18:01:50 +0000 (11:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 May 2019 18:55:04 +0000 (20:55 +0200)
We can store this function pointer directly in the bin_attribute
structure's private field. Do this to save one global pointer.

Cc: Wei-Ning Huang <wnhuang@chromium.org>
Cc: Julius Werner <jwerner@chromium.org>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/google/memconsole.c

index 166f07c..9681350 100644 (file)
 
 #include "memconsole.h"
 
-static ssize_t (*memconsole_read_func)(char *, loff_t, size_t);
-
 static ssize_t memconsole_read(struct file *filp, struct kobject *kobp,
                               struct bin_attribute *bin_attr, char *buf,
                               loff_t pos, size_t count)
 {
+       ssize_t (*memconsole_read_func)(char *, loff_t, size_t);
+
+       memconsole_read_func = bin_attr->private;
        if (WARN_ON_ONCE(!memconsole_read_func))
                return -EIO;
+
        return memconsole_read_func(buf, pos, count);
 }
 
@@ -40,7 +42,7 @@ static struct bin_attribute memconsole_bin_attr = {
 
 void memconsole_setup(ssize_t (*read_func)(char *, loff_t, size_t))
 {
-       memconsole_read_func = read_func;
+       memconsole_bin_attr.private = read_func;
 }
 EXPORT_SYMBOL(memconsole_setup);