]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/app/usbcan/ul_usb1.c
Device side of canqueue, compilation successful
[lincan.git] / embedded / app / usbcan / ul_usb1.c
1 /* ul_usb1.c
2  * Linux CAN-bus device driver.
3  * Written by Jan Kriz email:johen@post.cz
4  * This software is released under the GPL-License.
5  * Version lincan-0.3  17 Jun 2004
6  *
7  * Based on
8  *      USB Skeleton driver - 2.2
9  *
10  * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
11  *
12  *      This program is free software; you can redistribute it and/or
13  *      modify it under the terms of the GNU General Public License as
14  *      published by the Free Software Foundation, version 2.
15  *
16  * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c
17  * but has been rewritten to be easier to read and use.
18  *
19  */
20
21 #include "./can/ul_usb1.h"
22 #include "./can/can.h"
23 #include "./can/can_sysdep.h"
24 #include "./can/main.h"
25 #include "./can/devcommon.h"
26 #include "./can/setup.h"
27 // #include "./can/finish.h"
28 #include "./can/i82527.h"
29 //#include "../include/sja1000.h"
30 #include "./can/sja1000p.h"
31
32 #include "./can/errno.h"
33
34 /* Get a minor range for your devices from the usb maintainer */
35 #define USB_SKEL_MINOR_BASE     192
36
37 #define CAN_OP_MASK 0x80
38 #define CAN_OP_READ 0x80
39 #define CAN_OP_WRITE 0x00
40
41
42         /* our private defines. if this grows any larger, use your own .h file */
43 #define MAX_TRANSFER            (PAGE_SIZE - 512)
44 /* MAX_TRANSFER is chosen so that the VM is not stressed by
45    allocations > PAGE_SIZE and the number of packets in a page
46    is an integer 512 is the largest possible packet on EHCI */
47 #define WRITES_IN_FLIGHT        8
48 /* arbitrarily chosen */
49
50 /* Define these values to match your devices */
51 #define USB_SKEL_VENDOR_ID      0xDEAD
52 #define USB_SKEL_PRODUCT_ID     0x1001
53
54 /* table of devices that work with this driver */
55 // static struct usb_device_id ul_usb1_table [] = {
56 //      { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
57 //      { }                                     /* Terminating entry */
58 // };
59 // MODULE_DEVICE_TABLE(usb, ul_usb1_table);
60
61 // extern struct file_operations can_fops;
62
63 // struct ul_usb1_combo {
64 //      struct usb_ul_usb1 * dev;
65 //      struct urb * urb;
66 // };
67
68 /*
69  * IO_RANGE is the io-memory range that gets reserved, please adjust according
70  * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or
71  * #define IO_RANGE 0x20 for sja1000 chips in basic CAN mode.
72  */
73 #define IO_RANGE 0x100
74
75 /* Structure to hold all of our device specific stuff */
76 // struct usb_ul_usb1 {
77 //      struct usb_device       *udev;                  /* the usb device for this device */
78 //      struct usb_interface    *interface;             /* the interface for this device */
79 //      struct semaphore        limit_sem;              /* limiting the number of writes in progress */
80 //      struct usb_anchor       submitted;              /* in case we need to retract our submissions */
81 //      unsigned char           *bulk_in_buffer;        /* the buffer to receive data */
82 //      size_t                  bulk_in_size;           /* the size of the receive buffer */
83 //      unsigned char           *int_in_buffer; /* the buffer to receive data */
84 //      size_t                  int_in_size;            /* the size of the receive buffer */
85 //      __u8                    bulk_in_endpointAddr;   /* the address of the bulk in endpoint */
86 //      __u8                    bulk_out_endpointAddr;  /* the address of the bulk out endpoint */
87 //      __u8                    int_in_endpointAddr;    /* the address of the interrupt in endpoint */
88 //      int                             int_in_interval;
89 //      int                     errors;                 /* the last request tanked */
90 //      int                     open_count;             /* count the number of openers */
91 //      spinlock_t              err_lock;               /* lock for errors */
92 //      struct mutex            io_mutex;               /* synchronize I/O with disconnect */
93 //      struct urb              *irq;
94 //      struct candevice_t              *candev;
95 // };
96 //
97 // static struct usb_driver ul_usb1_driver;
98
99 /** ul_usb1_request_io
100  * ul_usb1_request_io: - reserve io or memory range for can board
101  * @candev: pointer to candevice/board which asks for io. Field @io_addr
102  *      of @candev is used in most cases to define start of the range
103  *
104  * The function ul_usb1_request_io() is used to reserve the io-memory. If your
105  * hardware uses a dedicated memory range as hardware control registers you
106  * will have to add the code to reserve this memory as well.
107  * %IO_RANGE is the io-memory range that gets reserved, please adjust according
108  * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or
109  * #define IO_RANGE 0x20 for sja1000 chips in basic CAN mode.
110  * Return Value: The function returns zero on success or %-ENODEV on failure
111  * File: src/ul_usb1.c
112  */
113 int ul_usb1_request_io(struct candevice_t *candev)
114 {
115 //      ((struct usb_ul_usb1*)candev->sysdevptr.anydev)->candev=candev;
116         return 0;
117 }
118
119 /** ul_usb1_release_io
120  * ul_usb1_release_io - free reserved io memory range
121  * @candev: pointer to candevice/board which releases io
122  *
123  * The function ul_usb1_release_io() is used to free reserved io-memory.
124  * In case you have reserved more io memory, don't forget to free it here.
125  * IO_RANGE is the io-memory range that gets released, please adjust according
126  * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or
127  * #define IO_RANGE 0x20 for sja1000 chips in basic CAN mode.
128  * Return Value: The function always returns zero
129  * File: src/ul_usb1.c
130  */
131 int ul_usb1_release_io(struct candevice_t *candev)
132 {
133 /*      struct usb_ul_usb1 *dev;
134         if (candev->sysdevptr.anydev){
135                 dev=(struct usb_ul_usb1*) candev->sysdevptr.anydev;
136                 usb_put_dev(dev->udev);
137                 usb_kill_urb(dev->irq);
138                 usb_free_urb(dev->irq);
139                 kfree(dev->bulk_in_buffer);
140                 kfree(dev->int_in_buffer);
141                 if (dev->candev){
142                         dev->candev->sysdevptr.anydev=NULL;
143                         //cleanup_usbdev(dev->candev);
144                 }
145                 kfree(dev);
146         }*/
147         return 0;
148 }
149
150 /** ul_usb1_reset
151  * ul_usb1_reset - hardware reset routine
152  * @candev: Pointer to candevice/board structure
153  *
154  * The function ul_usb1_reset() is used to give a hardware reset. This is
155  * rather hardware specific so I haven't included example code. Don't forget to
156  * check the reset status of the chip before returning.
157  * Return Value: The function returns zero on success or %-ENODEV on failure
158  * File: src/ul_usb1.c
159  */
160 int ul_usb1_reset(struct candevice_t *candev)
161 {
162         return 0;
163 }
164
165 #define RESET_ADDR 0x0
166 #define NR_82527 0
167 #define NR_SJA1000 1
168
169 /** ul_usb1_init_hw_data
170  * ul_usb1_init_hw_data - Initialize hardware cards
171  * @candev: Pointer to candevice/board structure
172  *
173  * The function ul_usb1_init_hw_data() is used to initialize the hardware
174  * structure containing information about the installed CAN-board.
175  * %RESET_ADDR represents the io-address of the hardware reset register.
176  * %NR_82527 represents the number of Intel 82527 chips on the board.
177  * %NR_SJA1000 represents the number of Philips sja1000 chips on the board.
178  * The flags entry can currently only be %CANDEV_PROGRAMMABLE_IRQ to indicate that
179  * the hardware uses programmable interrupts.
180  * Return Value: The function always returns zero
181  * File: src/ul_usb1.c
182  */
183 int ul_usb1_init_hw_data(struct candevice_t *candev)
184 {
185         candev->res_addr=RESET_ADDR;
186         candev->nr_82527_chips=NR_82527;
187         candev->nr_sja1000_chips=NR_SJA1000;
188         candev->nr_all_chips=NR_82527+NR_SJA1000;
189         //candev->flags |= CANDEV_PROGRAMMABLE_IRQ;
190
191         return 0;
192 }
193
194 /** ul_usb1_init_chip_data
195  * ul_usb1_init_chip_data - Initialize chips
196  * @candev: Pointer to candevice/board structure
197  * @chipnr: Number of the CAN chip on the hardware card
198  *
199  * The function ul_usb1_init_chip_data() is used to initialize the hardware
200  * structure containing information about the CAN chips.
201  * %CHIP_TYPE represents the type of CAN chip. %CHIP_TYPE can be "i82527" or
202  * "sja1000".
203  * The @chip_base_addr entry represents the start of the 'official' memory map
204  * of the installed chip. It's likely that this is the same as the @io_addr
205  * argument supplied at module loading time.
206  * The @clock entry holds the chip clock value in Hz.
207  * The entry @sja_cdr_reg holds hardware specific options for the Clock Divider
208  * register. Options defined in the %sja1000.h file:
209  * %sjaCDR_CLKOUT_MASK, %sjaCDR_CLK_OFF, %sjaCDR_RXINPEN, %sjaCDR_CBP, %sjaCDR_PELICAN
210  * The entry @sja_ocr_reg holds hardware specific options for the Output Control
211  * register. Options defined in the %sja1000.h file:
212  * %sjaOCR_MODE_BIPHASE, %sjaOCR_MODE_TEST, %sjaOCR_MODE_NORMAL, %sjaOCR_MODE_CLOCK,
213  * %sjaOCR_TX0_LH, %sjaOCR_TX1_ZZ.
214  * The entry @int_clk_reg holds hardware specific options for the Clock Out
215  * register. Options defined in the %i82527.h file:
216  * %iCLK_CD0, %iCLK_CD1, %iCLK_CD2, %iCLK_CD3, %iCLK_SL0, %iCLK_SL1.
217  * The entry @int_bus_reg holds hardware specific options for the Bus
218  * Configuration register. Options defined in the %i82527.h file:
219  * %iBUS_DR0, %iBUS_DR1, %iBUS_DT1, %iBUS_POL, %iBUS_CBY.
220  * The entry @int_cpu_reg holds hardware specific options for the cpu interface
221  * register. Options defined in the %i82527.h file:
222  * %iCPU_CEN, %iCPU_MUX, %iCPU_SLP, %iCPU_PWD, %iCPU_DMC, %iCPU_DSC, %iCPU_RST.
223  * Return Value: The function always returns zero
224  * File: src/ul_usb1.c
225  */
226 int ul_usb1_init_chip_data(struct candevice_t *candev, int chipnr)
227 {
228         /*i82527_fill_chipspecops(candev->chip[chipnr]);*/
229         /*sja1000_fill_chipspecops(candev->chip[chipnr]);*/
230         sja1000p_fill_chipspecops(candev->chip[chipnr]);
231
232         candev->chip[chipnr]->flags|= CHIP_IRQ_CUSTOM;
233
234         candev->chip[chipnr]->chip_base_addr=0;
235         candev->chip[chipnr]->clock = 24000000;
236         candev->chip[chipnr]->int_cpu_reg = iCPU_DSC;
237         candev->chip[chipnr]->int_clk_reg = iCLK_SL1;
238         candev->chip[chipnr]->int_bus_reg = iBUS_CBY;
239         candev->chip[chipnr]->sja_cdr_reg = sjaCDR_CBP | sjaCDR_CLK_OFF;
240         candev->chip[chipnr]->sja_ocr_reg = sjaOCR_MODE_NORMAL |
241                                                                 sjaOCR_TX0_LH;
242
243         return 0;
244 }
245
246 /** ul_usb1_init_obj_data
247  * ul_usb1_init_obj_data - Initialize message buffers
248  * @chip: Pointer to chip specific structure
249  * @objnr: Number of the message buffer
250  *
251  * The function ul_usb1_init_obj_data() is used to initialize the hardware
252  * structure containing information about the different message objects on the
253  * CAN chip. In case of the sja1000 there's only one message object but on the
254  * i82527 chip there are 15.
255  * The code below is for a i82527 chip and initializes the object base addresses
256  * The entry @obj_base_addr represents the first memory address of the message
257  * object. In case of the sja1000 @obj_base_addr is taken the same as the chips
258  * base address.
259  * Unless the hardware uses a segmented memory map, flags can be set zero.
260  * Return Value: The function always returns zero
261  * File: src/ul_usb1.c
262  */
263 int ul_usb1_init_obj_data(struct canchip_t *chip, int objnr)
264 {
265         chip->msgobj[objnr]->obj_base_addr=chip->chip_base_addr+(objnr+1)*0x10;
266
267         return 0;
268 }
269
270 /** ul_usb1_program_irq
271  * ul_usb1_program_irq - program interrupts
272  * @candev: Pointer to candevice/board structure
273  *
274  * The function ul_usb1_program_irq() is used for hardware that uses
275  * programmable interrupts. If your hardware doesn't use programmable interrupts
276  * you should not set the @candevices_t->flags entry to %CANDEV_PROGRAMMABLE_IRQ and
277  * leave this function unedited. Again this function is hardware specific so
278  * there's no example code.
279  * Return value: The function returns zero on success or %-ENODEV on failure
280  * File: src/ul_usb1.c
281  */
282 int ul_usb1_program_irq(struct candevice_t *candev)
283 {
284         return 0;
285 }
286
287 /** ul_usb1_write_register
288  * ul_usb1_write_register - Low level write register routine
289  * @data: data to be written
290  * @address: memory address to write to
291  *
292  * The function ul_usb1_write_register() is used to write to hardware registers
293  * on the CAN chip. You should only have to edit this function if your hardware
294  * uses some specific write process.
295  * Return Value: The function does not return a value
296  * File: src/ul_usb1.c
297  */
298 void ul_usb1_write_register(struct candevice_t *candev,unsigned data, unsigned long address)
299 {
300         struct usb_ul_usb1 *dev;
301         int retval;
302         int bytes_transferred;
303         unsigned char buffer[2];
304         buffer[0]=((unsigned char)address & ~CAN_OP_MASK)+CAN_OP_WRITE;
305         buffer[1]=(unsigned char)data;
306
307         dev = (struct usb_ul_usb1 *)candev->sysdevptr.anydev;
308
309 //      mutex_lock(&dev->io_mutex);
310 //      if (!dev) {             /* disconnect() was called */
311 //              CANMSG("Sending %lu:%X : ERR No device\n",address,(uint8_t)data);
312 //              retval = -ENODEV;
313 //              goto exit;
314 //      }
315 //      if (!dev->interface) {          /* disconnect() was called */
316 //              CANMSG("Sending %lu:%X : ERR No interface\n",address,(uint8_t)data);
317 //              retval = -ENODEV;
318 //              goto exit;
319 //      }
320
321         /* do a blocking bulk write to send data to the device */
322 /*      retval = usb_bulk_msg(dev->udev,
323                               usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
324                               buffer,
325                               2,
326                               &bytes_transferred, 10000);
327         CANMSG("Sending %lu:%X : retval %d, transferred %d bytes\n",address,(uint8_t)data,retval,bytes_transferred);
328
329 exit:
330         mutex_unlock(&dev->io_mutex);*/
331 }
332
333 /** ul_usb1_read_register
334  * ul_usb1_read_register - Low level read register routine
335  * @address: memory address to read from
336  *
337  * The function ul_usb1_read_register() is used to read from hardware registers
338  * on the CAN chip. You should only have to edit this function if your hardware
339  * uses some specific read process.
340  * Return Value: The function returns the value stored in @address
341  * File: src/ul_usb1.c
342  */
343 unsigned ul_usb1_read_register(struct candevice_t *candev,unsigned long address)
344 {
345         struct usb_ul_usb1 *dev;
346         int retval;
347         int bytes_transferred;
348         unsigned char buffer[2];
349         buffer[0]=((unsigned char)address & ~CAN_OP_MASK)+CAN_OP_READ;
350         buffer[1]=0x00;
351
352         dev = (struct usb_ul_usb1 *)candev->sysdevptr.anydev;
353
354 //      mutex_lock(&dev->io_mutex);
355 //      if (!dev) {             /* disconnect() was called */
356 //              retval = -ENODEV;
357 //              goto exit;
358 //      }
359 //      if (!dev->interface) {          /* disconnect() was called */
360 //              retval = -ENODEV;
361 //              goto exit;
362 //      }
363
364         /* do a blocking bulk write to send data to the device */
365 /*      retval = usb_bulk_msg(dev->udev,
366                               usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
367                               buffer,
368                               2,
369                               &bytes_transferred, 10000);
370
371         CANMSG("Requested: %ld : retval %d, transferred %d bytes\n",address,retval,bytes_transferred);
372         if ((retval)||(bytes_transferred!=2)){
373                 retval = -EFAULT;
374                 goto exit;
375         }
376 */
377         /* do a blocking bulk read to get data from the device */
378 //      retval = usb_bulk_msg(dev->udev,
379 //                            usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr),
380 //                            dev->bulk_in_buffer,
381 //                            dev->bulk_in_size,
382 //                            &bytes_transferred, 10000);
383
384         /* if the read was successful, copy the data to userspace */
385 /*      CANMSG("Received %d bytes : %u:%X\n",bytes_transferred,(dev->bulk_in_buffer[0] & 0x7F),dev->bulk_in_buffer[1]);
386         if (!retval) {
387                 if (bytes_transferred!=2)
388                         retval = -EFAULT;
389                 else
390                         retval = dev->bulk_in_buffer[1];
391         }
392
393 exit:
394         mutex_unlock(&dev->io_mutex);
395         return retval;*/
396 }
397
398 /* !!! Don't change this function !!! */
399 int ul_usb1_register(struct hwspecops_t *hwspecops)
400 {
401         hwspecops->request_io = ul_usb1_request_io;
402         hwspecops->release_io = ul_usb1_release_io;
403         hwspecops->reset = ul_usb1_reset;
404         hwspecops->init_hw_data = ul_usb1_init_hw_data;
405         hwspecops->init_chip_data = ul_usb1_init_chip_data;
406         hwspecops->init_obj_data = ul_usb1_init_obj_data;
407         hwspecops->write_register = ul_usb1_write_register;
408         hwspecops->read_register = ul_usb1_read_register;
409         hwspecops->program_irq = ul_usb1_program_irq;
410         return 0;
411 }
412
413
414
415
416 /* --------------------------------------------------------------------------------------------------- */
417
418
419 // static void ul_usb1_irq(struct urb *urb)
420 // {
421 //      struct usb_ul_usb1 *dev = urb->context;
422 //      struct ul_usb1_combo devc;
423 //      int retval;
424 //
425 //      CANMSG("Interrupt poll\n");
426 //
427 //      switch (urb->status) {
428 //      case 0:
429 //              /* success */
430 //              break;
431 //      case -ECONNRESET:
432 //      case -ENOENT:
433 //      case -ESHUTDOWN:
434 //              /* this urb is terminated, clean up */
435 //              CANMSG("%s - urb shutting down with status: %d\n", __FUNCTION__, urb->status);
436 //              return;
437 //      default:
438 //              CANMSG("%s - nonzero urb status received: %d\n", __FUNCTION__, urb->status);
439 //              goto exit;
440 //      }
441 //
442 //      devc.dev = dev;
443 //      devc.urb = urb;
444 //
445 //      dev->candev->chip[0]->chipspecops->irq_handler(0,dev->candev->chip[0]);
446 //      CANMSG("Interrupt caught\n");
447 //
448 //  exit:
449 //      retval = usb_submit_urb (urb, GFP_ATOMIC);
450 //      if (retval)
451 //              CANMSG("%s - usb_submit_urb failed with result %d\n",
452 //                   __FUNCTION__, retval);
453 // }
454
455 // static void ul_usb1_delete(struct usb_ul_usb1 *dev)
456 // {
457 //      usb_put_dev(dev->udev);
458 //      usb_kill_urb(dev->irq);
459 //      usb_free_urb(dev->irq);
460 //      kfree(dev->bulk_in_buffer);
461 //      kfree(dev->int_in_buffer);
462 //      if (dev->candev){
463 //              dev->candev->sysdevptr.anydev=NULL;
464 //              cleanup_usbdev(dev->candev);
465 //      }
466 //      kfree(dev);
467 // }
468
469 // static int ul_usb1_probe(struct usb_interface *interface, const struct usb_device_id *id)
470 // {
471 //      struct usb_ul_usb1 *dev;
472 //      struct usb_host_interface *iface_desc;
473 //      struct usb_endpoint_descriptor *endpoint;
474 //      struct candevice_t *candev;
475 //      size_t buffer_size;
476 //      int i;
477 //      int retval = -ENOMEM;
478 //
479 //      /* allocate memory for our device state and initialize it */
480 //      dev = kzalloc(sizeof(*dev), GFP_KERNEL);
481 //      if (!dev) {
482 //              err("Out of memory");
483 //              goto error;
484 //      }
485 //      sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);
486 //      mutex_init(&dev->io_mutex);
487 //      spin_lock_init(&dev->err_lock);
488 //      init_usb_anchor(&dev->submitted);
489 //
490 // //   dev->udev = usb_get_dev(interface_to_usbdev(interface));
491 //      dev->udev = interface_to_usbdev(interface);
492 //      dev->interface = interface;
493 //
494 //      /* set up the endpoint information */
495 //      /* use only the first bulk-in and bulk-out endpoints */
496 //      iface_desc = interface->cur_altsetting;
497 //      for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
498 //              endpoint = &iface_desc->endpoint[i].desc;
499 //
500 //              if (!dev->bulk_in_endpointAddr &&
501 //                  usb_endpoint_is_bulk_in(endpoint)) {
502 //                      /* we found a bulk in endpoint */
503 //                      buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
504 //                      dev->bulk_in_size = buffer_size;
505 //                      dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
506 //                      dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
507 //                      if (!dev->bulk_in_buffer) {
508 //                              err("Could not allocate bulk_in_buffer");
509 //                              goto error;
510 //                      }
511 //              }
512 //
513 //              if (!dev->bulk_out_endpointAddr &&
514 //                  usb_endpoint_is_bulk_out(endpoint)) {
515 //                      /* we found a bulk out endpoint */
516 //                              dev->bulk_out_endpointAddr = endpoint->bEndpointAddress;
517 //              }
518 //
519 //              if (!dev->int_in_endpointAddr &&
520 //                  usb_endpoint_is_int_in(endpoint)) {
521 //                      /* we found an interrupt in endpoint */
522 //                      buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
523 //                      dev->int_in_size = buffer_size;
524 //                      dev->int_in_endpointAddr = endpoint->bEndpointAddress;
525 //                      dev->int_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
526 //                      dev->int_in_interval = endpoint->bInterval;
527 //                      if (!dev->int_in_buffer) {
528 //                              err("Could not allocate int_in_buffer");
529 //                              goto error;
530 //                      }
531 //              }
532 //      }
533 //      if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr && dev->int_in_endpointAddr)) {
534 //              err("Could not find all bulk-in, bulk-out and interrupt endpoints");
535 //              goto error;
536 //      }
537 //
538 //      /* save our data pointer in this interface device */
539 //      usb_set_intfdata(interface, dev);
540 //
541 //      if (main_init_done==1)
542 //              register_usbdev("ul_usb1",(void *) dev);
543 //      else {
544 //              mutex_lock(&usbdev_reg_mutex);
545 //              if (main_init_done==1)
546 //                      register_usbdev("ul_usb1",(void *) dev);
547 //              else {
548 //                      for (i=0;i<MAX_HW_CARDS;i++){
549 //                              if (usbregq[i]==NULL){
550 //                                      usbregq[i]=(struct usbdev_reg_query *)can_checked_malloc(sizeof(struct usbdev_reg_query));
551 //                                      if (!usbregq[i]){
552 //                                              CANMSG("Error allocating usbdev_reg_query");
553 //                                              mutex_unlock(&usbdev_reg_mutex);
554 //                                              goto error;
555 //                                      }
556 //                                      sprintf (usbregq[i]->hwname,"ul_usb1");
557 //                                      usbregq[i]->anydev=(void *) dev;
558 //                                      break;
559 //                              }
560 //                      }
561 //                      if (i==MAX_HW_CARDS){
562 //                              CANMSG("No free space to register new card");
563 //                              mutex_unlock(&usbdev_reg_mutex);
564 //                              goto error;
565 //                      }
566 //              }
567 //              mutex_unlock(&usbdev_reg_mutex);
568 //      }
569 //
570 //      dev->irq = usb_alloc_urb(0, GFP_KERNEL);
571 //      if (!dev->irq){
572 //              CANMSG("Error allocating usb urb\n");
573 //              goto error;
574 //      }
575 //      dev->irq->dev = dev->udev;
576 //      usb_fill_int_urb(dev->irq, dev->udev,
577 //                       usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
578 //                       dev->int_in_buffer, dev->int_in_size,
579 //                       ul_usb1_irq, dev, dev->int_in_interval);
580 // /*   usb_fill_bulk_urb(dev->irq, dev->udev,
581 //                       usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr),
582 //                       dev->int_in_buffer, dev->int_in_size,
583 //                       ul_usb1_irq, dev);*/
584 //
585 // /*   dev->irq->transfer_dma = wacom->data_dma;
586 //      dev->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;*/
587 //      retval=usb_submit_urb(dev->irq, GFP_KERNEL);
588 //      if (retval){
589 //              CANMSG("INT URB %d\n",retval);
590 //              return -EIO;
591 //      }else
592 //              CANMSG("INT URB SUCCCESS\n");
593 //
594 //      /* let the user know what node this device is now attached to */
595 //      info("USB Skeleton device now attached");
596 //      return 0;
597 //
598 // error:
599 //              ul_usb1_delete(dev);
600 //      return retval;
601 // }
602
603 // static void ul_usb1_disconnect(struct usb_interface *interface)
604 // {
605 //      struct usb_ul_usb1 *dev;
606 //      int minor = interface->minor;
607 //
608 //      dev = usb_get_intfdata(interface);
609 //      usb_set_intfdata(interface, NULL);
610 //
611 //      /* prevent more I/O from starting */
612 //      mutex_lock(&dev->io_mutex);
613 //      dev->interface = NULL;
614 //      mutex_unlock(&dev->io_mutex);
615 //
616 //      //usb_kill_anchored_urbs(&dev->submitted);
617 //
618 //      ul_usb1_delete(dev);
619 //
620 //      info("USB Skeleton now disconnected");
621 // }
622
623 // static struct usb_driver ul_usb1_driver = {
624 //      .name =         "ul_usb1-can",
625 //      .id_table = ul_usb1_table,
626 //      .probe =        ul_usb1_probe,
627 //      .disconnect =   ul_usb1_disconnect,
628 //      .id_table =     ul_usb1_table,
629 // };
630
631 // int ul_usb1_init(void){
632 //      return usb_register(&ul_usb1_driver);
633 // }
634 //
635 // void ul_usb1_exit(void){
636 //      usb_deregister(&ul_usb1_driver);
637 // }