mfd: wm97xx-core: Platform data can be NULL
authorRobert Jarzmik <robert.jarzmik@free.fr>
Sun, 3 Jun 2018 20:16:17 +0000 (22:16 +0200)
committerLee Jones <lee.jones@linaro.org>
Mon, 11 Jun 2018 08:11:03 +0000 (09:11 +0100)
It is not mandatory that platform data is passed along the ac97
codec. Actually there are configuration without a battery connected to
the ADC of the codec.

This is for example the case for the PXA zylonite platform, so fix the
NULL dereferencing by adding a test.

Fixes: a5c6951c49fb ("mfd: wm97xx-core: core support for wm97xx Codec")
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/wm97xx-core.c

index 4141ee52a70b08484c7a50b6960eaeb71848021a..f5a8347f837f26d1af1627ea626f70a16176edd9 100644 (file)
@@ -278,7 +278,7 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 
        codec_pdata = &wm97xx->codec_pdata;
        codec_pdata->ac97 = wm97xx->ac97;
-       codec_pdata->batt_pdata = pdata->batt_pdata;
+       codec_pdata->batt_pdata = pdata ? pdata->batt_pdata : NULL;
 
        switch (adev->vendor_id) {
        case WM9705_VENDOR_ID: