mfd: pm8xxx-pwm: Check for the NULL pointer

In some targets there might not be any platform data
for PWM driver, and its a valid case. On such target
check for the NULL pointer for the platform data.

Change-Id: If534b172f916e639491256a2346dd7bdd9a7cbcd
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
This commit is contained in:
Jay Chokshi
2012-03-02 15:28:23 -08:00
parent 566b084d3c
commit d9e4bc2f22
+7 -2
View File
@@ -1364,7 +1364,7 @@ static int __devinit pm8xxx_pwm_probe(struct platform_device *pdev)
{
const struct pm8xxx_pwm_platform_data *pdata = pdev->dev.platform_data;
struct pm8xxx_pwm_chip *chip;
int i;
int i, dtest_channel;
enum pm8xxx_version version;
chip = kzalloc(sizeof *chip, GFP_KERNEL);
@@ -1373,6 +1373,11 @@ static int __devinit pm8xxx_pwm_probe(struct platform_device *pdev)
return -ENOMEM;
}
if (pdata != NULL)
dtest_channel = pdata->dtest_channel;
else
dtest_channel = -1;
mutex_init(&chip->pwm_mutex);
chip->dev = &pdev->dev;
@@ -1413,7 +1418,7 @@ static int __devinit pm8xxx_pwm_probe(struct platform_device *pdev)
for (i = 0; i < chip->pwm_channels; i++) {
chip->pwm_dev[i].pwm_id = i;
chip->pwm_dev[i].chip = chip;
if (i == pdata->dtest_channel)
if (i == dtest_channel)
chip->pwm_dev[i].dtest_mode_supported = 1;
}