.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * memconsole.c |
---|
3 | 4 | * |
---|
4 | 5 | * Architecture-independent parts of the memory based BIOS console. |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright 2017 Google Inc. |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License v2.0 as published by |
---|
10 | | - * the Free Software Foundation. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | 8 | */ |
---|
17 | 9 | |
---|
18 | | -#include <linux/init.h> |
---|
19 | 10 | #include <linux/sysfs.h> |
---|
20 | 11 | #include <linux/kobject.h> |
---|
21 | 12 | #include <linux/module.h> |
---|
22 | 13 | |
---|
23 | 14 | #include "memconsole.h" |
---|
24 | 15 | |
---|
25 | | -static ssize_t (*memconsole_read_func)(char *, loff_t, size_t); |
---|
26 | | - |
---|
27 | 16 | static ssize_t memconsole_read(struct file *filp, struct kobject *kobp, |
---|
28 | 17 | struct bin_attribute *bin_attr, char *buf, |
---|
29 | 18 | loff_t pos, size_t count) |
---|
30 | 19 | { |
---|
| 20 | + ssize_t (*memconsole_read_func)(char *, loff_t, size_t); |
---|
| 21 | + |
---|
| 22 | + memconsole_read_func = bin_attr->private; |
---|
31 | 23 | if (WARN_ON_ONCE(!memconsole_read_func)) |
---|
32 | 24 | return -EIO; |
---|
| 25 | + |
---|
33 | 26 | return memconsole_read_func(buf, pos, count); |
---|
34 | 27 | } |
---|
35 | 28 | |
---|
.. | .. |
---|
40 | 33 | |
---|
41 | 34 | void memconsole_setup(ssize_t (*read_func)(char *, loff_t, size_t)) |
---|
42 | 35 | { |
---|
43 | | - memconsole_read_func = read_func; |
---|
| 36 | + memconsole_bin_attr.private = read_func; |
---|
44 | 37 | } |
---|
45 | 38 | EXPORT_SYMBOL(memconsole_setup); |
---|
46 | 39 | |
---|