mutex_unlock(&vme_buses_lock);
}
+static void vme_dev_release(struct device *dev)
+{
+ kfree(dev);
+}
+
int vme_register_bridge(struct vme_bridge *bridge)
{
struct device *dev;
* specification.
*/
for (i = 0; i < VME_SLOTS_MAX; i++) {
- dev = &bridge->dev[i];
+ bridge->dev[i] = kzalloc(sizeof(struct device), GFP_KERNEL);
+ if (!bridge->dev[i]) {
+ retval = -ENOMEM;
+ goto err_devalloc;
+ }
+ dev = bridge->dev[i];
memset(dev, 0, sizeof(struct device));
dev->parent = bridge->parent;
dev->bus = &vme_bus_type;
+ dev->release = vme_dev_release;
/*
* We save a pointer to the bridge in platform_data so that we
* can get to it later. We keep driver_data for use by the
return retval;
err_reg:
+ kfree(dev);
+err_devalloc:
while (--i >= 0) {
- dev = &bridge->dev[i];
+ dev = bridge->dev[i];
device_unregister(dev);
}
vme_remove_bus(bridge);
for (i = 0; i < VME_SLOTS_MAX; i++) {
- dev = &bridge->dev[i];
+ dev = bridge->dev[i];
device_unregister(dev);
}
vme_remove_bus(bridge);
/* Determine slot number */
num = 0;
while (num < VME_SLOTS_MAX) {
- if (&bridge->dev[num] == dev)
+ if (bridge->dev[num] == dev)
break;
num++;
void *driver_priv; /* Private pointer for the bridge driver */
struct list_head bus_list; /* list of VME buses */
- struct device dev[VME_SLOTS_MAX]; /* Device registered with
+ struct device *dev[VME_SLOTS_MAX]; /* Device registered with
* device model on VME bus
*/