Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1393128
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/6] mcb: Correctly initialize the bus's device |
| Date | 2016-05-03 09:50 +0200 |
| Message-ID | <ruDfI-3LT-37@gated-at.bofh.it> (permalink) |
| References | <ruDfH-3LT-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
drivers/mcb/mcb-core.c | 19 ++++++++++++++++---
include/linux/mcb.h | 5 ++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index a4be451..1e336cc 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -187,6 +187,7 @@ 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)
@@ -194,14 +195,26 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
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);
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ed06e15..3efafbc 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -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;
--
2.8.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/6] MCB patches for v4.7 Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 09:50 +0200
[PATCH 1/6] mcb: Correctly initialize the bus's device Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 09:50 +0200
Re: [PATCH 0/6] MCB patches for v4.7 Johannes Thumshirn <jthmshirn@suse.de> - 2016-05-03 10:10 +0200
Re: [PATCH 0/6] MCB patches for v4.7 Greg KH <gregkh@linuxfoundation.org> - 2016-05-04 01:00 +0200
[PATCH 6/6] mcb: Implement bus->dev.release callback Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
[PATCH 5/6] mcb: Delete num_cells variable which is not required Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
[PATCH 4/6] mcb: Replace ioremap and request_region with the devm version Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
[PATCH 3/6] mcb: Fixed bar number assignment for the gdd Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
csiph-web