aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/eeprom
diff options
context:
space:
mode:
authorNikolay Balandin <nbalandin@dev.rtsoft.ru>2013-05-28 16:01:21 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-30 08:49:32 -0400
commit01fe7b43e7c83fe8fbf0b30b47f4ccd2f2058682 (patch)
treee78eb70bace621face561939ba2ee0cc5a715409 /drivers/misc/eeprom
parentf0ac23639c62add367309101d18ae2aa1d4a377c (diff)
drivers/misc: at25: convert to use devm_kzalloc
Use devm_kzalloc to make cleanup paths simpler Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/eeprom')
-rw-r--r--drivers/misc/eeprom/at25.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index ad8fd8e64937..840b3594a5ae 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -371,11 +371,10 @@ static int at25_probe(struct spi_device *spi)
371 if (np) { 371 if (np) {
372 err = at25_np_to_chip(&spi->dev, np, &chip); 372 err = at25_np_to_chip(&spi->dev, np, &chip);
373 if (err) 373 if (err)
374 goto fail; 374 return err;
375 } else { 375 } else {
376 dev_err(&spi->dev, "Error: no chip description\n"); 376 dev_err(&spi->dev, "Error: no chip description\n");
377 err = -ENODEV; 377 return -ENODEV;
378 goto fail;
379 } 378 }
380 } else 379 } else
381 chip = *(struct spi_eeprom *)spi->dev.platform_data; 380 chip = *(struct spi_eeprom *)spi->dev.platform_data;
@@ -389,8 +388,7 @@ static int at25_probe(struct spi_device *spi)
389 addrlen = 3; 388 addrlen = 3;
390 else { 389 else {
391 dev_dbg(&spi->dev, "unsupported address type\n"); 390 dev_dbg(&spi->dev, "unsupported address type\n");
392 err = -EINVAL; 391 return -EINVAL;
393 goto fail;
394 } 392 }
395 393
396 /* Ping the chip ... the status register is pretty portable, 394 /* Ping the chip ... the status register is pretty portable,
@@ -400,14 +398,12 @@ static int at25_probe(struct spi_device *spi)
400 sr = spi_w8r8(spi, AT25_RDSR); 398 sr = spi_w8r8(spi, AT25_RDSR);
401 if (sr < 0 || sr & AT25_SR_nRDY) { 399 if (sr < 0 || sr & AT25_SR_nRDY) {
402 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr); 400 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr);
403 err = -ENXIO; 401 return -ENXIO;
404 goto fail;
405 } 402 }
406 403
407 if (!(at25 = kzalloc(sizeof *at25, GFP_KERNEL))) { 404 at25 = devm_kzalloc(&spi->dev, sizeof(struct at25_data), GFP_KERNEL);
408 err = -ENOMEM; 405 if (!at25)
409 goto fail; 406 return -ENOMEM;
410 }
411 407
412 mutex_init(&at25->lock); 408 mutex_init(&at25->lock);
413 at25->chip = chip; 409 at25->chip = chip;
@@ -439,7 +435,7 @@ static int at25_probe(struct spi_device *spi)
439 435
440 err = sysfs_create_bin_file(&spi->dev.kobj, &at25->bin); 436 err = sysfs_create_bin_file(&spi->dev.kobj, &at25->bin);
441 if (err) 437 if (err)
442 goto fail; 438 return err;
443 439
444 if (chip.setup) 440 if (chip.setup)
445 chip.setup(&at25->mem, chip.context); 441 chip.setup(&at25->mem, chip.context);
@@ -453,10 +449,6 @@ static int at25_probe(struct spi_device *spi)
453 (chip.flags & EE_READONLY) ? " (readonly)" : "", 449 (chip.flags & EE_READONLY) ? " (readonly)" : "",
454 at25->chip.page_size); 450 at25->chip.page_size);
455 return 0; 451 return 0;
456fail:
457 dev_dbg(&spi->dev, "probe err %d\n", err);
458 kfree(at25);
459 return err;
460} 452}
461 453
462static int at25_remove(struct spi_device *spi) 454static int at25_remove(struct spi_device *spi)
@@ -465,7 +457,6 @@ static int at25_remove(struct spi_device *spi)
465 457
466 at25 = spi_get_drvdata(spi); 458 at25 = spi_get_drvdata(spi);
467 sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin); 459 sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin);
468 kfree(at25);
469 return 0; 460 return 0;
470} 461}
471 462