tifm: hide details of interrupt processing from socket drivers
authorAlex Dubov <oakad@yahoo.com>
Thu, 12 Apr 2007 06:59:12 +0000 (16:59 +1000)
committerPierre Ossman <drzeus@drzeus.cx>
Tue, 1 May 2007 11:04:12 +0000 (13:04 +0200)
Instead of passing transformed value of adapter interrupt status to
socket drivers, implement two separate callbacks - one for card events
and another for dma events.

Signed-off-by: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/misc/tifm_7xx1.c
drivers/misc/tifm_core.c
drivers/mmc/tifm_sd.c
include/linux/tifm.h

index bc60e2fc3c2cc8e6342a74403cdd2b5687b7c8a0..d6652b3301dc080aacdd6fddd542c075db1b1418 100644 (file)
 #include <linux/freezer.h>
 
 #define DRIVER_NAME "tifm_7xx1"
-#define DRIVER_VERSION "0.7"
+#define DRIVER_VERSION "0.8"
+
+#define TIFM_IRQ_ENABLE           0x80000000
+#define TIFM_IRQ_SOCKMASK(x)      (x)
+#define TIFM_IRQ_CARDMASK(x)      ((x) << 8)
+#define TIFM_IRQ_FIFOMASK(x)      ((x) << 16)
+#define TIFM_IRQ_SETALL           0xffffffff
 
 static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
 {
@@ -31,7 +37,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
        struct tifm_adapter *fm = dev_id;
        struct tifm_dev *sock;
        unsigned int irq_status;
-       unsigned int sock_irq_status, cnt;
+       unsigned int cnt;
 
        spin_lock(&fm->lock);
        irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
@@ -45,12 +51,12 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
 
                for (cnt = 0; cnt < fm->num_sockets; cnt++) {
                        sock = fm->sockets[cnt];
-                       sock_irq_status = (irq_status >> cnt)
-                                         & (TIFM_IRQ_FIFOMASK(1)
-                                            | TIFM_IRQ_CARDMASK(1));
-
-                       if (sock && sock_irq_status)
-                               sock->signal_irq(sock, sock_irq_status);
+                       if (sock) {
+                               if ((irq_status >> cnt) & TIFM_IRQ_FIFOMASK(1))
+                                       sock->data_event(sock);
+                               if ((irq_status >> cnt) & TIFM_IRQ_CARDMASK(1))
+                                       sock->card_event(sock);
+                       }
                }
 
                fm->socket_change_set |= irq_status
index 6b10ebe9d9365d89bc40d1487c24a9ed86bf91e8..6799b9cca055a1e4b3c1ef8c4c4f92e04214da2c 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/idr.h>
 
 #define DRIVER_NAME "tifm_core"
-#define DRIVER_VERSION "0.7"
+#define DRIVER_VERSION "0.8"
 
 static DEFINE_IDR(tifm_adapter_idr);
 static DEFINE_SPINLOCK(tifm_adapter_lock);
@@ -175,8 +175,7 @@ void tifm_free_device(struct device *dev)
 }
 EXPORT_SYMBOL(tifm_free_device);
 
-static void tifm_dummy_signal_irq(struct tifm_dev *sock,
-                                 unsigned int sock_irq_status)
+static void tifm_dummy_event(struct tifm_dev *sock)
 {
        return;
 }
@@ -191,7 +190,8 @@ struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm)
                dev->dev.parent = fm->dev;
                dev->dev.bus = &tifm_bus_type;
                dev->dev.release = tifm_free_device;
-               dev->signal_irq = tifm_dummy_signal_irq;
+               dev->card_event = tifm_dummy_event;
+               dev->data_event = tifm_dummy_event;
        }
        return dev;
 }
@@ -249,7 +249,8 @@ static int tifm_device_remove(struct device *dev)
        struct tifm_driver *drv = fm_dev->drv;
 
        if (drv) {
-               fm_dev->signal_irq = tifm_dummy_signal_irq;
+               fm_dev->card_event = tifm_dummy_event;
+               fm_dev->data_event = tifm_dummy_event;
                if (drv->remove)
                        drv->remove(fm_dev);
                fm_dev->drv = NULL;
index 0581d09c58fc6424a075cf36b9ad25560bbe872c..8905b129e4e17ec5329684c942f63143dc8d52f6 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/io.h>
 
 #define DRIVER_NAME "tifm_sd"
-#define DRIVER_VERSION "0.7"
+#define DRIVER_VERSION "0.8"
 
 static int no_dma = 0;
 static int fixed_timeout = 0;
@@ -316,24 +316,38 @@ change_state:
 }
 
 /* Called from interrupt handler */
-static void tifm_sd_signal_irq(struct tifm_dev *sock,
-                              unsigned int sock_irq_status)
+static void tifm_sd_data_event(struct tifm_dev *sock)
 {
        struct tifm_sd *host;
-       unsigned int host_status = 0, fifo_status = 0;
-       int error_code = 0;
+       unsigned int fifo_status = 0;
 
        spin_lock(&sock->lock);
        host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
 
-       if (sock_irq_status & FIFO_EVENT) {
-               fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS);
-               writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS);
+       fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS);
+       writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS);
+
+       host->flags |= fifo_status & FIFO_RDY;
+
+       if (host->req)
+               tifm_sd_process_cmd(sock, host, 0);
+
+       dev_dbg(&sock->dev, "fifo_status %x\n", fifo_status);
+       spin_unlock(&sock->lock);
+
+}
+
+/* Called from interrupt handler */
+static void tifm_sd_card_event(struct tifm_dev *sock)
+{
+       struct tifm_sd *host;
+       unsigned int host_status = 0;
+       int error_code = 0;
+
+       spin_lock(&sock->lock);
+       host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
 
-               host->flags |= fifo_status & FIFO_RDY;
-       }
 
-       if (sock_irq_status & CARD_EVENT) {
                host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
                writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
 
@@ -377,13 +391,11 @@ static void tifm_sd_signal_irq(struct tifm_dev *sock,
                        host->written_blocks++;
                        host->flags &= ~CARD_BUSY;
                }
-        }
 
        if (host->req)
                tifm_sd_process_cmd(sock, host, host_status);
 done:
-       dev_dbg(&sock->dev, "host_status %x, fifo_status %x\n",
-               host_status, fifo_status);
+       dev_dbg(&sock->dev, "host_status %x\n", host_status);
        spin_unlock(&sock->lock);
 }
 
@@ -882,7 +894,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
        mmc->max_blk_size = 2048;
        mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
        mmc->max_seg_size = mmc->max_req_size;
-       sock->signal_irq = tifm_sd_signal_irq;
+       sock->card_event = tifm_sd_card_event;
+       sock->data_event = tifm_sd_data_event;
        rc = tifm_sd_initialize_host(host);
 
        if (!rc)
index 3deb0a6c13708b7e6158dc52583982185a7c7003..4470961655c504ff06f68b9973075bf3ecbe7673 100644 (file)
@@ -60,13 +60,6 @@ enum {
        SOCK_MS_SYSTEM                 = 0x190,
        SOCK_FIFO_ACCESS               = 0x200 };
 
-
-#define TIFM_IRQ_ENABLE           0x80000000
-#define TIFM_IRQ_SOCKMASK(x)      (x)
-#define TIFM_IRQ_CARDMASK(x)      ((x) << 8)
-#define TIFM_IRQ_FIFOMASK(x)      ((x) << 16)
-#define TIFM_IRQ_SETALL           0xffffffff
-
 #define TIFM_CTRL_LED             0x00000040
 #define TIFM_CTRL_FAST_CLK        0x00000100
 
@@ -90,8 +83,8 @@ struct tifm_dev {
        tifm_media_id           media_id;
        unsigned int            socket_id;
 
-       void                    (*signal_irq)(struct tifm_dev *sock,
-                                             unsigned int sock_irq_status);
+       void          (*card_event)(struct tifm_dev *sock);
+       void          (*data_event)(struct tifm_dev *sock);
 
        struct tifm_driver      *drv;
        struct device           dev;