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: <1167c489-92cb-440e-a2c0-4f47190de5ac@linaro.org>
Date: Fri, 7 Mar 2025 17:42:05 +0000
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: Jennifer Berringer <jberring@...hat.com>,
 Sebastian Reichel <sre@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH v4 1/2] nvmem: core: add nvmem_cell_size()

Hi Jennifer,

On 28/02/2025 18:03, Jennifer Berringer wrote:
> This function allows nvmem consumers to know the size of an nvmem cell
> before calling nvmem_cell_write() or nvmem_cell_read(), which is helpful
> for drivers that may need to handle devices with different cell sizes.
> 
> Signed-off-by: Jennifer Berringer <jberring@...hat.com>
> ---
>   drivers/nvmem/core.c           | 18 ++++++++++++++++++
>   include/linux/nvmem-consumer.h |  6 ++++++
>   2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index d6494dfc20a7..4d0cbd20da48 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1624,6 +1624,24 @@ void nvmem_cell_put(struct nvmem_cell *cell)
>   }
>   EXPORT_SYMBOL_GPL(nvmem_cell_put);
>   
> +/**
> + * nvmem_cell_size() - Get nvmem cell size in bytes.
> + *
> + * @cell: nvmem cell.
> + *
> + * Return: size of the nvmem cell.
> + */
> +size_t nvmem_cell_size(struct nvmem_cell *cell)
> +{
> +	struct nvmem_cell_entry *entry = cell->entry;
> +
> +	if (!entry)
> +		return 0;
> +
> +	return entry->bytes;
> +}
> +EXPORT_SYMBOL_GPL(nvmem_cell_size);
> +

There is a similar patch on the list, could you take a look and see if 
that is usable in power reset driver.

https://lore.kernel.org/lkml/20250306093900.2199442-3-o.rempel@pengutronix.de/T/#m97bbb1870d7140661894a4e806a695e563588524



--srini
>   static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf)
>   {
>   	u8 *p, *b;
> diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
> index 34c0e58dfa26..a2020527d2d3 100644
> --- a/include/linux/nvmem-consumer.h
> +++ b/include/linux/nvmem-consumer.h
> @@ -54,6 +54,7 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id);
>   struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *id);
>   void nvmem_cell_put(struct nvmem_cell *cell);
>   void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
> +size_t nvmem_cell_size(struct nvmem_cell *cell);
>   void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
>   int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
>   int nvmem_cell_read_u8(struct device *dev, const char *cell_id, u8 *val);
> @@ -117,6 +118,11 @@ static inline void nvmem_cell_put(struct nvmem_cell *cell)
>   {
>   }
>   
> +static inline size_t nvmem_cell_size(struct nvmem_cell *cell)
> +{
> +	return 0;
> +}
> +
>   static inline void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
>   {
>   	return ERR_PTR(-EOPNOTSUPP);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ