This source file includes following definitions.
- state_show
- dim2_sysfs_probe
- dim2_sysfs_destroy
1
2
3
4
5
6
7
8
9
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12 #include <linux/kernel.h>
13 #include "sysfs.h"
14 #include <linux/device.h>
15
16 static ssize_t state_show(struct device *dev, struct device_attribute *attr,
17 char *buf)
18 {
19 bool state = dim2_sysfs_get_state_cb();
20
21 return sprintf(buf, "%s\n", state ? "locked" : "");
22 }
23
24 static DEVICE_ATTR_RO(state);
25
26 static struct attribute *dev_attrs[] = {
27 &dev_attr_state.attr,
28 NULL,
29 };
30
31 static struct attribute_group dev_attr_group = {
32 .attrs = dev_attrs,
33 };
34
35 static const struct attribute_group *dev_attr_groups[] = {
36 &dev_attr_group,
37 NULL,
38 };
39
40 int dim2_sysfs_probe(struct device *dev)
41 {
42 dev->groups = dev_attr_groups;
43 return device_register(dev);
44 }
45
46 void dim2_sysfs_destroy(struct device *dev)
47 {
48 device_unregister(dev);
49 }