drivers/usb/host/ehci-sh.c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver detaches. This patch uses these functions for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6c40f5ee0f
commit
a926e298b6
@ -125,33 +125,27 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
|
|||||||
hcd->rsrc_start = res->start;
|
hcd->rsrc_start = res->start;
|
||||||
hcd->rsrc_len = resource_size(res);
|
hcd->rsrc_len = resource_size(res);
|
||||||
|
|
||||||
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
|
hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
|
||||||
driver->description)) {
|
|
||||||
dev_dbg(&pdev->dev, "controller already in use\n");
|
|
||||||
ret = -EBUSY;
|
|
||||||
goto fail_request_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
|
|
||||||
if (hcd->regs == NULL) {
|
if (hcd->regs == NULL) {
|
||||||
dev_dbg(&pdev->dev, "error mapping memory\n");
|
dev_dbg(&pdev->dev, "error mapping memory\n");
|
||||||
ret = -ENXIO;
|
ret = -ENXIO;
|
||||||
goto fail_ioremap;
|
goto fail_request_resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = kmalloc(sizeof(struct ehci_sh_priv), GFP_KERNEL);
|
priv = devm_kzalloc(&pdev->dev, sizeof(struct ehci_sh_priv),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
dev_dbg(&pdev->dev, "error allocating priv data\n");
|
dev_dbg(&pdev->dev, "error allocating priv data\n");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto fail_alloc;
|
goto fail_request_resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These are optional, we don't care if they fail */
|
/* These are optional, we don't care if they fail */
|
||||||
priv->fclk = clk_get(&pdev->dev, "usb_fck");
|
priv->fclk = devm_clk_get(&pdev->dev, "usb_fck");
|
||||||
if (IS_ERR(priv->fclk))
|
if (IS_ERR(priv->fclk))
|
||||||
priv->fclk = NULL;
|
priv->fclk = NULL;
|
||||||
|
|
||||||
priv->iclk = clk_get(&pdev->dev, "usb_ick");
|
priv->iclk = devm_clk_get(&pdev->dev, "usb_ick");
|
||||||
if (IS_ERR(priv->iclk))
|
if (IS_ERR(priv->iclk))
|
||||||
priv->iclk = NULL;
|
priv->iclk = NULL;
|
||||||
|
|
||||||
@ -176,14 +170,6 @@ fail_add_hcd:
|
|||||||
clk_disable(priv->iclk);
|
clk_disable(priv->iclk);
|
||||||
clk_disable(priv->fclk);
|
clk_disable(priv->fclk);
|
||||||
|
|
||||||
clk_put(priv->iclk);
|
|
||||||
clk_put(priv->fclk);
|
|
||||||
|
|
||||||
kfree(priv);
|
|
||||||
fail_alloc:
|
|
||||||
iounmap(hcd->regs);
|
|
||||||
fail_ioremap:
|
|
||||||
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
|
|
||||||
fail_request_resource:
|
fail_request_resource:
|
||||||
usb_put_hcd(hcd);
|
usb_put_hcd(hcd);
|
||||||
fail_create_hcd:
|
fail_create_hcd:
|
||||||
@ -198,19 +184,12 @@ static int __exit ehci_hcd_sh_remove(struct platform_device *pdev)
|
|||||||
struct usb_hcd *hcd = priv->hcd;
|
struct usb_hcd *hcd = priv->hcd;
|
||||||
|
|
||||||
usb_remove_hcd(hcd);
|
usb_remove_hcd(hcd);
|
||||||
iounmap(hcd->regs);
|
|
||||||
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
|
|
||||||
usb_put_hcd(hcd);
|
usb_put_hcd(hcd);
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
clk_disable(priv->fclk);
|
clk_disable(priv->fclk);
|
||||||
clk_disable(priv->iclk);
|
clk_disable(priv->iclk);
|
||||||
|
|
||||||
clk_put(priv->fclk);
|
|
||||||
clk_put(priv->iclk);
|
|
||||||
|
|
||||||
kfree(priv);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user