block.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*
  2. * Block driver for media (i.e., flash cards)
  3. *
  4. * Copyright 2002 Hewlett-Packard Company
  5. * Copyright 2005-2007 Pierre Ossman
  6. *
  7. * Use consistent with the GNU GPL is permitted,
  8. * provided that this copyright notice is
  9. * preserved in its entirety in all copies and derived works.
  10. *
  11. * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
  12. * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
  13. * FITNESS FOR ANY PARTICULAR PURPOSE.
  14. *
  15. * Many thanks to Alessandro Rubini and Jonathan Corbet!
  16. *
  17. * Author: Andrew Christian
  18. * 28 May 2002
  19. */
  20. #include <linux/moduleparam.h>
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <linux/kernel.h>
  24. #include <linux/fs.h>
  25. #include <linux/errno.h>
  26. #include <linux/hdreg.h>
  27. #include <linux/kdev_t.h>
  28. #include <linux/blkdev.h>
  29. #include <linux/mutex.h>
  30. #include <linux/scatterlist.h>
  31. #include <linux/mmc/card.h>
  32. #include <linux/mmc/host.h>
  33. #include <linux/mmc/mmc.h>
  34. #include <linux/mmc/sd.h>
  35. #include <asm/system.h>
  36. #include <asm/uaccess.h>
  37. #include "queue.h"
  38. #include <cybook.h>
  39. /*
  40. * max 8 partitions per card
  41. */
  42. #define MMC_SHIFT 3
  43. #define MMC_NUM_MINORS (256 >> MMC_SHIFT)
  44. static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))];
  45. /* [MTR] Hackish, but needed:
  46. * We need a way to not expose the last X MB of the MoviNand to protect the
  47. * bootloader from unexpected erase. So we pass a parameter from the BL
  48. * that will say that we allow us to access the BL partition
  49. *
  50. * TODO: This should be put somewhere else...
  51. */
  52. static int __init get_movirestrict_mode(char *str)
  53. {
  54. int ints[2];
  55. str = get_options(str, 2, ints);
  56. if (ints[1] == 0xd34db33f)
  57. {
  58. platform_capability |= PLAT_CAP_UNRESTRICT;
  59. }
  60. printk(KERN_ERR "movirest = 0x%08X", ints[1]);
  61. return 1;
  62. }
  63. __setup("movirest=", get_movirestrict_mode);
  64. /*
  65. * There is one mmc_blk_data per slot.
  66. */
  67. struct mmc_blk_data {
  68. spinlock_t lock;
  69. struct gendisk *disk;
  70. struct mmc_queue queue;
  71. unsigned int usage;
  72. unsigned int block_bits;
  73. unsigned int read_only;
  74. };
  75. static DEFINE_MUTEX(open_lock);
  76. static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
  77. {
  78. struct mmc_blk_data *md;
  79. mutex_lock(&open_lock);
  80. md = disk->private_data;
  81. if (md && md->usage == 0)
  82. md = NULL;
  83. if (md)
  84. md->usage++;
  85. mutex_unlock(&open_lock);
  86. return md;
  87. }
  88. static void mmc_blk_put(struct mmc_blk_data *md)
  89. {
  90. mutex_lock(&open_lock);
  91. md->usage--;
  92. if (md->usage == 0) {
  93. int devidx = md->disk->first_minor >> MMC_SHIFT;
  94. __clear_bit(devidx, dev_use);
  95. put_disk(md->disk);
  96. kfree(md);
  97. }
  98. mutex_unlock(&open_lock);
  99. }
  100. static int mmc_blk_open(struct inode *inode, struct file *filp)
  101. {
  102. struct mmc_blk_data *md;
  103. int ret = -ENXIO;
  104. md = mmc_blk_get(inode->i_bdev->bd_disk);
  105. if (md) {
  106. if (md->usage == 2)
  107. check_disk_change(inode->i_bdev);
  108. ret = 0;
  109. if ((filp->f_mode & FMODE_WRITE) && md->read_only)
  110. ret = -EROFS;
  111. }
  112. return ret;
  113. }
  114. static int mmc_blk_release(struct inode *inode, struct file *filp)
  115. {
  116. struct mmc_blk_data *md = inode->i_bdev->bd_disk->private_data;
  117. mmc_blk_put(md);
  118. return 0;
  119. }
  120. static int
  121. mmc_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  122. {
  123. geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16);
  124. geo->heads = 4;
  125. geo->sectors = 16;
  126. return 0;
  127. }
  128. static struct block_device_operations mmc_bdops = {
  129. .open = mmc_blk_open,
  130. .release = mmc_blk_release,
  131. .getgeo = mmc_blk_getgeo,
  132. .owner = THIS_MODULE,
  133. };
  134. struct mmc_blk_request {
  135. struct mmc_request mrq;
  136. struct mmc_command cmd;
  137. struct mmc_command stop;
  138. struct mmc_data data;
  139. };
  140. static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
  141. {
  142. int err;
  143. u32 blocks;
  144. struct mmc_request mrq;
  145. struct mmc_command cmd;
  146. struct mmc_data data;
  147. unsigned int timeout_us;
  148. struct scatterlist sg;
  149. memset(&cmd, 0, sizeof(struct mmc_command));
  150. cmd.opcode = MMC_APP_CMD;
  151. cmd.arg = card->rca << 16;
  152. cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
  153. err = mmc_wait_for_cmd(card->host, &cmd, 0);
  154. if (err)
  155. return (u32)-1;
  156. if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD))
  157. return (u32)-1;
  158. memset(&cmd, 0, sizeof(struct mmc_command));
  159. cmd.opcode = SD_APP_SEND_NUM_WR_BLKS;
  160. cmd.arg = 0;
  161. cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
  162. memset(&data, 0, sizeof(struct mmc_data));
  163. data.timeout_ns = card->csd.tacc_ns * 100;
  164. data.timeout_clks = card->csd.tacc_clks * 100;
  165. timeout_us = data.timeout_ns / 1000;
  166. timeout_us += data.timeout_clks * 1000 /
  167. (card->host->ios.clock / 1000);
  168. if (timeout_us > 100000) {
  169. data.timeout_ns = 100000000;
  170. data.timeout_clks = 0;
  171. }
  172. data.blksz = 4;
  173. data.blocks = 1;
  174. data.flags = MMC_DATA_READ;
  175. data.sg = &sg;
  176. data.sg_len = 1;
  177. memset(&mrq, 0, sizeof(struct mmc_request));
  178. mrq.cmd = &cmd;
  179. mrq.data = &data;
  180. sg_init_one(&sg, &blocks, 4);
  181. mmc_wait_for_req(card->host, &mrq);
  182. if (cmd.error || data.error)
  183. return (u32)-1;
  184. blocks = ntohl(blocks);
  185. return blocks;
  186. }
  187. static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
  188. {
  189. struct mmc_blk_data *md = mq->data;
  190. struct mmc_card *card = md->queue.card;
  191. struct mmc_blk_request brq;
  192. int ret = 1, sg_pos, data_size;
  193. mmc_claim_host(card->host);
  194. do {
  195. struct mmc_command cmd;
  196. u32 readcmd, writecmd;
  197. memset(&brq, 0, sizeof(struct mmc_blk_request));
  198. brq.mrq.cmd = &brq.cmd;
  199. brq.mrq.data = &brq.data;
  200. brq.cmd.arg = req->sector;
  201. if (!mmc_card_blockaddr(card))
  202. brq.cmd.arg <<= 9;
  203. brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
  204. brq.data.blksz = 1 << md->block_bits;
  205. brq.stop.opcode = MMC_STOP_TRANSMISSION;
  206. brq.stop.arg = 0;
  207. brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
  208. brq.data.blocks = req->nr_sectors >> (md->block_bits - 9);
  209. if (brq.data.blocks > card->host->max_blk_count)
  210. brq.data.blocks = card->host->max_blk_count;
  211. /*
  212. * If the host doesn't support multiple block writes, force
  213. * block writes to single block. SD cards are excepted from
  214. * this rule as they support querying the number of
  215. * successfully written sectors.
  216. */
  217. if (rq_data_dir(req) != READ &&
  218. !(card->host->caps & MMC_CAP_MULTIWRITE) &&
  219. !mmc_card_sd(card))
  220. brq.data.blocks = 1;
  221. if (brq.data.blocks > 1) {
  222. /* Qisda, Daniel Lee, 2009/07/21, e600 { */
  223. // For S3C2416
  224. brq.data.flags |= MMC_DATA_MULTI;
  225. /* Qisda, Daniel Lee, 2009/07/21, e600 } */
  226. /* SPI multiblock writes terminate using a special
  227. * token, not a STOP_TRANSMISSION request.
  228. */
  229. if (!mmc_host_is_spi(card->host)
  230. || rq_data_dir(req) == READ)
  231. brq.mrq.stop = &brq.stop;
  232. readcmd = MMC_READ_MULTIPLE_BLOCK;
  233. writecmd = MMC_WRITE_MULTIPLE_BLOCK;
  234. } else {
  235. brq.mrq.stop = NULL;
  236. readcmd = MMC_READ_SINGLE_BLOCK;
  237. writecmd = MMC_WRITE_BLOCK;
  238. }
  239. if (rq_data_dir(req) == READ) {
  240. brq.cmd.opcode = readcmd;
  241. brq.data.flags |= MMC_DATA_READ;
  242. } else {
  243. brq.cmd.opcode = writecmd;
  244. brq.data.flags |= MMC_DATA_WRITE;
  245. }
  246. mmc_set_data_timeout(&brq.data, card);
  247. brq.data.sg = mq->sg;
  248. brq.data.sg_len = mmc_queue_map_sg(mq);
  249. mmc_queue_bounce_pre(mq);
  250. if (brq.data.blocks !=
  251. (req->nr_sectors >> (md->block_bits - 9))) {
  252. data_size = brq.data.blocks * brq.data.blksz;
  253. for (sg_pos = 0; sg_pos < brq.data.sg_len; sg_pos++) {
  254. data_size -= mq->sg[sg_pos].length;
  255. if (data_size <= 0) {
  256. mq->sg[sg_pos].length += data_size;
  257. sg_pos++;
  258. break;
  259. }
  260. }
  261. brq.data.sg_len = sg_pos;
  262. }
  263. mmc_wait_for_req(card->host, &brq.mrq);
  264. mmc_queue_bounce_post(mq);
  265. if (brq.cmd.error) {
  266. printk(KERN_ERR "%s: error %d sending read/write command\n",
  267. req->rq_disk->disk_name, brq.cmd.error);
  268. goto cmd_err;
  269. }
  270. if (brq.data.error) {
  271. printk(KERN_ERR "%s: error %d transferring data\n",
  272. req->rq_disk->disk_name, brq.data.error);
  273. goto cmd_err;
  274. }
  275. if (brq.stop.error) {
  276. printk(KERN_ERR "%s: error %d sending stop command\n",
  277. req->rq_disk->disk_name, brq.stop.error);
  278. goto cmd_err;
  279. }
  280. if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
  281. do {
  282. int err;
  283. cmd.opcode = MMC_SEND_STATUS;
  284. cmd.arg = card->rca << 16;
  285. cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
  286. err = mmc_wait_for_cmd(card->host, &cmd, 5);
  287. if (err) {
  288. printk(KERN_ERR "%s: error %d requesting status\n",
  289. req->rq_disk->disk_name, err);
  290. goto cmd_err;
  291. }
  292. /*
  293. * Some cards mishandle the status bits,
  294. * so make sure to check both the busy
  295. * indication and the card state.
  296. */
  297. } while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
  298. (R1_CURRENT_STATE(cmd.resp[0]) == 7));
  299. #if 0
  300. if (cmd.resp[0] & ~0x00000900)
  301. printk(KERN_ERR "%s: status = %08x\n",
  302. req->rq_disk->disk_name, cmd.resp[0]);
  303. if (mmc_decode_status(cmd.resp))
  304. goto cmd_err;
  305. #endif
  306. }
  307. /*
  308. * A block was successfully transferred.
  309. */
  310. spin_lock_irq(&md->lock);
  311. ret = end_that_request_chunk(req, 1, brq.data.bytes_xfered);
  312. if (!ret) {
  313. /*
  314. * The whole request completed successfully.
  315. */
  316. add_disk_randomness(req->rq_disk);
  317. blkdev_dequeue_request(req);
  318. end_that_request_last(req, 1);
  319. }
  320. spin_unlock_irq(&md->lock);
  321. } while (ret);
  322. mmc_release_host(card->host);
  323. return 1;
  324. cmd_err:
  325. /*
  326. * If this is an SD card and we're writing, we can first
  327. * mark the known good sectors as ok.
  328. *
  329. * If the card is not SD, we can still ok written sectors
  330. * if the controller can do proper error reporting.
  331. *
  332. * For reads we just fail the entire chunk as that should
  333. * be safe in all cases.
  334. */
  335. if (rq_data_dir(req) != READ && mmc_card_sd(card)) {
  336. u32 blocks;
  337. unsigned int bytes;
  338. blocks = mmc_sd_num_wr_blocks(card);
  339. if (blocks != (u32)-1) {
  340. if (card->csd.write_partial)
  341. bytes = blocks << md->block_bits;
  342. else
  343. bytes = blocks << 9;
  344. spin_lock_irq(&md->lock);
  345. ret = end_that_request_chunk(req, 1, bytes);
  346. spin_unlock_irq(&md->lock);
  347. }
  348. } else if (rq_data_dir(req) != READ &&
  349. (card->host->caps & MMC_CAP_MULTIWRITE)) {
  350. spin_lock_irq(&md->lock);
  351. ret = end_that_request_chunk(req, 1, brq.data.bytes_xfered);
  352. spin_unlock_irq(&md->lock);
  353. }
  354. mmc_release_host(card->host);
  355. spin_lock_irq(&md->lock);
  356. while (ret) {
  357. ret = end_that_request_chunk(req, 0,
  358. req->current_nr_sectors << 9);
  359. }
  360. add_disk_randomness(req->rq_disk);
  361. blkdev_dequeue_request(req);
  362. end_that_request_last(req, 0);
  363. spin_unlock_irq(&md->lock);
  364. return 0;
  365. }
  366. static inline int mmc_blk_readonly(struct mmc_card *card)
  367. {
  368. return mmc_card_readonly(card) ||
  369. !(card->csd.cmdclass & CCC_BLOCK_WRITE);
  370. }
  371. /* We will remove 10 MB of block, and block are 512 byte long */
  372. #define BLK_COUNT_REMOVE ((10 * 1024 * 1024) / 512)
  373. static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
  374. {
  375. struct mmc_blk_data *md;
  376. int devidx, ret;
  377. /* Qisda, howard hsu, 2010/01/21, fix start slot for SD card { */
  378. //devidx = find_first_zero_bit(dev_use, MMC_NUM_MINORS);
  379. devidx = find_next_zero_bit(dev_use, MMC_NUM_MINORS, card->host->first_devidx);
  380. /* } Qisda, howard hsu, 2010/01/21, fix start slot for SD card */
  381. if (devidx >= MMC_NUM_MINORS)
  382. return ERR_PTR(-ENOSPC);
  383. __set_bit(devidx, dev_use);
  384. md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL);
  385. if (!md) {
  386. ret = -ENOMEM;
  387. goto out;
  388. }
  389. /*
  390. * Set the read-only status based on the supported commands
  391. * and the write protect switch.
  392. */
  393. md->read_only = mmc_blk_readonly(card);
  394. /*
  395. * Both SD and MMC specifications state (although a bit
  396. * unclearly in the MMC case) that a block size of 512
  397. * bytes must always be supported by the card.
  398. */
  399. md->block_bits = 9;
  400. md->disk = alloc_disk(1 << MMC_SHIFT);
  401. if (md->disk == NULL) {
  402. ret = -ENOMEM;
  403. goto err_kfree;
  404. }
  405. spin_lock_init(&md->lock);
  406. md->usage = 1;
  407. ret = mmc_init_queue(&md->queue, card, &md->lock);
  408. if (ret)
  409. goto err_putdisk;
  410. md->queue.issue_fn = mmc_blk_issue_rq;
  411. md->queue.data = md;
  412. md->disk->major = MMC_BLOCK_MAJOR;
  413. md->disk->first_minor = devidx << MMC_SHIFT;
  414. md->disk->fops = &mmc_bdops;
  415. md->disk->private_data = md;
  416. md->disk->queue = md->queue.queue;
  417. md->disk->driverfs_dev = &card->dev;
  418. /*
  419. * As discussed on lkml, GENHD_FL_REMOVABLE should:
  420. *
  421. * - be set for removable media with permanent block devices
  422. * - be unset for removable block devices with permanent media
  423. *
  424. * Since MMC block devices clearly fall under the second
  425. * case, we do not set GENHD_FL_REMOVABLE. Userspace
  426. * should use the block device creation/destruction hotplug
  427. * messages to tell when the card is present.
  428. */
  429. sprintf(md->disk->disk_name, "mmcblk%d", devidx);
  430. blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
  431. if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {
  432. /*
  433. * The EXT_CSD sector count is in number or 512 byte
  434. * sectors.
  435. */
  436. if ((devidx == 0) && (GET_CAPABILITY(PLAT_CAP_UNRESTRICT) != 0))
  437. /* We are on the Movi Device and not booting in "full mode" */
  438. {
  439. set_capacity(md->disk, card->ext_csd.sectors);
  440. }
  441. else /* remove 10MB to the sector counts */
  442. {
  443. set_capacity(md->disk, card->ext_csd.sectors - BLK_COUNT_REMOVE);
  444. }
  445. } else {
  446. /*
  447. * The CSD capacity field is in units of read_blkbits.
  448. * set_capacity takes units of 512 bytes.
  449. */
  450. if ((devidx == 0) && (GET_CAPABILITY(PLAT_CAP_UNRESTRICT) != 0))
  451. /* We are on the Movi Device and not booting in "full mode" */
  452. {
  453. set_capacity(md->disk,
  454. card->csd.capacity << (card->csd.read_blkbits - 9));
  455. }
  456. else /* remove 10MB to the sector counts */
  457. {
  458. set_capacity(md->disk,
  459. (card->csd.capacity << (card->csd.read_blkbits - 9)) - BLK_COUNT_REMOVE);
  460. }
  461. }
  462. return md;
  463. err_putdisk:
  464. put_disk(md->disk);
  465. err_kfree:
  466. kfree(md);
  467. out:
  468. return ERR_PTR(ret);
  469. }
  470. static int
  471. mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
  472. {
  473. struct mmc_command cmd;
  474. int err;
  475. /* Block-addressed cards ignore MMC_SET_BLOCKLEN. */
  476. if (mmc_card_blockaddr(card))
  477. return 0;
  478. mmc_claim_host(card->host);
  479. cmd.opcode = MMC_SET_BLOCKLEN;
  480. cmd.arg = 1 << md->block_bits;
  481. cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
  482. err = mmc_wait_for_cmd(card->host, &cmd, 5);
  483. mmc_release_host(card->host);
  484. if (err) {
  485. printk(KERN_ERR "%s: unable to set block size to %d: %d\n",
  486. md->disk->disk_name, cmd.arg, err);
  487. return -EINVAL;
  488. }
  489. return 0;
  490. }
  491. static int mmc_blk_probe(struct mmc_card *card)
  492. {
  493. struct mmc_blk_data *md;
  494. int err;
  495. /*
  496. * Check that the card supports the command class(es) we need.
  497. */
  498. if (!(card->csd.cmdclass & CCC_BLOCK_READ))
  499. return -ENODEV;
  500. md = mmc_blk_alloc(card);
  501. if (IS_ERR(md))
  502. return PTR_ERR(md);
  503. err = mmc_blk_set_blksize(md, card);
  504. if (err)
  505. goto out;
  506. printk(KERN_INFO "%s: %s %s %lluKB %s\n",
  507. md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
  508. (unsigned long long)(get_capacity(md->disk) >> 1),
  509. md->read_only ? "(ro)" : "");
  510. mmc_set_drvdata(card, md);
  511. add_disk(md->disk);
  512. return 0;
  513. out:
  514. mmc_blk_put(md);
  515. return err;
  516. }
  517. static void mmc_blk_remove(struct mmc_card *card)
  518. {
  519. struct mmc_blk_data *md = mmc_get_drvdata(card);
  520. if (md) {
  521. /* Stop new requests from getting into the queue */
  522. del_gendisk(md->disk);
  523. /* Then flush out any already in there */
  524. mmc_cleanup_queue(&md->queue);
  525. mmc_blk_put(md);
  526. }
  527. mmc_set_drvdata(card, NULL);
  528. }
  529. #ifdef CONFIG_PM
  530. static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state)
  531. {
  532. struct mmc_blk_data *md = mmc_get_drvdata(card);
  533. if (md) {
  534. mmc_queue_suspend(&md->queue);
  535. }
  536. return 0;
  537. }
  538. static int mmc_blk_resume(struct mmc_card *card)
  539. {
  540. struct mmc_blk_data *md = mmc_get_drvdata(card);
  541. if (md) {
  542. mmc_blk_set_blksize(md, card);
  543. mmc_queue_resume(&md->queue);
  544. }
  545. return 0;
  546. }
  547. #else
  548. #define mmc_blk_suspend NULL
  549. #define mmc_blk_resume NULL
  550. #endif
  551. static struct mmc_driver mmc_driver = {
  552. .drv = {
  553. .name = "mmcblk",
  554. },
  555. .probe = mmc_blk_probe,
  556. .remove = mmc_blk_remove,
  557. .suspend = mmc_blk_suspend,
  558. .resume = mmc_blk_resume,
  559. };
  560. static int __init mmc_blk_init(void)
  561. {
  562. int res = -ENOMEM;
  563. res = register_blkdev(MMC_BLOCK_MAJOR, "mmc");
  564. if (res)
  565. goto out;
  566. return mmc_register_driver(&mmc_driver);
  567. out:
  568. return res;
  569. }
  570. static void __exit mmc_blk_exit(void)
  571. {
  572. mmc_unregister_driver(&mmc_driver);
  573. unregister_blkdev(MMC_BLOCK_MAJOR, "mmc");
  574. }
  575. module_init(mmc_blk_init);
  576. module_exit(mmc_blk_exit);
  577. MODULE_LICENSE("GPL");
  578. MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");