perf scripts python: exported-sql-viewer.py: Use new 'has_calls' column
[linux/fpc-iii.git] / drivers / firmware / google / memconsole.c
blobfe5aa740c34d6fd00d75d06cb77805f3dc9b3ee9
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/init.h>
11 #include <linux/sysfs.h>
12 #include <linux/kobject.h>
13 #include <linux/module.h>
15 #include "memconsole.h"
17 static ssize_t (*memconsole_read_func)(char *, loff_t, size_t);
19 static ssize_t memconsole_read(struct file *filp, struct kobject *kobp,
20 struct bin_attribute *bin_attr, char *buf,
21 loff_t pos, size_t count)
23 if (WARN_ON_ONCE(!memconsole_read_func))
24 return -EIO;
25 return memconsole_read_func(buf, pos, count);
28 static struct bin_attribute memconsole_bin_attr = {
29 .attr = {.name = "log", .mode = 0444},
30 .read = memconsole_read,
33 void memconsole_setup(ssize_t (*read_func)(char *, loff_t, size_t))
35 memconsole_read_func = read_func;
37 EXPORT_SYMBOL(memconsole_setup);
39 int memconsole_sysfs_init(void)
41 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
43 EXPORT_SYMBOL(memconsole_sysfs_init);
45 void memconsole_exit(void)
47 sysfs_remove_bin_file(firmware_kobj, &memconsole_bin_attr);
49 EXPORT_SYMBOL(memconsole_exit);
51 MODULE_AUTHOR("Google, Inc.");
52 MODULE_LICENSE("GPL");