realtek_cr.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /* Driver for Realtek RTS51xx USB card reader
  2. *
  3. * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2, or (at your option) any
  8. * later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Author:
  19. * wwang (wei_wang@realsil.com.cn)
  20. * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
  21. */
  22. #include <linux/module.h>
  23. #include <linux/blkdev.h>
  24. #include <linux/kthread.h>
  25. #include <linux/sched.h>
  26. #include <linux/workqueue.h>
  27. #include <linux/kernel.h>
  28. #include <linux/version.h>
  29. #include <scsi/scsi.h>
  30. #include <scsi/scsi_cmnd.h>
  31. #include <scsi/scsi_device.h>
  32. #include <linux/cdrom.h>
  33. #include <linux/usb.h>
  34. #include <linux/slab.h>
  35. #include <linux/usb_usual.h>
  36. #include "usb.h"
  37. #include "transport.h"
  38. #include "protocol.h"
  39. #include "debug.h"
  40. MODULE_DESCRIPTION("Driver for Realtek USB Card Reader");
  41. MODULE_AUTHOR("wwang <wei_wang@realsil.com.cn>");
  42. MODULE_LICENSE("GPL");
  43. MODULE_VERSION("1.03");
  44. static int auto_delink_en = 1;
  45. module_param(auto_delink_en, int, S_IRUGO | S_IWUSR);
  46. MODULE_PARM_DESC(auto_delink_en, "enable auto delink");
  47. struct rts51x_status {
  48. u16 vid;
  49. u16 pid;
  50. u8 cur_lun;
  51. u8 card_type;
  52. u8 total_lun;
  53. u16 fw_ver;
  54. u8 phy_exist;
  55. u8 multi_flag;
  56. u8 multi_card;
  57. u8 log_exist;
  58. union {
  59. u8 detailed_type1;
  60. u8 detailed_type2;
  61. } detailed_type;
  62. u8 function[2];
  63. };
  64. struct rts51x_chip {
  65. u16 vendor_id;
  66. u16 product_id;
  67. char max_lun;
  68. struct rts51x_status *status;
  69. int status_len;
  70. u32 flag;
  71. };
  72. /* flag definition */
  73. #define FLIDX_AUTO_DELINK 0x01
  74. #define SCSI_LUN(srb) ((srb)->device->lun)
  75. /* Bit Operation */
  76. #define SET_BIT(data, idx) ((data) |= 1 << (idx))
  77. #define CLR_BIT(data, idx) ((data) &= ~(1 << (idx)))
  78. #define CHK_BIT(data, idx) ((data) & (1 << (idx)))
  79. #define SET_AUTO_DELINK(chip) ((chip)->flag |= FLIDX_AUTO_DELINK)
  80. #define CLR_AUTO_DELINK(chip) ((chip)->flag &= ~FLIDX_AUTO_DELINK)
  81. #define CHK_AUTO_DELINK(chip) ((chip)->flag & FLIDX_AUTO_DELINK)
  82. #define RTS51X_GET_VID(chip) ((chip)->vendor_id)
  83. #define RTS51X_GET_PID(chip) ((chip)->product_id)
  84. #define FW_VERSION(chip) ((chip)->status[0].fw_ver)
  85. #define STATUS_LEN(chip) ((chip)->status_len)
  86. /* Check card reader function */
  87. #define SUPPORT_DETAILED_TYPE1(chip) \
  88. CHK_BIT((chip)->status[0].function[0], 1)
  89. #define SUPPORT_OT(chip) \
  90. CHK_BIT((chip)->status[0].function[0], 2)
  91. #define SUPPORT_OC(chip) \
  92. CHK_BIT((chip)->status[0].function[0], 3)
  93. #define SUPPORT_AUTO_DELINK(chip) \
  94. CHK_BIT((chip)->status[0].function[0], 4)
  95. #define SUPPORT_SDIO(chip) \
  96. CHK_BIT((chip)->status[0].function[1], 0)
  97. #define SUPPORT_DETAILED_TYPE2(chip) \
  98. CHK_BIT((chip)->status[0].function[1], 1)
  99. #define CHECK_PID(chip, pid) (RTS51X_GET_PID(chip) == (pid))
  100. #define CHECK_FW_VER(chip, fw_ver) (FW_VERSION(chip) == (fw_ver))
  101. #define CHECK_ID(chip, pid, fw_ver) \
  102. (CHECK_PID((chip), (pid)) && CHECK_FW_VER((chip), (fw_ver)))
  103. #define wait_timeout_x(task_state, msecs) \
  104. do { \
  105. set_current_state((task_state)); \
  106. schedule_timeout((msecs) * HZ / 1000); \
  107. } while (0)
  108. #define wait_timeout(msecs) \
  109. wait_timeout_x(TASK_INTERRUPTIBLE, (msecs))
  110. static int init_realtek_cr(struct us_data *us);
  111. /*
  112. * The table of devices
  113. */
  114. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  115. vendorName, productName, useProtocol, useTransport, \
  116. initFunction, flags) \
  117. {\
  118. USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  119. .driver_info = (flags)|(USB_US_TYPE_STOR<<24)\
  120. }
  121. static const struct usb_device_id realtek_cr_ids[] = {
  122. # include "unusual_realtek.h"
  123. { } /* Terminating entry */
  124. };
  125. MODULE_DEVICE_TABLE(usb, realtek_cr_ids);
  126. #undef UNUSUAL_DEV
  127. /*
  128. * The flags table
  129. */
  130. #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
  131. vendor_name, product_name, use_protocol, use_transport, \
  132. init_function, Flags) \
  133. { \
  134. .vendorName = vendor_name, \
  135. .productName = product_name, \
  136. .useProtocol = use_protocol, \
  137. .useTransport = use_transport, \
  138. .initFunction = init_function, \
  139. }
  140. static struct us_unusual_dev realtek_cr_unusual_dev_list[] = {
  141. # include "unusual_realtek.h"
  142. { } /* Terminating entry */
  143. };
  144. #undef UNUSUAL_DEV
  145. static int rts51x_bulk_transport(struct us_data *us, u8 lun,
  146. u8 *cmd, int cmd_len, u8 *buf, int buf_len,
  147. enum dma_data_direction dir, int *act_len)
  148. {
  149. struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
  150. struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
  151. int result;
  152. unsigned int residue;
  153. unsigned int cswlen;
  154. unsigned int cbwlen = US_BULK_CB_WRAP_LEN;
  155. /* set up the command wrapper */
  156. bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
  157. bcb->DataTransferLength = cpu_to_le32(buf_len);
  158. bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0;
  159. bcb->Tag = ++us->tag;
  160. bcb->Lun = lun;
  161. bcb->Length = cmd_len;
  162. /* copy the command payload */
  163. memset(bcb->CDB, 0, sizeof(bcb->CDB));
  164. memcpy(bcb->CDB, cmd, bcb->Length);
  165. /* send it to out endpoint */
  166. result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
  167. bcb, cbwlen, NULL);
  168. if (result != USB_STOR_XFER_GOOD)
  169. return USB_STOR_TRANSPORT_ERROR;
  170. /* DATA STAGE */
  171. /* send/receive data payload, if there is any */
  172. if (buf && buf_len) {
  173. unsigned int pipe = (dir == DMA_FROM_DEVICE) ?
  174. us->recv_bulk_pipe : us->send_bulk_pipe;
  175. result = usb_stor_bulk_transfer_buf(us, pipe,
  176. buf, buf_len, NULL);
  177. if (result == USB_STOR_XFER_ERROR)
  178. return USB_STOR_TRANSPORT_ERROR;
  179. }
  180. /* get CSW for device status */
  181. result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
  182. bcs, US_BULK_CS_WRAP_LEN, &cswlen);
  183. if (result != USB_STOR_XFER_GOOD)
  184. return USB_STOR_TRANSPORT_ERROR;
  185. /* check bulk status */
  186. if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN)) {
  187. US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n",
  188. le32_to_cpu(bcs->Signature),
  189. US_BULK_CS_SIGN);
  190. return USB_STOR_TRANSPORT_ERROR;
  191. }
  192. residue = bcs->Residue;
  193. if (bcs->Tag != us->tag)
  194. return USB_STOR_TRANSPORT_ERROR;
  195. /* try to compute the actual residue, based on how much data
  196. * was really transferred and what the device tells us */
  197. if (residue)
  198. residue = residue < buf_len ? residue : buf_len;
  199. if (act_len)
  200. *act_len = buf_len - residue;
  201. /* based on the status code, we report good or bad */
  202. switch (bcs->Status) {
  203. case US_BULK_STAT_OK:
  204. /* command good -- note that data could be short */
  205. return USB_STOR_TRANSPORT_GOOD;
  206. case US_BULK_STAT_FAIL:
  207. /* command failed */
  208. return USB_STOR_TRANSPORT_FAILED;
  209. case US_BULK_STAT_PHASE:
  210. /* phase error -- note that a transport reset will be
  211. * invoked by the invoke_transport() function
  212. */
  213. return USB_STOR_TRANSPORT_ERROR;
  214. }
  215. /* we should never get here, but if we do, we're in trouble */
  216. return USB_STOR_TRANSPORT_ERROR;
  217. }
  218. /* Determine what the maximum LUN supported is */
  219. static int rts51x_get_max_lun(struct us_data *us)
  220. {
  221. int result;
  222. /* issue the command */
  223. us->iobuf[0] = 0;
  224. result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
  225. US_BULK_GET_MAX_LUN,
  226. USB_DIR_IN | USB_TYPE_CLASS |
  227. USB_RECIP_INTERFACE,
  228. 0, us->ifnum, us->iobuf, 1, 10*HZ);
  229. US_DEBUGP("GetMaxLUN command result is %d, data is %d\n",
  230. result, us->iobuf[0]);
  231. /* if we have a successful request, return the result */
  232. if (result > 0)
  233. return us->iobuf[0];
  234. return 0;
  235. }
  236. static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
  237. {
  238. int retval;
  239. u8 cmnd[12] = {0};
  240. US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);
  241. cmnd[0] = 0xF0;
  242. cmnd[1] = 0x0D;
  243. cmnd[2] = (u8)(addr >> 8);
  244. cmnd[3] = (u8)addr;
  245. cmnd[4] = (u8)(len >> 8);
  246. cmnd[5] = (u8)len;
  247. retval = rts51x_bulk_transport(us, 0, cmnd, 12,
  248. data, len, DMA_FROM_DEVICE, NULL);
  249. if (retval != USB_STOR_TRANSPORT_GOOD)
  250. return -EIO;
  251. return 0;
  252. }
  253. static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
  254. {
  255. int retval;
  256. u8 cmnd[12] = {0};
  257. US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);
  258. cmnd[0] = 0xF0;
  259. cmnd[1] = 0x0E;
  260. cmnd[2] = (u8)(addr >> 8);
  261. cmnd[3] = (u8)addr;
  262. cmnd[4] = (u8)(len >> 8);
  263. cmnd[5] = (u8)len;
  264. retval = rts51x_bulk_transport(us, 0, cmnd, 12,
  265. data, len, DMA_TO_DEVICE, NULL);
  266. if (retval != USB_STOR_TRANSPORT_GOOD)
  267. return -EIO;
  268. return 0;
  269. }
  270. static int rts51x_read_status(struct us_data *us,
  271. u8 lun, u8 *status, int len, int *actlen)
  272. {
  273. int retval;
  274. u8 cmnd[12] = {0};
  275. US_DEBUGP("%s, lun = %d\n", __func__, lun);
  276. cmnd[0] = 0xF0;
  277. cmnd[1] = 0x09;
  278. retval = rts51x_bulk_transport(us, lun, cmnd, 12,
  279. status, len, DMA_FROM_DEVICE, actlen);
  280. if (retval != USB_STOR_TRANSPORT_GOOD)
  281. return -EIO;
  282. return 0;
  283. }
  284. static int rts51x_check_status(struct us_data *us, u8 lun)
  285. {
  286. struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
  287. int retval;
  288. u8 buf[16];
  289. retval = rts51x_read_status(us, lun, buf, 16, &(chip->status_len));
  290. if (retval < 0)
  291. return -EIO;
  292. US_DEBUGP("chip->status_len = %d\n", chip->status_len);
  293. chip->status[lun].vid = ((u16)buf[0] << 8) | buf[1];
  294. chip->status[lun].pid = ((u16)buf[2] << 8) | buf[3];
  295. chip->status[lun].cur_lun = buf[4];
  296. chip->status[lun].card_type = buf[5];
  297. chip->status[lun].total_lun = buf[6];
  298. chip->status[lun].fw_ver = ((u16)buf[7] << 8) | buf[8];
  299. chip->status[lun].phy_exist = buf[9];
  300. chip->status[lun].multi_flag = buf[10];
  301. chip->status[lun].multi_card = buf[11];
  302. chip->status[lun].log_exist = buf[12];
  303. if (chip->status_len == 16) {
  304. chip->status[lun].detailed_type.detailed_type1 = buf[13];
  305. chip->status[lun].function[0] = buf[14];
  306. chip->status[lun].function[1] = buf[15];
  307. }
  308. return 0;
  309. }
  310. static int enable_oscillator(struct us_data *us)
  311. {
  312. int retval;
  313. u8 value;
  314. retval = rts51x_read_mem(us, 0xFE77, &value, 1);
  315. if (retval < 0)
  316. return -EIO;
  317. value |= 0x04;
  318. retval = rts51x_write_mem(us, 0xFE77, &value, 1);
  319. if (retval < 0)
  320. return -EIO;
  321. retval = rts51x_read_mem(us, 0xFE77, &value, 1);
  322. if (retval < 0)
  323. return -EIO;
  324. if (!(value & 0x04))
  325. return -EIO;
  326. return 0;
  327. }
  328. static int do_config_autodelink(struct us_data *us, int enable, int force)
  329. {
  330. int retval;
  331. u8 value;
  332. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  333. if (retval < 0)
  334. return -EIO;
  335. if (enable) {
  336. if (force)
  337. value |= 0x03;
  338. else
  339. value |= 0x01;
  340. } else {
  341. value &= ~0x03;
  342. }
  343. US_DEBUGP("In %s,set 0xfe47 to 0x%x\n", __func__, value);
  344. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  345. if (retval < 0)
  346. return -EIO;
  347. return 0;
  348. }
  349. static int config_autodelink_after_power_on(struct us_data *us)
  350. {
  351. struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
  352. int retval;
  353. u8 value;
  354. if (!CHK_AUTO_DELINK(chip))
  355. return 0;
  356. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  357. if (retval < 0)
  358. return -EIO;
  359. if (auto_delink_en) {
  360. CLR_BIT(value, 0);
  361. CLR_BIT(value, 1);
  362. SET_BIT(value, 2);
  363. if (CHECK_ID(chip, 0x0138, 0x3882))
  364. CLR_BIT(value, 2);
  365. SET_BIT(value, 7);
  366. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  367. if (retval < 0)
  368. return -EIO;
  369. retval = enable_oscillator(us);
  370. if (retval == 0)
  371. (void)do_config_autodelink(us, 1, 0);
  372. } else {
  373. /* Autodelink controlled by firmware */
  374. SET_BIT(value, 2);
  375. if (CHECK_ID(chip, 0x0138, 0x3882))
  376. CLR_BIT(value, 2);
  377. if (CHECK_ID(chip, 0x0159, 0x5889) ||
  378. CHECK_ID(chip, 0x0138, 0x3880)) {
  379. CLR_BIT(value, 0);
  380. CLR_BIT(value, 7);
  381. }
  382. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  383. if (retval < 0)
  384. return -EIO;
  385. if (CHECK_ID(chip, 0x0159, 0x5888)) {
  386. value = 0xFF;
  387. retval = rts51x_write_mem(us, 0xFE79, &value, 1);
  388. if (retval < 0)
  389. return -EIO;
  390. value = 0x01;
  391. retval = rts51x_write_mem(us, 0x48, &value, 1);
  392. if (retval < 0)
  393. return -EIO;
  394. }
  395. }
  396. return 0;
  397. }
  398. static int config_autodelink_before_power_down(struct us_data *us)
  399. {
  400. struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
  401. int retval;
  402. u8 value;
  403. if (!CHK_AUTO_DELINK(chip))
  404. return 0;
  405. if (auto_delink_en) {
  406. retval = rts51x_read_mem(us, 0xFE77, &value, 1);
  407. if (retval < 0)
  408. return -EIO;
  409. SET_BIT(value, 2);
  410. retval = rts51x_write_mem(us, 0xFE77, &value, 1);
  411. if (retval < 0)
  412. return -EIO;
  413. if (CHECK_ID(chip, 0x0159, 0x5888)) {
  414. value = 0x01;
  415. retval = rts51x_write_mem(us, 0x48, &value, 1);
  416. if (retval < 0)
  417. return -EIO;
  418. }
  419. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  420. if (retval < 0)
  421. return -EIO;
  422. SET_BIT(value, 0);
  423. if (CHECK_ID(chip, 0x0138, 0x3882))
  424. SET_BIT(value, 2);
  425. retval = rts51x_write_mem(us, 0xFE77, &value, 1);
  426. if (retval < 0)
  427. return -EIO;
  428. } else {
  429. if (CHECK_ID(chip, 0x0159, 0x5889) ||
  430. CHECK_ID(chip, 0x0138, 0x3880) ||
  431. CHECK_ID(chip, 0x0138, 0x3882)) {
  432. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  433. if (retval < 0)
  434. return -EIO;
  435. if (CHECK_ID(chip, 0x0159, 0x5889) ||
  436. CHECK_ID(chip, 0x0138, 0x3880)) {
  437. SET_BIT(value, 0);
  438. SET_BIT(value, 7);
  439. }
  440. if (CHECK_ID(chip, 0x0138, 0x3882))
  441. SET_BIT(value, 2);
  442. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  443. if (retval < 0)
  444. return -EIO;
  445. }
  446. if (CHECK_ID(chip, 0x0159, 0x5888)) {
  447. value = 0x01;
  448. retval = rts51x_write_mem(us, 0x48, &value, 1);
  449. if (retval < 0)
  450. return -EIO;
  451. }
  452. }
  453. return 0;
  454. }
  455. static void realtek_cr_destructor(void *extra)
  456. {
  457. struct rts51x_chip *chip = (struct rts51x_chip *)extra;
  458. if (!chip)
  459. return;
  460. kfree(chip->status);
  461. }
  462. #ifdef CONFIG_PM
  463. static void realtek_pm_hook(struct us_data *us, int pm_state)
  464. {
  465. if (pm_state == US_SUSPEND)
  466. (void)config_autodelink_before_power_down(us);
  467. }
  468. #endif
  469. static int init_realtek_cr(struct us_data *us)
  470. {
  471. struct rts51x_chip *chip;
  472. int size, i, retval;
  473. chip = kzalloc(sizeof(struct rts51x_chip), GFP_KERNEL);
  474. if (!chip)
  475. return -ENOMEM;
  476. us->extra = chip;
  477. us->extra_destructor = realtek_cr_destructor;
  478. #ifdef CONFIG_PM
  479. us->suspend_resume_hook = realtek_pm_hook;
  480. #endif
  481. us->max_lun = chip->max_lun = rts51x_get_max_lun(us);
  482. US_DEBUGP("chip->max_lun = %d\n", chip->max_lun);
  483. size = (chip->max_lun + 1) * sizeof(struct rts51x_status);
  484. chip->status = kzalloc(size, GFP_KERNEL);
  485. if (!chip->status)
  486. goto INIT_FAIL;
  487. for (i = 0; i <= (int)(chip->max_lun); i++) {
  488. retval = rts51x_check_status(us, (u8)i);
  489. if (retval < 0)
  490. goto INIT_FAIL;
  491. }
  492. if (CHECK_FW_VER(chip, 0x5888) || CHECK_FW_VER(chip, 0x5889) ||
  493. CHECK_FW_VER(chip, 0x5901))
  494. SET_AUTO_DELINK(chip);
  495. if (STATUS_LEN(chip) == 16) {
  496. if (SUPPORT_AUTO_DELINK(chip))
  497. SET_AUTO_DELINK(chip);
  498. }
  499. US_DEBUGP("chip->flag = 0x%x\n", chip->flag);
  500. (void)config_autodelink_after_power_on(us);
  501. return 0;
  502. INIT_FAIL:
  503. if (us->extra) {
  504. kfree(chip->status);
  505. kfree(us->extra);
  506. us->extra = NULL;
  507. }
  508. return -EIO;
  509. }
  510. static int realtek_cr_probe(struct usb_interface *intf,
  511. const struct usb_device_id *id)
  512. {
  513. struct us_data *us;
  514. int result;
  515. US_DEBUGP("Probe Realtek Card Reader!\n");
  516. result = usb_stor_probe1(&us, intf, id,
  517. (id - realtek_cr_ids) + realtek_cr_unusual_dev_list);
  518. if (result)
  519. return result;
  520. result = usb_stor_probe2(us);
  521. return result;
  522. }
  523. static struct usb_driver realtek_cr_driver = {
  524. .name = "ums-realtek",
  525. .probe = realtek_cr_probe,
  526. .disconnect = usb_stor_disconnect,
  527. .suspend = usb_stor_suspend,
  528. .resume = usb_stor_resume,
  529. .reset_resume = usb_stor_reset_resume,
  530. .pre_reset = usb_stor_pre_reset,
  531. .post_reset = usb_stor_post_reset,
  532. .id_table = realtek_cr_ids,
  533. .soft_unbind = 1,
  534. };
  535. static int __init realtek_cr_init(void)
  536. {
  537. return usb_register(&realtek_cr_driver);
  538. }
  539. static void __exit realtek_cr_exit(void)
  540. {
  541. usb_deregister(&realtek_cr_driver);
  542. }
  543. module_init(realtek_cr_init);
  544. module_exit(realtek_cr_exit);