All of lore.kernel.org
 help / color / mirror / Atom feed
From: Moritz Fischer <moritz.fischer@ettus.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] i2c: mux: Allow muxes to work as children of i2c bus without i2c-parent
Date: Thu, 29 Dec 2016 14:50:10 -0800	[thread overview]
Message-ID: <1483051810-12511-1-git-send-email-moritz.fischer@ettus.com> (raw)

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.

Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: u-boot at lists.denx.de
---
 drivers/i2c/muxes/i2c-mux-uclass.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index 7a698b6..e01b773 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -86,6 +86,15 @@ 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)
-- 
2.7.4

             reply	other threads:[~2016-12-29 22:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29 22:50 Moritz Fischer [this message]
2017-01-02 14:24 ` [U-Boot] [PATCH] i2c: mux: Allow muxes to work as children of i2c bus without i2c-parent Michal Simek
2017-01-02 19:20   ` Moritz Fischer
2017-01-03  9:22     ` Michal Simek
2017-01-03 16:15       ` Moritz Fischer
2017-01-04  9:40         ` Michal Simek
2017-01-18 21:42           ` Simon Glass
2017-01-23  7:21             ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1483051810-12511-1-git-send-email-moritz.fischer@ettus.com \
    --to=moritz.fischer@ettus.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.