[PATCH] usb: isp1760: Use devm_kcalloc

From: zhangjiao2
Date: Tue Sep 10 2024 - 05:00:33 EST


From: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>

Use devm_kcalloc to simplify code.

Signed-off-by: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>
---
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