asoc: codecs: max98088: check for revision id
Nikesh Oswal [Wed, 14 Mar 2012 12:18:09 +0000 (17:18 +0530)]
check for revision id, it must be 0x40 as per the datasheet,
if its not 0x40 then dont allow the card to register by failing
in the codec probe. This functionality will be required when the
same board support multiple codecs. Also register the irq only
after validating the codec.

Change-Id: I8553b85d534428c7137ec2d03e2f814b898609a6
Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-on: http://git-master/r/90061
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/soc/codecs/max98088.c

index cee6354..e2ad10d 100644 (file)
@@ -2073,6 +2073,15 @@ static int max98088_probe(struct snd_soc_codec *codec)
        max98088->mic1pre = 0;
        max98088->mic2pre = 0;
 
+       ret = snd_soc_read(codec, M98088_REG_FF_REV_ID);
+       if (ret != 0x40) {
+               dev_err(codec->dev, "Failed to read device revision: %d\n",
+                       ret);
+               ret = -ENODEV;
+               goto err_access;
+       }
+       dev_info(codec->dev, "revision %c\n", ret + 'A');
+
        if (max98088->irq) {
                /* register an audio interrupt */
                ret = request_threaded_irq(max98088->irq, NULL,
@@ -2085,14 +2094,6 @@ static int max98088_probe(struct snd_soc_codec *codec)
                }
        }
 
-       ret = snd_soc_read(codec, M98088_REG_FF_REV_ID);
-       if (ret < 0) {
-               dev_err(codec->dev, "Failed to read device revision: %d\n",
-                       ret);
-               goto err_access;
-       }
-       dev_info(codec->dev, "revision %c\n", ret + 'A');
-
        snd_soc_write(codec, M98088_REG_51_PWR_SYS, M98088_PWRSV);
 
        /* initialize registers cache to hardware default */