Commit 7a3156f2 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: converted usblcd over to new usb_register_dev() changes.

parent 81897611
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
struct lcd_usb_data { struct lcd_usb_data {
struct usb_device *lcd_dev; /* init: probe_lcd */ struct usb_device *lcd_dev; /* init: probe_lcd */
unsigned int ifnum; /* Interface number of the USB device */ unsigned int ifnum; /* Interface number of the USB device */
int minor; /* minor number for this device */
int isopen; /* nz if open */ int isopen; /* nz if open */
int present; /* Device is present on the bus */ int present; /* Device is present on the bus */
char *obuf, *ibuf; /* transfer buffers */ char *obuf, *ibuf; /* transfer buffers */
...@@ -245,6 +244,13 @@ file_operations usb_lcd_fops = { ...@@ -245,6 +244,13 @@ file_operations usb_lcd_fops = {
.release = close_lcd, .release = close_lcd,
}; };
static struct usb_class_driver usb_lcd_class = {
.name = "usb/lcd%d",
.fops = &usb_lcd_fops,
.mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
.minor_base = USBLCD_MINOR,
};
static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id) static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *dev = interface_to_usbdev(intf);
...@@ -268,7 +274,7 @@ static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -268,7 +274,7 @@ static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id)
(i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF),
dev->devnum); dev->devnum);
retval = usb_register_dev(&usb_lcd_fops, USBLCD_MINOR, 1, &lcd->minor); retval = usb_register_dev(intf, &usb_lcd_class);
if (retval) { if (retval) {
err("Not able to get a minor for this device."); err("Not able to get a minor for this device.");
return -ENOMEM; return -ENOMEM;
...@@ -279,12 +285,14 @@ static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -279,12 +285,14 @@ static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id)
if (!(lcd->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) { if (!(lcd->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
err("probe_lcd: Not enough memory for the output buffer"); err("probe_lcd: Not enough memory for the output buffer");
usb_deregister_dev(intf, &usb_lcd_class);
return -ENOMEM; return -ENOMEM;
} }
dbg("probe_lcd: obuf address:%p", lcd->obuf); dbg("probe_lcd: obuf address:%p", lcd->obuf);
if (!(lcd->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) { if (!(lcd->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
err("probe_lcd: Not enough memory for the input buffer"); err("probe_lcd: Not enough memory for the input buffer");
usb_deregister_dev(intf, &usb_lcd_class);
kfree(lcd->obuf); kfree(lcd->obuf);
return -ENOMEM; return -ENOMEM;
} }
...@@ -300,7 +308,7 @@ static void disconnect_lcd(struct usb_interface *intf) ...@@ -300,7 +308,7 @@ static void disconnect_lcd(struct usb_interface *intf)
usb_set_intfdata (intf, NULL); usb_set_intfdata (intf, NULL);
if (lcd) { if (lcd) {
usb_deregister_dev(1, lcd->minor); usb_deregister_dev(intf, &usb_lcd_class);
if (lcd->isopen) { if (lcd->isopen) {
lcd->isopen = 0; lcd->isopen = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment