mtd: spi-nor: use le32_to_cpu_array()
diff mbox series

Message ID 70ea17c5-c4cf-819c-9b47-5755d821b4b3@cogentembedded.com
State Accepted
Delegated to: Ambarus Tudor
Headers show
Series
  • mtd: spi-nor: use le32_to_cpu_array()
Related show

Commit Message

Sergei Shtylyov Feb. 1, 2020, 8:55 p.m. UTC
The driver calls le32_to_cpu() to convert the little-endian tables
to  a CPU endianness, where le32_to_cpus() should have been called.
Was going to use that one... and then discovered a whole array
converter, le32_to_cpu_array()! :-)

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
This patch is against the 'spi-nor/next' branch of the MTD 'linux.git' repo
plus couple of SPI NOR patches posted earlier...

 drivers/mtd/spi-nor/spi-nor.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Ambarus Tudor Feb. 17, 2020, 12:03 a.m. UTC | #1
On Saturday, February 1, 2020 10:55:08 PM EET Sergei Shtylyov wrote:
> The driver calls le32_to_cpu() to convert the little-endian tables
> to  a CPU endianness, where le32_to_cpus() should have been called.
> Was going to use that one... and then discovered a whole array
> converter, le32_to_cpu_array()! 
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> 
> ---
> This patch is against the 'spi-nor/next' branch of the MTD 'linux.git' repo
> plus couple of SPI NOR patches posted earlier...
> 
>  drivers/mtd/spi-nor/spi-nor.c |   11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)

Applied to spi-nor/next. Thanks.

ta

Patch
diff mbox series

Index: linux/drivers/mtd/spi-nor/spi-nor.c
===================================================================
--- linux.orig/drivers/mtd/spi-nor/spi-nor.c
+++ linux/drivers/mtd/spi-nor/spi-nor.c
@@ -3626,8 +3626,7 @@  static int spi_nor_parse_bfpt(struct spi
 		return err;
 
 	/* Fix endianness of the BFPT DWORDs. */
-	for (i = 0; i < BFPT_DWORD_MAX; i++)
-		bfpt.dwords[i] = le32_to_cpu(bfpt.dwords[i]);
+	le32_to_cpu_array(bfpt.dwords, BFPT_DWORD_MAX);
 
 	/* Number of address bytes. */
 	switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
@@ -4085,7 +4084,7 @@  static int spi_nor_parse_smpt(struct spi
 	u32 *smpt;
 	size_t len;
 	u32 addr;
-	int i, ret;
+	int ret;
 
 	/* Read the Sector Map Parameter Table. */
 	len = smpt_header->length * sizeof(*smpt);
@@ -4099,8 +4098,7 @@  static int spi_nor_parse_smpt(struct spi
 		goto out;
 
 	/* Fix endianness of the SMPT DWORDs. */
-	for (i = 0; i < smpt_header->length; i++)
-		smpt[i] = le32_to_cpu(smpt[i]);
+	le32_to_cpu_array(smpt, smpt_header->length);
 
 	sector_map = spi_nor_get_map_in_use(nor, smpt, smpt_header->length);
 	if (IS_ERR(sector_map)) {
@@ -4193,8 +4191,7 @@  static int spi_nor_parse_4bait(struct sp
 		goto out;
 
 	/* Fix endianness of the 4BAIT DWORDs. */
-	for (i = 0; i < SFDP_4BAIT_DWORD_MAX; i++)
-		dwords[i] = le32_to_cpu(dwords[i]);
+	le32_to_cpu_array(dwords, SFDP_4BAIT_DWORD_MAX);
 
 	/*
 	 * Compute the subset of (Fast) Read commands for which the 4-byte