WIP FPC-III support
[linux/fpc-iii.git] / drivers / firmware / google / memconsole.c
blob44d314ad69e4ec0e44395723b311c97256ec98f2
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * memconsole.c
5 * Architecture-independent parts of the memory based BIOS console.
7 * Copyright 2017 Google Inc.
8 */
10 #include <linux/sysfs.h>
11 #include <linux/kobject.h>
12 #include <linux/module.h>
14 #include "memconsole.h"
16 static ssize_t memconsole_read(struct file *filp, struct kobject *kobp,
17 struct bin_attribute *bin_attr, char *buf,
18 loff_t pos, size_t count)
20 ssize_t (*memconsole_read_func)(char *, loff_t, size_t);
22 memconsole_read_func = bin_attr->private;
23 if (WARN_ON_ONCE(!memconsole_read_func))
24 return -EIO;
26 return memconsole_read_func(buf, pos, count);
29 static struct bin_attribute memconsole_bin_attr = {
30 .attr = {.name = "log", .mode = 0444},
31 .read = memconsole_read,
34 void memconsole_setup(ssize_t (*read_func)(char *, loff_t, size_t))
36 memconsole_bin_attr.private = read_func;
38 EXPORT_SYMBOL(memconsole_setup);
40 int memconsole_sysfs_init(void)
42 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
44 EXPORT_SYMBOL(memconsole_sysfs_init);
46 void memconsole_exit(void)
48 sysfs_remove_bin_file(firmware_kobj, &memconsole_bin_attr);
50 EXPORT_SYMBOL(memconsole_exit);
52 MODULE_AUTHOR("Google, Inc.");
53 MODULE_LICENSE("GPL");