All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC V2 2/4] i2c: mux: add function to reparent a mux
@ 2015-03-17  7:15 Wolfram Sang
  2015-03-19 15:39 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2015-03-17  7:15 UTC (permalink / raw)
  To: linux-sh

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

Used for n-to-1 demuxes. Needs discussion.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Changes since RFC V1: none, only rebased

 drivers/i2c/i2c-mux.c   | 8 ++++++++
 include/linux/i2c-mux.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 593f7ca9adc783..c64f3fc9bb3750 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -100,6 +100,14 @@ static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent)
 	return class;
 }
 
+void i2c_mux_reparent(struct i2c_adapter *adap, struct i2c_adapter *new_parent)
+{
+	struct i2c_mux_priv *priv = adap->algo_data;
+
+	priv->parent = new_parent;
+}
+EXPORT_SYMBOL_GPL(i2c_mux_reparent);
+
 struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
 				struct device *mux_dev,
 				void *mux_priv, u32 force_nr, u32 chan_id,
diff --git a/include/linux/i2c-mux.h b/include/linux/i2c-mux.h
index b5f9a007a3abdd..488a7744732853 100644
--- a/include/linux/i2c-mux.h
+++ b/include/linux/i2c-mux.h
@@ -44,6 +44,8 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
 
 void i2c_del_mux_adapter(struct i2c_adapter *adap);
 
+void i2c_mux_reparent(struct i2c_adapter *adap, struct i2c_adapter *new_parent);
+
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_I2C_MUX_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC V2 2/4] i2c: mux: add function to reparent a mux
  2015-03-17  7:15 [RFC V2 2/4] i2c: mux: add function to reparent a mux Wolfram Sang
@ 2015-03-19 15:39 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2015-03-19 15:39 UTC (permalink / raw)
  To: linux-sh

[-- Attachment #1: Type: text/plain, Size: 2264 bytes --]

On Tue, Mar 17, 2015 at 08:15:22AM +0100, Wolfram Sang wrote:
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> 
> Used for n-to-1 demuxes. Needs discussion.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

So, I'll discuss this with myself ;)

While this works, it is abusing the driver model quite much.
sysfs-representation will not notice the new parent and it does not look
possible to mark instantiated slaves as "kernel-driven" for the
currently active bus. They will only be marked for the bus they were
attached during instantiation.

It is nice to have some working code in case you need core switching and
leaving the childs active. However, I think an approach with
de/re-registering will be much cleaner.

I will hack something for that next week taking the DT binding from this
approach. I think we are quite OK with that one, or?

> ---
> 
> Changes since RFC V1: none, only rebased
> 
>  drivers/i2c/i2c-mux.c   | 8 ++++++++
>  include/linux/i2c-mux.h | 2 ++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 593f7ca9adc783..c64f3fc9bb3750 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -100,6 +100,14 @@ static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent)
>  	return class;
>  }
>  
> +void i2c_mux_reparent(struct i2c_adapter *adap, struct i2c_adapter *new_parent)
> +{
> +	struct i2c_mux_priv *priv = adap->algo_data;
> +
> +	priv->parent = new_parent;
> +}
> +EXPORT_SYMBOL_GPL(i2c_mux_reparent);
> +
>  struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
>  				struct device *mux_dev,
>  				void *mux_priv, u32 force_nr, u32 chan_id,
> diff --git a/include/linux/i2c-mux.h b/include/linux/i2c-mux.h
> index b5f9a007a3abdd..488a7744732853 100644
> --- a/include/linux/i2c-mux.h
> +++ b/include/linux/i2c-mux.h
> @@ -44,6 +44,8 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
>  
>  void i2c_del_mux_adapter(struct i2c_adapter *adap);
>  
> +void i2c_mux_reparent(struct i2c_adapter *adap, struct i2c_adapter *new_parent);
> +
>  #endif /* __KERNEL__ */
>  
>  #endif /* _LINUX_I2C_MUX_H */
> -- 
> 2.1.4
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-19 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17  7:15 [RFC V2 2/4] i2c: mux: add function to reparent a mux Wolfram Sang
2015-03-19 15:39 ` Wolfram Sang

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.