some kmalloc/memset ->kzalloc (tree wide)
[safe/jmp/linux-2.6] / drivers / mmc / card / block.c
index 8eba037..93fe2e5 100644 (file)
@@ -32,8 +32,8 @@
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
-#include <linux/mmc/protocol.h>
-#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/mmc/sd.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -45,8 +45,6 @@
  */
 #define MMC_SHIFT      3
 
-static int major;
-
 /*
  * There is one mmc_blk_data per slot.
  */
@@ -137,23 +135,6 @@ struct mmc_blk_request {
        struct mmc_data         data;
 };
 
-static int mmc_blk_prep_rq(struct mmc_queue *mq, struct request *req)
-{
-       struct mmc_blk_data *md = mq->data;
-       int stat = BLKPREP_OK;
-
-       /*
-        * If we have no device, we haven't finished initialising.
-        */
-       if (!md || !mq->card) {
-               printk(KERN_ERR "%s: killing request - no device/host\n",
-                      req->rq_disk->disk_name);
-               stat = BLKPREP_KILL;
-       }
-
-       return stat;
-}
-
 static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
 {
        int err;
@@ -226,8 +207,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
        struct mmc_blk_request brq;
        int ret = 1, sg_pos, data_size;
 
-       if (mmc_card_claim_host(card))
-               goto flush_queue;
+       mmc_claim_host(card->host);
 
        do {
                struct mmc_command cmd;
@@ -282,7 +262,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                }
 
                brq.data.sg = mq->sg;
-               brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg);
+               brq.data.sg_len = mmc_queue_map_sg(mq);
+
+               mmc_queue_bounce_pre(mq);
 
                if (brq.data.blocks !=
                    (req->nr_sectors >> (md->block_bits - 9))) {
@@ -299,6 +281,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                }
 
                mmc_wait_for_req(card->host, &brq.mrq);
+
+               mmc_queue_bounce_post(mq);
+
                if (brq.cmd.error) {
                        printk(KERN_ERR "%s: error %d sending read/write command\n",
                               req->rq_disk->disk_name, brq.cmd.error);
@@ -357,7 +342,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                spin_unlock_irq(&md->lock);
        } while (ret);
 
-       mmc_card_release_host(card);
+       mmc_release_host(card->host);
 
        return 1;
 
@@ -393,9 +378,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                spin_unlock_irq(&md->lock);
        }
 
-flush_queue:
-
-       mmc_card_release_host(card);
+       mmc_release_host(card->host);
 
        spin_lock_irq(&md->lock);
        while (ret) {
@@ -431,13 +414,12 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
                return ERR_PTR(-ENOSPC);
        __set_bit(devidx, dev_use);
 
-       md = kmalloc(sizeof(struct mmc_blk_data), GFP_KERNEL);
+       md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL);
        if (!md) {
                ret = -ENOMEM;
                goto out;
        }
 
-       memset(md, 0, sizeof(struct mmc_blk_data));
 
        /*
         * Set the read-only status based on the supported commands
@@ -465,11 +447,10 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
        if (ret)
                goto err_putdisk;
 
-       md->queue.prep_fn = mmc_blk_prep_rq;
        md->queue.issue_fn = mmc_blk_issue_rq;
        md->queue.data = md;
 
-       md->disk->major = major;
+       md->disk->major = MMC_BLOCK_MAJOR;
        md->disk->first_minor = devidx << MMC_SHIFT;
        md->disk->fops = &mmc_bdops;
        md->disk->private_data = md;
@@ -526,12 +507,12 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
        if (mmc_card_blockaddr(card))
                return 0;
 
-       mmc_card_claim_host(card);
+       mmc_claim_host(card->host);
        cmd.opcode = MMC_SET_BLOCKLEN;
        cmd.arg = 1 << md->block_bits;
        cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
        err = mmc_wait_for_cmd(card->host, &cmd, 5);
-       mmc_card_release_host(card);
+       mmc_release_host(card->host);
 
        if (err) {
                printk(KERN_ERR "%s: unable to set block size to %d: %d\n",
@@ -637,14 +618,9 @@ static int __init mmc_blk_init(void)
 {
        int res = -ENOMEM;
 
-       res = register_blkdev(major, "mmc");
-       if (res < 0) {
-               printk(KERN_WARNING "Unable to get major %d for MMC media: %d\n",
-                      major, res);
+       res = register_blkdev(MMC_BLOCK_MAJOR, "mmc");
+       if (res)
                goto out;
-       }
-       if (major == 0)
-               major = res;
 
        return mmc_register_driver(&mmc_driver);
 
@@ -655,7 +631,7 @@ static int __init mmc_blk_init(void)
 static void __exit mmc_blk_exit(void)
 {
        mmc_unregister_driver(&mmc_driver);
-       unregister_blkdev(major, "mmc");
+       unregister_blkdev(MMC_BLOCK_MAJOR, "mmc");
 }
 
 module_init(mmc_blk_init);
@@ -664,5 +640,3 @@ module_exit(mmc_blk_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");
 
-module_param(major, int, 0444);
-MODULE_PARM_DESC(major, "specify the major device number for MMC block driver");