From patchwork Mon Jul 22 11:02:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 18511 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 29F0925E1F for ; Mon, 22 Jul 2013 11:19:33 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha12sf8499005vcb.8 for ; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=gOPI3arwsWj4CVl2cUyh3FoikVKTg4K+a3XxtuXkHoI=; b=EAv+3rpDtmym7jKR9WNj3eOW+YXofkvUax2eCqov9iSKNgCVurQN7waQw419jpZeCW ah92NIyuNQeQ0DM4380z1+szdIxtGsEVmrVIrfK7/Eq7hSmsIbQfFjv7IkVfjJ9WW8At ozmr4uSzs17OzYIge8qBwrrejHlRZEVEREVMy4P2abNAmpwUVk4gHmW/ZWF50iAY6T1P /GKPj5H0YhnpLc1OFGqKiPpdxnaAhzLpMZ9MwSWsp/FeI/IzI2JBZax8h12z1MOV2HU2 geQV+TLMUJ9e5bfZmFLbu2Q7wEu9jEknQcFWG7ocg39rUqp53xXnzqyrUNSF00Yyfmtb 5gLA== X-Received: by 10.236.119.107 with SMTP id m71mr15679086yhh.0.1374491972875; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.98.67 with SMTP id eg3ls2675720qeb.28.gmail; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) X-Received: by 10.58.76.34 with SMTP id h2mr9172165vew.93.1374491972763; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id op1si6900198vcb.90.2013.07.22.04.19.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id ox1so4974899veb.27 for ; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) X-Received: by 10.52.35.109 with SMTP id g13mr7725190vdj.21.1374491972654; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp50169veb; Mon, 22 Jul 2013 04:19:32 -0700 (PDT) X-Received: by 10.66.136.237 with SMTP id qd13mr31703276pab.74.1374491971800; Mon, 22 Jul 2013 04:19:31 -0700 (PDT) Received: from mail-pb0-f51.google.com (mail-pb0-f51.google.com [209.85.160.51]) by mx.google.com with ESMTPS id lo1si19568369pab.180.2013.07.22.04.19.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.51 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.51; Received: by mail-pb0-f51.google.com with SMTP id um15so6965766pbc.24 for ; Mon, 22 Jul 2013 04:19:31 -0700 (PDT) X-Received: by 10.66.154.162 with SMTP id vp2mr6627189pab.34.1374491971371; Mon, 22 Jul 2013 04:19:31 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id ry2sm35249515pbc.41.2013.07.22.04.19.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:30 -0700 (PDT) From: Sachin Kamat To: linux-iio@vger.kernel.org Cc: jic23@cam.ac.uk, jic23@kernel.org, sachin.kamat@linaro.org, patches@linaro.org, Marek Vasut Subject: [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Date: Mon, 22 Jul 2013 16:32:58 +0530 Message-Id: <1374490981-24373-6-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374490981-24373-1-git-send-email-sachin.kamat@linaro.org> References: <1374490981-24373-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQk4S7auASsdWikJ8Agqy6ujcnVACBRbIp/BHFnk5DMN22pkVFnvia7zy2s7k+sX4QFCYG/m X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Marek Vasut Reviewed-by: Marek Vasut --- drivers/staging/iio/adc/mxs-lradc.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 327914e..6f8d3a0 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -913,7 +913,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) int i; /* Allocate the IIO device. */ - iio = iio_device_alloc(sizeof(*lradc)); + iio = devm_iio_device_alloc(dev, sizeof(*lradc)); if (!iio) { dev_err(dev, "Failed to allocate IIO device\n"); return -ENOMEM; @@ -925,10 +925,8 @@ static int mxs_lradc_probe(struct platform_device *pdev) iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); lradc->dev = &pdev->dev; lradc->base = devm_ioremap_resource(dev, iores); - if (IS_ERR(lradc->base)) { - ret = PTR_ERR(lradc->base); - goto err_addr; - } + if (IS_ERR(lradc->base)) + return PTR_ERR(lradc->base); INIT_WORK(&lradc->ts_work, mxs_lradc_ts_work); @@ -948,16 +946,14 @@ static int mxs_lradc_probe(struct platform_device *pdev) /* Grab all IRQ sources */ for (i = 0; i < of_cfg->irq_count; i++) { lradc->irq[i] = platform_get_irq(pdev, i); - if (lradc->irq[i] < 0) { - ret = -EINVAL; - goto err_addr; - } + if (lradc->irq[i] < 0) + return -EINVAL; ret = devm_request_irq(dev, lradc->irq[i], mxs_lradc_handle_irq, 0, of_cfg->irq_name[i], iio); if (ret) - goto err_addr; + return ret; } platform_set_drvdata(pdev, iio); @@ -977,7 +973,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) &mxs_lradc_trigger_handler, &mxs_lradc_buffer_ops); if (ret) - goto err_addr; + return ret; ret = mxs_lradc_trigger_init(iio); if (ret) @@ -1008,8 +1004,6 @@ err_dev: mxs_lradc_trigger_remove(iio); err_trig: iio_triggered_buffer_cleanup(iio); -err_addr: - iio_device_free(iio); return ret; } @@ -1025,7 +1019,6 @@ static int mxs_lradc_remove(struct platform_device *pdev) iio_device_unregister(iio); iio_triggered_buffer_cleanup(iio); mxs_lradc_trigger_remove(iio); - iio_device_free(iio); return 0; }