flexcop-usb.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /*
  2. * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
  3. * flexcop-usb.c - covers the USB part
  4. * see flexcop.c for copyright information
  5. */
  6. #define FC_LOG_PREFIX "flexcop_usb"
  7. #include "flexcop-usb.h"
  8. #include "flexcop-common.h"
  9. /* Version information */
  10. #define DRIVER_VERSION "0.1"
  11. #define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV USB Driver"
  12. #define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
  13. /* debug */
  14. #ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
  15. #define dprintk(level,args...) \
  16. do { if ((debug & level)) printk(args); } while (0)
  17. #define debug_dump(b, l, method) do {\
  18. int i; \
  19. for (i = 0; i < l; i++) \
  20. method("%02x ", b[i]); \
  21. method("\n"); \
  22. } while (0)
  23. #define DEBSTATUS ""
  24. #else
  25. #define dprintk(level, args...)
  26. #define debug_dump(b, l, method)
  27. #define DEBSTATUS " (debugging is not enabled)"
  28. #endif
  29. static int debug;
  30. module_param(debug, int, 0644);
  31. MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,"
  32. "ctrl=4,i2c=8,v8mem=16 (or-able))." DEBSTATUS);
  33. #undef DEBSTATUS
  34. #define deb_info(args...) dprintk(0x01, args)
  35. #define deb_ts(args...) dprintk(0x02, args)
  36. #define deb_ctrl(args...) dprintk(0x04, args)
  37. #define deb_i2c(args...) dprintk(0x08, args)
  38. #define deb_v8(args...) dprintk(0x10, args)
  39. /* JLP 111700: we will include the 1 bit gap between the upper and lower 3 bits
  40. * in the IBI address, to make the V8 code simpler.
  41. * PCI ADDRESS FORMAT: 0x71C -> 0000 0111 0001 1100 (the six bits used)
  42. * in general: 0000 0HHH 000L LL00
  43. * IBI ADDRESS FORMAT: RHHH BLLL
  44. *
  45. * where R is the read(1)/write(0) bit, B is the busy bit
  46. * and HHH and LLL are the two sets of three bits from the PCI address.
  47. */
  48. #define B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(usPCI) (u8) \
  49. (((usPCI >> 2) & 0x07) + ((usPCI >> 4) & 0x70))
  50. #define B2C2_FLEX_INTERNALADDR_TO_PCIOFFSET(ucAddr) (u16) \
  51. (((ucAddr & 0x07) << 2) + ((ucAddr & 0x70) << 4))
  52. /*
  53. * DKT 020228
  54. * - forget about this VENDOR_BUFFER_SIZE, read and write register
  55. * deal with DWORD or 4 bytes, that should be should from now on
  56. * - from now on, we don't support anything older than firm 1.00
  57. * I eliminated the write register as a 2 trip of writing hi word and lo word
  58. * and force this to write only 4 bytes at a time.
  59. * NOTE: this should work with all the firmware from 1.00 and newer
  60. */
  61. static int flexcop_usb_readwrite_dw(struct flexcop_device *fc, u16 wRegOffsPCI, u32 *val, u8 read)
  62. {
  63. struct flexcop_usb *fc_usb = fc->bus_specific;
  64. u8 request = read ? B2C2_USB_READ_REG : B2C2_USB_WRITE_REG;
  65. u8 request_type = (read ? USB_DIR_IN : USB_DIR_OUT) | USB_TYPE_VENDOR;
  66. u8 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) |
  67. (read ? 0x80 : 0);
  68. int len = usb_control_msg(fc_usb->udev,
  69. read ? B2C2_USB_CTRL_PIPE_IN : B2C2_USB_CTRL_PIPE_OUT,
  70. request,
  71. request_type, /* 0xc0 read or 0x40 write */
  72. wAddress,
  73. 0,
  74. val,
  75. sizeof(u32),
  76. B2C2_WAIT_FOR_OPERATION_RDW * HZ);
  77. if (len != sizeof(u32)) {
  78. err("error while %s dword from %d (%d).", read ? "reading" :
  79. "writing", wAddress, wRegOffsPCI);
  80. return -EIO;
  81. }
  82. return 0;
  83. }
  84. /*
  85. * DKT 010817 - add support for V8 memory read/write and flash update
  86. */
  87. static int flexcop_usb_v8_memory_req(struct flexcop_usb *fc_usb,
  88. flexcop_usb_request_t req, u8 page, u16 wAddress,
  89. u8 *pbBuffer, u32 buflen)
  90. {
  91. u8 request_type = USB_TYPE_VENDOR;
  92. u16 wIndex;
  93. int nWaitTime, pipe, len;
  94. wIndex = page << 8;
  95. switch (req) {
  96. case B2C2_USB_READ_V8_MEM:
  97. nWaitTime = B2C2_WAIT_FOR_OPERATION_V8READ;
  98. request_type |= USB_DIR_IN;
  99. pipe = B2C2_USB_CTRL_PIPE_IN;
  100. break;
  101. case B2C2_USB_WRITE_V8_MEM:
  102. wIndex |= pbBuffer[0];
  103. request_type |= USB_DIR_OUT;
  104. nWaitTime = B2C2_WAIT_FOR_OPERATION_V8WRITE;
  105. pipe = B2C2_USB_CTRL_PIPE_OUT;
  106. break;
  107. case B2C2_USB_FLASH_BLOCK:
  108. request_type |= USB_DIR_OUT;
  109. nWaitTime = B2C2_WAIT_FOR_OPERATION_V8FLASH;
  110. pipe = B2C2_USB_CTRL_PIPE_OUT;
  111. break;
  112. default:
  113. deb_info("unsupported request for v8_mem_req %x.\n", req);
  114. return -EINVAL;
  115. }
  116. deb_v8("v8mem: %02x %02x %04x %04x, len: %d\n", request_type, req,
  117. wAddress, wIndex, buflen);
  118. len = usb_control_msg(fc_usb->udev, pipe,
  119. req,
  120. request_type,
  121. wAddress,
  122. wIndex,
  123. pbBuffer,
  124. buflen,
  125. nWaitTime * HZ);
  126. debug_dump(pbBuffer, len, deb_v8);
  127. return len == buflen ? 0 : -EIO;
  128. }
  129. #define bytes_left_to_read_on_page(paddr,buflen) \
  130. ((V8_MEMORY_PAGE_SIZE - (paddr & V8_MEMORY_PAGE_MASK)) > buflen \
  131. ? buflen : (V8_MEMORY_PAGE_SIZE - (paddr & V8_MEMORY_PAGE_MASK)))
  132. static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb,
  133. flexcop_usb_request_t req, flexcop_usb_mem_page_t page_start,
  134. u32 addr, int extended, u8 *buf, u32 len)
  135. {
  136. int i,ret = 0;
  137. u16 wMax;
  138. u32 pagechunk = 0;
  139. switch(req) {
  140. case B2C2_USB_READ_V8_MEM:
  141. wMax = USB_MEM_READ_MAX;
  142. break;
  143. case B2C2_USB_WRITE_V8_MEM:
  144. wMax = USB_MEM_WRITE_MAX;
  145. break;
  146. case B2C2_USB_FLASH_BLOCK:
  147. wMax = USB_FLASH_MAX;
  148. break;
  149. default:
  150. return -EINVAL;
  151. break;
  152. }
  153. for (i = 0; i < len;) {
  154. pagechunk =
  155. wMax < bytes_left_to_read_on_page(addr, len) ?
  156. wMax :
  157. bytes_left_to_read_on_page(addr, len);
  158. deb_info("%x\n",
  159. (addr & V8_MEMORY_PAGE_MASK) |
  160. (V8_MEMORY_EXTENDED*extended));
  161. ret = flexcop_usb_v8_memory_req(fc_usb, req,
  162. page_start + (addr / V8_MEMORY_PAGE_SIZE),
  163. (addr & V8_MEMORY_PAGE_MASK) |
  164. (V8_MEMORY_EXTENDED*extended),
  165. &buf[i], pagechunk);
  166. if (ret < 0)
  167. return ret;
  168. addr += pagechunk;
  169. len -= pagechunk;
  170. }
  171. return 0;
  172. }
  173. static int flexcop_usb_get_mac_addr(struct flexcop_device *fc, int extended)
  174. {
  175. return flexcop_usb_memory_req(fc->bus_specific, B2C2_USB_READ_V8_MEM,
  176. V8_MEMORY_PAGE_FLASH, 0x1f010, 1,
  177. fc->dvb_adapter.proposed_mac, 6);
  178. }
  179. #if 0
  180. static int flexcop_usb_utility_req(struct flexcop_usb *fc_usb, int set,
  181. flexcop_usb_utility_function_t func, u8 extra, u16 wIndex,
  182. u16 buflen, u8 *pvBuffer)
  183. {
  184. u16 wValue;
  185. u8 request_type = (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR;
  186. int nWaitTime = 2,
  187. pipe = set ? B2C2_USB_CTRL_PIPE_OUT : B2C2_USB_CTRL_PIPE_IN, len;
  188. wValue = (func << 8) | extra;
  189. len = usb_control_msg(fc_usb->udev,pipe,
  190. B2C2_USB_UTILITY,
  191. request_type,
  192. wValue,
  193. wIndex,
  194. pvBuffer,
  195. buflen,
  196. nWaitTime * HZ);
  197. return len == buflen ? 0 : -EIO;
  198. }
  199. #endif
  200. /* usb i2c stuff */
  201. static int flexcop_usb_i2c_req(struct flexcop_i2c_adapter *i2c,
  202. flexcop_usb_request_t req, flexcop_usb_i2c_function_t func,
  203. u8 chipaddr, u8 addr, u8 *buf, u8 buflen)
  204. {
  205. struct flexcop_usb *fc_usb = i2c->fc->bus_specific;
  206. u16 wValue, wIndex;
  207. int nWaitTime,pipe,len;
  208. u8 request_type = USB_TYPE_VENDOR;
  209. switch (func) {
  210. case USB_FUNC_I2C_WRITE:
  211. case USB_FUNC_I2C_MULTIWRITE:
  212. case USB_FUNC_I2C_REPEATWRITE:
  213. /* DKT 020208 - add this to support special case of DiSEqC */
  214. case USB_FUNC_I2C_CHECKWRITE:
  215. pipe = B2C2_USB_CTRL_PIPE_OUT;
  216. nWaitTime = 2;
  217. request_type |= USB_DIR_OUT;
  218. break;
  219. case USB_FUNC_I2C_READ:
  220. case USB_FUNC_I2C_REPEATREAD:
  221. pipe = B2C2_USB_CTRL_PIPE_IN;
  222. nWaitTime = 2;
  223. request_type |= USB_DIR_IN;
  224. break;
  225. default:
  226. deb_info("unsupported function for i2c_req %x\n", func);
  227. return -EINVAL;
  228. }
  229. wValue = (func << 8) | (i2c->port << 4);
  230. wIndex = (chipaddr << 8 ) | addr;
  231. deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",
  232. func, request_type, req,
  233. wValue & 0xff, wValue >> 8,
  234. wIndex & 0xff, wIndex >> 8);
  235. len = usb_control_msg(fc_usb->udev,pipe,
  236. req,
  237. request_type,
  238. wValue,
  239. wIndex,
  240. buf,
  241. buflen,
  242. nWaitTime * HZ);
  243. return len == buflen ? 0 : -EREMOTEIO;
  244. }
  245. /* actual bus specific access functions,
  246. make sure prototype are/will be equal to pci */
  247. static flexcop_ibi_value flexcop_usb_read_ibi_reg(struct flexcop_device *fc,
  248. flexcop_ibi_register reg)
  249. {
  250. flexcop_ibi_value val;
  251. val.raw = 0;
  252. flexcop_usb_readwrite_dw(fc, reg, &val.raw, 1);
  253. return val;
  254. }
  255. static int flexcop_usb_write_ibi_reg(struct flexcop_device *fc,
  256. flexcop_ibi_register reg, flexcop_ibi_value val)
  257. {
  258. return flexcop_usb_readwrite_dw(fc, reg, &val.raw, 0);
  259. }
  260. static int flexcop_usb_i2c_request(struct flexcop_i2c_adapter *i2c,
  261. flexcop_access_op_t op, u8 chipaddr, u8 addr, u8 *buf, u16 len)
  262. {
  263. if (op == FC_READ)
  264. return flexcop_usb_i2c_req(i2c, B2C2_USB_I2C_REQUEST,
  265. USB_FUNC_I2C_READ, chipaddr, addr, buf, len);
  266. else
  267. return flexcop_usb_i2c_req(i2c, B2C2_USB_I2C_REQUEST,
  268. USB_FUNC_I2C_WRITE, chipaddr, addr, buf, len);
  269. }
  270. static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb,
  271. u8 *buffer, int buffer_length)
  272. {
  273. u8 *b;
  274. int l;
  275. deb_ts("tmp_buffer_length=%d, buffer_length=%d\n",
  276. fc_usb->tmp_buffer_length, buffer_length);
  277. if (fc_usb->tmp_buffer_length > 0) {
  278. memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer,
  279. buffer_length);
  280. fc_usb->tmp_buffer_length += buffer_length;
  281. b = fc_usb->tmp_buffer;
  282. l = fc_usb->tmp_buffer_length;
  283. } else {
  284. b=buffer;
  285. l=buffer_length;
  286. }
  287. while (l >= 190) {
  288. if (*b == 0xff) {
  289. switch (*(b+1) & 0x03) {
  290. case 0x01: /* media packet */
  291. if (*(b+2) == 0x47)
  292. flexcop_pass_dmx_packets(
  293. fc_usb->fc_dev, b+2, 1);
  294. else
  295. deb_ts("not ts packet %*ph\n", 4, b+2);
  296. b += 190;
  297. l -= 190;
  298. break;
  299. default:
  300. deb_ts("wrong packet type\n");
  301. l = 0;
  302. break;
  303. }
  304. } else {
  305. deb_ts("wrong header\n");
  306. l = 0;
  307. }
  308. }
  309. if (l>0)
  310. memcpy(fc_usb->tmp_buffer, b, l);
  311. fc_usb->tmp_buffer_length = l;
  312. }
  313. static void flexcop_usb_urb_complete(struct urb *urb)
  314. {
  315. struct flexcop_usb *fc_usb = urb->context;
  316. int i;
  317. if (urb->actual_length > 0)
  318. deb_ts("urb completed, bufsize: %d actlen; %d\n",
  319. urb->transfer_buffer_length, urb->actual_length);
  320. for (i = 0; i < urb->number_of_packets; i++) {
  321. if (urb->iso_frame_desc[i].status < 0) {
  322. err("iso frame descriptor %d has an error: %d\n", i,
  323. urb->iso_frame_desc[i].status);
  324. } else
  325. if (urb->iso_frame_desc[i].actual_length > 0) {
  326. deb_ts("passed %d bytes to the demux\n",
  327. urb->iso_frame_desc[i].actual_length);
  328. flexcop_usb_process_frame(fc_usb,
  329. urb->transfer_buffer +
  330. urb->iso_frame_desc[i].offset,
  331. urb->iso_frame_desc[i].actual_length);
  332. }
  333. urb->iso_frame_desc[i].status = 0;
  334. urb->iso_frame_desc[i].actual_length = 0;
  335. }
  336. usb_submit_urb(urb,GFP_ATOMIC);
  337. }
  338. static int flexcop_usb_stream_control(struct flexcop_device *fc, int onoff)
  339. {
  340. /* submit/kill iso packets */
  341. return 0;
  342. }
  343. static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
  344. {
  345. int i;
  346. for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
  347. if (fc_usb->iso_urb[i] != NULL) {
  348. deb_ts("unlinking/killing urb no. %d\n",i);
  349. usb_kill_urb(fc_usb->iso_urb[i]);
  350. usb_free_urb(fc_usb->iso_urb[i]);
  351. }
  352. if (fc_usb->iso_buffer != NULL)
  353. usb_free_coherent(fc_usb->udev,
  354. fc_usb->buffer_size, fc_usb->iso_buffer,
  355. fc_usb->dma_addr);
  356. }
  357. static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
  358. {
  359. u16 frame_size = le16_to_cpu(
  360. fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize);
  361. int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO *
  362. frame_size, i, j, ret;
  363. int buffer_offset = 0;
  364. deb_ts("creating %d iso-urbs with %d frames "
  365. "each of %d bytes size = %d.\n", B2C2_USB_NUM_ISO_URB,
  366. B2C2_USB_FRAMES_PER_ISO, frame_size, bufsize);
  367. fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev,
  368. bufsize, GFP_KERNEL, &fc_usb->dma_addr);
  369. if (fc_usb->iso_buffer == NULL)
  370. return -ENOMEM;
  371. memset(fc_usb->iso_buffer, 0, bufsize);
  372. fc_usb->buffer_size = bufsize;
  373. /* creating iso urbs */
  374. for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
  375. fc_usb->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,
  376. GFP_ATOMIC);
  377. if (fc_usb->iso_urb[i] == NULL) {
  378. ret = -ENOMEM;
  379. goto urb_error;
  380. }
  381. }
  382. /* initialising and submitting iso urbs */
  383. for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
  384. int frame_offset = 0;
  385. struct urb *urb = fc_usb->iso_urb[i];
  386. deb_ts("initializing and submitting urb no. %d "
  387. "(buf_offset: %d).\n", i, buffer_offset);
  388. urb->dev = fc_usb->udev;
  389. urb->context = fc_usb;
  390. urb->complete = flexcop_usb_urb_complete;
  391. urb->pipe = B2C2_USB_DATA_PIPE;
  392. urb->transfer_flags = URB_ISO_ASAP;
  393. urb->interval = 1;
  394. urb->number_of_packets = B2C2_USB_FRAMES_PER_ISO;
  395. urb->transfer_buffer_length = frame_size * B2C2_USB_FRAMES_PER_ISO;
  396. urb->transfer_buffer = fc_usb->iso_buffer + buffer_offset;
  397. buffer_offset += frame_size * B2C2_USB_FRAMES_PER_ISO;
  398. for (j = 0; j < B2C2_USB_FRAMES_PER_ISO; j++) {
  399. deb_ts("urb no: %d, frame: %d, frame_offset: %d\n",
  400. i, j, frame_offset);
  401. urb->iso_frame_desc[j].offset = frame_offset;
  402. urb->iso_frame_desc[j].length = frame_size;
  403. frame_offset += frame_size;
  404. }
  405. if ((ret = usb_submit_urb(fc_usb->iso_urb[i],GFP_ATOMIC))) {
  406. err("submitting urb %d failed with %d.", i, ret);
  407. goto urb_error;
  408. }
  409. deb_ts("submitted urb no. %d.\n",i);
  410. }
  411. /* SRAM */
  412. flexcop_sram_set_dest(fc_usb->fc_dev, FC_SRAM_DEST_MEDIA |
  413. FC_SRAM_DEST_NET | FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI,
  414. FC_SRAM_DEST_TARGET_WAN_USB);
  415. flexcop_wan_set_speed(fc_usb->fc_dev, FC_WAN_SPEED_8MBITS);
  416. flexcop_sram_ctrl(fc_usb->fc_dev, 1, 1, 1);
  417. return 0;
  418. urb_error:
  419. flexcop_usb_transfer_exit(fc_usb);
  420. return ret;
  421. }
  422. static int flexcop_usb_init(struct flexcop_usb *fc_usb)
  423. {
  424. /* use the alternate setting with the larges buffer */
  425. usb_set_interface(fc_usb->udev,0,1);
  426. switch (fc_usb->udev->speed) {
  427. case USB_SPEED_LOW:
  428. err("cannot handle USB speed because it is too slow.");
  429. return -ENODEV;
  430. break;
  431. case USB_SPEED_FULL:
  432. info("running at FULL speed.");
  433. break;
  434. case USB_SPEED_HIGH:
  435. info("running at HIGH speed.");
  436. break;
  437. case USB_SPEED_UNKNOWN: /* fall through */
  438. default:
  439. err("cannot handle USB speed because it is unknown.");
  440. return -ENODEV;
  441. }
  442. usb_set_intfdata(fc_usb->uintf, fc_usb);
  443. return 0;
  444. }
  445. static void flexcop_usb_exit(struct flexcop_usb *fc_usb)
  446. {
  447. usb_set_intfdata(fc_usb->uintf, NULL);
  448. }
  449. static int flexcop_usb_probe(struct usb_interface *intf,
  450. const struct usb_device_id *id)
  451. {
  452. struct usb_device *udev = interface_to_usbdev(intf);
  453. struct flexcop_usb *fc_usb = NULL;
  454. struct flexcop_device *fc = NULL;
  455. int ret;
  456. if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
  457. err("out of memory\n");
  458. return -ENOMEM;
  459. }
  460. /* general flexcop init */
  461. fc_usb = fc->bus_specific;
  462. fc_usb->fc_dev = fc;
  463. fc->read_ibi_reg = flexcop_usb_read_ibi_reg;
  464. fc->write_ibi_reg = flexcop_usb_write_ibi_reg;
  465. fc->i2c_request = flexcop_usb_i2c_request;
  466. fc->get_mac_addr = flexcop_usb_get_mac_addr;
  467. fc->stream_control = flexcop_usb_stream_control;
  468. fc->pid_filtering = 1;
  469. fc->bus_type = FC_USB;
  470. fc->dev = &udev->dev;
  471. fc->owner = THIS_MODULE;
  472. /* bus specific part */
  473. fc_usb->udev = udev;
  474. fc_usb->uintf = intf;
  475. if ((ret = flexcop_usb_init(fc_usb)) != 0)
  476. goto err_kfree;
  477. /* init flexcop */
  478. if ((ret = flexcop_device_initialize(fc)) != 0)
  479. goto err_usb_exit;
  480. /* xfer init */
  481. if ((ret = flexcop_usb_transfer_init(fc_usb)) != 0)
  482. goto err_fc_exit;
  483. info("%s successfully initialized and connected.", DRIVER_NAME);
  484. return 0;
  485. err_fc_exit:
  486. flexcop_device_exit(fc);
  487. err_usb_exit:
  488. flexcop_usb_exit(fc_usb);
  489. err_kfree:
  490. flexcop_device_kfree(fc);
  491. return ret;
  492. }
  493. static void flexcop_usb_disconnect(struct usb_interface *intf)
  494. {
  495. struct flexcop_usb *fc_usb = usb_get_intfdata(intf);
  496. flexcop_usb_transfer_exit(fc_usb);
  497. flexcop_device_exit(fc_usb->fc_dev);
  498. flexcop_usb_exit(fc_usb);
  499. flexcop_device_kfree(fc_usb->fc_dev);
  500. info("%s successfully deinitialized and disconnected.", DRIVER_NAME);
  501. }
  502. static struct usb_device_id flexcop_usb_table [] = {
  503. { USB_DEVICE(0x0af7, 0x0101) },
  504. { }
  505. };
  506. MODULE_DEVICE_TABLE (usb, flexcop_usb_table);
  507. /* usb specific object needed to register this driver with the usb subsystem */
  508. static struct usb_driver flexcop_usb_driver = {
  509. .name = "b2c2_flexcop_usb",
  510. .probe = flexcop_usb_probe,
  511. .disconnect = flexcop_usb_disconnect,
  512. .id_table = flexcop_usb_table,
  513. };
  514. module_usb_driver(flexcop_usb_driver);
  515. MODULE_AUTHOR(DRIVER_AUTHOR);
  516. MODULE_DESCRIPTION(DRIVER_NAME);
  517. MODULE_LICENSE("GPL");