public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: isp1760: Use devm_kcalloc
@ 2024-09-10  7:26 zhangjiao2
  2024-09-10  9:04 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: zhangjiao2 @ 2024-09-10  7:26 UTC (permalink / raw)
  To: rui.silva; +Cc: gregkh, linux-usb, linux-kernel, zhang jiao

From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

Use devm_kcalloc to simplify code.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 drivers/usb/isp1760/isp1760-hcd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 0e5e4cb74c87..593ce841ae53 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -2572,18 +2572,18 @@ int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
 
 	priv->hcd = hcd;
 
-	priv->atl_slots = kcalloc(mem_layout->slot_num,
+	priv->atl_slots = devm_kcalloc(dev, mem_layout->slot_num,
 				  sizeof(struct isp1760_slotinfo), GFP_KERNEL);
 	if (!priv->atl_slots) {
 		ret = -ENOMEM;
 		goto put_hcd;
 	}
 
-	priv->int_slots = kcalloc(mem_layout->slot_num,
+	priv->int_slots = devm_kcalloc(dev, mem_layout->slot_num,
 				  sizeof(struct isp1760_slotinfo), GFP_KERNEL);
 	if (!priv->int_slots) {
 		ret = -ENOMEM;
-		goto free_atl_slots;
+		goto put_hcd;
 	}
 
 	init_memory(priv);
@@ -2597,16 +2597,12 @@ int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
 
 	ret = usb_add_hcd(hcd, irq, irqflags);
 	if (ret)
-		goto free_int_slots;
+		goto put_hcd;
 
 	device_wakeup_enable(hcd->self.controller);
 
 	return 0;
 
-free_int_slots:
-	kfree(priv->int_slots);
-free_atl_slots:
-	kfree(priv->atl_slots);
 put_hcd:
 	usb_put_hcd(hcd);
 	return ret;
@@ -2619,6 +2615,4 @@ void isp1760_hcd_unregister(struct isp1760_hcd *priv)
 
 	usb_remove_hcd(priv->hcd);
 	usb_put_hcd(priv->hcd);
-	kfree(priv->atl_slots);
-	kfree(priv->int_slots);
 }
-- 
2.33.0




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

end of thread, other threads:[~2024-09-10  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10  7:26 [PATCH] usb: isp1760: Use devm_kcalloc zhangjiao2
2024-09-10  9:04 ` Greg KH

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