lkml.org 
[lkml]   [2020]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/4] i2c: addition of client reg/unreg callbacks
From
Date
Hi all,

Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>

Thanks

On 5/5/20 7:51 AM, Alain Volmat wrote:
> 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);
>

\
 
 \ /
  Last update: 2020-05-11 10:29    [W:0.062 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site