Skip to contentSkip to conversation

nvmem: core: Allow ignoring length when reading a cell

PATCH In review Vivek Gautam 3 participants 6 messages Dec 19, 2016 – Jan 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmem: core: Allow ignoring length when reading a cell

nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field.

---

Based on torvalds's master branch.
- Tested against 'next-20161219' tag on db410c (apq8016) target for thermal sensors.

 drivers/nvmem/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvmem/core.c +4 -2
index 965911d..4c38842 100644
@@ -970,7 +970,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
 	if (cell->bit_offset || cell->nbits)
 		nvmem_shift_read_buffer_in_place(cell, buf);
 
-	*len = cell->bytes;
+	if (len)
+		*len = cell->bytes;
 
 	return 0;
 }
@@ -979,7 +980,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
  * nvmem_cell_read() - Read a given nvmem cell
  *
  * @cell: nvmem cell to be read.
- * @len: pointer to length of cell which will be populated on successful read.
+ * @len: pointer to length of cell which will be populated on successful read;
+ *	 can be NULL.
  *
  * Return: ERR_PTR() on error or a valid pointer to a char * buffer on success.
  * The buffer should be freed by the consumer with a kfree().
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Vivek Gautam

nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field.

---

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw
Quoted 10 lines · Stephen Boyd
Quoted 7 lines · Vivek Gautam

nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field.

---

Thanks Stephen.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw
In reply to Stephen Boyd

Hi Srinivas,

Quoted 10 lines · Stephen Boyd
Quoted 7 lines · Vivek Gautam

nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field.

---

Can you please pick this patch as well, adding Stephen's 'Reviewed-by' tag.

Regards
Vivek

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw
Quoted 9 lines · Vivek Gautam

Hi Srinivas,

Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Vivek Gautam

nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

---

Can you please pick this patch as well, adding Stephen's 'Reviewed-by' tag.

This is already in my queue for 4.11 release, as this is an enhancement. I will send them to Greg once we hit rc4 or rc5.

thanks,
srini

Quoted 4 lines

Regards
Vivek

#5 lore raw
Quoted 12 lines · Srinivas Kandagatla
Quoted 9 lines · Vivek Gautam

Hi Srinivas,

Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Vivek Gautam

nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

---

Can you please pick this patch as well, adding Stephen's 'Reviewed-by' tag.

This is already in my queue for 4.11 release, as this is an enhancement. I will send them to Greg once we hit rc4 or rc5.

Okay. Thanks for picking.

Regards
Vivek

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project