diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:52 -0400 |
commit | c5b7c7c395a34f12cdf246d66c1feeff2933d584 (patch) | |
tree | 8af335c30bb92991f4bfd8251de4fed9907b07bd /drivers/usb/input/kbtab.c | |
parent | 3c42f0c3dde8feb59fc87df45cadb847d5511c0a (diff) |
[PATCH] drivers/usb/input: convert to dynamic input_dev allocation
Input: convert drivers/iusb/input to dynamic input_dev allocation
This is required for input_dev sysfs integration
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/input/kbtab.c')
-rw-r--r-- | drivers/usb/input/kbtab.c | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index b6f6ac8d9c2f..a248664b5d1d 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -34,7 +34,7 @@ MODULE_PARM_DESC(kb_pressure_click, "pressure threshold for clicks"); | |||
34 | struct kbtab { | 34 | struct kbtab { |
35 | signed char *data; | 35 | signed char *data; |
36 | dma_addr_t data_dma; | 36 | dma_addr_t data_dma; |
37 | struct input_dev dev; | 37 | struct input_dev *dev; |
38 | struct usb_device *usbdev; | 38 | struct usb_device *usbdev; |
39 | struct urb *irq; | 39 | struct urb *irq; |
40 | int x, y; | 40 | int x, y; |
@@ -48,7 +48,7 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs) | |||
48 | { | 48 | { |
49 | struct kbtab *kbtab = urb->context; | 49 | struct kbtab *kbtab = urb->context; |
50 | unsigned char *data = kbtab->data; | 50 | unsigned char *data = kbtab->data; |
51 | struct input_dev *dev = &kbtab->dev; | 51 | struct input_dev *dev = kbtab->dev; |
52 | int retval; | 52 | int retval; |
53 | 53 | ||
54 | switch (urb->status) { | 54 | switch (urb->status) { |
@@ -124,53 +124,43 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
124 | struct usb_device *dev = interface_to_usbdev(intf); | 124 | struct usb_device *dev = interface_to_usbdev(intf); |
125 | struct usb_endpoint_descriptor *endpoint; | 125 | struct usb_endpoint_descriptor *endpoint; |
126 | struct kbtab *kbtab; | 126 | struct kbtab *kbtab; |
127 | char path[64]; | 127 | struct input_dev *input_dev; |
128 | 128 | ||
129 | if (!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL))) | 129 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
130 | return -ENOMEM; | 130 | input_dev = input_allocate_device(); |
131 | memset(kbtab, 0, sizeof(struct kbtab)); | 131 | if (!kbtab || !input_dev) |
132 | goto fail1; | ||
132 | 133 | ||
133 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); | 134 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); |
134 | if (!kbtab->data) { | 135 | if (!kbtab->data) |
135 | kfree(kbtab); | 136 | goto fail1; |
136 | return -ENOMEM; | ||
137 | } | ||
138 | 137 | ||
139 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); | 138 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); |
140 | if (!kbtab->irq) { | 139 | if (!kbtab->irq) |
141 | usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 140 | goto fail2; |
142 | kfree(kbtab); | ||
143 | return -ENOMEM; | ||
144 | } | ||
145 | |||
146 | kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | ||
147 | kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
148 | |||
149 | kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
150 | |||
151 | kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); | ||
152 | 141 | ||
153 | kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL); | 142 | kbtab->usbdev = dev; |
154 | 143 | kbtab->dev = input_dev; | |
155 | kbtab->dev.absmax[ABS_X] = 0x2000; | ||
156 | kbtab->dev.absmax[ABS_Y] = 0x1750; | ||
157 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; | ||
158 | 144 | ||
159 | kbtab->dev.absfuzz[ABS_X] = 4; | 145 | usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys)); |
160 | kbtab->dev.absfuzz[ABS_Y] = 4; | 146 | strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys)); |
161 | 147 | ||
162 | kbtab->dev.private = kbtab; | 148 | input_dev->name = "KB Gear Tablet"; |
163 | kbtab->dev.open = kbtab_open; | 149 | input_dev->phys = kbtab->phys; |
164 | kbtab->dev.close = kbtab_close; | 150 | usb_to_input_id(dev, &input_dev->id); |
151 | input_dev->cdev.dev = &intf->dev; | ||
152 | input_dev->private = kbtab; | ||
165 | 153 | ||
166 | usb_make_path(dev, path, 64); | 154 | input_dev->open = kbtab_open; |
167 | sprintf(kbtab->phys, "%s/input0", path); | 155 | input_dev->close = kbtab_close; |
168 | 156 | ||
169 | kbtab->dev.name = "KB Gear Tablet"; | 157 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); |
170 | kbtab->dev.phys = kbtab->phys; | 158 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
171 | usb_to_input_id(dev, &kbtab->dev.id); | 159 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); |
172 | kbtab->dev.dev = &intf->dev; | 160 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
173 | kbtab->usbdev = dev; | 161 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); |
162 | input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0); | ||
163 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | ||
174 | 164 | ||
175 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 165 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
176 | 166 | ||
@@ -181,23 +171,25 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
181 | kbtab->irq->transfer_dma = kbtab->data_dma; | 171 | kbtab->irq->transfer_dma = kbtab->data_dma; |
182 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 172 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
183 | 173 | ||
184 | input_register_device(&kbtab->dev); | 174 | input_register_device(kbtab->dev); |
185 | |||
186 | printk(KERN_INFO "input: KB Gear Tablet on %s\n", path); | ||
187 | 175 | ||
188 | usb_set_intfdata(intf, kbtab); | 176 | usb_set_intfdata(intf, kbtab); |
189 | |||
190 | return 0; | 177 | return 0; |
178 | |||
179 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | ||
180 | fail1: input_free_device(input_dev); | ||
181 | kfree(kbtab); | ||
182 | return -ENOMEM; | ||
191 | } | 183 | } |
192 | 184 | ||
193 | static void kbtab_disconnect(struct usb_interface *intf) | 185 | static void kbtab_disconnect(struct usb_interface *intf) |
194 | { | 186 | { |
195 | struct kbtab *kbtab = usb_get_intfdata (intf); | 187 | struct kbtab *kbtab = usb_get_intfdata(intf); |
196 | 188 | ||
197 | usb_set_intfdata(intf, NULL); | 189 | usb_set_intfdata(intf, NULL); |
198 | if (kbtab) { | 190 | if (kbtab) { |
199 | usb_kill_urb(kbtab->irq); | 191 | usb_kill_urb(kbtab->irq); |
200 | input_unregister_device(&kbtab->dev); | 192 | input_unregister_device(kbtab->dev); |
201 | usb_free_urb(kbtab->irq); | 193 | usb_free_urb(kbtab->irq); |
202 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); | 194 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); |
203 | kfree(kbtab); | 195 | kfree(kbtab); |