[V3,1/6] nvmem: core: add nvmem_dev_size() helper

Message ID 20230127125709.32191-1-zajec5@gmail.com
State New
Headers
Series [V3,1/6] nvmem: core: add nvmem_dev_size() helper |

Commit Message

Rafał Miłecki Jan. 27, 2023, 12:57 p.m. UTC
  From: Rafał Miłecki <rafal@milecki.pl>

This is required by layouts that need to read whole NVMEM space. It
applies to NVMEM devices without hardcoded layout (like U-Boot
environment data block).

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V2: Drop "const" from "const size_t"
---
 drivers/nvmem/core.c           | 13 +++++++++++++
 include/linux/nvmem-consumer.h |  1 +
 2 files changed, 14 insertions(+)
  

Comments

Miquel Raynal Jan. 30, 2023, 10:56 a.m. UTC | #1
Hi Rafał,

zajec5@gmail.com wrote on Fri, 27 Jan 2023 13:57:04 +0100:

> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This is required by layouts that need to read whole NVMEM space. It
> applies to NVMEM devices without hardcoded layout (like U-Boot
> environment data block).
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> V2: Drop "const" from "const size_t"

It would be good if you could always add a cover-letter, just so that
we can reply to the whole series. In my case I wanted to add a global

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Because I gave this series a quick review and it looks good to me.

Thanks,
Miquèl

> ---
>  drivers/nvmem/core.c           | 13 +++++++++++++
>  include/linux/nvmem-consumer.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 38a5728bc65c..9e77af0164aa 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -2063,6 +2063,19 @@ void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries)
>  }
>  EXPORT_SYMBOL_GPL(nvmem_del_cell_lookups);
>  
> +/**
> + * nvmem_dev_size() - Get the size of a given nvmem device.
> + *
> + * @nvmem: nvmem device.
> + *
> + * Return: size of the nvmem device.
> + */
> +size_t nvmem_dev_size(struct nvmem_device *nvmem)
> +{
> +	return nvmem->size;
> +}
> +EXPORT_SYMBOL_GPL(nvmem_dev_size);
> +
>  /**
>   * nvmem_dev_name() - Get the name of a given nvmem device.
>   *
> diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
> index fa030d93b768..c3005ab6cc4f 100644
> --- a/include/linux/nvmem-consumer.h
> +++ b/include/linux/nvmem-consumer.h
> @@ -78,6 +78,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
>  int nvmem_device_cell_write(struct nvmem_device *nvmem,
>  			    struct nvmem_cell_info *info, void *buf);
>  
> +size_t nvmem_dev_size(struct nvmem_device *nvmem);
>  const char *nvmem_dev_name(struct nvmem_device *nvmem);
>  
>  void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries,
  
Rafał Miłecki Jan. 30, 2023, 12:34 p.m. UTC | #2
On 30.01.2023 11:56, Miquel Raynal wrote:
> Hi Rafał,
> 
> zajec5@gmail.com wrote on Fri, 27 Jan 2023 13:57:04 +0100:
> 
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> This is required by layouts that need to read whole NVMEM space. It
>> applies to NVMEM devices without hardcoded layout (like U-Boot
>> environment data block).
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> ---
>> V2: Drop "const" from "const size_t"
> 
> It would be good if you could always add a cover-letter, just so that
> we can reply to the whole series. In my case I wanted to add a global
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> 
> Because I gave this series a quick review and it looks good to me.

Good point, I'll keep that in mind and do that in future for all bigger
series.
Thank you.
  

Patch

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 38a5728bc65c..9e77af0164aa 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -2063,6 +2063,19 @@  void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries)
 }
 EXPORT_SYMBOL_GPL(nvmem_del_cell_lookups);
 
+/**
+ * nvmem_dev_size() - Get the size of a given nvmem device.
+ *
+ * @nvmem: nvmem device.
+ *
+ * Return: size of the nvmem device.
+ */
+size_t nvmem_dev_size(struct nvmem_device *nvmem)
+{
+	return nvmem->size;
+}
+EXPORT_SYMBOL_GPL(nvmem_dev_size);
+
 /**
  * nvmem_dev_name() - Get the name of a given nvmem device.
  *
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index fa030d93b768..c3005ab6cc4f 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -78,6 +78,7 @@  ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
 int nvmem_device_cell_write(struct nvmem_device *nvmem,
 			    struct nvmem_cell_info *info, void *buf);
 
+size_t nvmem_dev_size(struct nvmem_device *nvmem);
 const char *nvmem_dev_name(struct nvmem_device *nvmem);
 
 void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries,