diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 13:16:28 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 13:16:28 -0800 |
commit | 3e5b08cbbf78bedd316904ab0cf3b27119433ee5 (patch) | |
tree | 0365745c1b7441c1868551c024410c829c3accc6 /drivers/usb/misc/usbled.c | |
parent | da40d036fd716f0efb2917076220814b1e927ae1 (diff) | |
parent | 2af10844eb6ed104f9505bf3a7ba3ceb02264f31 (diff) |
Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (144 commits)
USB: add support for Dream Cheeky DL100B Webmail Notifier (1d34:0004)
USB: serial: ftdi_sio: add support for TIOCSERGETLSR
USB: ehci-mxc: Setup portsc register prior to accessing OTG viewport
USB: atmel_usba_udc: fix freeing irq in usba_udc_remove()
usb: ehci-omap: fix tll channel enable mask
usb: ohci-omap3: fix trivial typo
USB: gadget: ci13xxx: don't assume that PAGE_SIZE is 4096
USB: gadget: ci13xxx: fix complete() callback for no_interrupt rq's
USB: gadget: update ci13xxx to work with g_ether
USB: gadgets: ci13xxx: fix probing of compiled-in gadget drivers
Revert "USB: musb: pm: don't rely fully on clock support"
Revert "USB: musb: blackfin: pm: make it work"
USB: uas: Use GFP_NOIO instead of GFP_KERNEL in I/O submission path
USB: uas: Ensure we only bind to a UAS interface
USB: uas: Rename sense pipe and sense urb to status pipe and status urb
USB: uas: Use kzalloc instead of kmalloc
USB: uas: Fix up the Sense IU
usb: musb: core: kill unneeded #include's
DA8xx: assign name to MUSB IRQ resource
usb: gadget: g_ncm added
...
Manually fix up trivial conflicts in USB Kconfig changes in:
arch/arm/mach-omap2/Kconfig
arch/sh/Kconfig
drivers/usb/Kconfig
drivers/usb/host/ehci-hcd.c
and annoying chip clock data conflicts in:
arch/arm/mach-omap2/clock3xxx_data.c
arch/arm/mach-omap2/clock44xx_data.c
Diffstat (limited to 'drivers/usb/misc/usbled.c')
-rw-r--r-- | drivers/usb/misc/usbled.c | 118 |
1 files changed, 90 insertions, 28 deletions
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index c96f51de169..1732d9bc097 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c @@ -1,5 +1,5 @@ /* - * USB LED driver - 1.1 + * USB LED driver * * Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com) * @@ -20,12 +20,17 @@ #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com" #define DRIVER_DESC "USB LED Driver" -#define VENDOR_ID 0x0fc5 -#define PRODUCT_ID 0x1223 +enum led_type { + DELCOM_VISUAL_SIGNAL_INDICATOR, + DREAM_CHEEKY_WEBMAIL_NOTIFIER, +}; /* table of devices that work with this driver */ static const struct usb_device_id id_table[] = { - { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, + { USB_DEVICE(0x0fc5, 0x1223), + .driver_info = DELCOM_VISUAL_SIGNAL_INDICATOR }, + { USB_DEVICE(0x1d34, 0x0004), + .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, { }, }; MODULE_DEVICE_TABLE (usb, id_table); @@ -35,15 +40,12 @@ struct usb_led { unsigned char blue; unsigned char red; unsigned char green; + enum led_type type; }; -#define BLUE 0x04 -#define RED 0x02 -#define GREEN 0x01 static void change_color(struct usb_led *led) { int retval; - unsigned char color = 0x07; unsigned char *buffer; buffer = kmalloc(8, GFP_KERNEL); @@ -52,25 +54,59 @@ static void change_color(struct usb_led *led) return; } - if (led->blue) - color &= ~(BLUE); - if (led->red) - color &= ~(RED); - if (led->green) - color &= ~(GREEN); - dev_dbg(&led->udev->dev, - "blue = %d, red = %d, green = %d, color = %.2x\n", - led->blue, led->red, led->green, color); - - retval = usb_control_msg(led->udev, - usb_sndctrlpipe(led->udev, 0), - 0x12, - 0xc8, - (0x02 * 0x100) + 0x0a, - (0x00 * 0x100) + color, - buffer, - 8, - 2000); + switch (led->type) { + case DELCOM_VISUAL_SIGNAL_INDICATOR: { + unsigned char color = 0x07; + + if (led->blue) + color &= ~0x04; + if (led->red) + color &= ~0x02; + if (led->green) + color &= ~0x01; + dev_dbg(&led->udev->dev, + "blue = %d, red = %d, green = %d, color = %.2x\n", + led->blue, led->red, led->green, color); + + retval = usb_control_msg(led->udev, + usb_sndctrlpipe(led->udev, 0), + 0x12, + 0xc8, + (0x02 * 0x100) + 0x0a, + (0x00 * 0x100) + color, + buffer, + 8, + 2000); + break; + } + + case DREAM_CHEEKY_WEBMAIL_NOTIFIER: + dev_dbg(&led->udev->dev, + "red = %d, green = %d, blue = %d\n", + led->red, led->green, led->blue); + + buffer[0] = led->red; + buffer[1] = led->green; + buffer[2] = led->blue; + buffer[3] = buffer[4] = buffer[5] = 0; + buffer[6] = 0x1a; + buffer[7] = 0x05; + + retval = usb_control_msg(led->udev, + usb_sndctrlpipe(led->udev, 0), + 0x09, + 0x21, + 0x200, + 0, + buffer, + 8, + 2000); + break; + + default: + dev_err(&led->udev->dev, "unknown device type %d\n", led->type); + } + if (retval) dev_dbg(&led->udev->dev, "retval = %d\n", retval); kfree(buffer); @@ -107,11 +143,12 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL); if (dev == NULL) { - dev_err(&interface->dev, "Out of memory\n"); + dev_err(&interface->dev, "out of memory\n"); goto error_mem; } dev->udev = usb_get_dev(udev); + dev->type = id->driver_info; usb_set_intfdata (interface, dev); @@ -125,6 +162,31 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id if (retval) goto error; + if (dev->type == DREAM_CHEEKY_WEBMAIL_NOTIFIER) { + unsigned char *enable; + + enable = kmemdup("\x1f\x02\0\x5f\0\0\x1a\x03", 8, GFP_KERNEL); + if (!enable) { + dev_err(&interface->dev, "out of memory\n"); + retval = -ENOMEM; + goto error; + } + + retval = usb_control_msg(udev, + usb_sndctrlpipe(udev, 0), + 0x09, + 0x21, + 0x200, + 0, + enable, + 8, + 2000); + + kfree(enable); + if (retval != 8) + goto error; + } + dev_info(&interface->dev, "USB LED device now attached\n"); return 0; |