From: Kishon Vijay Abraham I <kishon@ti.com>
To: gregkh@linuxfoundation.org, kishon@ti.com,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, balbi@ti.com
Subject: [PATCH 4/5] usb: musb: omap: use devres API to allocate resources
Date: Tue, 5 Jun 2012 15:08:37 +0530 [thread overview]
Message-ID: <1338889118-10032-5-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1338889118-10032-1-git-send-email-kishon@ti.com>
used devres API while allocating memory resource and while getting
usb phy so that these resources are released automatically on driver
detach.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/usb/musb/omap2430.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 24d1cd5..f895d99 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -319,7 +319,7 @@ static int omap2430_musb_init(struct musb *musb)
* up through ULPI. TWL4030-family PMICs include one,
* which needs a driver, drivers aren't always needed.
*/
- musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+ musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
if (!musb->xceiv) {
pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV;
@@ -416,7 +416,6 @@ static int omap2430_musb_exit(struct musb *musb)
del_timer_sync(&musb_idle_timer);
omap2430_low_level_exit(musb);
- usb_put_phy(musb->xceiv);
return 0;
}
@@ -443,7 +442,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
struct omap2430_glue *glue;
int ret = -ENOMEM;
- glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+ glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
if (!glue) {
dev_err(&pdev->dev, "failed to allocate glue context\n");
goto err0;
@@ -452,7 +451,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
musb = platform_device_alloc("musb-hdrc", -1);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err0;
}
musb->dev.parent = &pdev->dev;
@@ -479,13 +478,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err2;
+ goto err1;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err2;
+ goto err1;
}
pm_runtime_enable(&pdev->dev);
@@ -493,16 +492,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err2;
+ goto err1;
}
return 0;
-err2:
- platform_device_put(musb);
-
err1:
- kfree(glue);
+ platform_device_put(musb);
err0:
return ret;
@@ -515,7 +511,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev)
cancel_work_sync(&glue->omap_musb_mailbox_work);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
- kfree(glue);
return 0;
}
--
1.7.5.4
next prev parent reply other threads:[~2012-06-05 9:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-05 9:38 [PATCH 0/5] usb: musb: cleanup Kishon Vijay Abraham I
2012-06-05 9:38 ` [PATCH 1/5] usb: musb: move work_struct(otg_notifier_work) from core to omap glue Kishon Vijay Abraham I
[not found] ` <1338889118-10032-2-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2012-06-05 12:00 ` Sergei Shtylyov
2012-06-05 9:38 ` [PATCH 2/5] usb: musb: twl: use mailbox API to send VBUS or ID events Kishon Vijay Abraham I
2012-06-05 9:38 ` [PATCH 3/5] drivers: usb: musb: move otg specific initializations from twl to glue Kishon Vijay Abraham I
2012-06-05 9:38 ` Kishon Vijay Abraham I [this message]
2012-06-05 9:38 ` [PATCH 5/5] drivers: usb: otg: twl: use devres API to allocate resources Kishon Vijay Abraham I
2012-06-12 10:48 ` [PATCH 0/5] usb: musb: cleanup Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338889118-10032-5-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox