diff mbox

ASoC: adau1701: fix adau1701_reg_read()

Message ID 1404399096-4056-1-git-send-email-zonque@gmail.com (mailing list archive)
State Accepted
Commit 3ad80b828b2533f37c221e2df155774efd6ed814
Headers show

Commit Message

Daniel Mack July 3, 2014, 2:51 p.m. UTC
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.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/soc/codecs/adau1701.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Lars-Peter Clausen July 3, 2014, 5:21 p.m. UTC | #1
On 07/03/2014 04:51 PM, Daniel Mack wrote:
> 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.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

Thanks.

> ---
>   sound/soc/codecs/adau1701.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
> index defb277..15feb12 100644
> --- a/sound/soc/codecs/adau1701.c
> +++ b/sound/soc/codecs/adau1701.c
> @@ -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;
>   }
>
Mark Brown July 3, 2014, 6:43 p.m. UTC | #2
On Thu, Jul 03, 2014 at 04:51:36PM +0200, Daniel Mack wrote:
> 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.
diff mbox

Patch

diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index defb277..15feb12 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -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;
 }