diff options
author | Bartosz Golaszewski <bgolaszewski@baylibre.com> | 2018-09-21 06:40:01 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-28 15:14:53 +0200 |
commit | c853d6904f1428c081de5367da2569933556a668 (patch) | |
tree | 31ed0e7d369956f00905450c62cf617c26677ce1 /drivers/misc | |
parent | 3790e28cdbc8e7c4ffff62a9e4db89fe6e066c0b (diff) | |
download | blackbird-obmc-linux-c853d6904f1428c081de5367da2569933556a668.tar.gz blackbird-obmc-linux-c853d6904f1428c081de5367da2569933556a668.zip |
eeprom: eeprom_93xx46: use resource management
Use resource managed variants of nvmem_register() and kzalloc().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/eeprom/eeprom_93xx46.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c index 38766968bfa2..c6dd9ad9bf7b 100644 --- a/drivers/misc/eeprom/eeprom_93xx46.c +++ b/drivers/misc/eeprom/eeprom_93xx46.c @@ -439,7 +439,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi) return -ENODEV; } - edev = kzalloc(sizeof(*edev), GFP_KERNEL); + edev = devm_kzalloc(&spi->dev, sizeof(*edev), GFP_KERNEL); if (!edev) return -ENOMEM; @@ -449,8 +449,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi) edev->addrlen = 6; else { dev_err(&spi->dev, "unspecified address type\n"); - err = -EINVAL; - goto fail; + return -EINVAL; } mutex_init(&edev->lock); @@ -473,11 +472,9 @@ static int eeprom_93xx46_probe(struct spi_device *spi) edev->nvmem_config.word_size = 1; edev->nvmem_config.size = edev->size; - edev->nvmem = nvmem_register(&edev->nvmem_config); - if (IS_ERR(edev->nvmem)) { - err = PTR_ERR(edev->nvmem); - goto fail; - } + edev->nvmem = devm_nvmem_register(&spi->dev, &edev->nvmem_config); + if (IS_ERR(edev->nvmem)) + return PTR_ERR(edev->nvmem); dev_info(&spi->dev, "%d-bit eeprom %s\n", (pd->flags & EE_ADDR8) ? 8 : 16, @@ -490,21 +487,15 @@ static int eeprom_93xx46_probe(struct spi_device *spi) spi_set_drvdata(spi, edev); return 0; -fail: - kfree(edev); - return err; } static int eeprom_93xx46_remove(struct spi_device *spi) { struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi); - nvmem_unregister(edev->nvmem); - if (!(edev->pdata->flags & EE_READONLY)) device_remove_file(&spi->dev, &dev_attr_erase); - kfree(edev); return 0; } |