[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180910074404.8041-2-brgl@bgdev.pl>
Date: Mon, 10 Sep 2018 09:44:03 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh@...nel.org>,
"Gustavo A . R . Silva" <gustavo@...eddedor.com>,
Devang Panchal <devang.panchal@...tnautics.com>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc: linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH 1/2] eeprom: eeprom_93xx46: use resource management
From: Bartosz Golaszewski <bgolaszewski@...libre.com>
Use resource managed variants of nvmem_register() and kzalloc().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index 38766968bfa2..a06853543204 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;
@@ -473,7 +473,7 @@ 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);
+ edev->nvmem = devm_nvmem_register(&spi->dev, &edev->nvmem_config);
if (IS_ERR(edev->nvmem)) {
err = PTR_ERR(edev->nvmem);
goto fail;
@@ -499,12 +499,9 @@ 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;
}
--
2.18.0
Powered by blists - more mailing lists