Skip to content

Commit

Permalink
mcb: Correctly initialize the bus's device
Browse files Browse the repository at this point in the history
The mcb bus' device member wasn't correctly initialized and thus wasn't placed
correctly into the driver model.

Signed-off-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Andreas Werner <[email protected]>
Tested-by: Andreas Werner <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Johannes Thumshirn authored and gregkh committed May 3, 2016
1 parent bc46b45 commit 18d2881
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
19 changes: 16 additions & 3 deletions drivers/mcb/mcb-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,34 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
{
struct mcb_bus *bus;
int bus_nr;
int rc;

bus = kzalloc(sizeof(struct mcb_bus), GFP_KERNEL);
if (!bus)
return ERR_PTR(-ENOMEM);

bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL);
if (bus_nr < 0) {
kfree(bus);
return ERR_PTR(bus_nr);
rc = bus_nr;
goto err_free;
}

INIT_LIST_HEAD(&bus->children);
bus->bus_nr = bus_nr;
bus->carrier = carrier;

device_initialize(&bus->dev);
bus->dev.parent = carrier;
bus->dev.bus = &mcb_bus_type;

dev_set_name(&bus->dev, "mcb:%d", bus_nr);
rc = device_add(&bus->dev);
if (rc)
goto err_free;

return bus;
err_free:
kfree(bus);
return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(mcb_alloc_bus);

Expand Down
5 changes: 2 additions & 3 deletions include/linux/mcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ struct mcb_device;
/**
* struct mcb_bus - MEN Chameleon Bus
*
* @dev: pointer to carrier device
* @children: the child busses
* @dev: bus device
* @carrier: pointer to carrier device
* @bus_nr: mcb bus number
* @get_irq: callback to get IRQ number
*/
struct mcb_bus {
struct list_head children;
struct device dev;
struct device *carrier;
int bus_nr;
Expand Down

0 comments on commit 18d2881

Please sign in to comment.