From patchwork Mon Sep 3 10:18:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11145 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6260523E29 for ; Mon, 3 Sep 2012 10:21:03 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id EE001A188C8 for ; Mon, 3 Sep 2012 10:20:15 +0000 (UTC) Received: by iafj25 with SMTP id j25so7144780iaf.11 for ; Mon, 03 Sep 2012 03:21:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=zNqoRcVjVMFxhfR716ia01wcalWRQtICuG4253269tM=; b=DqwyLL/58wY4nisrdLbV082MLxNqampOAdjDoe7EAw58kffcZ6HpcKmNHumim4VeYw cYQBB/RCs/PS+8rwtj5a9FseRWkp/C9/pukYFuNPMuguJB43bCJgB4v44O2l026b/7nc +EzPL0oMTwpkAmc4dvPrdNOVk/74gY1tPo3aWhCvYGsxN17u/NiK57J79KG48l1PSqdj y048KqI8oBX/FTavSd8a3omDZjavZ8/CvOCo964bdKEerroYMh5cABqJXeMInhBG2gOu 0AvCgca737Xrl6/7Mu/PcGPj2vOQ+TQgWTF40LpXCP00xWStYYdVs8t28fBwPUSiHLdt l/5g== Received: by 10.42.109.194 with SMTP id m2mr14625268icp.48.1346667662210; Mon, 03 Sep 2012 03:21:02 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp129137igc; Mon, 3 Sep 2012 03:21:01 -0700 (PDT) Received: by 10.66.74.100 with SMTP id s4mr33071789pav.27.1346667660665; Mon, 03 Sep 2012 03:21:00 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id sb7si21762985pbc.241.2012.09.03.03.21.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Sep 2012 03:21:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by pbcmd12 with SMTP id md12so8502726pbc.37 for ; Mon, 03 Sep 2012 03:21:00 -0700 (PDT) Received: by 10.66.74.195 with SMTP id w3mr32892870pav.64.1346667659980; Mon, 03 Sep 2012 03:20:59 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id gf8sm9633261pbc.52.2012.09.03.03.20.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Sep 2012 03:20:59 -0700 (PDT) From: Sachin Kamat To: linux-usb@vger.kernel.org Cc: balbi@ti.com, gregkh@linuxfoundation.org, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 1/3] usb: gadget: s3c-hsudc: Use devm_* functions Date: Mon, 3 Sep 2012 15:48:18 +0530 Message-Id: <1346667500-22555-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQl240DAkpHO09oVDlpLX2DUPayGanxp36+52V3dPRWY9eH3InW3I5Iqo6PWT3OrYtD9JycA devm_* functions are used to replace kzalloc, request_mem_region, ioremap clk_get and request_irq functions in probe call. With the usage of devm_* functions explicit freeing and unmapping is not required. Signed-off-by: Sachin Kamat --- drivers/usb/gadget/s3c-hsudc.c | 41 ++++++++------------------------------- 1 files changed, 9 insertions(+), 32 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index e26a4e7..fe4a461 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -135,7 +135,6 @@ struct s3c_hsudc_req { * @dev: The device reference used by probe function. * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). * @regs: Remapped base address of controller's register space. - * @mem_rsrc: Device memory resource used for remapping device register space. * irq: IRQ number used by the controller. * uclk: Reference to the controller clock. * ep0state: Current state of EP0. @@ -150,7 +149,6 @@ struct s3c_hsudc { struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; spinlock_t lock; void __iomem *regs; - struct resource *mem_rsrc; int irq; struct clk *uclk; int ep0state; @@ -1271,7 +1269,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; int ret, i; - hsudc = kzalloc(sizeof(struct s3c_hsudc) + + hsudc = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsudc) + sizeof(struct s3c_hsudc_ep) * pd->epnum, GFP_KERNEL); if (!hsudc) { @@ -1296,25 +1294,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "unable to obtain driver resource data\n"); - ret = -ENODEV; - goto err_res; - } - - hsudc->mem_rsrc = request_mem_region(res->start, resource_size(res), - dev_name(&pdev->dev)); - if (!hsudc->mem_rsrc) { - dev_err(dev, "failed to reserve register area\n"); - ret = -ENODEV; - goto err_res; - } - hsudc->regs = ioremap(res->start, resource_size(res)); + hsudc->regs = devm_request_and_ioremap(&pdev->dev, res); if (!hsudc->regs) { dev_err(dev, "error mapping device register area\n"); ret = -EBUSY; - goto err_remap; + goto err_res; } spin_lock_init(&hsudc->lock); @@ -1337,21 +1322,22 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ret = platform_get_irq(pdev, 0); if (ret < 0) { dev_err(dev, "unable to obtain IRQ number\n"); - goto err_irq; + goto err_res; } hsudc->irq = ret; - ret = request_irq(hsudc->irq, s3c_hsudc_irq, 0, driver_name, hsudc); + ret = devm_request_irq(&pdev->dev, hsudc->irq, s3c_hsudc_irq, 0, + driver_name, hsudc); if (ret < 0) { dev_err(dev, "irq request failed\n"); - goto err_irq; + goto err_res; } - hsudc->uclk = clk_get(&pdev->dev, "usb-device"); + hsudc->uclk = devm_clk_get(&pdev->dev, "usb-device"); if (IS_ERR(hsudc->uclk)) { dev_err(dev, "failed to find usb-device clock source\n"); ret = PTR_ERR(hsudc->uclk); - goto err_clk; + goto err_res; } clk_enable(hsudc->uclk); @@ -1377,21 +1363,12 @@ err_add_udc: device_unregister(&hsudc->gadget.dev); err_add_device: clk_disable(hsudc->uclk); - clk_put(hsudc->uclk); -err_clk: - free_irq(hsudc->irq, hsudc); -err_irq: - iounmap(hsudc->regs); - -err_remap: - release_mem_region(res->start, resource_size(res)); err_res: if (!IS_ERR_OR_NULL(hsudc->transceiver)) usb_put_phy(hsudc->transceiver); regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); err_supplies: - kfree(hsudc); return ret; }