Skip to content

Commit

Permalink
leds: 88pm860x - fix checking in probe function
Browse files Browse the repository at this point in the history
Improve device and platform data checks in probe function.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
  • Loading branch information
Christoph Fritz authored and Richard Purdie committed May 26, 2010
1 parent b1cdc46 commit 98652ef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/leds/leds-88pm860x.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ static int pm860x_led_probe(struct platform_device *pdev)
if (pdev->dev.parent->platform_data) {
pm860x_pdata = pdev->dev.parent->platform_data;
pdata = pm860x_pdata->led;
} else
pdata = NULL;
} else {
dev_err(&pdev->dev, "missing platform data\n");
return -EINVAL;
}

data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL);
if (data == NULL)
Expand All @@ -268,8 +270,11 @@ static int pm860x_led_probe(struct platform_device *pdev)
data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion;
data->iset = pdata->iset;
data->port = __check_device(pdata, data->name);
if (data->port < 0)
if (data->port < 0) {
dev_err(&pdev->dev, "check device failed\n");
kfree(data);
return -EINVAL;
}

data->current_brightness = 0;
data->cdev.name = data->name;
Expand Down

0 comments on commit 98652ef

Please sign in to comment.