From: Peter Rosin <peda@lysator.liu.se> To: Wolfram Sang <wsa@the-dreams.de> Cc: Peter Rosin <peda@axentia.se>, Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>, Mark Rutland <mark.rutland@arm.com>, Ian Campbell <ijc+devicetree@hellion.org.uk>, Kumar Gala <galak@codeaurora.org>, Peter Korsgaard <peter.korsgaard@barco.com>, Guenter Roeck <linux@roeck-us.net>, Jonathan Cameron <jic23@kernel.org>, Hartmut Knaack <knaack.h@gmx.de>, Lars-Peter Clausen <lars@metafoo.de>, Peter Meerwald <pmeerw@pmeerw.net>, Antti Palosaari <crope@iki.fi>, Mauro Carvalho Chehab <mchehab@osg.samsung.com>, Frank Rowand <frowand.list@gmail.com>, Grant Likely <grant.likely@linaro.org>, Adriana Reus <adriana.reus@intel.com>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, Krzysztof Kozlowski <k.kozlowski@samsung.com>, Hans Verkuil <hans.verkuil@cisco.com>, Nicholas Mc Guire <hofrat@osadl.org>, Olli Salonen <olli.salonen@iki.fi>, Peter Rosin <peda@lysator.liu.se>, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v2 7/8] i2c: muxes always lock the parent adapter Date: Tue, 5 Jan 2016 16:57:17 +0100 [thread overview] Message-ID: <1452009438-27347-8-git-send-email-peda@lysator.liu.se> (raw) In-Reply-To: <1452009438-27347-1-git-send-email-peda@lysator.liu.se> From: Peter Rosin <peda@axentia.se> Instead of checking for i2c parent adapters for every lock/unlock, simply override the locking for muxes to always lock/unlock the parent adapter directly. Signed-off-by: Peter Rosin <peda@axentia.se> --- drivers/i2c/i2c-core.c | 21 +++------------------ drivers/i2c/i2c-mux.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 34a7748b4652..4683777f81ca 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -963,12 +963,7 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) */ static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, int flags) { - struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter); - - if (parent) - i2c_lock_adapter(parent); - else - rt_mutex_lock(&adapter->bus_lock); + rt_mutex_lock(&adapter->bus_lock); } /** @@ -977,12 +972,7 @@ static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, int flags) */ static int i2c_adapter_trylock_bus(struct i2c_adapter *adapter, int flags) { - struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter); - - if (parent) - return parent->trylock_bus(parent, flags); - else - return rt_mutex_trylock(&adapter->bus_lock); + return rt_mutex_trylock(&adapter->bus_lock); } /** @@ -991,12 +981,7 @@ static int i2c_adapter_trylock_bus(struct i2c_adapter *adapter, int flags) */ static void i2c_adapter_unlock_bus(struct i2c_adapter *adapter, int flags) { - struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter); - - if (parent) - i2c_unlock_adapter(parent); - else - rt_mutex_unlock(&adapter->bus_lock); + rt_mutex_unlock(&adapter->bus_lock); } static void i2c_dev_set_name(struct i2c_adapter *adap, diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 5c1088079231..dd8a790cb4cc 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -98,6 +98,30 @@ static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent) return class; } +static void i2c_parent_lock_bus(struct i2c_adapter *adapter, int flags) +{ + struct i2c_mux_priv *priv = adapter->algo_data; + struct i2c_adapter *parent = priv->muxc->parent; + + parent->lock_bus(parent, flags); +} + +static int i2c_parent_trylock_bus(struct i2c_adapter *adapter, int flags) +{ + struct i2c_mux_priv *priv = adapter->algo_data; + struct i2c_adapter *parent = priv->muxc->parent; + + return parent->trylock_bus(parent, flags); +} + +static void i2c_parent_unlock_bus(struct i2c_adapter *adapter, int flags) +{ + struct i2c_mux_priv *priv = adapter->algo_data; + struct i2c_adapter *parent = priv->muxc->parent; + + parent->unlock_bus(parent, flags); +} + int i2c_mux_reserve_adapters(struct i2c_mux_core *muxc, int adapters) { struct i2c_adapter **adapter; @@ -181,6 +205,9 @@ int i2c_add_mux_adapter(struct i2c_mux_core *muxc, priv->adap.retries = parent->retries; priv->adap.timeout = parent->timeout; priv->adap.quirks = parent->quirks; + priv->adap.lock_bus = i2c_parent_lock_bus; + priv->adap.trylock_bus = i2c_parent_trylock_bus; + priv->adap.unlock_bus = i2c_parent_unlock_bus; /* Sanity check on class */ if (i2c_mux_parent_classes(parent) & class) -- 2.1.4
WARNING: multiple messages have this Message-ID (diff)
From: Peter Rosin <peda@lysator.liu.se> To: Wolfram Sang <wsa@the-dreams.de> Cc: Peter Rosin <peda@axentia.se>, Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>, Mark Rutland <mark.rutland@arm.com>, Ian Campbell <ijc+devicetree@hellion.org.uk>, Kumar Gala <galak@codeaurora.org>, Peter Korsgaard <peter.korsgaard@barco.com>, Guenter Roeck <linux@roeck-us.net>, Jonathan Cameron <jic23@kernel.org>, Hartmut Knaack <knaack.h@gmx.de>, Lars-Peter Clausen <lars@metafoo.de>, Peter Meerwald <pmeerw@pmeerw.net>, Antti Palosaari <crope@iki.fi>, Mauro Carvalho Chehab <mchehab@osg.samsung.com>, Frank Rowand <frowand.list@gmail.com>, Grant Likely <grant.likely@linaro.org>, Adriana Reus <adriana.reus@intel.com>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, Krzysztof Kozlowski <k.kozlowski@samsung.com>, Hans Verkuil <hans.verkuil@cisco.com>, Nicholas Mc Guire <hofrat@osadl.org>, Olli Salonen <olli.salonen@iki.fi>Peter Rosin <pe> Subject: [PATCH v2 7/8] i2c: muxes always lock the parent adapter Date: Tue, 5 Jan 2016 16:57:17 +0100 [thread overview] Message-ID: <1452009438-27347-8-git-send-email-peda@lysator.liu.se> (raw) In-Reply-To: <1452009438-27347-1-git-send-email-peda@lysator.liu.se> From: Peter Rosin <peda@axentia.se> Instead of checking for i2c parent adapters for every lock/unlock, simply override the locking for muxes to always lock/unlock the parent adapter directly. Signed-off-by: Peter Rosin <peda@axentia.se> --- drivers/i2c/i2c-core.c | 21 +++------------------ drivers/i2c/i2c-mux.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 34a7748b4652..4683777f81ca 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -963,12 +963,7 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) */ static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, int flags) { - struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter); - - if (parent) - i2c_lock_adapter(parent); - else - rt_mutex_lock(&adapter->bus_lock); + rt_mutex_lock(&adapter->bus_lock); } /** @@ -977,12 +972,7 @@ static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, int flags) */ static int i2c_adapter_trylock_bus(struct i2c_adapter *adapter, int flags) { - struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter); - - if (parent) - return parent->trylock_bus(parent, flags); - else - return rt_mutex_trylock(&adapter->bus_lock); + return rt_mutex_trylock(&adapter->bus_lock); } /** @@ -991,12 +981,7 @@ static int i2c_adapter_trylock_bus(struct i2c_adapter *adapter, int flags) */ static void i2c_adapter_unlock_bus(struct i2c_adapter *adapter, int flags) { - struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter); - - if (parent) - i2c_unlock_adapter(parent); - else - rt_mutex_unlock(&adapter->bus_lock); + rt_mutex_unlock(&adapter->bus_lock); } static void i2c_dev_set_name(struct i2c_adapter *adap, diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 5c1088079231..dd8a790cb4cc 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -98,6 +98,30 @@ static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent) return class; } +static void i2c_parent_lock_bus(struct i2c_adapter *adapter, int flags) +{ + struct i2c_mux_priv *priv = adapter->algo_data; + struct i2c_adapter *parent = priv->muxc->parent; + + parent->lock_bus(parent, flags); +} + +static int i2c_parent_trylock_bus(struct i2c_adapter *adapter, int flags) +{ + struct i2c_mux_priv *priv = adapter->algo_data; + struct i2c_adapter *parent = priv->muxc->parent; + + return parent->trylock_bus(parent, flags); +} + +static void i2c_parent_unlock_bus(struct i2c_adapter *adapter, int flags) +{ + struct i2c_mux_priv *priv = adapter->algo_data; + struct i2c_adapter *parent = priv->muxc->parent; + + parent->unlock_bus(parent, flags); +} + int i2c_mux_reserve_adapters(struct i2c_mux_core *muxc, int adapters) { struct i2c_adapter **adapter; @@ -181,6 +205,9 @@ int i2c_add_mux_adapter(struct i2c_mux_core *muxc, priv->adap.retries = parent->retries; priv->adap.timeout = parent->timeout; priv->adap.quirks = parent->quirks; + priv->adap.lock_bus = i2c_parent_lock_bus; + priv->adap.trylock_bus = i2c_parent_trylock_bus; + priv->adap.unlock_bus = i2c_parent_unlock_bus; /* Sanity check on class */ if (i2c_mux_parent_classes(parent) & class) -- 2.1.4
next prev parent reply other threads:[~2016-01-05 15:58 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-05 15:57 [PATCH v2 0/8] i2c mux cleanup and locking update Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 15:57 ` [PATCH v2 1/8] i2c-mux: add common core data for every mux instance Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 16:42 ` Guenter Roeck 2016-01-05 16:42 ` Guenter Roeck 2016-01-05 18:55 ` Peter Rosin 2016-01-05 18:55 ` Peter Rosin 2016-03-24 9:50 ` Vladimir Zapolskiy 2016-03-24 9:50 ` Vladimir Zapolskiy 2016-03-24 11:05 ` Peter Rosin 2016-03-24 11:05 ` Peter Rosin 2016-03-24 14:24 ` Vladimir Zapolskiy 2016-03-24 14:24 ` Vladimir Zapolskiy 2016-03-24 18:59 ` Peter Rosin 2016-03-24 18:59 ` Peter Rosin 2016-04-11 20:59 ` Wolfram Sang 2016-04-11 20:59 ` Wolfram Sang 2016-01-05 15:57 ` [PATCH v2 2/8] i2c-mux: move select and deselect ops to i2c_mux_core Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 15:57 ` [PATCH v2 3/8] i2c-mux: move the slave side adapter management " Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 16:49 ` kbuild test robot 2016-01-05 16:49 ` kbuild test robot 2016-01-05 19:16 ` Peter Rosin 2016-01-05 19:16 ` Peter Rosin 2016-01-05 22:17 ` Peter Rosin 2016-01-05 22:17 ` Peter Rosin 2016-01-05 15:57 ` [PATCH v2 4/8] i2c-mux: remove the mux dev pointer from the mux per channel data Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 15:57 ` [PATCH v2 5/8] i2c-mux: pinctrl: get rid of the driver private struct device pointer Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 15:57 ` [PATCH v2 6/8] i2c: allow adapter drivers to override the adapter locking Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-05 15:57 ` Peter Rosin [this message] 2016-01-05 15:57 ` [PATCH v2 7/8] i2c: muxes always lock the parent adapter Peter Rosin 2016-01-05 15:57 ` [PATCH v2 8/8] i2c-mux: relax locking of the top i2c adapter during i2c controlled muxing Peter Rosin 2016-01-05 15:57 ` Peter Rosin 2016-01-06 14:49 ` Rob Herring 2016-01-06 14:49 ` Rob Herring 2016-01-07 8:21 ` Peter Rosin 2016-01-07 8:21 ` Peter Rosin 2016-01-05 18:48 ` [PATCH v2 0/8] i2c mux cleanup and locking update Wolfram Sang 2016-01-05 18:48 ` Wolfram Sang 2016-01-05 19:01 ` Peter Rosin 2016-01-05 19:01 ` Peter Rosin 2016-01-06 13:23 ` Crt Mori 2016-01-06 13:23 ` Crt Mori 2016-01-06 17:17 ` Antti Palosaari 2016-01-06 17:17 ` Antti Palosaari 2016-01-07 8:14 ` Peter Rosin 2016-01-07 8:14 ` Peter Rosin
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=1452009438-27347-8-git-send-email-peda@lysator.liu.se \ --to=peda@lysator.liu.se \ --cc=adriana.reus@intel.com \ --cc=crope@iki.fi \ --cc=devicetree@vger.kernel.org \ --cc=frowand.list@gmail.com \ --cc=galak@codeaurora.org \ --cc=grant.likely@linaro.org \ --cc=hans.verkuil@cisco.com \ --cc=hofrat@osadl.org \ --cc=ijc+devicetree@hellion.org.uk \ --cc=jic23@kernel.org \ --cc=k.kozlowski@samsung.com \ --cc=knaack.h@gmx.de \ --cc=lars@metafoo.de \ --cc=linux-i2c@vger.kernel.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux@roeck-us.net \ --cc=mark.rutland@arm.com \ --cc=mchehab@osg.samsung.com \ --cc=olli.salonen@iki.fi \ --cc=pawel.moll@arm.com \ --cc=peda@axentia.se \ --cc=peter.korsgaard@barco.com \ --cc=pmeerw@pmeerw.net \ --cc=robh+dt@kernel.org \ --cc=srinivas.pandruvada@linux.intel.com \ --cc=wsa@the-dreams.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: linkBe 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.