]> err.no Git - linux-2.6/blobdiff - drivers/mmc/mmc_block.c
Merge branch 'master'
[linux-2.6] / drivers / mmc / mmc_block.c
index b9837cc5b9ac0a871a65350d3b8ed36481a37de5..8eb2a2ede64b5c1272515c7f2d37150a5eb792df 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/kdev_t.h>
 #include <linux/blkdev.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/mutex.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/protocol.h>
@@ -57,33 +58,33 @@ struct mmc_blk_data {
        unsigned int    read_only;
 };
 
-static DECLARE_MUTEX(open_lock);
+static DEFINE_MUTEX(open_lock);
 
 static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
 {
        struct mmc_blk_data *md;
 
-       down(&open_lock);
+       mutex_lock(&open_lock);
        md = disk->private_data;
        if (md && md->usage == 0)
                md = NULL;
        if (md)
                md->usage++;
-       up(&open_lock);
+       mutex_unlock(&open_lock);
 
        return md;
 }
 
 static void mmc_blk_put(struct mmc_blk_data *md)
 {
-       down(&open_lock);
+       mutex_lock(&open_lock);
        md->usage--;
        if (md->usage == 0) {
                put_disk(md->disk);
                mmc_cleanup_queue(&md->queue);
                kfree(md);
        }
-       up(&open_lock);
+       mutex_unlock(&open_lock);
 }
 
 static int mmc_blk_open(struct inode *inode, struct file *filp)
@@ -113,31 +114,18 @@ static int mmc_blk_release(struct inode *inode, struct file *filp)
 }
 
 static int
-mmc_blk_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
+mmc_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 {
-       struct block_device *bdev = inode->i_bdev;
-
-       if (cmd == HDIO_GETGEO) {
-               struct hd_geometry geo;
-
-               memset(&geo, 0, sizeof(struct hd_geometry));
-
-               geo.cylinders   = get_capacity(bdev->bd_disk) / (4 * 16);
-               geo.heads       = 4;
-               geo.sectors     = 16;
-               geo.start       = get_start_sect(bdev);
-
-               return copy_to_user((void __user *)arg, &geo, sizeof(geo))
-                       ? -EFAULT : 0;
-       }
-
-       return -ENOTTY;
+       geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16);
+       geo->heads = 4;
+       geo->sectors = 16;
+       return 0;
 }
 
 static struct block_device_operations mmc_bdops = {
        .open                   = mmc_blk_open,
        .release                = mmc_blk_release,
-       .ioctl                  = mmc_blk_ioctl,
+       .getgeo                 = mmc_blk_getgeo,
        .owner                  = THIS_MODULE,
 };
 
@@ -183,14 +171,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                brq.mrq.data = &brq.data;
 
                brq.cmd.arg = req->sector << 9;
-               brq.cmd.flags = MMC_RSP_R1;
+               brq.cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
                brq.data.timeout_ns = card->csd.tacc_ns * 10;
                brq.data.timeout_clks = card->csd.tacc_clks * 10;
                brq.data.blksz_bits = md->block_bits;
                brq.data.blocks = req->nr_sectors >> (md->block_bits - 9);
                brq.stop.opcode = MMC_STOP_TRANSMISSION;
                brq.stop.arg = 0;
-               brq.stop.flags = MMC_RSP_R1B;
+               brq.stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
 
                if (rq_data_dir(req) == READ) {
                        brq.cmd.opcode = brq.data.blocks > 1 ? MMC_READ_MULTIPLE_BLOCK : MMC_READ_SINGLE_BLOCK;
@@ -200,7 +188,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                        brq.data.flags |= MMC_DATA_WRITE;
                        brq.data.blocks = 1;
                }
-               brq.mrq.stop = brq.data.blocks > 1 ? &brq.stop : NULL;
+
+               if (brq.data.blocks > 1) {
+                       brq.data.flags |= MMC_DATA_MULTI;
+                       brq.mrq.stop = &brq.stop;
+               } else {
+                       brq.mrq.stop = NULL;
+               }
 
                brq.data.sg = mq->sg;
                brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg);
@@ -229,7 +223,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 
                        cmd.opcode = MMC_SEND_STATUS;
                        cmd.arg = card->rca << 16;
-                       cmd.flags = MMC_RSP_R1;
+                       cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
                        err = mmc_wait_for_cmd(card->host, &cmd, 5);
                        if (err) {
                                printk(KERN_ERR "%s: error %d requesting status\n",
@@ -257,7 +251,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                         */
                        add_disk_randomness(req->rq_disk);
                        blkdev_dequeue_request(req);
-                       end_that_request_last(req);
+                       end_that_request_last(req, 1);
                }
                spin_unlock_irq(&md->lock);
        } while (ret);
@@ -283,7 +277,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 
        add_disk_randomness(req->rq_disk);
        blkdev_dequeue_request(req);
-       end_that_request_last(req);
+       end_that_request_last(req, 0);
        spin_unlock_irq(&md->lock);
 
        return 0;
@@ -436,7 +430,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
        mmc_card_claim_host(card);
        cmd.opcode = MMC_SET_BLOCKLEN;
        cmd.arg = 1 << md->block_bits;
-       cmd.flags = MMC_RSP_R1;
+       cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
        err = mmc_wait_for_cmd(card->host, &cmd, 5);
        mmc_card_release_host(card);
 
@@ -468,9 +462,10 @@ static int mmc_blk_probe(struct mmc_card *card)
        if (err)
                goto out;
 
-       printk(KERN_INFO "%s: %s %s %luKiB %s\n",
+       printk(KERN_INFO "%s: %s %s %lluKiB %s\n",
                md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
-               get_capacity(md->disk) >> 1, md->read_only ? "(ro)" : "");
+               (unsigned long long)(get_capacity(md->disk) >> 1),
+               md->read_only ? "(ro)" : "");
 
        mmc_set_drvdata(card, md);
        add_disk(md->disk);