aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/leds/leds-pca9532.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index f0883e6ebc50..62b60a038e2c 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -204,8 +204,8 @@ static int pca9532_configure(struct i2c_client *client,
204 led->ldev.brightness = LED_OFF; 204 led->ldev.brightness = LED_OFF;
205 led->ldev.brightness_set = pca9532_set_brightness; 205 led->ldev.brightness_set = pca9532_set_brightness;
206 led->ldev.blink_set = pca9532_set_blink; 206 led->ldev.blink_set = pca9532_set_blink;
207 if (led_classdev_register(&client->dev, 207 err = led_classdev_register(&client->dev, &led->ldev);
208 &led->ldev) < 0) { 208 if (err < 0) {
209 dev_err(&client->dev, 209 dev_err(&client->dev,
210 "couldn't register LED %s\n", 210 "couldn't register LED %s\n",
211 led->name); 211 led->name);
@@ -263,7 +263,6 @@ exit:
263 } 263 }
264 264
265 return err; 265 return err;
266
267} 266}
268 267
269static int pca9532_probe(struct i2c_client *client, 268static int pca9532_probe(struct i2c_client *client,
@@ -271,12 +270,16 @@ static int pca9532_probe(struct i2c_client *client,
271{ 270{
272 struct pca9532_data *data = i2c_get_clientdata(client); 271 struct pca9532_data *data = i2c_get_clientdata(client);
273 struct pca9532_platform_data *pca9532_pdata = client->dev.platform_data; 272 struct pca9532_platform_data *pca9532_pdata = client->dev.platform_data;
273 int err;
274
275 if (!pca9532_pdata)
276 return -EIO;
274 277
275 if (!i2c_check_functionality(client->adapter, 278 if (!i2c_check_functionality(client->adapter,
276 I2C_FUNC_SMBUS_BYTE_DATA)) 279 I2C_FUNC_SMBUS_BYTE_DATA))
277 return -EIO; 280 return -EIO;
278 281
279 data = kzalloc(sizeof(struct pca9532_data), GFP_KERNEL); 282 data = kzalloc(sizeof(*data), GFP_KERNEL);
280 if (!data) 283 if (!data)
281 return -ENOMEM; 284 return -ENOMEM;
282 285
@@ -285,12 +288,13 @@ static int pca9532_probe(struct i2c_client *client,
285 data->client = client; 288 data->client = client;
286 mutex_init(&data->update_lock); 289 mutex_init(&data->update_lock);
287 290
288 if (pca9532_pdata == NULL) 291 err = pca9532_configure(client, data, pca9532_pdata);
289 return -EIO; 292 if (err) {
290 293 kfree(data);
291 pca9532_configure(client, data, pca9532_pdata); 294 i2c_set_clientdata(client, NULL);
292 return 0; 295 }
293 296
297 return err;
294} 298}
295 299
296static int pca9532_remove(struct i2c_client *client) 300static int pca9532_remove(struct i2c_client *client)