Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value
@ 2014-04-03  7:53 Axel Lin
  2014-04-03 15:33 ` Nicolin Chen
  2014-04-03 16:50 ` Brian Austin
  0 siblings, 2 replies; 5+ messages in thread
From: Axel Lin @ 2014-04-03  7:53 UTC (permalink / raw)
  To: Mark Brown
  Cc: Brian Austin, alsa-devel, Liam Girdwood, Paul Handrigan,
	Nicolin Chen

Fix checking return value of regmap_read().
Also fix reporting the chip_id value. CS42XX8_CHIPID_CHIP_ID_MASK is 0xF0,
so the chip_id value is (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4).

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 sound/soc/codecs/cs42xx8.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
index 082299a..b1606cf 100644
--- a/sound/soc/codecs/cs42xx8.c
+++ b/sound/soc/codecs/cs42xx8.c
@@ -495,17 +495,16 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
 	regcache_cache_bypass(cs42xx8->regmap, true);
 
 	/* Validate the chip ID */
-	regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
-	if (val < 0) {
+	ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
+	if (ret < 0) {
 		dev_err(dev, "failed to get device ID: %x", val);
-		ret = -EINVAL;
 		goto err_enable;
 	}
 
 	/* The top four bits of the chip ID should be 0000 */
-	if ((val & CS42XX8_CHIPID_CHIP_ID_MASK) != 0x00) {
+	if (((val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4) != 0x00) {
 		dev_err(dev, "unmatched chip ID: %d\n",
-				val & CS42XX8_CHIPID_CHIP_ID_MASK);
+			(val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4);
 		ret = -EINVAL;
 		goto err_enable;
 	}
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value
  2014-04-03  7:53 [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value Axel Lin
@ 2014-04-03 15:33 ` Nicolin Chen
  2014-04-03 16:48   ` Paul Handrigan
  2014-04-03 21:33   ` Mark Brown
  2014-04-03 16:50 ` Brian Austin
  1 sibling, 2 replies; 5+ messages in thread
From: Nicolin Chen @ 2014-04-03 15:33 UTC (permalink / raw)
  To: Axel Lin
  Cc: alsa-devel, Brian Austin, Mark Brown, Liam Girdwood,
	Paul Handrigan

On Thu, Apr 03, 2014 at 03:53:36PM +0800, Axel Lin wrote:
> Fix checking return value of regmap_read().
> Also fix reporting the chip_id value. CS42XX8_CHIPID_CHIP_ID_MASK is 0xF0,
> so the chip_id value is (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4).
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  sound/soc/codecs/cs42xx8.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
> index 082299a..b1606cf 100644
> --- a/sound/soc/codecs/cs42xx8.c
> +++ b/sound/soc/codecs/cs42xx8.c
> @@ -495,17 +495,16 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
>  	regcache_cache_bypass(cs42xx8->regmap, true);
>  
>  	/* Validate the chip ID */
> -	regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
> -	if (val < 0) {
> +	ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
> +	if (ret < 0) {
>  		dev_err(dev, "failed to get device ID: %x", val);

%d and ret would be better here since val won't be useful in this case.

Thank you for the fix.
Nicolin Chen

> -		ret = -EINVAL;
>  		goto err_enable;
>  	}
>  
>  	/* The top four bits of the chip ID should be 0000 */
> -	if ((val & CS42XX8_CHIPID_CHIP_ID_MASK) != 0x00) {
> +	if (((val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4) != 0x00) {
>  		dev_err(dev, "unmatched chip ID: %d\n",
> -				val & CS42XX8_CHIPID_CHIP_ID_MASK);
> +			(val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4);
>  		ret = -EINVAL;
>  		goto err_enable;
>  	}
> -- 
> 1.8.3.2
> 
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value
  2014-04-03 15:33 ` Nicolin Chen
@ 2014-04-03 16:48   ` Paul Handrigan
  2014-04-03 21:33   ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Handrigan @ 2014-04-03 16:48 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: alsa-devel, Axel Lin, Brian Austin, Paul Handrigan, Liam Girdwood,
	Mark Brown

Acked-by: Paul Handrigan <paul.handrigan@cirrus.com>

On Thu, 3 Apr 2014, Nicolin Chen wrote:

> On Thu, Apr 03, 2014 at 03:53:36PM +0800, Axel Lin wrote:
>> Fix checking return value of regmap_read().
>> Also fix reporting the chip_id value. CS42XX8_CHIPID_CHIP_ID_MASK is 0xF0,
>> so the chip_id value is (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4).
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>>  sound/soc/codecs/cs42xx8.c | 9 ++++-----
>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
>> index 082299a..b1606cf 100644
>> --- a/sound/soc/codecs/cs42xx8.c
>> +++ b/sound/soc/codecs/cs42xx8.c
>> @@ -495,17 +495,16 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
>>  	regcache_cache_bypass(cs42xx8->regmap, true);
>>
>>  	/* Validate the chip ID */
>> -	regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
>> -	if (val < 0) {
>> +	ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
>> +	if (ret < 0) {
>>  		dev_err(dev, "failed to get device ID: %x", val);
>
> %d and ret would be better here since val won't be useful in this case.
>
> Thank you for the fix.
> Nicolin Chen
>
>> -		ret = -EINVAL;
>>  		goto err_enable;
>>  	}
>>
>>  	/* The top four bits of the chip ID should be 0000 */
>> -	if ((val & CS42XX8_CHIPID_CHIP_ID_MASK) != 0x00) {
>> +	if (((val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4) != 0x00) {
>>  		dev_err(dev, "unmatched chip ID: %d\n",
>> -				val & CS42XX8_CHIPID_CHIP_ID_MASK);
>> +			(val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4);
>>  		ret = -EINVAL;
>>  		goto err_enable;
>>  	}
>> --
>> 1.8.3.2
>>
>>
>>
>>
>>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value
  2014-04-03  7:53 [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value Axel Lin
  2014-04-03 15:33 ` Nicolin Chen
@ 2014-04-03 16:50 ` Brian Austin
  1 sibling, 0 replies; 5+ messages in thread
From: Brian Austin @ 2014-04-03 16:50 UTC (permalink / raw)
  To: Axel Lin
  Cc: alsa-devel, Brian Austin, Paul Handrigan, Liam Girdwood,
	Mark Brown, Nicolin Chen

> Fix checking return value of regmap_read().
> Also fix reporting the chip_id value. CS42XX8_CHIPID_CHIP_ID_MASK is 0xF0,
> so the chip_id value is (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4).
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
Acked-by: Brian Austin <brian.austin@cirrus.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value
  2014-04-03 15:33 ` Nicolin Chen
  2014-04-03 16:48   ` Paul Handrigan
@ 2014-04-03 21:33   ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2014-04-03 21:33 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: Brian Austin, alsa-devel, Axel Lin, Liam Girdwood, Paul Handrigan


[-- Attachment #1.1: Type: text/plain, Size: 421 bytes --]

On Thu, Apr 03, 2014 at 11:33:15PM +0800, Nicolin Chen wrote:
> On Thu, Apr 03, 2014 at 03:53:36PM +0800, Axel Lin wrote:

> > +	ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
> > +	if (ret < 0) {
> >  		dev_err(dev, "failed to get device ID: %x", val);

> %d and ret would be better here since val won't be useful in this case.

Yes, they would - val won't have anything in particular in it if the I/O
fails.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-03 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-03  7:53 [PATCH] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value Axel Lin
2014-04-03 15:33 ` Nicolin Chen
2014-04-03 16:48   ` Paul Handrigan
2014-04-03 21:33   ` Mark Brown
2014-04-03 16:50 ` Brian Austin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox