[PATCH 1/4] i2c: adapter: register it's own device
Sascha Hauer
s.hauer at pengutronix.de
Fri Nov 2 03:29:40 EDT 2012
On Thu, Nov 01, 2012 at 10:44:49AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> so we can show the this of i2c busses
> set the bus device as parent of all devices.
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
> drivers/i2c/busses/i2c-imx.c | 20 ++++++++++----------
> drivers/i2c/busses/i2c-omap.c | 30 +++++++++++++++---------------
> drivers/i2c/i2c.c | 18 +++++++++++++++---
> include/i2c/i2c.h | 2 +-
> 4 files changed, 41 insertions(+), 29 deletions(-)
>
> int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
> {
> - if (i2c_get_adapter(adapter->nr))
> - return -EBUSY;
If you remove this and instead depend on register_device bailing out
later then you should change the error value register_device returns
to -EBUSY. Currently it returns -EINVAL, -EBUSY seems much better here.
> + int ret;
> +
> + adapter->dev.id = adapter->nr;
> + strcpy(adapter->dev.name, "i2c");
> +
> + if (adapter->dev.parent)
> + dev_add_child(adapter->dev.parent, &adapter->dev);
We should push the dev_add_child to the driver core. Doing this here
means that...
> +
> + ret = register_device(&adapter->dev);
> + if (ret)
> + return ret;
... the parents child list will be corrupted when register_device fails.
At least w1 and mdiobus have the same problem. But ok, we can fix that
later.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list