wm97xx_battery: Handle missing platform data gracefully

Don't unconditionally dereference the WM97xx core platform data since
it may not be present, causing an oops.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>

authored by Mark Brown and committed by Anton Vorontsov 12b336a8 be8cde8b

+8 -2
+8 -2
drivers/power/wm97xx_battery.c
··· 175 175 dev_err(&dev->dev, "Do not pass platform_data through " 176 176 "wm97xx_bat_set_pdata!\n"); 177 177 return -EINVAL; 178 - } else 179 - pdata = wmdata->batt_pdata; 178 + } 179 + 180 + if (!wmdata) { 181 + dev_err(&dev->dev, "No platform data supplied\n"); 182 + return -EINVAL; 183 + } 184 + 185 + pdata = wmdata->batt_pdata; 180 186 181 187 if (dev->id != -1) 182 188 return -EINVAL;