]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/message/i2o/driver.c
Merge branch 'fixes-davem' of master.kernel.org:/pub/scm/linux/kernel/git/linville...
[linux-2.6-omap-h63xx.git] / drivers / message / i2o / driver.c
index 739bfdef0c6d04b5d96a70aa333d276a8874bf6d..e0d474b174336ba20c7c714e356aabc09a715e07 100644 (file)
@@ -17,6 +17,9 @@
 #include <linux/module.h>
 #include <linux/rwsem.h>
 #include <linux/i2o.h>
+#include <linux/workqueue.h>
+#include <linux/string.h>
+#include <linux/slab.h>
 #include "core.h"
 
 #define OSM_NAME       "i2o"
@@ -31,9 +34,7 @@ static spinlock_t i2o_drivers_lock;
 static struct i2o_driver **i2o_drivers;
 
 /**
- *     i2o_bus_match - Tell if a I2O device class id match the class ids of
- *                     the I2O driver (OSM)
- *
+ *     i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
  *     @dev: device which should be verified
  *     @drv: the driver to match against
  *
@@ -61,6 +62,7 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv)
 struct bus_type i2o_bus_type = {
        .name = "i2o",
        .match = i2o_bus_match,
+       .dev_attrs = i2o_device_attrs
 };
 
 /**
@@ -121,8 +123,12 @@ int i2o_driver_register(struct i2o_driver *drv)
        }
 
        rc = driver_register(&drv->driver);
-       if (rc)
-               destroy_workqueue(drv->event_queue);
+       if (rc) {
+               if (drv->event) {
+                       destroy_workqueue(drv->event_queue);
+                       drv->event_queue = NULL;
+               }
+       }
 
        return rc;
 };
@@ -213,14 +219,14 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
                /* cut of header from message size (in 32-bit words) */
                size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5;
 
-               evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC | __GFP_ZERO);
+               evt = kzalloc(size * 4 + sizeof(*evt), GFP_ATOMIC);
                if (!evt)
                        return -ENOMEM;
 
                evt->size = size;
                evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt);
                evt->event_indicator = le32_to_cpu(msg->body[0]);
-               memcpy(&evt->tcntxt, &msg->u.s.tcntxt, size * 4);
+               memcpy(&evt->data, &msg->body[1], size * 4);
 
                list_for_each_entry_safe(dev, tmp, &c->devices, list)
                    if (dev->lct_data.tid == tid) {
@@ -228,7 +234,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
                        break;
                }
 
-               INIT_WORK(&evt->work, (void (*)(void *))drv->event, evt);
+               INIT_WORK(&evt->work, drv->event);
                queue_work(drv->event_queue, &evt->work);
                return 1;
        }
@@ -244,7 +250,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
 
 /**
  *     i2o_driver_notify_controller_add_all - Send notify of added controller
- *                                            to all I2O drivers
+ *     @c: newly added controller
  *
  *     Send notifications to all registered drivers that a new controller was
  *     added.
@@ -254,7 +260,7 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
        int i;
        struct i2o_driver *drv;
 
-       for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+       for (i = 0; i < i2o_max_drivers; i++) {
                drv = i2o_drivers[i];
 
                if (drv)
@@ -263,8 +269,8 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
 }
 
 /**
- *     i2o_driver_notify_controller_remove_all - Send notify of removed
- *                                               controller to all I2O drivers
+ *     i2o_driver_notify_controller_remove_all - Send notify of removed controller
+ *     @c: controller that is being removed
  *
  *     Send notifications to all registered drivers that a controller was
  *     removed.
@@ -274,7 +280,7 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
        int i;
        struct i2o_driver *drv;
 
-       for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+       for (i = 0; i < i2o_max_drivers; i++) {
                drv = i2o_drivers[i];
 
                if (drv)
@@ -283,8 +289,8 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
 }
 
 /**
- *     i2o_driver_notify_device_add_all - Send notify of added device to all
- *                                        I2O drivers
+ *     i2o_driver_notify_device_add_all - Send notify of added device
+ *     @i2o_dev: newly added I2O device
  *
  *     Send notifications to all registered drivers that a device was added.
  */
@@ -293,7 +299,7 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
        int i;
        struct i2o_driver *drv;
 
-       for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+       for (i = 0; i < i2o_max_drivers; i++) {
                drv = i2o_drivers[i];
 
                if (drv)
@@ -302,8 +308,8 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
 }
 
 /**
- *     i2o_driver_notify_device_remove_all - Send notify of removed device to
- *                                           all I2O drivers
+ *     i2o_driver_notify_device_remove_all - Send notify of removed device
+ *     @i2o_dev: device that is being removed
  *
  *     Send notifications to all registered drivers that a device was removed.
  */
@@ -312,7 +318,7 @@ void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev)
        int i;
        struct i2o_driver *drv;
 
-       for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+       for (i = 0; i < i2o_max_drivers; i++) {
                drv = i2o_drivers[i];
 
                if (drv)
@@ -333,22 +339,18 @@ int __init i2o_driver_init(void)
 
        spin_lock_init(&i2o_drivers_lock);
 
-       if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
-           ((i2o_max_drivers ^ (i2o_max_drivers - 1)) !=
-            (2 * i2o_max_drivers - 1))) {
-               osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
-                        "a power of 2\n", i2o_max_drivers);
+       if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64)) {
+               osm_warn("max_drivers set to %d, but must be >=2 and <= 64\n",
+                        i2o_max_drivers);
                i2o_max_drivers = I2O_MAX_DRIVERS;
        }
        osm_info("max drivers = %d\n", i2o_max_drivers);
 
        i2o_drivers =
-           kmalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL);
+           kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL);
        if (!i2o_drivers)
                return -ENOMEM;
 
-       memset(i2o_drivers, 0, i2o_max_drivers * sizeof(*i2o_drivers));
-
        rc = bus_register(&i2o_bus_type);
 
        if (rc < 0)
@@ -360,9 +362,9 @@ int __init i2o_driver_init(void)
 /**
  *     i2o_driver_exit - clean up I2O drivers (OSMs)
  *
- *     Unregisters the I2O bus and free driver array.
+ *     Unregisters the I2O bus and frees driver array.
  */
-void __exit i2o_driver_exit(void)
+void i2o_driver_exit(void)
 {
        bus_unregister(&i2o_bus_type);
        kfree(i2o_drivers);