lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <511f7da1-1a65-884b-cce8-55ffeba76c7c@gmail.com>
Date:   Tue, 30 Mar 2021 19:28:08 +0300
From:   Dmitry Osipenko <digetx@...il.com>
To:     Yicong Yang <yangyicong@...ilicon.com>, wsa@...nel.org,
        andriy.shevchenko@...ux.intel.com, linux-i2c@...r.kernel.org,
        Sergey.Semin@...kalelectronics.ru, linux-kernel@...r.kernel.org
Cc:     treding@...dia.com, jarkko.nikula@...ux.intel.com,
        rmk+kernel@...linux.org.uk, song.bao.hua@...ilicon.com,
        john.garry@...wei.com, mika.westerberg@...ux.intel.com,
        prime.zeng@...wei.com, linuxarm@...wei.com
Subject: Re: [PATCH v5 1/5] i2c: core: add managed function for adding i2c
 adapters

30.03.2021 17:19, Yicong Yang пишет:
> Some I2C controller drivers will only unregister the I2C
> adapter in their .remove() callback, which can be done
> by simply using a managed variant to add the I2C adapter.
> 
> So add the managed functions for adding the I2C adapter.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Signed-off-by: Yicong Yang <yangyicong@...ilicon.com>
> ---
>  drivers/i2c/i2c-core-base.c | 26 ++++++++++++++++++++++++++
>  include/linux/i2c.h         |  1 +
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 63ebf72..de9402c 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -1703,6 +1703,32 @@ void i2c_del_adapter(struct i2c_adapter *adap)
>  }
>  EXPORT_SYMBOL(i2c_del_adapter);
>  
> +static void devm_i2c_del_adapter(void *adapter)
> +{
> +	i2c_del_adapter(adapter);
> +}
> +
> +/**
> + * devm_i2c_add_adapter - device-managed variant of i2c_add_adapter()
> + * @dev: managing device for adding this I2C adapter
> + * @adapter: the adapter to add
> + * Context: can sleep
> + *
> + * Add adapter with dynamic bus number, same with i2c_add_adapter()
> + * but the adapter will be auto deleted on driver detach.
> + */
> +int devm_i2c_add_adapter(struct device *dev, struct i2c_adapter *adapter)
> +{
> +	int ret;
> +
> +	ret = i2c_add_adapter(adapter);
> +	if (ret)
> +		return ret;
> +
> +	return devm_add_action_or_reset(dev, devm_i2c_del_adapter, adapter);
> +}
> +EXPORT_SYMBOL_GPL(devm_i2c_add_adapter);
> +
>  static void i2c_parse_timing(struct device *dev, char *prop_name, u32 *cur_val_p,
>  			    u32 def_val, bool use_def)
>  {
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 5662265..10bd0b0 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -844,6 +844,7 @@ static inline void i2c_mark_adapter_resumed(struct i2c_adapter *adap)
>   */
>  #if IS_ENABLED(CONFIG_I2C)
>  int i2c_add_adapter(struct i2c_adapter *adap);
> +int devm_i2c_add_adapter(struct device *dev, struct i2c_adapter *adapter);
>  void i2c_del_adapter(struct i2c_adapter *adap);
>  int i2c_add_numbered_adapter(struct i2c_adapter *adap);
>  
> 

Reviewed-by: Dmitry Osipenko <digetx@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ