diff mbox series

[v3,7/7] nvmem: add a comment about resource management

Message ID 20200219092218.18143-8-brgl@bgdev.pl
State New
Headers show
Series nvmem/gpio: fix resource management | expand

Commit Message

Bartosz Golaszewski Feb. 19, 2020, 9:22 a.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

The fact that part of the resources associated with the nvmem resources
is freed by the release() callback in device_type caused me some
confusion. Add a comment explaining that to nvmem_register().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/nvmem/core.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Srinivas Kandagatla Feb. 19, 2020, 10:57 a.m. UTC | #1
On 19/02/2020 09:22, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> The fact that part of the resources associated with the nvmem resources
> is freed by the release() callback in device_type caused me some
> confusion. Add a comment explaining that to nvmem_register().

I see this patch totally unnecessary!

I expect people creating patch in this area to understand what exactly 
they are doing. This is not going to help them in anyway, other than 
misleading and re-documenting device_add which is already available at

https://www.kernel.org/doc/html/v5.5/driver-api/infrastructure.html


thanks,
srini


> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>   drivers/nvmem/core.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 40fe5913c264..6e28f3fddf53 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -397,6 +397,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
>   
>   	dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
>   
> +	/*
> +	 * After calling device_add() we can stop freeing previously
> +	 * allocated resources - they'll be freed from nvmem_release()
> +	 * when the device's reference count drops to 0.
> +	 */
>   	rval = device_add(&nvmem->dev);
>   	if (rval)
>   		goto err_put_device;
>
diff mbox series

Patch

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 40fe5913c264..6e28f3fddf53 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -397,6 +397,11 @@  struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 
 	dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
 
+	/*
+	 * After calling device_add() we can stop freeing previously
+	 * allocated resources - they'll be freed from nvmem_release()
+	 * when the device's reference count drops to 0.
+	 */
 	rval = device_add(&nvmem->dev);
 	if (rval)
 		goto err_put_device;