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: <f3ffb0f7-2d27-9c58-549f-dc44209f27c6@linaro.org>
Date:   Tue, 2 Jan 2018 11:44:55 +0000
From:   Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To:     Andrey Smirnov <andrew.smirnov@...il.com>
Cc:     Heiko Stuebner <heiko@...ech.de>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Carlo Caione <carlo@...one.org>,
        Kevin Hilman <khilman@...libre.com>,
        Matthias Brugger <matthias.bgg@...il.com>, cphealy@...il.com,
        linux-kernel@...r.kernel.org, linux-mediatek@...ts.infradead.org,
        linux-rockchip@...ts.infradead.org,
        linux-amlogic@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 02/21] nvmem: Introduce devm_nvmem_(un)register()

Thanks for the patch,

On 01/01/18 23:22, Andrey Smirnov wrote:
> Introduce devm_nvmem_register()/devm_nvmem_unregister() to make
> .remove() unnecessary in trivial drivers.
> 
> Cc: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
> Cc: Heiko Stuebner <heiko@...ech.de>
> Cc: Masahiro Yamada <yamada.masahiro@...ionext.com>
> Cc: Carlo Caione <carlo@...one.org>
> Cc: Kevin Hilman <khilman@...libre.com>
> Cc: Matthias Brugger <matthias.bgg@...il.com>
> Cc: cphealy@...il.com
> Cc: linux-kernel@...r.kernel.org
> Cc: linux-mediatek@...ts.infradead.org
> Cc: linux-rockchip@...ts.infradead.org
> Cc: linux-amlogic@...ts.infradead.org
> Cc: linux-arm-kernel@...ts.infradead.org
> Signed-off-by: Andrey Smirnov <andrew.smirnov@...il.com>
> ---
>   drivers/nvmem/core.c           | 41 +++++++++++++++++++++++++++++++++++++++++
>   include/linux/nvmem-provider.h | 17 +++++++++++++++++
>   2 files changed, 58 insertions(+)
> 
Patch looks good, kernel doc for these exported symbols are missing, you 
should add them in next version!


Thanks,
Srini

> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 57cbeacfbeb2..84f07ba1f36d 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -551,6 +551,47 @@ int nvmem_unregister(struct nvmem_device *nvmem)
>   }
>   EXPORT_SYMBOL_GPL(nvmem_unregister);
>   
> +static void devm_nvmem_release(struct device *dev, void *res)
> +{
> +	WARN_ON(nvmem_unregister(*(struct nvmem_device **)res));
> +}
> +
> +struct nvmem_device *devm_nvmem_register(struct device *dev,
> +					 const struct nvmem_config *config)
> +{
> +	struct nvmem_device **ptr, *nvmem;
> +
> +	ptr = devres_alloc(devm_nvmem_release, sizeof(*ptr), GFP_KERNEL);
> +	if (!ptr)
> +		return ERR_PTR(-ENOMEM);
> +
> +	nvmem = nvmem_register(config);
> +
> +	if (!IS_ERR(nvmem)) {
> +		*ptr = nvmem;
> +		devres_add(dev, ptr);
> +	} else {
> +		devres_free(ptr);
> +	}
> +
> +	return nvmem;
> +}
> +EXPORT_SYMBOL_GPL(devm_nvmem_register);
> +
> +static int devm_nvmem_match(struct device *dev, void *res, void *data)
> +{./drivers/base/devres.c
> +	struct nvmem_device **r = res;
> +
> +	return *r == data;
> +}
> +
> +int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
> +{
> +	return devres_release(dev, devm_nvmem_release, devm_nvmem_match, nvmem);
> +}
> +EXPORT_SYMBOL(devm_nvmem_unregister);
> +
> +
>   static struct nvmem_device *__nvmem_device_get(struct device_node *np,
>   					       struct nvmem_cell **cellp,
>   					       const char *cell_id)
> diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
> index 497706f5adca..493f2f529f00 100644
> --- a/include/linux/nvmem-provider.h
> +++ b/include/linux/nvmem-provider.h
> @@ -47,6 +47,11 @@ struct nvmem_config {
>   struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
>   int nvmem_unregister(struct nvmem_device *nvmem);
>   
> +struct nvmem_device *devm_nvmem_register(struct device *dev,
> +					 const struct nvmem_config *cfg);
> +
> +int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
> +
>   #else
>   
>   static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
> @@ -59,5 +64,17 @@ static inline int nvmem_unregister(struct nvmem_device *nvmem)
>   	return -ENOSYS;
>   }
>   
> +static inline struct nvmem_device *
> +devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
> +{
> +	return nvmem_register(c);
> +}
> +
> +static inline int
> +devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
> +{
> +	return nvmem_unregister(nvmem);
> +}
> +
>   #endif /* CONFIG_NVMEM */
>   #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ