hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/acpi/bgrt.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * BGRT boot graphic support
34 * Authors: Matthew Garrett, Josh Triplett <josh@joshtriplett.org>
45 * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
56 * Copyright 2012 Intel Corporation
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/kernel.h>
....@@ -18,40 +15,19 @@
1815 static void *bgrt_image;
1916 static struct kobject *bgrt_kobj;
2017
21
-static ssize_t show_version(struct device *dev,
22
- struct device_attribute *attr, char *buf)
23
-{
24
- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.version);
25
-}
26
-static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
18
+#define BGRT_SHOW(_name, _member) \
19
+ static ssize_t _name##_show(struct kobject *kobj, \
20
+ struct kobj_attribute *attr, char *buf) \
21
+ { \
22
+ return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab._member); \
23
+ } \
24
+ struct kobj_attribute bgrt_attr_##_name = __ATTR_RO(_name)
2725
28
-static ssize_t show_status(struct device *dev,
29
- struct device_attribute *attr, char *buf)
30
-{
31
- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.status);
32
-}
33
-static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
34
-
35
-static ssize_t show_type(struct device *dev,
36
- struct device_attribute *attr, char *buf)
37
-{
38
- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_type);
39
-}
40
-static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
41
-
42
-static ssize_t show_xoffset(struct device *dev,
43
- struct device_attribute *attr, char *buf)
44
-{
45
- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_offset_x);
46
-}
47
-static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL);
48
-
49
-static ssize_t show_yoffset(struct device *dev,
50
- struct device_attribute *attr, char *buf)
51
-{
52
- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_offset_y);
53
-}
54
-static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
26
+BGRT_SHOW(version, version);
27
+BGRT_SHOW(status, status);
28
+BGRT_SHOW(type, image_type);
29
+BGRT_SHOW(xoffset, image_offset_x);
30
+BGRT_SHOW(yoffset, image_offset_y);
5531
5632 static ssize_t image_read(struct file *file, struct kobject *kobj,
5733 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
....@@ -63,11 +39,11 @@
6339 static BIN_ATTR_RO(image, 0); /* size gets filled in later */
6440
6541 static struct attribute *bgrt_attributes[] = {
66
- &dev_attr_version.attr,
67
- &dev_attr_status.attr,
68
- &dev_attr_type.attr,
69
- &dev_attr_xoffset.attr,
70
- &dev_attr_yoffset.attr,
42
+ &bgrt_attr_version.attr,
43
+ &bgrt_attr_status.attr,
44
+ &bgrt_attr_type.attr,
45
+ &bgrt_attr_xoffset.attr,
46
+ &bgrt_attr_yoffset.attr,
7147 NULL,
7248 };
7349