aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/kbtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/kbtab.c')
-rw-r--r--drivers/usb/input/kbtab.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index fedbcb127c21..c4781b9d1297 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -100,7 +100,7 @@ MODULE_DEVICE_TABLE(usb, kbtab_ids);
100 100
101static int kbtab_open(struct input_dev *dev) 101static int kbtab_open(struct input_dev *dev)
102{ 102{
103 struct kbtab *kbtab = dev->private; 103 struct kbtab *kbtab = input_get_drvdata(dev);
104 104
105 kbtab->irq->dev = kbtab->usbdev; 105 kbtab->irq->dev = kbtab->usbdev;
106 if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) 106 if (usb_submit_urb(kbtab->irq, GFP_KERNEL))
@@ -111,7 +111,7 @@ static int kbtab_open(struct input_dev *dev)
111 111
112static void kbtab_close(struct input_dev *dev) 112static void kbtab_close(struct input_dev *dev)
113{ 113{
114 struct kbtab *kbtab = dev->private; 114 struct kbtab *kbtab = input_get_drvdata(dev);
115 115
116 usb_kill_urb(kbtab->irq); 116 usb_kill_urb(kbtab->irq);
117} 117}
@@ -122,6 +122,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
122 struct usb_endpoint_descriptor *endpoint; 122 struct usb_endpoint_descriptor *endpoint;
123 struct kbtab *kbtab; 123 struct kbtab *kbtab;
124 struct input_dev *input_dev; 124 struct input_dev *input_dev;
125 int error = -ENOMEM;
125 126
126 kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); 127 kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
127 input_dev = input_allocate_device(); 128 input_dev = input_allocate_device();
@@ -145,8 +146,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
145 input_dev->name = "KB Gear Tablet"; 146 input_dev->name = "KB Gear Tablet";
146 input_dev->phys = kbtab->phys; 147 input_dev->phys = kbtab->phys;
147 usb_to_input_id(dev, &input_dev->id); 148 usb_to_input_id(dev, &input_dev->id);
148 input_dev->cdev.dev = &intf->dev; 149 input_dev->dev.parent = &intf->dev;
149 input_dev->private = kbtab; 150
151 input_set_drvdata(input_dev, kbtab);
150 152
151 input_dev->open = kbtab_open; 153 input_dev->open = kbtab_open;
152 input_dev->close = kbtab_close; 154 input_dev->close = kbtab_close;
@@ -168,15 +170,19 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
168 kbtab->irq->transfer_dma = kbtab->data_dma; 170 kbtab->irq->transfer_dma = kbtab->data_dma;
169 kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 171 kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
170 172
171 input_register_device(kbtab->dev); 173 error = input_register_device(kbtab->dev);
174 if (error)
175 goto fail3;
172 176
173 usb_set_intfdata(intf, kbtab); 177 usb_set_intfdata(intf, kbtab);
178
174 return 0; 179 return 0;
175 180
176fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); 181 fail3: usb_free_urb(kbtab->irq);
177fail1: input_free_device(input_dev); 182 fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma);
183 fail1: input_free_device(input_dev);
178 kfree(kbtab); 184 kfree(kbtab);
179 return -ENOMEM; 185 return error;
180} 186}
181 187
182static void kbtab_disconnect(struct usb_interface *intf) 188static void kbtab_disconnect(struct usb_interface *intf)