aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/dmi-id.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 2678098d4504..a7bd87d52897 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -13,21 +13,35 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/autoconf.h> 14#include <linux/autoconf.h>
15 15
16struct dmi_device_attribute{
17 struct device_attribute dev_attr;
18 int field;
19};
20#define to_dmi_dev_attr(_dev_attr) \
21 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
22
16#define DEFINE_DMI_ATTR(_name, _mode, _show) \ 23#define DEFINE_DMI_ATTR(_name, _mode, _show) \
17static struct device_attribute sys_dmi_##_name##_attr = \ 24static struct device_attribute sys_dmi_##_name##_attr = \
18 __ATTR(_name, _mode, _show, NULL); 25 __ATTR(_name, _mode, _show, NULL);
19 26
20#define DEFINE_DMI_ATTR_WITH_SHOW(_name, _mode, _field) \ 27static ssize_t sys_dmi_field_show(struct device *dev,
21static ssize_t sys_dmi_##_name##_show(struct device *dev, \ 28 struct device_attribute *attr,
22 struct device_attribute *attr, \ 29 char *page)
23 char *page) \ 30{
24{ \ 31 int field = to_dmi_dev_attr(attr)->field;
25 ssize_t len; \ 32 ssize_t len;
26 len = scnprintf(page, PAGE_SIZE, "%s\n", dmi_get_system_info(_field)); \ 33 len = scnprintf(page, PAGE_SIZE, "%s\n", dmi_get_system_info(field));
27 page[len-1] = '\n'; \ 34 page[len-1] = '\n';
28 return len; \ 35 return len;
29} \ 36}
30DEFINE_DMI_ATTR(_name, _mode, sys_dmi_##_name##_show); 37
38#define DMI_ATTR(_name, _mode, _show, _field) \
39 { .dev_attr = __ATTR(_name, _mode, _show, NULL), \
40 .field = _field }
41
42#define DEFINE_DMI_ATTR_WITH_SHOW(_name, _mode, _field) \
43static struct dmi_device_attribute sys_dmi_##_name##_attr = \
44 DMI_ATTR(_name, _mode, sys_dmi_field_show, _field);
31 45
32DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR); 46DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR);
33DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION); 47DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION);
@@ -160,7 +174,7 @@ static struct device *dmi_dev;
160 174
161#define ADD_DMI_ATTR(_name, _field) \ 175#define ADD_DMI_ATTR(_name, _field) \
162 if (dmi_get_system_info(_field)) \ 176 if (dmi_get_system_info(_field)) \
163 sys_dmi_attributes[i++] = & sys_dmi_##_name##_attr.attr; 177 sys_dmi_attributes[i++] = &sys_dmi_##_name##_attr.dev_attr.attr;
164 178
165extern int dmi_available; 179extern int dmi_available;
166 180