diff options
author | Christoph Fritz <chf.fritz@googlemail.com> | 2010-04-17 07:57:17 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-05-26 08:07:54 -0400 |
commit | 98652efceab8f0b1a3a1b2750544a395ec056115 (patch) | |
tree | 9d2cbdcef2edaa14691ad07881611320ceaeb309 /drivers/leds/leds-88pm860x.c | |
parent | b1cdc4670b9508fcd47a15fbd12f70d269880b37 (diff) |
leds: 88pm860x - fix checking in probe function
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>
Diffstat (limited to 'drivers/leds/leds-88pm860x.c')
-rw-r--r-- | drivers/leds/leds-88pm860x.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index 16a60c06c96c..b7677106cff8 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c | |||
@@ -256,8 +256,10 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
256 | if (pdev->dev.parent->platform_data) { | 256 | if (pdev->dev.parent->platform_data) { |
257 | pm860x_pdata = pdev->dev.parent->platform_data; | 257 | pm860x_pdata = pdev->dev.parent->platform_data; |
258 | pdata = pm860x_pdata->led; | 258 | pdata = pm860x_pdata->led; |
259 | } else | 259 | } else { |
260 | pdata = NULL; | 260 | dev_err(&pdev->dev, "missing platform data\n"); |
261 | return -EINVAL; | ||
262 | } | ||
261 | 263 | ||
262 | data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL); | 264 | data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL); |
263 | if (data == NULL) | 265 | if (data == NULL) |
@@ -268,8 +270,11 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
268 | data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; | 270 | data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; |
269 | data->iset = pdata->iset; | 271 | data->iset = pdata->iset; |
270 | data->port = __check_device(pdata, data->name); | 272 | data->port = __check_device(pdata, data->name); |
271 | if (data->port < 0) | 273 | if (data->port < 0) { |
274 | dev_err(&pdev->dev, "check device failed\n"); | ||
275 | kfree(data); | ||
272 | return -EINVAL; | 276 | return -EINVAL; |
277 | } | ||
273 | 278 | ||
274 | data->current_brightness = 0; | 279 | data->current_brightness = 0; |
275 | data->cdev.name = data->name; | 280 | data->cdev.name = data->name; |