9 #include <linux/module.h>
10 #include <linux/kernel.h>
13 #include <linux/device.h>
14 #include <linux/slab.h>
20 #define to_dmi_dev_attr(_dev_attr) \
21 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34 #define DMI_ATTR(_name, _mode, _show, _field) \
35 { .dev_attr = __ATTR(_name, _mode, _show, NULL), \
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);
61 static void ascii_filter(
char *
d,
const char *
s)
65 if (*s >
' ' && *s < 127 && *s !=
':')
73 static const struct mafield {
94 const struct mafield *
f;
97 p = buffer + 3; left = buffer_size - 4;
99 for (f =
fields; f->prefix && left > 0; f++) {
111 l =
scnprintf(p, left,
":%s%s", f->prefix, t);
121 return p - buffer + 1;
135 __ATTR(modalias, 0444, sys_dmi_modalias_show,
NULL);
140 .attrs = sys_dmi_attributes,
144 &sys_dmi_attribute_group,
154 len = get_modalias(&env->
buf[env->
buflen - 1],
156 if (len >= (
sizeof(env->
buf) - env->
buflen))
162 static struct class dmi_class = {
165 .dev_uevent = dmi_dev_uevent,
168 static struct device *dmi_dev;
172 #define ADD_DMI_ATTR(_name, _field) \
173 if (dmi_get_system_info(_field)) \
174 sys_dmi_attributes[i++] = &sys_dmi_##_name##_attr.dev_attr.attr;
178 static void __init dmi_id_init_attr_table(
void)
204 sys_dmi_attributes[i++] = &sys_dmi_modalias_attr.
attr;
207 static int __init dmi_id_init(
void)
214 dmi_id_init_attr_table();
220 dmi_dev = kzalloc(
sizeof(*dmi_dev),
GFP_KERNEL);
223 goto fail_class_unregister;
226 dmi_dev->
class = &dmi_class;
228 dmi_dev->
groups = sys_dmi_attribute_groups;
232 goto fail_free_dmi_dev;
238 fail_class_unregister: