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>
diff --git a/drivers/mfd/pm8xxx-pwm.c b/drivers/mfd/pm8xxx-pwm.c
index 191e079..022cfb6 100644
--- a/drivers/mfd/pm8xxx-pwm.c
+++ b/drivers/mfd/pm8xxx-pwm.c
@@ -1364,7 +1364,7 @@
 {
 	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 @@
 		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 @@
 	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;
 	}