Skip to contentSkip to conversation

ASoC: adau1701: fix adau1701_reg_read()

PATCH Applied Daniel Mack 3 participants 3 messages Jul 3, 2014

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

PATCH 1/1 ASoC: adau1701: fix adau1701_reg_read()

Fix a long standing bug in the read register routing of adau1701. The bytes arrive in the buffer in big-endian, so the result has to be shifted before and-ing the bytes in the loop.

---
 sound/soc/codecs/adau1701.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/codecs/adau1701.c +4 -2
index defb277..15feb12 100644
@@ -240,8 +240,10 @@ static int adau1701_reg_read(void *context, unsigned int reg,
 
 	*value = 0;
 
-	for (i = 0; i < size; i++)
-		*value |= recv_buf[i] << (i * 8);
+	for (i = 0; i < size; i++) {
+		*value <<= 8;
+		*value |= recv_buf[i];
+	}
 
 	return 0;
 }
Signature · 1 line
1.9.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Daniel Mack

Fix a long standing bug in the read register routing of adau1701. The bytes arrive in the buffer in big-endian, so the result has to be shifted before and-ing the bytes in the loop.

Thanks.

Quoted 22 lines
---
  sound/soc/codecs/adau1701.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/codecs/adau1701.c +4 -2
index defb277..15feb12 100644
@@ -240,8 +240,10 @@ static int adau1701_reg_read(void *context, unsigned int reg,
 
  	*value = 0;
 
-	for (i = 0; i < size; i++)
-		*value |= recv_buf[i] << (i * 8);
+	for (i = 0; i < size; i++) {
+		*value <<= 8;
+		*value |= recv_buf[i];
+	}
 
  	return 0;
  }
maintainer Applied
#2 lore raw
In reply to Daniel Mack
Quoted 3 lines · Daniel Mack

Fix a long standing bug in the read register routing of adau1701. The bytes arrive in the buffer in big-endian, so the result has to be shifted before and-ing the bytes in the loop.

Applied, thanks.