aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/usbled.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 1616ad1793a4..43f84e50d514 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -33,10 +33,10 @@ static const struct usb_device_id id_table[] = {
33 .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, 33 .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER },
34 { }, 34 { },
35}; 35};
36MODULE_DEVICE_TABLE (usb, id_table); 36MODULE_DEVICE_TABLE(usb, id_table);
37 37
38struct usb_led { 38struct usb_led {
39 struct usb_device * udev; 39 struct usb_device *udev;
40 unsigned char blue; 40 unsigned char blue;
41 unsigned char red; 41 unsigned char red;
42 unsigned char green; 42 unsigned char green;
@@ -113,14 +113,16 @@ static void change_color(struct usb_led *led)
113} 113}
114 114
115#define show_set(value) \ 115#define show_set(value) \
116static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 116static ssize_t show_##value(struct device *dev, struct device_attribute *attr,\
117 char *buf) \
117{ \ 118{ \
118 struct usb_interface *intf = to_usb_interface(dev); \ 119 struct usb_interface *intf = to_usb_interface(dev); \
119 struct usb_led *led = usb_get_intfdata(intf); \ 120 struct usb_led *led = usb_get_intfdata(intf); \
120 \ 121 \
121 return sprintf(buf, "%d\n", led->value); \ 122 return sprintf(buf, "%d\n", led->value); \
122} \ 123} \
123static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 124static ssize_t set_##value(struct device *dev, struct device_attribute *attr,\
125 const char *buf, size_t count) \
124{ \ 126{ \
125 struct usb_interface *intf = to_usb_interface(dev); \ 127 struct usb_interface *intf = to_usb_interface(dev); \
126 struct usb_led *led = usb_get_intfdata(intf); \ 128 struct usb_led *led = usb_get_intfdata(intf); \
@@ -135,7 +137,8 @@ show_set(blue);
135show_set(red); 137show_set(red);
136show_set(green); 138show_set(green);
137 139
138static int led_probe(struct usb_interface *interface, const struct usb_device_id *id) 140static int led_probe(struct usb_interface *interface,
141 const struct usb_device_id *id)
139{ 142{
140 struct usb_device *udev = interface_to_usbdev(interface); 143 struct usb_device *udev = interface_to_usbdev(interface);
141 struct usb_led *dev = NULL; 144 struct usb_led *dev = NULL;
@@ -150,7 +153,7 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id
150 dev->udev = usb_get_dev(udev); 153 dev->udev = usb_get_dev(udev);
151 dev->type = id->driver_info; 154 dev->type = id->driver_info;
152 155
153 usb_set_intfdata (interface, dev); 156 usb_set_intfdata(interface, dev);
154 157
155 retval = device_create_file(&interface->dev, &dev_attr_blue); 158 retval = device_create_file(&interface->dev, &dev_attr_blue);
156 if (retval) 159 if (retval)
@@ -194,7 +197,7 @@ error:
194 device_remove_file(&interface->dev, &dev_attr_blue); 197 device_remove_file(&interface->dev, &dev_attr_blue);
195 device_remove_file(&interface->dev, &dev_attr_red); 198 device_remove_file(&interface->dev, &dev_attr_red);
196 device_remove_file(&interface->dev, &dev_attr_green); 199 device_remove_file(&interface->dev, &dev_attr_green);
197 usb_set_intfdata (interface, NULL); 200 usb_set_intfdata(interface, NULL);
198 usb_put_dev(dev->udev); 201 usb_put_dev(dev->udev);
199 kfree(dev); 202 kfree(dev);
200error_mem: 203error_mem:
@@ -205,14 +208,14 @@ static void led_disconnect(struct usb_interface *interface)
205{ 208{
206 struct usb_led *dev; 209 struct usb_led *dev;
207 210
208 dev = usb_get_intfdata (interface); 211 dev = usb_get_intfdata(interface);
209 212
210 device_remove_file(&interface->dev, &dev_attr_blue); 213 device_remove_file(&interface->dev, &dev_attr_blue);
211 device_remove_file(&interface->dev, &dev_attr_red); 214 device_remove_file(&interface->dev, &dev_attr_red);
212 device_remove_file(&interface->dev, &dev_attr_green); 215 device_remove_file(&interface->dev, &dev_attr_green);
213 216
214 /* first remove the files, then set the pointer to NULL */ 217 /* first remove the files, then set the pointer to NULL */
215 usb_set_intfdata (interface, NULL); 218 usb_set_intfdata(interface, NULL);
216 219
217 usb_put_dev(dev->udev); 220 usb_put_dev(dev->udev);
218 221
@@ -243,8 +246,8 @@ static void __exit usb_led_exit(void)
243 usb_deregister(&led_driver); 246 usb_deregister(&led_driver);
244} 247}
245 248
246module_init (usb_led_init); 249module_init(usb_led_init);
247module_exit (usb_led_exit); 250module_exit(usb_led_exit);
248 251
249MODULE_AUTHOR(DRIVER_AUTHOR); 252MODULE_AUTHOR(DRIVER_AUTHOR);
250MODULE_DESCRIPTION(DRIVER_DESC); 253MODULE_DESCRIPTION(DRIVER_DESC);