Merge branch 'machtypes' into pxa-palm
[safe/jmp/linux-2.6] / drivers / pcmcia / yenta_socket.c
index 9fcd661..0ab1fb6 100644 (file)
@@ -12,7 +12,6 @@
  */
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/sched.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
@@ -49,7 +48,7 @@ MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only
 #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
  */
@@ -442,7 +441,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 +477,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);
 }
@@ -889,14 +888,14 @@ 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;
@@ -923,7 +922,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
 
        socket->probe_status = 0;
 
-       if (request_irq(socket->cb_irq, yenta_probe_handler, SA_SHIRQ, "yenta", socket)) {
+       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");
                return -1;
        }
@@ -1006,14 +1005,14 @@ static void yenta_config_init(struct yenta_socket *socket)
 }
 
 /**
- * yenta_fixup_parent_subordinate - Fix subordinate bus# of the parent bridge
+ * yenta_fixup_parent_bridge - Fix subordinate bus# of the parent bridge
  * @cardbus_bridge: The PCI bus which the CardBus bridge bridges to
  *
  * Checks if devices on the bus which the CardBus bridge bridges to would be
  * 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)
 {
@@ -1104,7 +1103,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;
@@ -1172,7 +1171,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
 
        /* We must finish initialization here */
 
-       if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, SA_SHIRQ, "yenta", socket)) {
+       if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, IRQF_SHARED, "yenta", socket)) {
                /* No IRQ or request_irq failed. Poll */
                socket->cb_irq = 0; /* But zero is a valid IRQ number. */
                init_timer(&socket->poll_timer);
@@ -1197,8 +1196,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,7 +1216,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
        return ret;
 }
 
-
+#ifdef CONFIG_PM
 static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
 {
        struct yenta_socket *socket = pci_get_drvdata(dev);
@@ -1248,12 +1251,18 @@ static int yenta_dev_resume (struct pci_dev *dev)
        struct yenta_socket *socket = pci_get_drvdata(dev);
 
        if (socket) {
+               int rc;
+
                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);
+
+               rc = pci_enable_device(dev);
+               if (rc)
+                       return rc;
+
                pci_set_master(dev);
 
                if (socket->type && socket->type->restore_state)
@@ -1262,7 +1271,7 @@ static int yenta_dev_resume (struct pci_dev *dev)
 
        return pcmcia_socket_dev_resume(&dev->dev);
 }
-
+#endif
 
 #define CB_ID(vend,dev,type)                           \
        {                                               \
@@ -1359,8 +1368,10 @@ static struct pci_driver yenta_cardbus_driver = {
        .id_table       = yenta_table,
        .probe          = yenta_probe,
        .remove         = __devexit_p(yenta_close),
+#ifdef CONFIG_PM
        .suspend        = yenta_dev_suspend,
        .resume         = yenta_dev_resume,
+#endif
 };