]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pcmcia/ds.c
USB: drivers/usb/misc: Use an IS_ERR test rather than a NULL test
[linux-2.6-omap-h63xx.git] / drivers / pcmcia / ds.c
index 3ccf4091e8775bd6e568dfcdf0afa43759acd3d3..7956602554901297f86055cea142707f7eead769 100644 (file)
@@ -32,7 +32,6 @@
 #include <pcmcia/ss.h>
 
 #include "cs_internal.h"
-#include "ds_internal.h"
 
 /*====================================================================*/
 
@@ -69,8 +68,8 @@ spinlock_t pcmcia_dev_list_lock;
 /* String tables for error messages */
 
 typedef struct lookup_t {
-    int key;
-    char *msg;
+    const int key;
+    const char *msg;
 } lookup_t;
 
 static const lookup_t error_table[] = {
@@ -78,12 +77,10 @@ static const lookup_t error_table[] = {
     { -EIO,                    "Input/Output error" },
     { -ENODEV,                 "No card present" },
     { -EINVAL,                 "Bad parameter" },
-    { CS_BAD_ARGS,             "Bad arguments" },
     { -EACCES,                 "Configuration locked" },
     { -EBUSY,                  "Resource in use" },
     { -ENOSPC,                 "No more items" },
     { -ENOMEM,                 "Out of resource" },
-    { CS_BAD_TUPLE,            "Bad CIS tuple" }
 };
 
 
@@ -139,46 +136,32 @@ static const lookup_t service_table[] = {
     { ReplaceCIS,                      "ReplaceCIS" }
 };
 
-
-static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err)
+const char *pcmcia_error_func(int func)
 {
        int i;
-       char *serv;
-
-       if (!p_dev)
-               printk(KERN_NOTICE);
-       else
-               printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id);
 
        for (i = 0; i < ARRAY_SIZE(service_table); i++)
-               if (service_table[i].key == err->func)
-                       break;
-       if (i < ARRAY_SIZE(service_table))
-               serv = service_table[i].msg;
-       else
-               serv = "Unknown service number";
+               if (service_table[i].key == func)
+                       return service_table[i].msg;
 
-       for (i = 0; i < ARRAY_SIZE(error_table); i++)
-               if (error_table[i].key == err->retcode)
-                       break;
-       if (i < ARRAY_SIZE(error_table))
-               printk("%s: %s\n", serv, error_table[i].msg);
-       else
-               printk("%s: Unknown error code %#x\n", serv, err->retcode);
+       return "Unknown service number";
+}
+EXPORT_SYMBOL(pcmcia_error_func);
 
-       return 0;
-} /* report_error */
+const char *pcmcia_error_ret(int ret)
+{
+       int i;
 
-/* end of code which was in cs.c before */
+       for (i = 0; i < ARRAY_SIZE(error_table); i++)
+               if (error_table[i].key == ret)
+                       return error_table[i].msg;
+
+       return "unknown";
+}
+EXPORT_SYMBOL(pcmcia_error_ret);
 
 /*======================================================================*/
 
-void cs_error(struct pcmcia_device *p_dev, int func, int ret)
-{
-       error_info_t err = { func, ret };
-       pcmcia_report_error(p_dev, &err);
-}
-EXPORT_SYMBOL(cs_error);
 
 
 static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
@@ -411,6 +394,18 @@ static int pcmcia_device_probe(struct device * dev)
        p_drv = to_pcmcia_drv(dev->driver);
        s = p_dev->socket;
 
+       /* The PCMCIA code passes the match data in via dev->driver_data
+        * which is an ugly hack. Once the driver probe is called it may
+        * and often will overwrite the match data so we must save it first
+        *
+        * handle pseudo multifunction devices:
+        * there are at most two pseudo multifunction devices.
+        * if we're matching against the first, schedule a
+        * call which will then check whether there are two
+        * pseudo devices, and if not, add the second one.
+        */
+       did = p_dev->dev.driver_data;
+
        ds_dev_dbg(1, dev, "trying to bind to %s\n", p_drv->drv.name);
 
        if ((!p_drv->probe) || (!p_dev->function_config) ||
@@ -439,21 +434,14 @@ static int pcmcia_device_probe(struct device * dev)
                goto put_module;
        }
 
-       /* handle pseudo multifunction devices:
-        * there are at most two pseudo multifunction devices.
-        * if we're matching against the first, schedule a
-        * call which will then check whether there are two
-        * pseudo devices, and if not, add the second one.
-        */
-       did = p_dev->dev.driver_data;
        if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
            (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
                pcmcia_add_device_later(p_dev->socket, 0);
 
- put_module:
+put_module:
        if (ret)
                module_put(p_drv->owner);
- put_dev:
+put_dev:
        if (ret)
                put_device(dev);
        return (ret);