]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge branch 'i2c-mux-dt-3' of https://github.com/peda-r/i2c-mux into i2c/for-4.9
authorWolfram Sang <wsa@the-dreams.de>
Thu, 25 Aug 2016 22:49:37 +0000 (00:49 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 25 Aug 2016 22:49:37 +0000 (00:49 +0200)
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1  2 
MAINTAINERS
drivers/i2c/i2c-mux.c

diff --combined MAINTAINERS
index 4b9a6ae6aaf9386097834ed6c1dd226fb578721f,353bfe6bbaca5a25abca95330d3a07b5fa28e6a7..c58ee8c0b78277215df29862b671204e9acaf700
@@@ -2878,14 -2878,6 +2878,14 @@@ S:    Maintaine
  F:    drivers/iio/light/cm*
  F:    Documentation/devicetree/bindings/i2c/trivial-devices.txt
  
 +CAVIUM I2C DRIVER
 +M:    Jan Glauber <jglauber@cavium.com>
 +M:    David Daney <david.daney@cavium.com>
 +W:    http://www.cavium.com
 +S:    Supported
 +F:    drivers/i2c/busses/i2c-octeon*
 +F:    drivers/i2c/busses/i2c-thunderx*
 +
  CAVIUM LIQUIDIO NETWORK DRIVER
  M:     Derek Chickles <derek.chickles@caviumnetworks.com>
  M:     Satanand Burla <satananda.burla@caviumnetworks.com>
@@@ -5675,6 -5667,8 +5675,8 @@@ S:      Maintaine
  F:    Documentation/i2c/i2c-topology
  F:    Documentation/i2c/muxes/
  F:    Documentation/devicetree/bindings/i2c/i2c-mux*
+ F:    Documentation/devicetree/bindings/i2c/i2c-arb*
+ F:    Documentation/devicetree/bindings/i2c/i2c-gate*
  F:    drivers/i2c/i2c-mux.c
  F:    drivers/i2c/muxes/
  F:    include/linux/i2c-mux.h
diff --combined drivers/i2c/i2c-mux.c
index 764f195795e406486799cfc3a640eadd94b7911f,c1ae719d1a7a900b073b6fbd3ae6daad30b94efb..90f59c08875098ab70228314a10a6fca01c186de
@@@ -159,7 -159,7 +159,7 @@@ static int i2c_mux_trylock_bus(struct i
                return 0;       /* mux_lock not locked, failure */
        if (!(flags & I2C_LOCK_ROOT_ADAPTER))
                return 1;       /* we only want mux_lock, success */
 -      if (parent->trylock_bus(parent, flags))
 +      if (i2c_trylock_bus(parent, flags))
                return 1;       /* parent locked too, success */
        rt_mutex_unlock(&parent->mux_lock);
        return 0;               /* parent not locked, failure */
@@@ -193,7 -193,7 +193,7 @@@ static int i2c_parent_trylock_bus(struc
  
        if (!rt_mutex_trylock(&parent->mux_lock))
                return 0;       /* mux_lock not locked, failure */
 -      if (parent->trylock_bus(parent, flags))
 +      if (i2c_trylock_bus(parent, flags))
                return 1;       /* parent locked too, success */
        rt_mutex_unlock(&parent->mux_lock);
        return 0;               /* parent not locked, failure */
@@@ -255,6 -255,10 +255,10 @@@ struct i2c_mux_core *i2c_mux_alloc(stru
        muxc->dev = dev;
        if (flags & I2C_MUX_LOCKED)
                muxc->mux_locked = true;
+       if (flags & I2C_MUX_ARBITRATOR)
+               muxc->arbitrator = true;
+       if (flags & I2C_MUX_GATE)
+               muxc->gate = true;
        muxc->select = select;
        muxc->deselect = deselect;
        muxc->max_adapters = max_adapters;
@@@ -335,18 -339,42 +339,42 @@@ int i2c_mux_add_adapter(struct i2c_mux_
         * nothing if !CONFIG_OF.
         */
        if (muxc->dev->of_node) {
-               struct device_node *child;
+               struct device_node *dev_node = muxc->dev->of_node;
+               struct device_node *mux_node, *child = NULL;
                u32 reg;
  
-               for_each_child_of_node(muxc->dev->of_node, child) {
-                       ret = of_property_read_u32(child, "reg", &reg);
-                       if (ret)
-                               continue;
-                       if (chan_id == reg) {
-                               priv->adap.dev.of_node = child;
-                               break;
+               if (muxc->arbitrator)
+                       mux_node = of_get_child_by_name(dev_node, "i2c-arb");
+               else if (muxc->gate)
+                       mux_node = of_get_child_by_name(dev_node, "i2c-gate");
+               else
+                       mux_node = of_get_child_by_name(dev_node, "i2c-mux");
+               if (mux_node) {
+                       /* A "reg" property indicates an old-style DT entry */
+                       if (!of_property_read_u32(mux_node, "reg", &reg)) {
+                               of_node_put(mux_node);
+                               mux_node = NULL;
+                       }
+               }
+               if (!mux_node)
+                       mux_node = of_node_get(dev_node);
+               else if (muxc->arbitrator || muxc->gate)
+                       child = of_node_get(mux_node);
+               if (!child) {
+                       for_each_child_of_node(mux_node, child) {
+                               ret = of_property_read_u32(child, "reg", &reg);
+                               if (ret)
+                                       continue;
+                               if (chan_id == reg)
+                                       break;
                        }
                }
+               priv->adap.dev.of_node = child;
+               of_node_put(mux_node);
        }
  
        /*