diff options
Diffstat (limited to 'drivers/firmware/dmi-id.c')
-rw-r--r-- | drivers/firmware/dmi-id.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index 59c3b5aa89f4..b6e1eb77d148 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c | |||
@@ -13,21 +13,31 @@ | |||
13 | #include <linux/device.h> | 13 | #include <linux/device.h> |
14 | #include <linux/autoconf.h> | 14 | #include <linux/autoconf.h> |
15 | 15 | ||
16 | #define DEFINE_DMI_ATTR(_name, _mode, _show) \ | 16 | struct dmi_device_attribute{ |
17 | static struct device_attribute sys_dmi_##_name##_attr = \ | 17 | struct device_attribute dev_attr; |
18 | __ATTR(_name, _mode, _show, NULL); | 18 | int field; |
19 | 19 | }; | |
20 | #define DEFINE_DMI_ATTR_WITH_SHOW(_name, _mode, _field) \ | 20 | #define to_dmi_dev_attr(_dev_attr) \ |
21 | static ssize_t sys_dmi_##_name##_show(struct device *dev, \ | 21 | container_of(_dev_attr, struct dmi_device_attribute, dev_attr) |
22 | struct device_attribute *attr, \ | 22 | |
23 | char *page) \ | 23 | static ssize_t sys_dmi_field_show(struct device *dev, |
24 | { \ | 24 | struct device_attribute *attr, |
25 | ssize_t len; \ | 25 | char *page) |
26 | len = scnprintf(page, PAGE_SIZE, "%s\n", dmi_get_system_info(_field)); \ | 26 | { |
27 | page[len-1] = '\n'; \ | 27 | int field = to_dmi_dev_attr(attr)->field; |
28 | return len; \ | 28 | ssize_t len; |
29 | } \ | 29 | len = scnprintf(page, PAGE_SIZE, "%s\n", dmi_get_system_info(field)); |
30 | DEFINE_DMI_ATTR(_name, _mode, sys_dmi_##_name##_show); | 30 | page[len-1] = '\n'; |
31 | return len; | ||
32 | } | ||
33 | |||
34 | #define DMI_ATTR(_name, _mode, _show, _field) \ | ||
35 | { .dev_attr = __ATTR(_name, _mode, _show, NULL), \ | ||
36 | .field = _field } | ||
37 | |||
38 | #define DEFINE_DMI_ATTR_WITH_SHOW(_name, _mode, _field) \ | ||
39 | static struct dmi_device_attribute sys_dmi_##_name##_attr = \ | ||
40 | DMI_ATTR(_name, _mode, sys_dmi_field_show, _field); | ||
31 | 41 | ||
32 | DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR); | 42 | DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR); |
33 | DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION); | 43 | DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION); |
@@ -121,7 +131,8 @@ static ssize_t sys_dmi_modalias_show(struct device *dev, | |||
121 | return r+1; | 131 | return r+1; |
122 | } | 132 | } |
123 | 133 | ||
124 | DEFINE_DMI_ATTR(modalias, 0444, sys_dmi_modalias_show); | 134 | static struct device_attribute sys_dmi_modalias_attr = |
135 | __ATTR(modalias, 0444, sys_dmi_modalias_show, NULL); | ||
125 | 136 | ||
126 | static struct attribute *sys_dmi_attributes[DMI_STRING_MAX+2]; | 137 | static struct attribute *sys_dmi_attributes[DMI_STRING_MAX+2]; |
127 | 138 | ||
@@ -134,14 +145,17 @@ static struct attribute_group* sys_dmi_attribute_groups[] = { | |||
134 | NULL | 145 | NULL |
135 | }; | 146 | }; |
136 | 147 | ||
137 | static int dmi_dev_uevent(struct device *dev, char **envp, | 148 | static int dmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env) |
138 | int num_envp, char *buffer, int buffer_size) | ||
139 | { | 149 | { |
140 | strcpy(buffer, "MODALIAS="); | 150 | ssize_t len; |
141 | get_modalias(buffer+9, buffer_size-9); | 151 | |
142 | envp[0] = buffer; | 152 | if (add_uevent_var(env, "MODALIAS=")) |
143 | envp[1] = NULL; | 153 | return -ENOMEM; |
144 | 154 | len = get_modalias(&env->buf[env->buflen - 1], | |
155 | sizeof(env->buf) - env->buflen); | ||
156 | if (len >= (sizeof(env->buf) - env->buflen)) | ||
157 | return -ENOMEM; | ||
158 | env->buflen += len; | ||
145 | return 0; | 159 | return 0; |
146 | } | 160 | } |
147 | 161 | ||
@@ -157,7 +171,7 @@ static struct device *dmi_dev; | |||
157 | 171 | ||
158 | #define ADD_DMI_ATTR(_name, _field) \ | 172 | #define ADD_DMI_ATTR(_name, _field) \ |
159 | if (dmi_get_system_info(_field)) \ | 173 | if (dmi_get_system_info(_field)) \ |
160 | sys_dmi_attributes[i++] = & sys_dmi_##_name##_attr.attr; | 174 | sys_dmi_attributes[i++] = &sys_dmi_##_name##_attr.dev_attr.attr; |
161 | 175 | ||
162 | extern int dmi_available; | 176 | extern int dmi_available; |
163 | 177 | ||