From: Alain Volmat <alain.volmat@st.com>
To: <wsa@kernel.org>, <robh+dt@kernel.org>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
alexandre.torgue@st.com, linux-kernel@vger.kernel.org,
pierre-yves.mordret@st.com, alain.volmat@st.com,
linux-i2c@vger.kernel.org, mcoquelin.stm32@gmail.com,
fabrice.gasnier@st.com, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/4] i2c: addition of client hnotify reg/unreg callbacks
Date: Thu, 25 Jun 2020 09:39:27 +0200 [thread overview]
Message-ID: <1593070769-9106-3-git-send-email-alain.volmat@st.com> (raw)
In-Reply-To: <1593070769-9106-1-git-send-email-alain.volmat@st.com>
Addition of two callbacks reg_hnotify_cli and unreg_hnotify_cli
that can be implemented by adapter drivers in order to take action
whenever a client with HOST_NOTIFY flag is being registered to it.
Signed-off-by: Alain Volmat <alain.volmat@st.com>
---
v2: replace generic client reg/unreg callbacks with host-notify
client reg/unreg callbacks
drivers/i2c/i2c-core-base.c | 18 ++++++++++++++++--
include/linux/i2c.h | 8 ++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 26f03a14a478..46745e403e98 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -319,6 +319,14 @@ static int i2c_device_probe(struct device *dev)
if (!client)
return 0;
+ if (client->flags & I2C_CLIENT_HOST_NOTIFY) {
+ if (client->adapter->algo->reg_hnotify_cli) {
+ status = client->adapter->algo->reg_hnotify_cli(client);
+ if (status)
+ return status;
+ }
+ }
+
driver = to_i2c_driver(dev->driver);
client->irq = client->init_irq;
@@ -415,8 +423,11 @@ static int i2c_device_probe(struct device *dev)
dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false);
put_sync_adapter:
- if (client->flags & I2C_CLIENT_HOST_NOTIFY)
+ if (client->flags & I2C_CLIENT_HOST_NOTIFY) {
pm_runtime_put_sync(&client->adapter->dev);
+ if (client->adapter->algo->unreg_hnotify_cli)
+ client->adapter->algo->unreg_hnotify_cli(client);
+ }
return status;
}
@@ -442,8 +453,11 @@ static int i2c_device_remove(struct device *dev)
device_init_wakeup(&client->dev, false);
client->irq = 0;
- if (client->flags & I2C_CLIENT_HOST_NOTIFY)
+ if (client->flags & I2C_CLIENT_HOST_NOTIFY) {
pm_runtime_put(&client->adapter->dev);
+ if (client->adapter->algo->unreg_hnotify_cli)
+ client->adapter->algo->unreg_hnotify_cli(client);
+ }
return status;
}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index b8b8963f8bb9..35ad108adc68 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -507,6 +507,10 @@ 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_hnotify_cli: Callback informing that a new client with HOST_NOTIFY flag
+ * is being registered
+ * @unreg_hnotify_cli: Callback informing that a client with HOST_NOTIFY flag
+ * 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
*
@@ -543,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 HOST_NOTIFY client */
+ int (*reg_hnotify_cli)(struct i2c_client *client);
+ void (*unreg_hnotify_cli)(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.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-06-25 7:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 7:39 [PATCH v2 0/4] stm32-f7: Addition of SMBus Alert / Host-notify features Alain Volmat
2020-06-25 7:39 ` [PATCH v2 1/4] i2c: smbus: add core function handling SMBus host-notify Alain Volmat
2020-07-01 10:49 ` Wolfram Sang
2020-07-02 11:23 ` Alain Volmat
2020-06-25 7:39 ` Alain Volmat [this message]
2020-06-25 7:39 ` [PATCH v2 3/4] dt-bindings: i2c-stm32: add SMBus Alert bindings Alain Volmat
2020-06-30 19:41 ` Wolfram Sang
2020-07-14 2:30 ` Rob Herring
2020-07-21 6:22 ` Wolfram Sang
2020-06-25 7:39 ` [PATCH v2 4/4] i2c: stm32f7: Add SMBus-specific protocols support Alain Volmat
2020-06-30 16:05 ` [PATCH v2 0/4] stm32-f7: Addition of SMBus Alert / Host-notify features Wolfram Sang
2020-07-01 9:21 ` Alain Volmat
2020-07-01 9:28 ` 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=1593070769-9106-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).