aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/IR/ir-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/IR/ir-sysfs.c')
-rw-r--r--drivers/media/IR/ir-sysfs.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index aede78ddbace..a96738135bb0 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -18,11 +18,22 @@
18 18
19#define IRRCV_NUM_DEVICES 256 19#define IRRCV_NUM_DEVICES 256
20 20
21unsigned long ir_core_dev_number; 21/* bit array to represent IR sysfs device number */
22static unsigned long ir_core_dev_number;
22 23
24/* class for /sys/class/irrcv */
23static struct class *ir_input_class; 25static struct class *ir_input_class;
24 26
25 27/**
28 * show_protocol() - shows the current IR protocol
29 * @d: the device descriptor
30 * @mattr: the device attribute struct (unused)
31 * @buf: a pointer to the output buffer
32 *
33 * This routine is a callback routine for input read the IR protocol type.
34 * it is trigged by reading /sys/class/irrcv/irrcv?/current_protocol.
35 * It returns the protocol name, as understood by the driver.
36 */
26static ssize_t show_protocol(struct device *d, 37static ssize_t show_protocol(struct device *d,
27 struct device_attribute *mattr, char *buf) 38 struct device_attribute *mattr, char *buf)
28{ 39{
@@ -47,7 +58,19 @@ static ssize_t show_protocol(struct device *d,
47 return sprintf(buf, "%s\n", s); 58 return sprintf(buf, "%s\n", s);
48} 59}
49 60
50 61/**
62 * store_protocol() - shows the current IR protocol
63 * @d: the device descriptor
64 * @mattr: the device attribute struct (unused)
65 * @buf: a pointer to the input buffer
66 * @len: length of the input buffer
67 *
68 * This routine is a callback routine for changing the IR protocol type.
69 * it is trigged by reading /sys/class/irrcv/irrcv?/current_protocol.
70 * It changes the IR the protocol name, if the IR type is recognized
71 * by the driver.
72 * If an unknown protocol name is used, returns -EINVAL.
73 */
51static ssize_t store_protocol(struct device *d, 74static ssize_t store_protocol(struct device *d,
52 struct device_attribute *mattr, 75 struct device_attribute *mattr,
53 const char *data, 76 const char *data,
@@ -88,7 +111,9 @@ static ssize_t store_protocol(struct device *d,
88 return len; 111 return len;
89} 112}
90 113
91 114/*
115 * Static device attribute struct with the sysfs attributes for IR's
116 */
92static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR, 117static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR,
93 show_protocol, store_protocol); 118 show_protocol, store_protocol);
94 119
@@ -96,6 +121,12 @@ static struct attribute *ir_dev_attrs[] = {
96 &dev_attr_current_protocol.attr, 121 &dev_attr_current_protocol.attr,
97}; 122};
98 123
124/**
125 * ir_register_class() - creates the sysfs for /sys/class/irrcv/irrcv?
126 * @input_dev: the struct input_dev descriptor of the device
127 *
128 * This routine is used to register the syfs code for IR class
129 */
99int ir_register_class(struct input_dev *input_dev) 130int ir_register_class(struct input_dev *input_dev)
100{ 131{
101 int rc; 132 int rc;
@@ -127,6 +158,13 @@ int ir_register_class(struct input_dev *input_dev)
127 return 0; 158 return 0;
128}; 159};
129 160
161/**
162 * ir_unregister_class() - removes the sysfs for sysfs for
163 * /sys/class/irrcv/irrcv?
164 * @input_dev: the struct input_dev descriptor of the device
165 *
166 * This routine is used to unregister the syfs code for IR class
167 */
130void ir_unregister_class(struct input_dev *input_dev) 168void ir_unregister_class(struct input_dev *input_dev)
131{ 169{
132 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 170 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
@@ -142,6 +180,10 @@ void ir_unregister_class(struct input_dev *input_dev)
142 kfree(ir_dev->attr.name); 180 kfree(ir_dev->attr.name);
143} 181}
144 182
183/*
184 * Init/exit code for the module. Basically, creates/removes /sys/class/irrcv
185 */
186
145static int __init ir_core_init(void) 187static int __init ir_core_init(void)
146{ 188{
147 ir_input_class = class_create(THIS_MODULE, "irrcv"); 189 ir_input_class = class_create(THIS_MODULE, "irrcv");