Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get
@ 2026-03-04  4:16 Rosen Penev
  2026-03-04  8:31 ` Kunihiko Hayashi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rosen Penev @ 2026-03-04  4:16 UTC (permalink / raw)
  To: linux-phy
  Cc: Vinod Koul, Neil Armstrong, Kunihiko Hayashi, Masami Hiramatsu,
	Rosen Penev, moderated list:ARM/UNIPHIER ARCHITECTURE, open list

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.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/phy/socionext/phy-uniphier-usb3hs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/socionext/phy-uniphier-usb3hs.c b/drivers/phy/socionext/phy-uniphier-usb3hs.c
index 8c8673df0084..c8971eee3640 100644
--- a/drivers/phy/socionext/phy-uniphier-usb3hs.c
+++ b/drivers/phy/socionext/phy-uniphier-usb3hs.c
@@ -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);
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get
  2026-03-04  4:16 [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get Rosen Penev
@ 2026-03-04  8:31 ` Kunihiko Hayashi
  2026-08-12 13:33 ` Manivannan Sadhasivam
  2026-08-13  9:43 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Kunihiko Hayashi @ 2026-03-04  8:31 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-phy, Vinod Koul, Neil Armstrong, Masami Hiramatsu,
	moderated list:ARM/UNIPHIER ARCHITECTURE, open list

Hi Rosen,

On 2026/03/04 13:16, Rosen Penev wrote:
> 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.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>   drivers/phy/socionext/phy-uniphier-usb3hs.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/socionext/phy-uniphier-usb3hs.c
> b/drivers/phy/socionext/phy-uniphier-usb3hs.c
> index 8c8673df0084..c8971eee3640 100644
> --- a/drivers/phy/socionext/phy-uniphier-usb3hs.c
> +++ b/drivers/phy/socionext/phy-uniphier-usb3hs.c
> @@ -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);
>   

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.

Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you,

---
Best Regards
Kunihiko Hayashi


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get
  2026-03-04  4:16 [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get Rosen Penev
  2026-03-04  8:31 ` Kunihiko Hayashi
@ 2026-08-12 13:33 ` Manivannan Sadhasivam
  2026-08-13  9:43 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-08-12 13:33 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-phy, Vinod Koul, Neil Armstrong, Kunihiko Hayashi,
	Masami Hiramatsu, moderated list:ARM/UNIPHIER ARCHITECTURE,
	open list

On Tue, Mar 03, 2026 at 08:16:02PM -0800, Rosen Penev wrote:
> 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.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>

- Mani

-- 
மணிவண்ணன் சதாசிவம்


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get
  2026-03-04  4:16 [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get Rosen Penev
  2026-03-04  8:31 ` Kunihiko Hayashi
  2026-08-12 13:33 ` Manivannan Sadhasivam
@ 2026-08-13  9:43 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2026-08-13  9:43 UTC (permalink / raw)
  To: Rosen Penev, linux-phy, linux-arm-kernel
  Cc: LKML, kernel-janitors, Kunihiko Hayashi, Manivannan Sadhasivam,
	Masami Hiramatsu, Neil Armstrong, Vinod Koul

> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-13  9:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04  4:16 [PATCH] phy: uniphier-usb3: no devm for nvmem_cell_get Rosen Penev
2026-03-04  8:31 ` Kunihiko Hayashi
2026-08-12 13:33 ` Manivannan Sadhasivam
2026-08-13  9:43 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox