pcmcia: fix up alignf issues
[safe/jmp/linux-2.6] / drivers / pcmcia / yenta_socket.c
index 1344746..f19ad02 100644 (file)
@@ -6,24 +6,22 @@
  * Changelog:
  * Aug 2002: Manfred Spraul <manfred@colorfullife.com>
  *     Dynamically adjust the size of the bridge resource
- *     
+ *
  * May 2003: Dominik Brodowski <linux@brodo.de>
  *     Merge pci_socket.c and yenta.c into one file
  */
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/sched.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/io.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
 #include <pcmcia/cs.h>
 
-#include <asm/io.h>
-
 #include "yenta_socket.h"
 #include "i82365.h"
 
@@ -39,28 +37,43 @@ static int pwr_irqs_off;
 module_param(pwr_irqs_off, bool, 0644);
 MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!");
 
-#if 0
-#define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args)
-#else
-#define debug(x,args...)
-#endif
+static char o2_speedup[] = "default";
+module_param_string(o2_speedup, o2_speedup, sizeof(o2_speedup), 0444);
+MODULE_PARM_DESC(o2_speedup, "Use prefetch/burst for O2-bridges: 'on', 'off' "
+       "or 'default' (uses recommended behaviour for the detected bridge)");
+
+/*
+ * Only probe "regular" interrupts, don't
+ * touch dangerous spots like the mouse irq,
+ * because there are mice that apparently
+ * get really confused if they get fondled
+ * too intimately.
+ *
+ * Default to 11, 10, 9, 7, 6, 5, 4, 3.
+ */
+static u32 isa_interrupts = 0x0ef8;
+
+
+#define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args)
 
 /* Don't ask.. */
 #define to_cycles(ns)  ((ns)/120)
 #define to_ns(cycles)  ((cycles)*120)
 
-/**
+/*
  * yenta PCI irq probing.
  * currently only used in the TI/EnE initialization code
  */
 #ifdef CONFIG_YENTA_TI
 static int yenta_probe_cb_irq(struct yenta_socket *socket);
+static unsigned int yenta_probe_irq(struct yenta_socket *socket,
+                               u32 isa_irq_mask);
 #endif
 
 
 static unsigned int override_bios;
 module_param(override_bios, uint, 0000);
-MODULE_PARM_DESC (override_bios, "yenta ignore bios resource allocation");
+MODULE_PARM_DESC(override_bios, "yenta ignore bios resource allocation");
 
 /*
  * Generate easy-to-use ways of reading a cardbus sockets
@@ -70,13 +83,13 @@ MODULE_PARM_DESC (override_bios, "yenta ignore bios resource allocation");
 static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg)
 {
        u32 val = readl(socket->base + reg);
-       debug("%p %04x %08x\n", socket, reg, val);
+       debug("%04x %08x\n", socket, reg, val);
        return val;
 }
 
 static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val)
 {
-       debug("%p %04x %08x\n", socket, reg, val);
+       debug("%04x %08x\n", socket, reg, val);
        writel(val, socket->base + reg);
        readl(socket->base + reg); /* avoid problems with PCI write posting */
 }
@@ -85,7 +98,7 @@ static inline u8 config_readb(struct yenta_socket *socket, unsigned offset)
 {
        u8 val;
        pci_read_config_byte(socket->dev, offset, &val);
-       debug("%p %04x %02x\n", socket, offset, val);
+       debug("%04x %02x\n", socket, offset, val);
        return val;
 }
 
@@ -93,7 +106,7 @@ static inline u16 config_readw(struct yenta_socket *socket, unsigned offset)
 {
        u16 val;
        pci_read_config_word(socket->dev, offset, &val);
-       debug("%p %04x %04x\n", socket, offset, val);
+       debug("%04x %04x\n", socket, offset, val);
        return val;
 }
 
@@ -101,32 +114,32 @@ static inline u32 config_readl(struct yenta_socket *socket, unsigned offset)
 {
        u32 val;
        pci_read_config_dword(socket->dev, offset, &val);
-       debug("%p %04x %08x\n", socket, offset, val);
+       debug("%04x %08x\n", socket, offset, val);
        return val;
 }
 
 static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val)
 {
-       debug("%p %04x %02x\n", socket, offset, val);
+       debug("%04x %02x\n", socket, offset, val);
        pci_write_config_byte(socket->dev, offset, val);
 }
 
 static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val)
 {
-       debug("%p %04x %04x\n", socket, offset, val);
+       debug("%04x %04x\n", socket, offset, val);
        pci_write_config_word(socket->dev, offset, val);
 }
 
 static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val)
 {
-       debug("%p %04x %08x\n", socket, offset, val);
+       debug("%04x %08x\n", socket, offset, val);
        pci_write_config_dword(socket->dev, offset, val);
 }
 
 static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg)
 {
        u8 val = readb(socket->base + 0x800 + reg);
-       debug("%p %04x %02x\n", socket, reg, val);
+       debug("%04x %02x\n", socket, reg, val);
        return val;
 }
 
@@ -135,20 +148,20 @@ static inline u8 exca_readw(struct yenta_socket *socket, unsigned reg)
        u16 val;
        val = readb(socket->base + 0x800 + reg);
        val |= readb(socket->base + 0x800 + reg + 1) << 8;
-       debug("%p %04x %04x\n", socket, reg, val);
+       debug("%04x %04x\n", socket, reg, val);
        return val;
 }
 
 static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val)
 {
-       debug("%p %04x %02x\n", socket, reg, val);
+       debug("%04x %02x\n", socket, reg, val);
        writeb(val, socket->base + 0x800 + reg);
        readb(socket->base + 0x800 + reg); /* PCI write posting... */
 }
 
 static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val)
 {
-       debug("%p %04x %04x\n", socket, reg, val);
+       debug("%04x %04x\n", socket, reg, val);
        writeb(val, socket->base + 0x800 + reg);
        writeb(val >> 8, socket->base + 0x800 + reg + 1);
 
@@ -208,7 +221,7 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value)
 
 
        if (state & CB_CBCARD) {
-               val |= SS_CARDBUS;      
+               val |= SS_CARDBUS;
                val |= (state & CB_CARDSTS) ? SS_STSCHG : 0;
                val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT;
                val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0;
@@ -242,24 +255,42 @@ static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
                /* i82365SL-DF style */
                if (socket->flags & YENTA_16BIT_POWER_DF) {
                        switch (state->Vcc) {
-                       case 33: reg |= I365_VCC_3V; break;
-                       case 50: reg |= I365_VCC_5V; break;
-                       default: reg = 0; break;
+                       case 33:
+                               reg |= I365_VCC_3V;
+                               break;
+                       case 50:
+                               reg |= I365_VCC_5V;
+                               break;
+                       default:
+                               reg = 0;
+                               break;
                        }
                        switch (state->Vpp) {
                        case 33:
-                       case 50: reg |= I365_VPP1_5V; break;
-                       case 120: reg |= I365_VPP1_12V; break;
+                       case 50:
+                               reg |= I365_VPP1_5V;
+                               break;
+                       case 120:
+                               reg |= I365_VPP1_12V;
+                               break;
                        }
                } else {
                        /* i82365SL-B style */
                        switch (state->Vcc) {
-                       case 50: reg |= I365_VCC_5V; break;
-                       default: reg = 0; break;
+                       case 50:
+                               reg |= I365_VCC_5V;
+                               break;
+                       default:
+                               reg = 0;
+                               break;
                        }
                        switch (state->Vpp) {
-                       case 50: reg |= I365_VPP1_5V | I365_VPP2_5V; break;
-                       case 120: reg |= I365_VPP1_12V | I365_VPP2_12V; break;
+                       case 50:
+                               reg |= I365_VPP1_5V | I365_VPP2_5V;
+                               break;
+                       case 120:
+                               reg |= I365_VPP1_12V | I365_VPP2_12V;
+                               break;
                        }
                }
 
@@ -268,14 +299,26 @@ static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
        } else {
                u32 reg = 0;    /* CB_SC_STPCLK? */
                switch (state->Vcc) {
-               case 33: reg = CB_SC_VCC_3V; break;
-               case 50: reg = CB_SC_VCC_5V; break;
-               default: reg = 0; break;
+               case 33:
+                       reg = CB_SC_VCC_3V;
+                       break;
+               case 50:
+                       reg = CB_SC_VCC_5V;
+                       break;
+               default:
+                       reg = 0;
+                       break;
                }
                switch (state->Vpp) {
-               case 33:  reg |= CB_SC_VPP_3V; break;
-               case 50:  reg |= CB_SC_VPP_5V; break;
-               case 120: reg |= CB_SC_VPP_12V; break;
+               case 33:
+                       reg |= CB_SC_VPP_3V;
+                       break;
+               case 50:
+                       reg |= CB_SC_VPP_5V;
+                       break;
+               case 120:
+                       reg |= CB_SC_VPP_12V;
+                       break;
                }
                if (reg != cb_readl(socket, CB_SOCKET_CONTROL))
                        cb_writel(socket, CB_SOCKET_CONTROL, reg);
@@ -300,8 +343,8 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
                /* ISA interrupt control? */
                intr = exca_readb(socket, I365_INTCTL);
                intr = (intr & ~0xf);
-               if (!socket->cb_irq) {
-                       intr |= state->io_irq;
+               if (!socket->dev->irq) {
+                       intr |= socket->cb_irq ? socket->cb_irq : state->io_irq;
                        bridge |= CB_BRIDGE_INTR;
                }
                exca_writeb(socket, I365_INTCTL, intr);
@@ -311,7 +354,7 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
                reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA);
                reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET;
                reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0;
-               if (state->io_irq != socket->cb_irq) {
+               if (state->io_irq != socket->dev->irq) {
                        reg |= state->io_irq;
                        bridge |= CB_BRIDGE_INTR;
                }
@@ -319,23 +362,31 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
 
                reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK);
                reg |= I365_PWR_NORESET;
-               if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO;
-               if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT;
+               if (state->flags & SS_PWR_AUTO)
+                       reg |= I365_PWR_AUTO;
+               if (state->flags & SS_OUTPUT_ENA)
+                       reg |= I365_PWR_OUT;
                if (exca_readb(socket, I365_POWER) != reg)
                        exca_writeb(socket, I365_POWER, reg);
 
                /* CSC interrupt: no ISA irq for CSC */
-               reg = I365_CSC_DETECT;
+               reg = exca_readb(socket, I365_CSCINT);
+               reg &= I365_CSC_IRQ_MASK;
+               reg |= I365_CSC_DETECT;
                if (state->flags & SS_IOCARD) {
-                       if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG;
+                       if (state->csc_mask & SS_STSCHG)
+                               reg |= I365_CSC_STSCHG;
                } else {
-                       if (state->csc_mask & SS_BATDEAD) reg |= I365_CSC_BVD1;
-                       if (state->csc_mask & SS_BATWARN) reg |= I365_CSC_BVD2;
-                       if (state->csc_mask & SS_READY) reg |= I365_CSC_READY;
+                       if (state->csc_mask & SS_BATDEAD)
+                               reg |= I365_CSC_BVD1;
+                       if (state->csc_mask & SS_BATWARN)
+                               reg |= I365_CSC_BVD2;
+                       if (state->csc_mask & SS_READY)
+                               reg |= I365_CSC_READY;
                }
                exca_writeb(socket, I365_CSCINT, reg);
                exca_readb(socket, I365_CSC);
-               if(sock->zoom_video)
+               if (sock->zoom_video)
                        sock->zoom_video(sock, state->flags & SS_ZVCARD);
        }
        config_writew(socket, CB_BRIDGE_CONTROL, bridge);
@@ -373,9 +424,12 @@ static int yenta_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io
        exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop);
 
        ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
-       if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map);
-       if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map);
-       if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map);
+       if (io->flags & MAP_0WS)
+               ioctl |= I365_IOCTL_0WS(map);
+       if (io->flags & MAP_16BIT)
+               ioctl |= I365_IOCTL_16BIT(map);
+       if (io->flags & MAP_AUTOSZ)
+               ioctl |= I365_IOCTL_IOCS16(map);
        exca_writeb(socket, I365_IOCTL, ioctl);
 
        if (io->flags & MAP_ACTIVE)
@@ -421,10 +475,17 @@ static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *
 
        word = (stop >> 12) & 0x0fff;
        switch (to_cycles(mem->speed)) {
-               case 0: break;
-               case 1:  word |= I365_MEM_WS0; break;
-               case 2:  word |= I365_MEM_WS1; break;
-               default: word |= I365_MEM_WS1 | I365_MEM_WS0; break;
+       case 0:
+               break;
+       case 1:
+               word |= I365_MEM_WS0;
+               break;
+       case 2:
+               word |= I365_MEM_WS1;
+               break;
+       default:
+               word |= I365_MEM_WS1 | I365_MEM_WS0;
+               break;
        }
        exca_writew(socket, I365_MEM(map) + I365_W_STOP, word);
 
@@ -442,7 +503,7 @@ static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *
 
 
 
-static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t yenta_interrupt(int irq, void *dev_id)
 {
        unsigned int events;
        struct yenta_socket *socket = (struct yenta_socket *) dev_id;
@@ -478,7 +539,7 @@ static void yenta_interrupt_wrapper(unsigned long data)
 {
        struct yenta_socket *socket = (struct yenta_socket *) data;
 
-       yenta_interrupt(0, (void *)socket, NULL);
+       yenta_interrupt(0, (void *)socket);
        socket->poll_timer.expires = jiffies + HZ;
        add_timer(&socket->poll_timer);
 }
@@ -552,9 +613,9 @@ static int yenta_sock_suspend(struct pcmcia_socket *sock)
  * max 4 MB, min 16 kB. We try very hard to not get below
  * the "ACC" values, though.
  */
-#define BRIDGE_MEM_MAX 4*1024*1024
-#define BRIDGE_MEM_ACC 128*1024
-#define BRIDGE_MEM_MIN 16*1024
+#define BRIDGE_MEM_MAX (4*1024*1024)
+#define BRIDGE_MEM_ACC (128*1024)
+#define BRIDGE_MEM_MIN (16*1024)
 
 #define BRIDGE_IO_MAX 512
 #define BRIDGE_IO_ACC 256
@@ -579,7 +640,7 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
                int i;
                size = BRIDGE_MEM_MAX;
                if (size > avail/8) {
-                       size=(avail+1)/8;
+                       size = (avail+1)/8;
                        /* round size down to next power of 2 */
                        i = 0;
                        while ((size /= 2) != 0)
@@ -595,7 +656,7 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
 
        do {
                if (allocate_resource(root, res, size, start, end, align,
-                                     NULL, NULL)==0) {
+                                     NULL, NULL) == 0) {
                        return 1;
                }
                size = size/2;
@@ -609,9 +670,10 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
 static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
                            u32 min)
 {
+       struct resource *root;
        int i;
-       for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
-               struct resource * root = socket->dev->bus->resource[i];
+
+       pci_bus_for_each_resource(socket->dev->bus, root, i) {
                if (!root)
                        continue;
 
@@ -627,11 +689,12 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
 
 static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end)
 {
-       struct resource *root, *res;
+       struct pci_dev *dev = socket->dev;
+       struct resource *res;
        struct pci_bus_region region;
        unsigned mask;
 
-       res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr;
+       res = dev->resource + PCI_BRIDGE_RESOURCES + nr;
        /* Already allocated? */
        if (res->parent)
                return 0;
@@ -641,18 +704,19 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
        if (type & IORESOURCE_IO)
                mask = ~3;
 
-       res->name = socket->dev->subordinate->name;
+       res->name = dev->subordinate->name;
        res->flags = type;
 
        region.start = config_readl(socket, addr_start) & mask;
        region.end = config_readl(socket, addr_end) | ~mask;
        if (region.start && region.end > region.start && !override_bios) {
-               pcibios_bus_to_resource(socket->dev, res, &region);
-               root = pci_find_parent_resource(socket->dev, res);
-               if (root && (request_resource(root, res) == 0))
+               pcibios_bus_to_resource(dev, res, &region);
+               if (pci_claim_resource(dev, PCI_BRIDGE_RESOURCES + nr) == 0)
                        return 0;
-               printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n",
-                               pci_name(socket->dev), nr);
+               dev_printk(KERN_INFO, &dev->dev,
+                          "Preassigned resource %d busy or not available, "
+                          "reconfiguring...\n",
+                          nr);
        }
 
        if (type & IORESOURCE_IO) {
@@ -675,8 +739,9 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
                        return 1;
        }
 
-       printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n",
-              pci_name(socket->dev), type);
+       dev_printk(KERN_INFO, &dev->dev,
+                  "no resource of type %x available, trying to continue...\n",
+                  type);
        res->start = res->end = res->flags = 0;
        return 0;
 }
@@ -706,7 +771,7 @@ static void yenta_allocate_resources(struct yenta_socket *socket)
 static void yenta_free_resources(struct yenta_socket *socket)
 {
        int i;
-       for (i=0;i<4;i++) {
+       for (i = 0; i < 4; i++) {
                struct resource *res;
                res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i;
                if (res->start != 0 && res->end != 0)
@@ -719,7 +784,7 @@ static void yenta_free_resources(struct yenta_socket *socket)
 /*
  * Close it down - release our resources and go home..
  */
-static void yenta_close(struct pci_dev *dev)
+static void __devexit yenta_close(struct pci_dev *dev)
 {
        struct yenta_socket *sock = pci_get_drvdata(dev);
 
@@ -728,7 +793,7 @@ static void yenta_close(struct pci_dev *dev)
 
        /* we don't want a dying socket registered */
        pcmcia_unregister_socket(&sock->socket);
-       
+
        /* Disable all events so we don't die in an IRQ storm */
        cb_writel(sock, CB_SOCKET_MASK, 0x0);
        exca_writeb(sock, I365_CSCINT, 0);
@@ -847,22 +912,12 @@ static struct cardbus_type cardbus_type[] = {
 };
 
 
-/*
- * Only probe "regular" interrupts, don't
- * touch dangerous spots like the mouse irq,
- * because there are mice that apparently
- * get really confused if they get fondled
- * too intimately.
- *
- * Default to 11, 10, 9, 7, 6, 5, 4, 3.
- */
-static u32 isa_interrupts = 0x0ef8;
-
 static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
 {
        int i;
        unsigned long val;
        u32 mask;
+       u8 reg;
 
        /*
         * Probe for usable interrupts using the force
@@ -870,6 +925,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
         */
        cb_writel(socket, CB_SOCKET_EVENT, -1);
        cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
+       reg = exca_readb(socket, I365_CSCINT);
        exca_writeb(socket, I365_CSCINT, 0);
        val = probe_irq_on() & isa_irq_mask;
        for (i = 1; i < 16; i++) {
@@ -881,7 +937,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
                cb_writel(socket, CB_SOCKET_EVENT, -1);
        }
        cb_writel(socket, CB_SOCKET_MASK, 0);
-       exca_writeb(socket, I365_CSCINT, 0);
+       exca_writeb(socket, I365_CSCINT, reg);
 
        mask = probe_irq_mask(val) & 0xffff;
 
@@ -889,18 +945,18 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
 }
 
 
-/**
+/*
  * yenta PCI irq probing.
  * currently only used in the TI/EnE initialization code
  */
 #ifdef CONFIG_YENTA_TI
 
 /* interrupt handler, only used during probing */
-static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t yenta_probe_handler(int irq, void *dev_id)
 {
        struct yenta_socket *socket = (struct yenta_socket *) dev_id;
        u8 csc;
-        u32 cb_event;
+       u32 cb_event;
 
        /* Clear interrupt status for the event */
        cb_event = cb_readl(socket, CB_SOCKET_EVENT);
@@ -918,18 +974,22 @@ static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *re
 /* probes the PCI interrupt, use only on override functions */
 static int yenta_probe_cb_irq(struct yenta_socket *socket)
 {
+       u8 reg;
+
        if (!socket->cb_irq)
                return -1;
 
        socket->probe_status = 0;
 
        if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) {
-               printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n");
+               dev_printk(KERN_WARNING, &socket->dev->dev,
+                          "request_irq() in yenta_probe_cb_irq() failed!\n");
                return -1;
        }
 
        /* generate interrupt, wait */
-       exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG);
+       reg = exca_readb(socket, I365_CSCINT);
+       exca_writeb(socket, I365_CSCINT, reg | I365_CSC_STSCHG);
        cb_writel(socket, CB_SOCKET_EVENT, -1);
        cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
        cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
@@ -938,7 +998,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
 
        /* disable interrupts */
        cb_writel(socket, CB_SOCKET_MASK, 0);
-       exca_writeb(socket, I365_CSCINT, 0);
+       exca_writeb(socket, I365_CSCINT, reg);
        cb_writel(socket, CB_SOCKET_EVENT, -1);
        exca_readb(socket, I365_CSC);
 
@@ -961,8 +1021,9 @@ static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_i
        else
                socket->socket.irq_mask = 0;
 
-       printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n",
-              socket->socket.irq_mask, socket->cb_irq);
+       dev_printk(KERN_INFO, &socket->dev->dev,
+                  "ISA IRQ mask 0x%04x, PCI irq %d\n",
+                  socket->socket.irq_mask, socket->cb_irq);
 }
 
 /*
@@ -1013,13 +1074,13 @@ static void yenta_config_init(struct yenta_socket *socket)
  * invisible during PCI scans because of a misconfigured subordinate number
  * of the parent brige - some BIOSes seem to be too lazy to set it right.
  * Does the fixup carefully by checking how far it can go without conflicts.
- * See http://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information.
+ * See http\://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information.
  */
 static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
 {
        struct list_head *tmp;
        unsigned char upper_limit;
-       /*
+       /*
         * We only check and fix the parent bridge: All systems which need
         * this fixup that have been reviewed are laptops and the only bridge
         * which needed fixing was the parent bridge of the CardBus bridge:
@@ -1038,7 +1099,7 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
 
        /* check the bus ranges of all silbling bridges to prevent overlap */
        list_for_each(tmp, &bridge_to_fix->parent->children) {
-               struct pci_bus * silbling = pci_bus_b(tmp);
+               struct pci_bus *silbling = pci_bus_b(tmp);
                /*
                 * If the silbling has a higher secondary bus number
                 * and it's secondary is equal or smaller than our
@@ -1052,8 +1113,9 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
 
        /* Show that the wanted subordinate number is not possible: */
        if (cardbus_bridge->subordinate > upper_limit)
-               printk(KERN_WARNING "Yenta: Upper limit for fixing this "
-                       "bridge's parent bridge: #%02x\n", upper_limit);
+               dev_printk(KERN_WARNING, &cardbus_bridge->dev,
+                          "Upper limit for fixing this "
+                          "bridge's parent bridge: #%02x\n", upper_limit);
 
        /* If we have room to increase the bridge's subordinate number, */
        if (bridge_to_fix->subordinate < upper_limit) {
@@ -1062,10 +1124,11 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
                unsigned char subordinate_to_assign =
                        min(cardbus_bridge->subordinate, upper_limit);
 
-               printk(KERN_INFO "Yenta: Raising subordinate bus# of parent "
-                       "bus (#%02x) from #%02x to #%02x\n",
-                       bridge_to_fix->number,
-                       bridge_to_fix->subordinate, subordinate_to_assign);
+               dev_printk(KERN_INFO, &bridge_to_fix->dev,
+                          "Raising subordinate bus# of parent "
+                          "bus (#%02x) from #%02x to #%02x\n",
+                          bridge_to_fix->number,
+                          bridge_to_fix->subordinate, subordinate_to_assign);
 
                /* Save the new subordinate in the bus struct of the bridge */
                bridge_to_fix->subordinate = subordinate_to_assign;
@@ -1081,7 +1144,7 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
  * interrupt, and that we can map the cardbus area. Fill in the
  * socket information structure..
  */
-static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_id *id)
+static int __devinit yenta_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
        struct yenta_socket *socket;
        int ret;
@@ -1092,8 +1155,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
         * Bail out if so.
         */
        if (!dev->subordinate) {
-               printk(KERN_ERR "Yenta: no bus associated with %s! "
-                       "(try 'pci=assign-busses')\n", pci_name(dev));
+               dev_printk(KERN_ERR, &dev->dev, "no bus associated! "
+                          "(try 'pci=assign-busses')\n");
                return -ENODEV;
        }
 
@@ -1104,7 +1167,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
        /* prepare pcmcia_socket */
        socket->socket.ops = &yenta_socket_operations;
        socket->socket.resource_ops = &pccard_nonstatic_ops;
-       socket->socket.dev.dev = &dev->dev;
+       socket->socket.dev.parent = &dev->dev;
        socket->socket.driver_data = socket;
        socket->socket.owner = THIS_MODULE;
        socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
@@ -1128,7 +1191,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
                goto disable;
 
        if (!pci_resource_start(dev, 0)) {
-               printk(KERN_ERR "No cardbus resource!\n");
+               dev_printk(KERN_ERR, &dev->dev, "No cardbus resource!\n");
                ret = -ENODEV;
                goto release;
        }
@@ -1147,8 +1210,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
         * report the subsystem vendor and device for help debugging
         * the irq stuff...
         */
-       printk(KERN_INFO "Yenta: CardBus bridge found at %s [%04x:%04x]\n",
-               pci_name(dev), dev->subsystem_vendor, dev->subsystem_device);
+       dev_printk(KERN_INFO, &dev->dev, "CardBus bridge found [%04x:%04x]\n",
+                  dev->subsystem_vendor, dev->subsystem_device);
 
        yenta_config_init(socket);
 
@@ -1180,8 +1243,12 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
                socket->poll_timer.data = (unsigned long)socket;
                socket->poll_timer.expires = jiffies + HZ;
                add_timer(&socket->poll_timer);
-               printk(KERN_INFO "Yenta: no PCI IRQ, CardBus support disabled for this socket.\n"
-                      KERN_INFO "Yenta: check your BIOS CardBus, BIOS IRQ or ACPI settings.\n");
+               dev_printk(KERN_INFO, &dev->dev,
+                          "no PCI IRQ, CardBus support disabled for this "
+                          "socket.\n");
+               dev_printk(KERN_INFO, &dev->dev,
+                          "check your BIOS CardBus, BIOS IRQ or ACPI "
+                          "settings.\n");
        } else {
                socket->socket.features |= SS_CAP_CARDBUS;
        }
@@ -1189,7 +1256,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
        /* Figure out what the dang thing can do for the PCMCIA layer... */
        yenta_interrogate(socket);
        yenta_get_socket_capabilities(socket, isa_interrupts);
-       printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
+       dev_printk(KERN_INFO, &dev->dev,
+                  "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
 
        yenta_fixup_parent_bridge(dev->subordinate);
 
@@ -1197,8 +1265,12 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
        ret = pcmcia_register_socket(&socket->socket);
        if (ret == 0) {
                /* Add the yenta register attributes */
-               device_create_file(&dev->dev, &dev_attr_yenta_registers);
-               goto out;
+               ret = device_create_file(&dev->dev, &dev_attr_yenta_registers);
+               if (ret == 0)
+                       goto out;
+
+               /* error path... */
+               pcmcia_unregister_socket(&socket->socket);
        }
 
  unmap:
@@ -1213,58 +1285,72 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
        return ret;
 }
 
-
-static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
+#ifdef CONFIG_PM
+static int yenta_dev_suspend_noirq(struct device *dev)
 {
-       struct yenta_socket *socket = pci_get_drvdata(dev);
-       int ret;
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct yenta_socket *socket = pci_get_drvdata(pdev);
 
-       ret = pcmcia_socket_dev_suspend(&dev->dev, state);
+       if (!socket)
+               return 0;
 
-       if (socket) {
-               if (socket->type && socket->type->save_state)
-                       socket->type->save_state(socket);
+       if (socket->type && socket->type->save_state)
+               socket->type->save_state(socket);
 
-               /* FIXME: pci_save_state needs to have a better interface */
-               pci_save_state(dev);
-               pci_read_config_dword(dev, 16*4, &socket->saved_state[0]);
-               pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
-               pci_disable_device(dev);
+       pci_save_state(pdev);
+       pci_read_config_dword(pdev, 16*4, &socket->saved_state[0]);
+       pci_read_config_dword(pdev, 17*4, &socket->saved_state[1]);
+       pci_disable_device(pdev);
 
-               /*
-                * Some laptops (IBM T22) do not like us putting the Cardbus
-                * bridge into D3.  At a guess, some other laptop will
-                * probably require this, so leave it commented out for now.
-                */
-               /* pci_set_power_state(dev, 3); */
-       }
+       /*
+        * Some laptops (IBM T22) do not like us putting the Cardbus
+        * bridge into D3.  At a guess, some other laptop will
+        * probably require this, so leave it commented out for now.
+        */
+       /* pci_set_power_state(dev, 3); */
 
-       return ret;
+       return 0;
 }
 
-
-static int yenta_dev_resume (struct pci_dev *dev)
+static int yenta_dev_resume_noirq(struct device *dev)
 {
-       struct yenta_socket *socket = pci_get_drvdata(dev);
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct yenta_socket *socket = pci_get_drvdata(pdev);
+       int ret;
 
-       if (socket) {
-               pci_set_power_state(dev, 0);
-               /* FIXME: pci_restore_state needs to have a better interface */
-               pci_restore_state(dev);
-               pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
-               pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
-               pci_enable_device(dev);
-               pci_set_master(dev);
-
-               if (socket->type && socket->type->restore_state)
-                       socket->type->restore_state(socket);
-       }
+       if (!socket)
+               return 0;
 
-       return pcmcia_socket_dev_resume(&dev->dev);
+       pci_write_config_dword(pdev, 16*4, socket->saved_state[0]);
+       pci_write_config_dword(pdev, 17*4, socket->saved_state[1]);
+
+       ret = pci_enable_device(pdev);
+       if (ret)
+               return ret;
+
+       pci_set_master(pdev);
+
+       if (socket->type && socket->type->restore_state)
+               socket->type->restore_state(socket);
+
+       return 0;
 }
 
+static const struct dev_pm_ops yenta_pm_ops = {
+       .suspend_noirq = yenta_dev_suspend_noirq,
+       .resume_noirq = yenta_dev_resume_noirq,
+       .freeze_noirq = yenta_dev_suspend_noirq,
+       .thaw_noirq = yenta_dev_resume_noirq,
+       .poweroff_noirq = yenta_dev_suspend_noirq,
+       .restore_noirq = yenta_dev_resume_noirq,
+};
+
+#define YENTA_PM_OPS   (&yenta_pm_ops)
+#else
+#define YENTA_PM_OPS   NULL
+#endif
 
-#define CB_ID(vend,dev,type)                           \
+#define CB_ID(vend, dev, type)                         \
        {                                               \
                .vendor         = vend,                 \
                .device         = dev,                  \
@@ -1275,7 +1361,7 @@ static int yenta_dev_resume (struct pci_dev *dev)
                .driver_data    = CARDBUS_TYPE_##type,  \
        }
 
-static struct pci_device_id yenta_table [] = {
+static struct pci_device_id yenta_table[] = {
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
 
        /*
@@ -1319,10 +1405,10 @@ static struct pci_device_id yenta_table [] = {
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7510, TI12XX),
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7610, TI12XX),
 
-       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_710, TI12XX),
-       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_712, TI12XX),
-       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_720, TI12XX),
-       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_722, TI12XX),
+       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_710, ENE),
+       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_712, ENE),
+       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_720, ENE),
+       CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_722, ENE),
        CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, ENE),
        CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE),
        CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE),
@@ -1359,20 +1445,19 @@ static struct pci_driver yenta_cardbus_driver = {
        .id_table       = yenta_table,
        .probe          = yenta_probe,
        .remove         = __devexit_p(yenta_close),
-       .suspend        = yenta_dev_suspend,
-       .resume         = yenta_dev_resume,
+       .driver.pm      = YENTA_PM_OPS,
 };
 
 
 static int __init yenta_socket_init(void)
 {
-       return pci_register_driver (&yenta_cardbus_driver);
+       return pci_register_driver(&yenta_cardbus_driver);
 }
 
 
-static void __exit yenta_socket_exit (void)
+static void __exit yenta_socket_exit(void)
 {
-       pci_unregister_driver (&yenta_cardbus_driver);
+       pci_unregister_driver(&yenta_cardbus_driver);
 }