Skip to contentSkip to conversation

eeprom: use devres for nvmem providers

PATCH Superseded Bartosz Golaszewski 2 participants 7 messages Sep 10, 2018 Char and misc drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover eeprom: use devres for nvmem providers

From: Bartosz Golaszewski <[email protected]>

While working on the nvmem framework recently I noticed that there are many providers that don't use the devm variant of nvmem_register(). This series contains relevant updates for eeprom drivers.

Bartosz Golaszewski (2):
eeprom: eeprom_93xx46: use resource management
eeprom: at25: use devm_nvmem_register()

 drivers/misc/eeprom/at25.c          | 3 +--
 drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----
 2 files changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/2 eeprom: eeprom_93xx46: use resource management

From: Bartosz Golaszewski <[email protected]>

Use resource managed variants of nvmem_register() and kzalloc().

---
 drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/misc/eeprom/eeprom_93xx46.c +2 -5
index 38766968bfa2..a06853543204 100644
@@ -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;
 }
 
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/2 eeprom: at25: use devm_nvmem_register()

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Use the resource managed variant of nvmem_register().

---
 drivers/misc/eeprom/at25.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/eeprom/at25.c +1 -2
index 840afb398f9e..d874df72853f 100644
@@ -366,7 +366,7 @@ static int at25_probe(struct spi_device *spi)
 	at25->nvmem_config.word_size = 1;
 	at25->nvmem_config.size = chip.byte_len;
 
-	at25->nvmem = nvmem_register(&at25->nvmem_config);
+	at25->nvmem = devm_nvmem_register(&spi->dev, &at25->nvmem_config);
 	if (IS_ERR(at25->nvmem))
 		return PTR_ERR(at25->nvmem);
 
@@ -384,7 +384,6 @@ static int at25_remove(struct spi_device *spi)
 	struct at25_data	*at25;
 
 	at25 = spi_get_drvdata(spi);
-	nvmem_unregister(at25->nvmem);
 
 	return 0;
 }
Signature · 1 line
2.18.0
#3 lore raw
In reply to Bartosz Golaszewski
Quoted 6 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

While working on the nvmem framework recently I noticed that there are many providers that don't use the devm variant of nvmem_register(). This series contains relevant updates for eeprom drivers.

Quoted 6 lines

Bartosz Golaszewski (2):
eeprom: eeprom_93xx46: use resource management
eeprom: at25: use devm_nvmem_register()

  drivers/misc/eeprom/at25.c          | 3 +--
  drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----

Can you please consider consolidating the devm related changes in a single series, to easy the review!

Quoted 2 lines
  2 files changed, 3 insertions(+), 7 deletions(-)
#4 lore raw

2018-09-10 9:50 GMT+02:00 Srinivas Kandagatla <[email protected]>:

Quoted 14 lines · Bartosz Golaszewski
Quoted 11 lines

From: Bartosz Golaszewski <[email protected]>

While working on the nvmem framework recently I noticed that there are many providers that don't use the devm variant of nvmem_register(). This series contains relevant updates for eeprom drivers.

Bartosz Golaszewski (2):
eeprom: eeprom_93xx46: use resource management
eeprom: at25: use devm_nvmem_register()

Quoted 11 lines
Quoted 2 lines
  drivers/misc/eeprom/at25.c          | 3 +--
  drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----

Can you please consider consolidating the devm related changes in a single series, to easy the review!

Quoted 2 lines
  2 files changed, 3 insertions(+), 7 deletions(-)

Are you referring to the devm part of the bigger nvmem series? If so:
no, because the nvmem patches are required by the later patches in that series. These two patches are independent and should probably go through Greg's tree directly.

Best regards,
Bartosz Golaszewski

#5 lore raw
Quoted 23 lines · Bartosz Golaszewski

2018-09-10 9:50 GMT+02:00 Srinivas Kandagatla <[email protected]>:

Quoted 22 lines · Bartosz Golaszewski
Quoted 7 lines

From: Bartosz Golaszewski <[email protected]>

While working on the nvmem framework recently I noticed that there are many providers that don't use the devm variant of nvmem_register(). This series contains relevant updates for eeprom drivers.

Quoted 6 lines

Bartosz Golaszewski (2):
eeprom: eeprom_93xx46: use resource management
eeprom: at25: use devm_nvmem_register()

   drivers/misc/eeprom/at25.c          | 3 +--
   drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----

Can you please consider consolidating the devm related changes in a single series, to easy the review!

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
   2 files changed, 3 insertions(+), 7 deletions(-)

Are you referring to the devm part of the bigger nvmem series? If so:
no, because the nvmem patches are required by the later patches in

Yes, am referring to that series.
I dont see any reason why lpc and sunxi changes should not be in this series? Or there is no implicit reasoning or change log that suggests that these have to be part of that series!

--srini

Quoted 6 lines

that series. These two patches are independent and should probably go through Greg's tree directly.

Best regards,
Bartosz Golaszewski

#6 lore raw

2018-09-10 9:59 GMT+02:00 Srinivas Kandagatla <[email protected]>:

Quoted 36 lines · Bartosz Golaszewski
Quoted 33 lines

2018-09-10 9:50 GMT+02:00 Srinivas Kandagatla
<[email protected]>:

Quoted 29 lines · Bartosz Golaszewski
Quoted 8 lines

From: Bartosz Golaszewski <[email protected]>

While working on the nvmem framework recently I noticed that there are many providers that don't use the devm variant of nvmem_register(). This series contains relevant updates for eeprom drivers.

Quoted 6 lines

Bartosz Golaszewski (2):
eeprom: eeprom_93xx46: use resource management
eeprom: at25: use devm_nvmem_register()

   drivers/misc/eeprom/at25.c          | 3 +--
   drivers/misc/eeprom/eeprom_93xx46.c | 7 ++-----

Can you please consider consolidating the devm related changes in a single
series, to easy the review!

Quoted 2 lines
   2 files changed, 3 insertions(+), 7 deletions(-)
Quoted 9 lines
Quoted 2 lines

Are you referring to the devm part of the bigger nvmem series? If so:
no, because the nvmem patches are required by the later patches in

Yes, am referring to that series.
I dont see any reason why lpc and sunxi changes should not be in this series? Or there is no implicit reasoning or change log that suggests that these have to be part of that series!

Patch ("nvmem: change the signature of nvmem_unregister()") depends on those three patches in the other series. We need to change them first because they were still checking the return value of nvmem_unregister(). And this patch results from the earlier kref patch. I think that although this nvmem series is pretty big, it contains mostly related changes and it will be hard to submit them separately.

Bart

Quoted 10 lines

--srini

Quoted 6 lines

that series. These two patches are independent and should probably go through Greg's tree directly.

Best regards,
Bartosz Golaszewski