]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/pnp/pnpbios/core.c
[PATCH] Fix swsusp with PNP BIOS
[karo-tx-linux.git] / drivers / pnp / pnpbios / core.c
index 778a324028f4135bdb90bb4e655bac513c17e43d..551f58e298106060b5708cb288d04c8c7da39043 100644 (file)
@@ -56,7 +56,6 @@
 #include <linux/mm.h>
 #include <linux/smp.h>
 #include <linux/slab.h>
-#include <linux/kobject_uevent.h>
 #include <linux/completion.h>
 #include <linux/spinlock.h>
 #include <linux/dmi.h>
@@ -86,16 +85,6 @@ int pnp_bios_present(void)
 
 struct pnp_dev_node_info node_info;
 
-void *pnpbios_kmalloc(size_t size, int f)
-{
-       void *p = kmalloc( size, f );
-       if ( p == NULL )
-               printk(KERN_ERR "PnPBIOS: kmalloc() failed\n");
-       else
-               memset(p, 0, size);
-       return p;
-}
-
 /*
  *
  * DOCKING FUNCTIONS
@@ -116,21 +105,20 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
        char *argv [3], **envp, *buf, *scratch;
        int i = 0, value;
 
-       if (!hotplug_path [0])
-               return -ENOENT;
        if (!current->fs->root) {
                return -EAGAIN;
        }
-       if (!(envp = (char **) pnpbios_kmalloc (20 * sizeof (char *), GFP_KERNEL))) {
+       if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) {
                return -ENOMEM;
        }
-       if (!(buf = pnpbios_kmalloc (256, GFP_KERNEL))) {
+       if (!(buf = kcalloc (1, 256, GFP_KERNEL))) {
                kfree (envp);
                return -ENOMEM;
        }
 
-       /* only one standardized param to hotplug command: type */
-       argv [0] = hotplug_path;
+       /* FIXME: if there are actual users of this, it should be integrated into
+        * the driver core and use the usual infrastructure like sysfs and uevents */
+       argv [0] = "/sbin/pnpbios";
        argv [1] = "dock";
        argv [2] = NULL;
 
@@ -231,7 +219,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
        if(!pnpbios_is_dynamic(dev))
                return -EPERM;
 
-       node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
+       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -1;
        if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
@@ -254,7 +242,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
        if (!pnpbios_is_dynamic(dev))
                return -EPERM;
 
-       node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
+       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -1;
        if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
@@ -305,7 +293,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
        if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
                return -EPERM;
 
-       node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
+       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -ENOMEM;
 
@@ -347,7 +335,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
        }
 
        /* set the initial values for the PnP device */
-       dev_id = pnpbios_kmalloc(sizeof(struct pnp_id), GFP_KERNEL);
+       dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
        if (!dev_id)
                return -1;
        pnpid32_to_pnpid(node->eisa_id,id);
@@ -358,7 +346,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
        dev->flags = node->flags;
        if (!(dev->flags & PNPBIOS_NO_CONFIG))
                dev->capabilities |= PNP_CONFIGURABLE;
-       if (!(dev->flags & PNPBIOS_NO_DISABLE))
+       if (!(dev->flags & PNPBIOS_NO_DISABLE) && pnpbios_is_dynamic(dev))
                dev->capabilities |= PNP_DISABLE;
        dev->capabilities |= PNP_READ;
        if (pnpbios_is_dynamic(dev))
@@ -385,7 +373,7 @@ static void __init build_devlist(void)
        struct pnp_bios_node *node;
        struct pnp_dev *dev;
 
-       node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
+       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return;
 
@@ -402,7 +390,7 @@ static void __init build_devlist(void)
                                break;
                }
                nodes_got++;
-               dev =  pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL);
+               dev =  kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL);
                if (!dev)
                        break;
                if(insert_device(dev,node)<0)