Freezer: make kernel threads nonfreezable by default
[linux-2.6-block.git] / drivers / pnp / pnpbios / core.c
index 33adeba1a31f1c87930e1266989a44b36b9f775e..03baf1c64a2e04fa2307f37b504b3862e9837350 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/delay.h>
 #include <linux/acpi.h>
 #include <linux/freezer.h>
+#include <linux/kthread.h>
 
 #include <asm/page.h>
 #include <asm/desc.h>
@@ -109,10 +110,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
        if (!current->fs->root) {
                return -EAGAIN;
        }
-       if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) {
+       if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) {
                return -ENOMEM;
        }
-       if (!(buf = kcalloc (1, 256, GFP_KERNEL))) {
+       if (!(buf = kzalloc(256, GFP_KERNEL))) {
                kfree (envp);
                return -ENOMEM;
        }
@@ -159,9 +160,8 @@ static int pnp_dock_thread(void * unused)
 {
        static struct pnp_docking_station_info now;
        int docked = -1, d = 0;
-       daemonize("kpnpbiosd");
-       allow_signal(SIGKILL);
-       while(!unloading && !signal_pending(current))
+       set_freezable();
+       while (!unloading)
        {
                int status;
                
@@ -170,11 +170,8 @@ static int pnp_dock_thread(void * unused)
                 */
                msleep_interruptible(2000);
 
-               if(signal_pending(current)) {
-                       if (try_to_freeze())
-                               continue;
-                       break;
-               }
+               if (try_to_freeze())
+                       continue;
 
                status = pnp_bios_dock_station_info(&now);
 
@@ -220,7 +217,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
        if(!pnpbios_is_dynamic(dev))
                return -EPERM;
 
-       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
+       node = kzalloc(node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -1;
        if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
@@ -243,7 +240,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
        if (!pnpbios_is_dynamic(dev))
                return -EPERM;
 
-       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
+       node = kzalloc(node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -1;
        if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
@@ -294,7 +291,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
        if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
                return -EPERM;
 
-       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
+       node = kzalloc(node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -ENOMEM;
 
@@ -336,7 +333,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
        }
 
        /* set the initial values for the PnP device */
-       dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
+       dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
        if (!dev_id)
                return -1;
        pnpid32_to_pnpid(node->eisa_id,id);
@@ -374,7 +371,7 @@ static void __init build_devlist(void)
        struct pnp_bios_node *node;
        struct pnp_dev *dev;
 
-       node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
+       node = kzalloc(node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return;
 
@@ -391,7 +388,7 @@ static void __init build_devlist(void)
                                break;
                }
                nodes_got++;
-               dev =  kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL);
+               dev =  kzalloc(sizeof (struct pnp_dev), GFP_KERNEL);
                if (!dev)
                        break;
                if(insert_device(dev,node)<0)
@@ -574,6 +571,7 @@ static int __init pnpbios_init(void)
        /* scan for pnpbios devices */
        build_devlist();
 
+       pnp_platform_devices = 1;
        return 0;
 }
 
@@ -581,6 +579,7 @@ subsys_initcall(pnpbios_init);
 
 static int __init pnpbios_thread_init(void)
 {
+       struct task_struct *task;
 #if defined(CONFIG_PPC_MERGE)
        if (check_legacy_ioport(PNPBIOS_BASE))
                return 0;
@@ -589,7 +588,8 @@ static int __init pnpbios_thread_init(void)
                return 0;
 #ifdef CONFIG_HOTPLUG
        init_completion(&unload_sem);
-       if (kernel_thread(pnp_dock_thread, NULL, CLONE_KERNEL) > 0)
+       task = kthread_run(pnp_dock_thread, NULL, "kpnpbiosd");
+       if (!IS_ERR(task))
                unloading = 0;
 #endif
        return 0;