realtek_cr.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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. static int init_realtek_cr(struct us_data *us);
  104. /*
  105. * The table of devices
  106. */
  107. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  108. vendorName, productName, useProtocol, useTransport, \
  109. initFunction, flags) \
  110. {\
  111. USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  112. .driver_info = (flags)|(USB_US_TYPE_STOR<<24)\
  113. }
  114. static const struct usb_device_id realtek_cr_ids[] = {
  115. # include "unusual_realtek.h"
  116. {} /* Terminating entry */
  117. };
  118. MODULE_DEVICE_TABLE(usb, realtek_cr_ids);
  119. #undef UNUSUAL_DEV
  120. /*
  121. * The flags table
  122. */
  123. #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
  124. vendor_name, product_name, use_protocol, use_transport, \
  125. init_function, Flags) \
  126. { \
  127. .vendorName = vendor_name, \
  128. .productName = product_name, \
  129. .useProtocol = use_protocol, \
  130. .useTransport = use_transport, \
  131. .initFunction = init_function, \
  132. }
  133. static struct us_unusual_dev realtek_cr_unusual_dev_list[] = {
  134. # include "unusual_realtek.h"
  135. {} /* Terminating entry */
  136. };
  137. #undef UNUSUAL_DEV
  138. static int rts51x_bulk_transport(struct us_data *us, u8 lun,
  139. u8 *cmd, int cmd_len, u8 *buf, int buf_len,
  140. enum dma_data_direction dir, int *act_len)
  141. {
  142. struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *)us->iobuf;
  143. struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *)us->iobuf;
  144. int result;
  145. unsigned int residue;
  146. unsigned int cswlen;
  147. unsigned int cbwlen = US_BULK_CB_WRAP_LEN;
  148. /* set up the command wrapper */
  149. bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
  150. bcb->DataTransferLength = cpu_to_le32(buf_len);
  151. bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0;
  152. bcb->Tag = ++us->tag;
  153. bcb->Lun = lun;
  154. bcb->Length = cmd_len;
  155. /* copy the command payload */
  156. memset(bcb->CDB, 0, sizeof(bcb->CDB));
  157. memcpy(bcb->CDB, cmd, bcb->Length);
  158. /* send it to out endpoint */
  159. result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
  160. bcb, cbwlen, NULL);
  161. if (result != USB_STOR_XFER_GOOD)
  162. return USB_STOR_TRANSPORT_ERROR;
  163. /* DATA STAGE */
  164. /* send/receive data payload, if there is any */
  165. if (buf && buf_len) {
  166. unsigned int pipe = (dir == DMA_FROM_DEVICE) ?
  167. us->recv_bulk_pipe : us->send_bulk_pipe;
  168. result = usb_stor_bulk_transfer_buf(us, pipe,
  169. buf, buf_len, NULL);
  170. if (result == USB_STOR_XFER_ERROR)
  171. return USB_STOR_TRANSPORT_ERROR;
  172. }
  173. /* get CSW for device status */
  174. result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
  175. bcs, US_BULK_CS_WRAP_LEN, &cswlen);
  176. if (result != USB_STOR_XFER_GOOD)
  177. return USB_STOR_TRANSPORT_ERROR;
  178. /* check bulk status */
  179. if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN)) {
  180. US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n",
  181. le32_to_cpu(bcs->Signature), US_BULK_CS_SIGN);
  182. return USB_STOR_TRANSPORT_ERROR;
  183. }
  184. residue = bcs->Residue;
  185. if (bcs->Tag != us->tag)
  186. return USB_STOR_TRANSPORT_ERROR;
  187. /* try to compute the actual residue, based on how much data
  188. * was really transferred and what the device tells us */
  189. if (residue)
  190. residue = residue < buf_len ? residue : buf_len;
  191. if (act_len)
  192. *act_len = buf_len - residue;
  193. /* based on the status code, we report good or bad */
  194. switch (bcs->Status) {
  195. case US_BULK_STAT_OK:
  196. /* command good -- note that data could be short */
  197. return USB_STOR_TRANSPORT_GOOD;
  198. case US_BULK_STAT_FAIL:
  199. /* command failed */
  200. return USB_STOR_TRANSPORT_FAILED;
  201. case US_BULK_STAT_PHASE:
  202. /* phase error -- note that a transport reset will be
  203. * invoked by the invoke_transport() function
  204. */
  205. return USB_STOR_TRANSPORT_ERROR;
  206. }
  207. /* we should never get here, but if we do, we're in trouble */
  208. return USB_STOR_TRANSPORT_ERROR;
  209. }
  210. /* Determine what the maximum LUN supported is */
  211. static int rts51x_get_max_lun(struct us_data *us)
  212. {
  213. int result;
  214. /* issue the command */
  215. us->iobuf[0] = 0;
  216. result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
  217. US_BULK_GET_MAX_LUN,
  218. USB_DIR_IN | USB_TYPE_CLASS |
  219. USB_RECIP_INTERFACE,
  220. 0, us->ifnum, us->iobuf, 1, 10 * HZ);
  221. US_DEBUGP("GetMaxLUN command result is %d, data is %d\n",
  222. result, us->iobuf[0]);
  223. /* if we have a successful request, return the result */
  224. if (result > 0)
  225. return us->iobuf[0];
  226. return 0;
  227. }
  228. static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
  229. {
  230. int retval;
  231. u8 cmnd[12] = { 0 };
  232. US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);
  233. cmnd[0] = 0xF0;
  234. cmnd[1] = 0x0D;
  235. cmnd[2] = (u8) (addr >> 8);
  236. cmnd[3] = (u8) addr;
  237. cmnd[4] = (u8) (len >> 8);
  238. cmnd[5] = (u8) len;
  239. retval = rts51x_bulk_transport(us, 0, cmnd, 12,
  240. data, len, DMA_FROM_DEVICE, NULL);
  241. if (retval != USB_STOR_TRANSPORT_GOOD)
  242. return -EIO;
  243. return 0;
  244. }
  245. static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
  246. {
  247. int retval;
  248. u8 cmnd[12] = { 0 };
  249. US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);
  250. cmnd[0] = 0xF0;
  251. cmnd[1] = 0x0E;
  252. cmnd[2] = (u8) (addr >> 8);
  253. cmnd[3] = (u8) addr;
  254. cmnd[4] = (u8) (len >> 8);
  255. cmnd[5] = (u8) len;
  256. retval = rts51x_bulk_transport(us, 0, cmnd, 12,
  257. data, len, DMA_TO_DEVICE, NULL);
  258. if (retval != USB_STOR_TRANSPORT_GOOD)
  259. return -EIO;
  260. return 0;
  261. }
  262. static int rts51x_read_status(struct us_data *us,
  263. u8 lun, u8 *status, int len, int *actlen)
  264. {
  265. int retval;
  266. u8 cmnd[12] = { 0 };
  267. US_DEBUGP("%s, lun = %d\n", __func__, lun);
  268. cmnd[0] = 0xF0;
  269. cmnd[1] = 0x09;
  270. retval = rts51x_bulk_transport(us, lun, cmnd, 12,
  271. status, len, DMA_FROM_DEVICE, actlen);
  272. if (retval != USB_STOR_TRANSPORT_GOOD)
  273. return -EIO;
  274. return 0;
  275. }
  276. static int rts51x_check_status(struct us_data *us, u8 lun)
  277. {
  278. struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
  279. int retval;
  280. u8 buf[16];
  281. retval = rts51x_read_status(us, lun, buf, 16, &(chip->status_len));
  282. if (retval < 0)
  283. return -EIO;
  284. US_DEBUGP("chip->status_len = %d\n", chip->status_len);
  285. chip->status[lun].vid = ((u16) buf[0] << 8) | buf[1];
  286. chip->status[lun].pid = ((u16) buf[2] << 8) | buf[3];
  287. chip->status[lun].cur_lun = buf[4];
  288. chip->status[lun].card_type = buf[5];
  289. chip->status[lun].total_lun = buf[6];
  290. chip->status[lun].fw_ver = ((u16) buf[7] << 8) | buf[8];
  291. chip->status[lun].phy_exist = buf[9];
  292. chip->status[lun].multi_flag = buf[10];
  293. chip->status[lun].multi_card = buf[11];
  294. chip->status[lun].log_exist = buf[12];
  295. if (chip->status_len == 16) {
  296. chip->status[lun].detailed_type.detailed_type1 = buf[13];
  297. chip->status[lun].function[0] = buf[14];
  298. chip->status[lun].function[1] = buf[15];
  299. }
  300. return 0;
  301. }
  302. static int enable_oscillator(struct us_data *us)
  303. {
  304. int retval;
  305. u8 value;
  306. retval = rts51x_read_mem(us, 0xFE77, &value, 1);
  307. if (retval < 0)
  308. return -EIO;
  309. value |= 0x04;
  310. retval = rts51x_write_mem(us, 0xFE77, &value, 1);
  311. if (retval < 0)
  312. return -EIO;
  313. retval = rts51x_read_mem(us, 0xFE77, &value, 1);
  314. if (retval < 0)
  315. return -EIO;
  316. if (!(value & 0x04))
  317. return -EIO;
  318. return 0;
  319. }
  320. static int do_config_autodelink(struct us_data *us, int enable, int force)
  321. {
  322. int retval;
  323. u8 value;
  324. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  325. if (retval < 0)
  326. return -EIO;
  327. if (enable) {
  328. if (force)
  329. value |= 0x03;
  330. else
  331. value |= 0x01;
  332. } else {
  333. value &= ~0x03;
  334. }
  335. US_DEBUGP("In %s,set 0xfe47 to 0x%x\n", __func__, value);
  336. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  337. if (retval < 0)
  338. return -EIO;
  339. return 0;
  340. }
  341. static int config_autodelink_after_power_on(struct us_data *us)
  342. {
  343. struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
  344. int retval;
  345. u8 value;
  346. if (!CHK_AUTO_DELINK(chip))
  347. return 0;
  348. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  349. if (retval < 0)
  350. return -EIO;
  351. if (auto_delink_en) {
  352. CLR_BIT(value, 0);
  353. CLR_BIT(value, 1);
  354. SET_BIT(value, 2);
  355. if (CHECK_ID(chip, 0x0138, 0x3882))
  356. CLR_BIT(value, 2);
  357. SET_BIT(value, 7);
  358. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  359. if (retval < 0)
  360. return -EIO;
  361. retval = enable_oscillator(us);
  362. if (retval == 0)
  363. (void)do_config_autodelink(us, 1, 0);
  364. } else {
  365. /* Autodelink controlled by firmware */
  366. SET_BIT(value, 2);
  367. if (CHECK_ID(chip, 0x0138, 0x3882))
  368. CLR_BIT(value, 2);
  369. if (CHECK_ID(chip, 0x0159, 0x5889) ||
  370. CHECK_ID(chip, 0x0138, 0x3880)) {
  371. CLR_BIT(value, 0);
  372. CLR_BIT(value, 7);
  373. }
  374. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  375. if (retval < 0)
  376. return -EIO;
  377. if (CHECK_ID(chip, 0x0159, 0x5888)) {
  378. value = 0xFF;
  379. retval = rts51x_write_mem(us, 0xFE79, &value, 1);
  380. if (retval < 0)
  381. return -EIO;
  382. value = 0x01;
  383. retval = rts51x_write_mem(us, 0x48, &value, 1);
  384. if (retval < 0)
  385. return -EIO;
  386. }
  387. }
  388. return 0;
  389. }
  390. static int config_autodelink_before_power_down(struct us_data *us)
  391. {
  392. struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
  393. int retval;
  394. u8 value;
  395. if (!CHK_AUTO_DELINK(chip))
  396. return 0;
  397. if (auto_delink_en) {
  398. retval = rts51x_read_mem(us, 0xFE77, &value, 1);
  399. if (retval < 0)
  400. return -EIO;
  401. SET_BIT(value, 2);
  402. retval = rts51x_write_mem(us, 0xFE77, &value, 1);
  403. if (retval < 0)
  404. return -EIO;
  405. if (CHECK_ID(chip, 0x0159, 0x5888)) {
  406. value = 0x01;
  407. retval = rts51x_write_mem(us, 0x48, &value, 1);
  408. if (retval < 0)
  409. return -EIO;
  410. }
  411. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  412. if (retval < 0)
  413. return -EIO;
  414. SET_BIT(value, 0);
  415. if (CHECK_ID(chip, 0x0138, 0x3882))
  416. SET_BIT(value, 2);
  417. retval = rts51x_write_mem(us, 0xFE77, &value, 1);
  418. if (retval < 0)
  419. return -EIO;
  420. } else {
  421. if (CHECK_ID(chip, 0x0159, 0x5889) ||
  422. CHECK_ID(chip, 0x0138, 0x3880) ||
  423. CHECK_ID(chip, 0x0138, 0x3882)) {
  424. retval = rts51x_read_mem(us, 0xFE47, &value, 1);
  425. if (retval < 0)
  426. return -EIO;
  427. if (CHECK_ID(chip, 0x0159, 0x5889) ||
  428. CHECK_ID(chip, 0x0138, 0x3880)) {
  429. SET_BIT(value, 0);
  430. SET_BIT(value, 7);
  431. }
  432. if (CHECK_ID(chip, 0x0138, 0x3882))
  433. SET_BIT(value, 2);
  434. retval = rts51x_write_mem(us, 0xFE47, &value, 1);
  435. if (retval < 0)
  436. return -EIO;
  437. }
  438. if (CHECK_ID(chip, 0x0159, 0x5888)) {
  439. value = 0x01;
  440. retval = rts51x_write_mem(us, 0x48, &value, 1);
  441. if (retval < 0)
  442. return -EIO;
  443. }
  444. }
  445. return 0;
  446. }
  447. static void realtek_cr_destructor(void *extra)
  448. {
  449. struct rts51x_chip *chip = (struct rts51x_chip *)extra;
  450. if (!chip)
  451. return;
  452. kfree(chip->status);
  453. }
  454. #ifdef CONFIG_PM
  455. static void realtek_pm_hook(struct us_data *us, int pm_state)
  456. {
  457. if (pm_state == US_SUSPEND)
  458. (void)config_autodelink_before_power_down(us);
  459. }
  460. #endif
  461. static int init_realtek_cr(struct us_data *us)
  462. {
  463. struct rts51x_chip *chip;
  464. int size, i, retval;
  465. chip = kzalloc(sizeof(struct rts51x_chip), GFP_KERNEL);
  466. if (!chip)
  467. return -ENOMEM;
  468. us->extra = chip;
  469. us->extra_destructor = realtek_cr_destructor;
  470. #ifdef CONFIG_PM
  471. us->suspend_resume_hook = realtek_pm_hook;
  472. #endif
  473. us->max_lun = chip->max_lun = rts51x_get_max_lun(us);
  474. US_DEBUGP("chip->max_lun = %d\n", chip->max_lun);
  475. size = (chip->max_lun + 1) * sizeof(struct rts51x_status);
  476. chip->status = kzalloc(size, GFP_KERNEL);
  477. if (!chip->status)
  478. goto INIT_FAIL;
  479. for (i = 0; i <= (int)(chip->max_lun); i++) {
  480. retval = rts51x_check_status(us, (u8) i);
  481. if (retval < 0)
  482. goto INIT_FAIL;
  483. }
  484. if (CHECK_FW_VER(chip, 0x5888) || CHECK_FW_VER(chip, 0x5889) ||
  485. CHECK_FW_VER(chip, 0x5901))
  486. SET_AUTO_DELINK(chip);
  487. if (STATUS_LEN(chip) == 16) {
  488. if (SUPPORT_AUTO_DELINK(chip))
  489. SET_AUTO_DELINK(chip);
  490. }
  491. US_DEBUGP("chip->flag = 0x%x\n", chip->flag);
  492. (void)config_autodelink_after_power_on(us);
  493. return 0;
  494. INIT_FAIL:
  495. if (us->extra) {
  496. kfree(chip->status);
  497. kfree(us->extra);
  498. us->extra = NULL;
  499. }
  500. return -EIO;
  501. }
  502. static int realtek_cr_probe(struct usb_interface *intf,
  503. const struct usb_device_id *id)
  504. {
  505. struct us_data *us;
  506. int result;
  507. US_DEBUGP("Probe Realtek Card Reader!\n");
  508. result = usb_stor_probe1(&us, intf, id,
  509. (id - realtek_cr_ids) +
  510. realtek_cr_unusual_dev_list);
  511. if (result)
  512. return result;
  513. result = usb_stor_probe2(us);
  514. return result;
  515. }
  516. static struct usb_driver realtek_cr_driver = {
  517. .name = "ums-realtek",
  518. .probe = realtek_cr_probe,
  519. .disconnect = usb_stor_disconnect,
  520. .suspend = usb_stor_suspend,
  521. .resume = usb_stor_resume,
  522. .reset_resume = usb_stor_reset_resume,
  523. .pre_reset = usb_stor_pre_reset,
  524. .post_reset = usb_stor_post_reset,
  525. .id_table = realtek_cr_ids,
  526. .soft_unbind = 1,
  527. };
  528. static int __init realtek_cr_init(void)
  529. {
  530. return usb_register(&realtek_cr_driver);
  531. }
  532. static void __exit realtek_cr_exit(void)
  533. {
  534. usb_deregister(&realtek_cr_driver);
  535. }
  536. module_init(realtek_cr_init);
  537. module_exit(realtek_cr_exit);