Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mcb: Correctly initialize the bus's device

The mcb bus' device member wasn't correctly initialized and thus wasn't placed
correctly into the driver model.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Andreas Werner <andreas.werner@men.de>
Tested-by: Andreas Werner <andreas.werner@men.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johannes Thumshirn and committed by
Greg Kroah-Hartman
18d28819 bc46b45a

+18 -6
+16 -3
drivers/mcb/mcb-core.c
··· 187 187 { 188 188 struct mcb_bus *bus; 189 189 int bus_nr; 190 + int rc; 190 191 191 192 bus = kzalloc(sizeof(struct mcb_bus), GFP_KERNEL); 192 193 if (!bus) ··· 195 194 196 195 bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL); 197 196 if (bus_nr < 0) { 198 - kfree(bus); 199 - return ERR_PTR(bus_nr); 197 + rc = bus_nr; 198 + goto err_free; 200 199 } 201 200 202 - INIT_LIST_HEAD(&bus->children); 203 201 bus->bus_nr = bus_nr; 204 202 bus->carrier = carrier; 203 + 204 + device_initialize(&bus->dev); 205 + bus->dev.parent = carrier; 206 + bus->dev.bus = &mcb_bus_type; 207 + 208 + dev_set_name(&bus->dev, "mcb:%d", bus_nr); 209 + rc = device_add(&bus->dev); 210 + if (rc) 211 + goto err_free; 212 + 205 213 return bus; 214 + err_free: 215 + kfree(bus); 216 + return ERR_PTR(rc); 206 217 } 207 218 EXPORT_SYMBOL_GPL(mcb_alloc_bus); 208 219
+2 -3
include/linux/mcb.h
··· 21 21 /** 22 22 * struct mcb_bus - MEN Chameleon Bus 23 23 * 24 - * @dev: pointer to carrier device 25 - * @children: the child busses 24 + * @dev: bus device 25 + * @carrier: pointer to carrier device 26 26 * @bus_nr: mcb bus number 27 27 * @get_irq: callback to get IRQ number 28 28 */ 29 29 struct mcb_bus { 30 - struct list_head children; 31 30 struct device dev; 32 31 struct device *carrier; 33 32 int bus_nr;