[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1593070769-9106-3-git-send-email-alain.volmat@st.com>
Date: Thu, 25 Jun 2020 09:39:27 +0200
From: Alain Volmat <alain.volmat@...com>
To: <wsa@...nel.org>, <robh+dt@...nel.org>
CC: <mark.rutland@....com>, <pierre-yves.mordret@...com>,
<mcoquelin.stm32@...il.com>, <alexandre.torgue@...com>,
<linux-i2c@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <fabrice.gasnier@...com>,
<alain.volmat@...com>
Subject: [PATCH v2 2/4] i2c: addition of client hnotify reg/unreg callbacks
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@...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
Powered by blists - more mailing lists