]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/mmc/tifm_sd.c
mmc: Correct definition of R6
[linux-2.6.git] / drivers / mmc / tifm_sd.c
index 6d23dc08d169efff2cbf0fb759e025d548878c34..fa4a52886b97c9a358eab60cca56c05b5cd219fa 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/mmc/protocol.h>
 #include <linux/mmc/host.h>
 #include <linux/highmem.h>
+#include <asm/io.h>
 
 #define DRIVER_NAME "tifm_sd"
 #define DRIVER_VERSION "0.6"
@@ -98,7 +99,7 @@ struct tifm_sd {
 
        struct mmc_request    *req;
        struct work_struct    cmd_handler;
-       struct work_struct    abort_handler;
+       struct delayed_work   abort_handler;
        wait_queue_head_t     can_eject;
 
        size_t                written_blocks;
@@ -172,9 +173,6 @@ static unsigned int tifm_sd_op_flags(struct mmc_command *cmd)
        case MMC_RSP_R3:
                rc |= TIFM_MMCSD_RSP_R3;
                break;
-       case MMC_RSP_R6:
-               rc |= TIFM_MMCSD_RSP_R6;
-               break;
        default:
                BUG();
        }
@@ -386,7 +384,7 @@ static void tifm_sd_prepare_data(struct tifm_sd *card, struct mmc_command *cmd)
 
        writel(TIFM_FIFO_INT_SETALL,
                sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
-       writel(long_log2(cmd->data->blksz) - 2,
+       writel(ilog2(cmd->data->blksz) - 2,
                        sock->addr + SOCK_FIFO_PAGE_SIZE);
        writel(TIFM_FIFO_ENABLE, sock->addr + SOCK_FIFO_CONTROL);
        writel(TIFM_FIFO_INTMASK, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
@@ -495,19 +493,19 @@ err_out:
        mmc_request_done(mmc, mrq);
 }
 
-static void tifm_sd_end_cmd(void *data)
+static void tifm_sd_end_cmd(struct work_struct *work)
 {
-       struct tifm_sd *host = data;
+       struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
        struct tifm_dev *sock = host->dev;
        struct mmc_host *mmc = tifm_get_drvdata(sock);
        struct mmc_request *mrq;
-       struct mmc_data *r_data = 0;
+       struct mmc_data *r_data = NULL;
        unsigned long flags;
 
        spin_lock_irqsave(&sock->lock, flags);
 
        mrq = host->req;
-       host->req = 0;
+       host->req = NULL;
        host->state = IDLE;
 
        if (!mrq) {
@@ -546,7 +544,7 @@ static void tifm_sd_request_nodma(struct mmc_host *mmc, struct mmc_request *mrq)
        struct tifm_dev *sock = host->dev;
        unsigned long flags;
        struct mmc_data *r_data = mrq->cmd->data;
-       char *t_buffer = 0;
+       char *t_buffer = NULL;
 
        if (r_data) {
                t_buffer = kmap(r_data->sg->page);
@@ -607,19 +605,19 @@ err_out:
        mmc_request_done(mmc, mrq);
 }
 
-static void tifm_sd_end_cmd_nodma(void *data)
+static void tifm_sd_end_cmd_nodma(struct work_struct *work)
 {
-       struct tifm_sd *host = (struct tifm_sd*)data;
+       struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
        struct tifm_dev *sock = host->dev;
        struct mmc_host *mmc = tifm_get_drvdata(sock);
        struct mmc_request *mrq;
-       struct mmc_data *r_data = 0;
+       struct mmc_data *r_data = NULL;
        unsigned long flags;
 
        spin_lock_irqsave(&sock->lock, flags);
 
        mrq = host->req;
-       host->req = 0;
+       host->req = NULL;
        host->state = IDLE;
 
        if (!mrq) {
@@ -644,7 +642,7 @@ static void tifm_sd_end_cmd_nodma(void *data)
                        r_data->bytes_xfered += r_data->blksz -
                                readl(sock->addr + SOCK_MMCSD_BLOCK_LEN) + 1;
                }
-               host->buffer = 0;
+               host->buffer = NULL;
                host->buffer_pos = 0;
                host->buffer_size = 0;
        }
@@ -660,11 +658,14 @@ static void tifm_sd_end_cmd_nodma(void *data)
        mmc_request_done(mmc, mrq);
 }
 
-static void tifm_sd_abort(void *data)
+static void tifm_sd_abort(struct work_struct *work)
 {
+       struct tifm_sd *host =
+               container_of(work, struct tifm_sd, abort_handler.work);
+
        printk(KERN_ERR DRIVER_NAME
                ": card failed to respond for a long period of time");
-       tifm_eject(((struct tifm_sd*)data)->dev);
+       tifm_eject(host->dev);
 }
 
 static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
@@ -761,9 +762,9 @@ static struct mmc_host_ops tifm_sd_ops = {
        .get_ro  = tifm_sd_ro
 };
 
-static void tifm_sd_register_host(void *data)
+static void tifm_sd_register_host(struct work_struct *work)
 {
-       struct tifm_sd *host = (struct tifm_sd*)data;
+       struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
        struct tifm_dev *sock = host->dev;
        struct mmc_host *mmc = tifm_get_drvdata(sock);
        unsigned long flags;
@@ -771,8 +772,7 @@ static void tifm_sd_register_host(void *data)
        spin_lock_irqsave(&sock->lock, flags);
        host->flags |= HOST_REG;
        PREPARE_WORK(&host->cmd_handler,
-                       no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd,
-                       data);
+                       no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd);
        spin_unlock_irqrestore(&sock->lock, flags);
        dev_dbg(&sock->dev, "adding host\n");
        mmc_add_host(mmc);
@@ -798,8 +798,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
        host->dev = sock;
        host->clk_div = 61;
        init_waitqueue_head(&host->can_eject);
-       INIT_WORK(&host->cmd_handler, tifm_sd_register_host, host);
-       INIT_WORK(&host->abort_handler, tifm_sd_abort, host);
+       INIT_WORK(&host->cmd_handler, tifm_sd_register_host);
+       INIT_DELAYED_WORK(&host->abort_handler, tifm_sd_abort);
 
        tifm_set_drvdata(sock, mmc);
        sock->signal_irq = tifm_sd_signal_irq;
@@ -895,7 +895,7 @@ static void tifm_sd_remove(struct tifm_dev *sock)
                sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
        writel(0, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
 
-       tifm_set_drvdata(sock, 0);
+       tifm_set_drvdata(sock, NULL);
        mmc_free_host(mmc);
 }