Skip to contentSkip to conversation

phy: uniphier-usb3: no devm for nvmem_cell_get

PATCH Applied Rosen Penev 5 participants 6 messages Mar 4 – Sep 13

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: uniphier-usb3: no devm for nvmem_cell_get

There is absolutely no reason to extend the lifetime of nvmem_cell_get to after removal of the driver. Use and free right after use.

---
 drivers/phy/socionext/phy-uniphier-usb3hs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/socionext/phy-uniphier-usb3hs.c +2 -1
index 8c8673df0084..c8971eee3640 100644
@@ -104,11 +104,12 @@ static int uniphier_u3hsphy_get_nvparam(struct uniphier_u3hsphy_priv *priv,
 	struct nvmem_cell *cell;
 	u8 *buf;
 
-	cell = devm_nvmem_cell_get(priv->dev, name);
+	cell = nvmem_cell_get(priv->dev, name);
 	if (IS_ERR(cell))
 		return PTR_ERR(cell);
 
 	buf = nvmem_cell_read(cell, NULL);
+	nvmem_cell_put(cell);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Rosen,

Quoted 18 lines · Rosen Penev

There is absolutely no reason to extend the lifetime of nvmem_cell_get to after removal of the driver. Use and free right after use.

---
  drivers/phy/socionext/phy-uniphier-usb3hs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/socionext/phy-uniphier-usb3hs.c +0 -0
index 8c8673df0084..c8971eee3640 100644
@@ -104,11 +104,12 @@ static int uniphier_u3hsphy_get_nvparam(struct
 uniphier_u3hsphy_priv *priv,
  	struct nvmem_cell *cell;
  	u8 *buf;

drivers/phy/socionext/phy-uniphier-usb3hs.c static int uniphier_u3hsphy_get_nvparam(struct · line 115

Quoted 10 lines
drivers/phy/socionext/phy-uniphier-usb3hs.c +2 -1
 
-	cell = devm_nvmem_cell_get(priv->dev, name);
+	cell = nvmem_cell_get(priv->dev, name);
  	if (IS_ERR(cell))
  		return PTR_ERR(cell);
 
  	buf = nvmem_cell_read(cell, NULL);
+	nvmem_cell_put(cell);
  	if (IS_ERR(buf))
  		return PTR_ERR(buf);

Looks good to me.
This function is called multiple times and creates a cell each time, so it's probably better to delete it after using it.

Thank you,

---
Best Regards
Kunihiko Hayashi

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#3 lore raw
In reply to Rosen Penev
Quoted 2 lines

There is absolutely no reason to extend the lifetime of nvmem_cell_get to after removal of the driver. Use and free right after use.

How do you think about to increase the application of scope-based resource management?

Regards,
Markus

#4 lore raw
Quoted 5 lines · Markus Elfring
Quoted 3 lines

There is absolutely no reason to extend the lifetime of nvmem_cell_get to after removal of the driver. Use and free right after use.

How do you think about to increase the application of scope-based resource management?

I don't really like it.

Quoted 3 lines

Regards,
Markus

maintainer Applied
#5 lore raw
In reply to Rosen Penev
Quoted 4 lines · Rosen Penev

There is absolutely no reason to extend the lifetime of nvmem_cell_get to after removal of the driver. Use and free right after use.

Applied, thanks!

[1/1] phy: uniphier-usb3: no devm for nvmem_cell_get

      commit: b2d5ad12d78a1070553f4cb6bf3315105a3b3da3

Best regards,

Signature · 1 line
~Vinod