Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[deliverable/linux.git] / drivers / mmc / pxamci.c
index f31e247b2cbeabf479c912ae896453db70278935..eb9a8826e9b5892c6f6bf7fdb48842ecfe8f6d11 100644 (file)
 
 #include "pxamci.h"
 
-#ifdef CONFIG_MMC_DEBUG
-#define DBG(x...)      printk(KERN_DEBUG x)
-#else
-#define DBG(x...)      do { } while (0)
-#endif
-
 #define DRIVER_NAME    "pxa2xx-mci"
 
 #define NR_SG  1
@@ -178,14 +172,15 @@ static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd,
        if (cmd->flags & MMC_RSP_BUSY)
                cmdat |= CMDAT_BUSY;
 
-       switch (cmd->flags & (MMC_RSP_MASK | MMC_RSP_CRC)) {
-       case MMC_RSP_SHORT | MMC_RSP_CRC:
+#define RSP_TYPE(x)    ((x) & ~(MMC_RSP_BUSY|MMC_RSP_OPCODE))
+       switch (RSP_TYPE(mmc_resp_type(cmd))) {
+       case RSP_TYPE(MMC_RSP_R1): /* r1, r1b, r6 */
                cmdat |= CMDAT_RESP_SHORT;
                break;
-       case MMC_RSP_SHORT:
+       case RSP_TYPE(MMC_RSP_R3):
                cmdat |= CMDAT_RESP_R3;
                break;
-       case MMC_RSP_LONG | MMC_RSP_CRC:
+       case RSP_TYPE(MMC_RSP_R2):
                cmdat |= CMDAT_RESP_R2;
                break;
        default:
@@ -205,7 +200,7 @@ static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd,
 
 static void pxamci_finish_request(struct pxamci_host *host, struct mmc_request *mrq)
 {
-       DBG("PXAMCI: request done\n");
+       pr_debug("PXAMCI: request done\n");
        host->mrq = NULL;
        host->cmd = NULL;
        host->data = NULL;
@@ -251,7 +246,7 @@ static int pxamci_cmd_done(struct pxamci_host *host, unsigned int stat)
                        if ((cmd->resp[0] & 0x80000000) == 0)
                                cmd->error = MMC_ERR_BADCRC;
                } else {
-                       DBG("ignoring CRC from command %d - *risky*\n",cmd->opcode);
+                       pr_debug("ignoring CRC from command %d - *risky*\n",cmd->opcode);
                }
 #else
                cmd->error = MMC_ERR_BADCRC;
@@ -316,12 +311,12 @@ static irqreturn_t pxamci_irq(int irq, void *devid, struct pt_regs *regs)
 
        ireg = readl(host->base + MMC_I_REG);
 
-       DBG("PXAMCI: irq %08x\n", ireg);
+       pr_debug("PXAMCI: irq %08x\n", ireg);
 
        if (ireg) {
                unsigned stat = readl(host->base + MMC_STAT);
 
-               DBG("PXAMCI: stat %08x\n", stat);
+               pr_debug("PXAMCI: stat %08x\n", stat);
 
                if (ireg & END_CMD_RES)
                        handled |= pxamci_cmd_done(host, stat);
@@ -375,9 +370,9 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
        struct pxamci_host *host = mmc_priv(mmc);
 
-       DBG("pxamci_set_ios: clock %u power %u vdd %u.%02u\n",
-           ios->clock, ios->power_mode, ios->vdd / 100,
-           ios->vdd % 100);
+       pr_debug("pxamci_set_ios: clock %u power %u vdd %u.%02u\n",
+                ios->clock, ios->power_mode, ios->vdd / 100,
+                ios->vdd % 100);
 
        if (ios->clock) {
                unsigned int clk = CLOCKRATE / ios->clock;
@@ -404,8 +399,8 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                        host->cmdat |= CMDAT_INIT;
        }
 
-       DBG("pxamci_set_ios: clkrt = %x cmdat = %x\n",
-           host->clkrt, host->cmdat);
+       pr_debug("pxamci_set_ios: clkrt = %x cmdat = %x\n",
+                host->clkrt, host->cmdat);
 }
 
 static struct mmc_host_ops pxamci_ops = {
@@ -428,9 +423,8 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid, struct pt_regs *regs)
        return IRQ_HANDLED;
 }
 
-static int pxamci_probe(struct device *dev)
+static int pxamci_probe(struct platform_device *pdev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
        struct mmc_host *mmc;
        struct pxamci_host *host = NULL;
        struct resource *r;
@@ -438,14 +432,14 @@ static int pxamci_probe(struct device *dev)
 
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!r || irq == NO_IRQ)
+       if (!r || irq < 0)
                return -ENXIO;
 
        r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
        if (!r)
                return -EBUSY;
 
-       mmc = mmc_alloc_host(sizeof(struct pxamci_host), dev);
+       mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
        if (!mmc) {
                ret = -ENOMEM;
                goto out;
@@ -474,7 +468,7 @@ static int pxamci_probe(struct device *dev)
                         host->pdata->ocr_mask :
                         MMC_VDD_32_33|MMC_VDD_33_34;
 
-       host->sg_cpu = dma_alloc_coherent(dev, PAGE_SIZE, &host->sg_dma, GFP_KERNEL);
+       host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &host->sg_dma, GFP_KERNEL);
        if (!host->sg_cpu) {
                ret = -ENOMEM;
                goto out;
@@ -511,10 +505,10 @@ static int pxamci_probe(struct device *dev)
        if (ret)
                goto out;
 
-       dev_set_drvdata(dev, mmc);
+       platform_set_drvdata(pdev, mmc);
 
        if (host->pdata && host->pdata->init)
-               host->pdata->init(dev, pxamci_detect_irq, mmc);
+               host->pdata->init(&pdev->dev, pxamci_detect_irq, mmc);
 
        mmc_add_host(mmc);
 
@@ -527,7 +521,7 @@ static int pxamci_probe(struct device *dev)
                if (host->base)
                        iounmap(host->base);
                if (host->sg_cpu)
-                       dma_free_coherent(dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
+                       dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
        }
        if (mmc)
                mmc_free_host(mmc);
@@ -535,17 +529,17 @@ static int pxamci_probe(struct device *dev)
        return ret;
 }
 
-static int pxamci_remove(struct device *dev)
+static int pxamci_remove(struct platform_device *pdev)
 {
-       struct mmc_host *mmc = dev_get_drvdata(dev);
+       struct mmc_host *mmc = platform_get_drvdata(pdev);
 
-       dev_set_drvdata(dev, NULL);
+       platform_set_drvdata(pdev, NULL);
 
        if (mmc) {
                struct pxamci_host *host = mmc_priv(mmc);
 
                if (host->pdata && host->pdata->exit)
-                       host->pdata->exit(dev, mmc);
+                       host->pdata->exit(&pdev->dev, mmc);
 
                mmc_remove_host(mmc);
 
@@ -560,7 +554,7 @@ static int pxamci_remove(struct device *dev)
                free_irq(host->irq, host);
                pxa_free_dma(host->dma);
                iounmap(host->base);
-               dma_free_coherent(dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
+               dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
 
                release_resource(host->res);
 
@@ -570,9 +564,9 @@ static int pxamci_remove(struct device *dev)
 }
 
 #ifdef CONFIG_PM
-static int pxamci_suspend(struct device *dev, pm_message_t state)
+static int pxamci_suspend(struct platform_device *dev, pm_message_t state)
 {
-       struct mmc_host *mmc = dev_get_drvdata(dev);
+       struct mmc_host *mmc = platform_get_drvdata(dev);
        int ret = 0;
 
        if (mmc)
@@ -581,9 +575,9 @@ static int pxamci_suspend(struct device *dev, pm_message_t state)
        return ret;
 }
 
-static int pxamci_resume(struct device *dev)
+static int pxamci_resume(struct platform_device *dev)
 {
-       struct mmc_host *mmc = dev_get_drvdata(dev);
+       struct mmc_host *mmc = platform_get_drvdata(dev);
        int ret = 0;
 
        if (mmc)
@@ -596,23 +590,24 @@ static int pxamci_resume(struct device *dev)
 #define pxamci_resume  NULL
 #endif
 
-static struct device_driver pxamci_driver = {
-       .name           = DRIVER_NAME,
-       .bus            = &platform_bus_type,
+static struct platform_driver pxamci_driver = {
        .probe          = pxamci_probe,
        .remove         = pxamci_remove,
        .suspend        = pxamci_suspend,
        .resume         = pxamci_resume,
+       .driver         = {
+               .name   = DRIVER_NAME,
+       },
 };
 
 static int __init pxamci_init(void)
 {
-       return driver_register(&pxamci_driver);
+       return platform_driver_register(&pxamci_driver);
 }
 
 static void __exit pxamci_exit(void)
 {
-       driver_unregister(&pxamci_driver);
+       platform_driver_unregister(&pxamci_driver);
 }
 
 module_init(pxamci_init);
This page took 0.030798 seconds and 5 git commands to generate.