staging: unisys: Use kzalloc instead of kmalloc/memset
[cascardo/linux.git] / drivers / staging / unisys / visorbus / visorbus_main.c
index 22c6150..2c46745 100644 (file)
@@ -70,7 +70,6 @@ static const struct attribute_group *visorbus_bus_groups[] = {
        NULL,
 };
 
-
 /** This describes the TYPE of bus.
  *  (Don't confuse this with an INSTANCE of the bus.)
  */
@@ -282,12 +281,11 @@ devmajorminor_create_file(struct visor_device *dev, const char *name,
                rc = -ENOMEM;
                goto away;
        }
-       myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
+       myattr = kzalloc(sizeof(*myattr), GFP_KERNEL);
        if (!myattr) {
                rc = -ENOMEM;
                goto away;
        }
-       memset(myattr, 0, sizeof(struct devmajorminor_attribute));
        myattr->show = DEVMAJORMINOR_ATTR;
        myattr->store = NULL;
        myattr->slot = slot;
@@ -320,7 +318,7 @@ devmajorminor_remove_file(struct visor_device *dev, int slot)
        if (slot < 0 || slot >= maxdevnodes)
                return;
        myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr);
-       if (myattr)
+       if (!myattr)
                return;
        sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr);
        kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE);
@@ -472,6 +470,7 @@ static struct attribute *channel_attrs[] = {
                &dev_attr_typeguid.attr,
                &dev_attr_zoneguid.attr,
                &dev_attr_typename.attr,
+               NULL
 };
 
 static struct attribute_group channel_attr_grp = {
@@ -745,19 +744,6 @@ visordriver_probe_device(struct device *xdev)
 away:
        if (rc != 0)
                put_device(&dev->device);
-       /*  We could get here more than once if the child driver module is
-        *  unloaded and re-loaded while devices are present.  That's why we
-        *  need a flag to be sure that we only respond to the device_create
-        *  once.  We cannot respond to the device_create prior to here,
-        *  because until we call drv->probe() above, the channel has not been
-        *  initialized.
-        */
-       if (!dev->responded_to_device_create) {
-
-               dev->responded_to_device_create = true;
-               if (chipset_responders.device_create)
-                       (*chipset_responders.device_create)(dev, rc);
-       }
        return rc;
 }
 
@@ -768,7 +754,6 @@ away:
 static int
 visordriver_remove_device(struct device *xdev)
 {
-       int rc = 0;
        struct visor_device *dev;
        struct visor_driver *drv;
 
@@ -791,7 +776,7 @@ visordriver_remove_device(struct device *xdev)
 
        put_device(&dev->device);
 
-       return rc;
+       return 0;
 }
 
 /** A particular type of visor driver calls this function to register
@@ -1306,15 +1291,15 @@ chipset_device_create(struct visor_device *dev_info)
                         POSTCODE_SEVERITY_INFO);
 
        rc = create_visor_device(dev_info);
-       if (rc < 0) {
+       if (chipset_responders.device_create)
+               chipset_responders.device_create(dev_info, rc);
+
+       if (rc < 0)
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
-               if (chipset_responders.device_create)
-                       (*chipset_responders.device_create)(dev_info, rc);
-       }
-
-       POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
-                        POSTCODE_SEVERITY_INFO);
+       else
+               POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
+                                POSTCODE_SEVERITY_INFO);
 }
 
 static void