Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-drm-fsl-dcu.git] / net / atm / resources.c
index 18ac80698f835906cab6cd9f45971892ef42d46b..1bcf6dc8d40988b1f4a1e5198bfed470edb3e229 100644 (file)
@@ -8,7 +8,6 @@
  *          use the default destruct function initialized by sock_init_data */
 
 
-#include <linux/config.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/atmdev.h>
@@ -34,10 +33,9 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
 {
        struct atm_dev *dev;
 
-       dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return NULL;
-       memset(dev, 0, sizeof(*dev));
        dev->type = type;
        dev->signal = ATM_PHY_SIG_UNKNOWN;
        dev->link_rate = ATM_OC3_PCR;
@@ -114,14 +112,27 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
                printk(KERN_ERR "atm_dev_register: "
                       "atm_proc_dev_register failed for dev %s\n",
                       type);
-               mutex_unlock(&atm_dev_mutex);
-               kfree(dev);
-               return NULL;
+               goto out_fail;
        }
+
+       if (atm_register_sysfs(dev) < 0) {
+               printk(KERN_ERR "atm_dev_register: "
+                      "atm_register_sysfs failed for dev %s\n",
+                      type);
+               atm_proc_dev_deregister(dev);
+               goto out_fail;
+       }
+
        list_add_tail(&dev->dev_list, &atm_devs);
-       mutex_unlock(&atm_dev_mutex);
 
+out:
+       mutex_unlock(&atm_dev_mutex);
        return dev;
+
+out_fail:
+       kfree(dev);
+       dev = NULL;
+       goto out;
 }
 
 
@@ -131,8 +142,8 @@ void atm_dev_deregister(struct atm_dev *dev)
        set_bit(ATM_DF_REMOVED, &dev->flags);
 
        /*
-        * if we remove current device from atm_devs list, new device 
-        * with same number can appear, such we need deregister proc, 
+        * if we remove current device from atm_devs list, new device
+        * with same number can appear, such we need deregister proc,
         * release async all vccs and remove them from vccs list too
         */
        mutex_lock(&atm_dev_mutex);
@@ -140,6 +151,7 @@ void atm_dev_deregister(struct atm_dev *dev)
        mutex_unlock(&atm_dev_mutex);
 
        atm_dev_release_vccs(dev);
+       atm_unregister_sysfs(dev);
        atm_proc_dev_deregister(dev);
 
        atm_dev_put(dev);
@@ -216,7 +228,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
                                *tmp_p++ = dev->number;
                        }
                        mutex_unlock(&atm_dev_mutex);
-                       error = ((copy_to_user(buf, tmp_buf, size)) ||
+                       error = ((copy_to_user(buf, tmp_buf, size)) ||
                                        put_user(size, &iobuf->length))
                                                ? -EFAULT : 0;
                        kfree(tmp_buf);
@@ -235,7 +247,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
        if (!(dev = try_then_request_module(atm_dev_lookup(number),
                                            "atm-device-%d", number)))
                return -ENODEV;
-       
+
        switch (cmd) {
                case ATM_GETTYPE:
                        size = strlen(dev->type) + 1;
@@ -378,7 +390,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
                                goto done;
                        }
        }
-       
+
        if (size)
                error = put_user(size, &sioc->length)
                        ? -EFAULT : 0;
@@ -402,15 +414,15 @@ static __inline__ void *dev_get_idx(loff_t left)
 
 void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos)
 {
-       mutex_lock(&atm_dev_mutex);
+       mutex_lock(&atm_dev_mutex);
        return *pos ? dev_get_idx(*pos) : (void *) 1;
 }
 
 void atm_dev_seq_stop(struct seq_file *seq, void *v)
 {
-       mutex_unlock(&atm_dev_mutex);
+       mutex_unlock(&atm_dev_mutex);
 }
+
 void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;