From patchwork Wed Jul 25 12:05:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1237031 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id EF4E43FDFB for ; Wed, 25 Jul 2012 12:10:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932969Ab2GYMI5 (ORCPT ); Wed, 25 Jul 2012 08:08:57 -0400 Received: from na3sys009aog113.obsmtp.com ([74.125.149.209]:45887 "EHLO na3sys009aog113.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932906Ab2GYMIz (ORCPT ); Wed, 25 Jul 2012 08:08:55 -0400 Received: from mail-lpp01m010-f44.google.com ([209.85.215.44]) (using TLSv1) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKUA/h1npI9XI90zHVWdP8oM5EiAg7JpyB@postini.com; Wed, 25 Jul 2012 05:08:55 PDT Received: by lagv3 with SMTP id v3so650812lag.17 for ; Wed, 25 Jul 2012 05:08:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=iOB7ZCLg6NX+JMGykXrxyOZwK84d7vL+wUqpgxt2Hig=; b=RVDZu+6uUOMKaGQ5zGYzd2gLwCQ4EyauzcQDk5gMdUopjM3+5E2HFUTKO0CIdV1xY6 4TFxIbgWijOHPQguK7BgzKTwfRkzI69IzHJW/ltnEdWdJG86r/D8b7UhJ36XVtTwDvib kSHV2X8l1nD/yK677rFbL0V4JKzdLDW56MtN+2A8VL4+azmYRaOJ+buqo33n5BPlOjlh 2WF90REkErbVsGYx/Wkh8lIx4QC+OIZbWpBJIsu2DRhtFagDXHFrs/TM1jT+Msl4fync cjZQCATt+iwEzWXjaRIt95ybl+Z8/4KRhnkcSFC8gydIF+WFYa3NCwSqFz//QpX4A22X 8NwA== Received: by 10.152.122.9 with SMTP id lo9mr25705861lab.41.1343218132787; Wed, 25 Jul 2012 05:08:52 -0700 (PDT) Received: from localhost (cs78217178.pp.htv.fi. [62.78.217.178]) by mx.google.com with ESMTPS id sm7sm19384236lab.5.2012.07.25.05.08.51 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jul 2012 05:08:52 -0700 (PDT) From: Felipe Balbi To: zbr@ioremap.net Cc: Linux Kernel Mailing List , Linux OMAP Mailing List , Felipe Balbi Subject: [PATCH 4/6] w1: omap-hdq: convert to devm_* functions Date: Wed, 25 Jul 2012 15:05:30 +0300 Message-Id: <1343217932-25372-4-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.11 In-Reply-To: <1343217932-25372-1-git-send-email-balbi@ti.com> References: <1343217932-25372-1-git-send-email-balbi@ti.com> X-Gm-Message-State: ALoCoQm7nnlh3t57wW3Yv/1mdpIc3++eB54GHMMhLW5cgQPenlS+Ehq/jVTCvdGg6RgSBYrT872l Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org this lets us remove a bit of boilerplate code. Signed-off-by: Felipe Balbi --- drivers/w1/masters/omap_hdq.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 1ebddcf..b6eb0ba 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -546,33 +546,31 @@ static void omap_w1_write_byte(void *_hdq, u8 byte) static int __devinit omap_hdq_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct hdq_data *hdq_data; struct resource *res; int ret, irq; u8 rev; - hdq_data = kmalloc(sizeof(*hdq_data), GFP_KERNEL); + hdq_data = devm_kzalloc(dev, sizeof(*hdq_data), GFP_KERNEL); if (!hdq_data) { dev_dbg(&pdev->dev, "unable to allocate memory\n"); - ret = -ENOMEM; - goto err_kmalloc; + return -ENOMEM; } - hdq_data->dev = &pdev->dev; + hdq_data->dev = dev; platform_set_drvdata(pdev, hdq_data); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_dbg(&pdev->dev, "unable to get resource\n"); - ret = -ENXIO; - goto err_resource; + return -ENXIO; } - hdq_data->hdq_base = ioremap(res->start, resource_size(res)); + hdq_data->hdq_base = devm_request_and_ioremap(dev, res); if (!hdq_data->hdq_base) { dev_dbg(&pdev->dev, "ioremap failed\n"); - ret = -EINVAL; - goto err_ioremap; + return -ENOMEM; } hdq_data->hdq_usecount = 0; @@ -593,7 +591,8 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) goto err_irq; } - ret = request_irq(irq, hdq_isr, IRQF_DISABLED, "omap_hdq", hdq_data); + ret = devm_request_irq(dev, irq, hdq_isr, IRQF_DISABLED, + "omap_hdq", hdq_data); if (ret < 0) { dev_dbg(&pdev->dev, "could not request irq\n"); goto err_irq; @@ -618,16 +617,7 @@ err_irq: err_w1: pm_runtime_disable(&pdev->dev); - iounmap(hdq_data->hdq_base); - -err_ioremap: -err_resource: - platform_set_drvdata(pdev, NULL); - kfree(hdq_data); - -err_kmalloc: return ret; - } static int __devexit omap_hdq_remove(struct platform_device *pdev) @@ -646,10 +636,6 @@ static int __devexit omap_hdq_remove(struct platform_device *pdev) /* remove module dependency */ pm_runtime_disable(&pdev->dev); - free_irq(INT_24XX_HDQ_IRQ, hdq_data); - platform_set_drvdata(pdev, NULL); - iounmap(hdq_data->hdq_base); - kfree(hdq_data); return 0; }