temp revert rk change
[firefly-linux-kernel-4.4.55.git] / drivers / mmc / card / block.c
index d50a23be16543520b2617ba5671f30ffb4cd5cac..e6f74718e06f1e154a45179ebf809d7fdcb1f6d2 100755 (executable)
@@ -52,10 +52,6 @@ MODULE_ALIAS("mmc:block");
 #define INAND_CMD38_ARG_SECTRIM1 0x81
 #define INAND_CMD38_ARG_SECTRIM2 0x88
 
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
-static DEFINE_MUTEX(block_mutex); //added by xbw at 2011-04-21
-#endif
-
 /*
  * max 8 partitions per card
  */
@@ -114,12 +110,8 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 {
        struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
        int ret = -ENXIO;
-       
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
-       mutex_lock(&block_mutex); //added by xbw at 2011-04-21
-#else
-       //lock_kernel(); // The feature of block_mutex is same with lock_kernel£¬but the better. noted by xbw at 2011-08-09 
-#endif 
+
+       lock_kernel();
        if (md) {
                if (md->usage == 2)
                        check_disk_change(bdev);
@@ -130,12 +122,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
                        ret = -EROFS;
                }
        }
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
-       mutex_unlock(&block_mutex);
-#else  
        unlock_kernel();
-#endif
-       
 
        return ret;
 }
@@ -143,20 +130,10 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 static int mmc_blk_release(struct gendisk *disk, fmode_t mode)
 {
        struct mmc_blk_data *md = disk->private_data;
-       
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
-       mutex_lock(&block_mutex); //added by xbw at 2011-04-21
-#else
-       //lock_kernel(); // The feature of block_mutex is same with lock_kernel£¬but the better. noted by xbw at 2011-08-09
-#endif 
-       mmc_blk_put(md);
-       
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)      
-       mutex_unlock(&block_mutex);
-#else
-    unlock_kernel();
-#endif
 
+       lock_kernel();
+       mmc_blk_put(md);
+       unlock_kernel();
        return 0;
 }
 
@@ -256,13 +233,6 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
        return result;
 }
 
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) //Deleted by xbw@2011-03-21
-//static u32 get_card_status(struct mmc_card *card, struct request *req)
-//{
-//   return 0;
-//}
-
-#else
 static u32 get_card_status(struct mmc_card *card, struct request *req)
 {
        struct mmc_command cmd;
@@ -275,11 +245,10 @@ static u32 get_card_status(struct mmc_card *card, struct request *req)
        cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
        err = mmc_wait_for_cmd(card->host, &cmd, 0);
        if (err)
-               printk(KERN_DEBUG "%s: error %d sending status comand",
+               printk(KERN_ERR "%s: error %d sending status comand",
                       req->rq_disk->disk_name, err);
        return cmd.resp[0];
 }
-#endif
 
 static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
 {
@@ -386,22 +355,13 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
        mmc_claim_host(card->host);
 
        do {
-           #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) 
-               //struct mmc_command cmd;//Deleted by xbw@2011-03-21
-               #else
-               struct mmc_command cmd; 
-               #endif
-               
+               struct mmc_command cmd;
                u32 readcmd, writecmd, status = 0;
 
                memset(&brq, 0, sizeof(struct mmc_blk_request));
                brq.mrq.cmd = &brq.cmd;
                brq.mrq.data = &brq.data;
-               
-               #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
-               brq.cmd.retries = 2; //suppot retry read-write; added by xbw@2011-03-21
-        #endif
-        
+
                brq.cmd.arg = blk_rq_pos(req);
                if (!mmc_card_blockaddr(card))
                        brq.cmd.arg <<= 9;
@@ -481,11 +441,6 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
 
                mmc_queue_bounce_post(mq);
 
-        #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) 
-        //not turn CMD18 to CMD17. deleted by xbw at 2011-04-21
-
-        #else
-
                /*
                 * Check for errors here, but don't jump to cmd_err
                 * until later as we need to wait for the card to leave
@@ -494,7 +449,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
                if (brq.cmd.error || brq.data.error || brq.stop.error) {
                        if (brq.data.blocks > 1 && rq_data_dir(req) == READ) {
                                /* Redo read one sector at a time */
-                               printk(KERN_DEBUG "%s: retrying using single "
+                               printk(KERN_WARNING "%s: retrying using single "
                                       "block read\n", req->rq_disk->disk_name);
                                disable_multi = 1;
                                continue;
@@ -502,11 +457,10 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
                        status = get_card_status(card, req);
                } else if (disable_multi == 1) {
                        disable_multi = 0;
-               }   
-        #endif
+               }
 
                if (brq.cmd.error) {
-                       printk(KERN_DEBUG "%s: error %d sending read/write "
+                       printk(KERN_ERR "%s: error %d sending read/write "
                               "command, response %#x, card status %#x\n",
                               req->rq_disk->disk_name, brq.cmd.error,
                               brq.cmd.resp[0], status);
@@ -516,7 +470,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
                        if (brq.data.error == -ETIMEDOUT && brq.mrq.stop)
                                /* 'Stop' response contains card status */
                                status = brq.mrq.stop->resp[0];
-                       printk(KERN_DEBUG "%s: error %d transferring data,"
+                       printk(KERN_ERR "%s: error %d transferring data,"
                               " sector %u, nr %u, card status %#x\n",
                               req->rq_disk->disk_name, brq.data.error,
                               (unsigned)blk_rq_pos(req),
@@ -524,16 +478,12 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
                }
 
                if (brq.stop.error) {
-                       printk(KERN_DEBUG "%s: error %d sending stop command, "
+                       printk(KERN_ERR "%s: error %d sending stop command, "
                               "response %#x, card status %#x\n",
                               req->rq_disk->disk_name, brq.stop.error,
                               brq.stop.resp[0], status);
                }
 
- #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)  
- //Deleted by xbw@2011-03-21
-
- #else
                if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
                        do {
                                int err;
@@ -543,7 +493,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
                                cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
                                err = mmc_wait_for_cmd(card->host, &cmd, 5);
                                if (err) {
-                                       printk(KERN_DEBUG "%s: error %d requesting status\n",
+                                       printk(KERN_ERR "%s: error %d requesting status\n",
                                               req->rq_disk->disk_name, err);
                                        goto cmd_err;
                                }
@@ -563,9 +513,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
                                goto cmd_err;
 #endif
                }
-#endif         
 
-               if (brq.cmd.error || brq.stop.error || brq.data.error) {                
+               if (brq.cmd.error || brq.stop.error || brq.data.error) {
                        if (rq_data_dir(req) == READ) {
                                /*
                                 * After an error, we redo I/O one sector at a
@@ -718,11 +667,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 
        sprintf(md->disk->disk_name, "mmcblk%d", devidx);
 
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)  
-       printk("%s..%d **** devidx=%d, dev_use[0]=%lu, disk_name=%s *** ==xbw[%s]==\n",\
-           __FUNCTION__,__LINE__, devidx, dev_use[0], md->disk->disk_name,mmc_hostname(card->host));
-#endif
-    
        blk_queue_logical_block_size(md->queue.queue, 512);
 
        if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {