i2c: mux: Allow muxes to work as children of i2c bus without i2c-parent
PATCH v2 1/1 i2c: mux: Allow muxes to work as children of i2c bus without i2c-parent
For mux check if the parent is already a device of UCLASS_I2C and if yes just use that. Otherwise see if someone specified an i2c-parent phandle. This mimics the behavior found in the Kernel, as it removes the requirement to explicitly specify a i2c-parent phandle.
---
Changes from v1:
- Fixed comment style (Michal)
--- drivers/i2c/muxes/i2c-mux-uclass.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/i2c/muxes/i2c-mux-uclass.c +10 -0
@@ -86,6 +86,16 @@ static int i2c_mux_post_probe(struct udevice *mux)debug ("%s: %s\n" , __func__, mux->name); priv->selected =-1 ; +/* if parent is of i2c uclass already, we'll take that, otherwise +* look if we find an i2c-parent phandle +*/ +if (UCLASS_I2C ==device_get_uclass_id (mux->parent)) { + priv->i2c_bus =dev_get_parent (mux); +debug ("%s: bus=%p/%s\n" , __func__, priv->i2c_bus, + priv->i2c_bus->name); +return 0 ; + } + ret =uclass_get_device_by_phandle (UCLASS_I2C , mux,"i2c-parent" , &priv->i2c_bus);if (ret)
Signature · 1 line
2.7.4
PATCH v2 1/1 i2c: mux: Allow muxes to work as children of i2c bus without i2c-parent
Quoted 11 lines · Moritz Fischer
For mux check if the parent is already a device of
UCLASS_I2Cand if yes just use that. Otherwise see if someone specified an i2c-parent phandle. This mimics the behavior found in the Kernel, as it removes the requirement to explicitly specify a i2c-parent phandle.Signed-off-by Moritz Fischer <[email protected]>Cc Heiko Schocher <[email protected]>Cc Bin Meng <[email protected]>Cc Simon Glass <[email protected]>Cc Michal Simek <[email protected]>Cc u-boot at lists.denx.de
Quoted 6 lines
---
Changes from v1:
- Fixed comment style (Michal)--- drivers/i2c/muxes/i2c-mux-uclass.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Please see below
drivers/i2c/muxes/i2c-mux-uclass.c static int i2c_mux_post_probe(struct udevice *mux) · line 91
Quoted 12 lines
drivers/i2c/muxes/i2c-mux-uclass.c +3
-0@@ -86,6 +86,16 @@ static int i2c_mux_post_probe(struct udevice *mux)debug ("%s: %s\n" , __func__, mux->name); priv->selected =-1 ; +/* if parent is of i2c uclass already, we'll take that, otherwise +* look if we find an i2c-parent phandle +*/
/*
* if parent. ...
* ....
*/
Quoted 13 lines
drivers/i2c/muxes/i2c-mux-uclass.c +7
-1+if (UCLASS_I2C ==device_get_uclass_id (mux->parent)) { + priv->i2c_bus =dev_get_parent (mux); +debug ("%s: bus=%p/%s\n" , __func__, priv->i2c_bus, + priv->i2c_bus->name); +return 0 ; + } + ret =uclass_get_device_by_phandle (UCLASS_I2C , mux,"i2c-parent" , &priv->i2c_bus);if (ret) --2.7.4