From: Alain Volmat <alain.volmat@st.com>
To: <wsa@kernel.org>, <robh+dt@kernel.org>
Cc: <mark.rutland@arm.com>, <pierre-yves.mordret@st.com>,
<mcoquelin.stm32@gmail.com>, <alexandre.torgue@st.com>,
<linux-i2c@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <fabrice.gasnier@st.com>,
<alain.volmat@st.com>
Subject: [PATCH 2/4] i2c: addition of client reg/unreg callbacks
Date: Tue, 5 May 2020 07:51:09 +0200 [thread overview]
Message-ID: <1588657871-14747-3-git-send-email-alain.volmat@st.com> (raw)
In-Reply-To: <1588657871-14747-1-git-send-email-alain.volmat@st.com>
Addition of two callbacks reg_client and unreg_client that can be
implemented by adapter drivers in order to take action whenever a
client is being registered to it.
Signed-off-by: Alain Volmat <alain.volmat@st.com>
---
drivers/i2c/i2c-core-base.c | 11 +++++++++++
include/linux/i2c.h | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 2e4560671183..4c84c6264314 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -319,6 +319,12 @@ static int i2c_device_probe(struct device *dev)
if (!client)
return 0;
+ if (client->adapter->algo->reg_client) {
+ status = client->adapter->algo->reg_client(client);
+ if (status)
+ return status;
+ }
+
driver = to_i2c_driver(dev->driver);
client->irq = client->init_irq;
@@ -417,6 +423,8 @@ static int i2c_device_probe(struct device *dev)
put_sync_adapter:
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
pm_runtime_put_sync(&client->adapter->dev);
+ if (client->adapter->algo->reg_client)
+ client->adapter->algo->unreg_client(client);
return status;
}
@@ -445,6 +453,9 @@ static int i2c_device_remove(struct device *dev)
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
pm_runtime_put(&client->adapter->dev);
+ if (client->adapter->algo->unreg_client)
+ client->adapter->algo->unreg_client(client);
+
return status;
}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 45d36ba4826b..61b838caf454 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -509,6 +509,8 @@ i2c_register_board_info(int busnum, struct i2c_board_info const *info,
* so e.g. PMICs can be accessed very late before shutdown. Optional.
* @functionality: Return the flags that this algorithm/adapter pair supports
* from the ``I2C_FUNC_*`` flags.
+ * @reg_client: Callback informing that a new client is being registered
+ * @unreg_client: Callback informing that a client is being removed
* @reg_slave: Register given client to I2C slave mode of this adapter
* @unreg_slave: Unregister given client from I2C slave mode of this adapter
*
@@ -545,6 +547,10 @@ struct i2c_algorithm {
/* To determine what the adapter supports */
u32 (*functionality)(struct i2c_adapter *adap);
+ /* To inform the adapter of the probe/remove of a client */
+ int (*reg_client)(struct i2c_client *client);
+ void (*unreg_client)(struct i2c_client *client);
+
#if IS_ENABLED(CONFIG_I2C_SLAVE)
int (*reg_slave)(struct i2c_client *client);
int (*unreg_slave)(struct i2c_client *client);
--
2.17.1
next prev parent reply other threads:[~2020-05-05 5:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 5:51 [PATCH 0/4] stm32-f7: Addition of SMBus Alert / Host-notify features Alain Volmat
2020-05-05 5:51 ` [PATCH 1/4] i2c: smbus: add core function handling SMBus host-notify Alain Volmat
2020-05-11 8:26 ` Pierre Yves MORDRET
2020-05-23 10:46 ` Wolfram Sang
2020-05-26 10:23 ` Alain Volmat
2020-05-05 5:51 ` Alain Volmat [this message]
2020-05-11 8:28 ` [PATCH 2/4] i2c: addition of client reg/unreg callbacks Pierre Yves MORDRET
2020-05-23 10:49 ` Wolfram Sang
2020-05-05 5:51 ` [PATCH 3/4] dt-bindings: i2c-stm32: add SMBus Alert bindings Alain Volmat
2020-05-13 2:19 ` Rob Herring
2020-05-13 5:42 ` Alain Volmat
2020-05-18 10:53 ` Alain Volmat
2020-05-23 10:36 ` wsa
2020-05-26 10:31 ` Alain Volmat
2020-05-05 5:51 ` [PATCH 4/4] i2c: stm32f7: Add SMBus-specific protocols support Alain Volmat
2020-05-11 8:27 ` Pierre Yves MORDRET
2020-05-23 11:01 ` Wolfram Sang
2020-05-26 10:39 ` Alain Volmat
2020-06-30 6:40 ` Wolfram Sang
2020-06-30 9:31 ` Alain Volmat
2020-06-30 15:11 ` Wolfram Sang
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=1588657871-14747-3-git-send-email-alain.volmat@st.com \
--to=alain.volmat@st.com \
--cc=alexandre.torgue@st.com \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=pierre-yves.mordret@st.com \
--cc=robh+dt@kernel.org \
--cc=wsa@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).