From patchwork Mon Jul 22 11:02:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 18507 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2F0D725E1F for ; Mon, 22 Jul 2013 11:19:17 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id hr11sf3907164vcb.1 for ; Mon, 22 Jul 2013 04:19:16 -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=Wm3P191cKmxBglCfvtp8/9RehGjPZZu0uVxZIZIxRnQ=; b=GPhrLY69MjJjS4bDuqlmtUWj4Rb1NkPK6ZXfqC/gm0JLLKuevloqEE6z0z4HtBF261 oQOpuXTXac2gKgg2LGplemBEro5JCr7vNNcpXgurW3D3+8Bh335vuXO98sRFnLzJzp3W G95Zq1xn4I2c4f1+CE4+j6kib4bhgFc1dUmsXbHmNXdeN9dLSs7hpnpnLh7QVYcR60AC DQG2VoqUZJUC8OmWEQ+qpFTcvawyRAyiBCD0c+hQSZlPNGliNZEfN5HswcgrD4YL4aJF +dIpLJbh4nwuBCWNbpCLElDDuAHxPO1RkMbYyovQ7bb6ViLiQDy9MPwU/WPVgFf79bz+ 4sXw== X-Received: by 10.236.207.169 with SMTP id n29mr15321961yho.50.1374491956642; Mon, 22 Jul 2013 04:19:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.146 with SMTP id r18ls2638326qeq.23.gmail; Mon, 22 Jul 2013 04:19:16 -0700 (PDT) X-Received: by 10.221.4.138 with SMTP id oc10mr9461120vcb.26.1374491956512; Mon, 22 Jul 2013 04:19:16 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id zw14si6899876veb.102.2013.07.22.04.19.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id ht11so960609vcb.19 for ; Mon, 22 Jul 2013 04:19:16 -0700 (PDT) X-Received: by 10.52.120.77 with SMTP id la13mr7705741vdb.23.1374491956420; Mon, 22 Jul 2013 04:19:16 -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 yu8csp50154veb; Mon, 22 Jul 2013 04:19:15 -0700 (PDT) X-Received: by 10.66.253.100 with SMTP id zz4mr30783970pac.48.1374491955570; Mon, 22 Jul 2013 04:19:15 -0700 (PDT) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by mx.google.com with ESMTPS id of1si18461331pbb.282.2013.07.22.04.19.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.177 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.192.177; Received: by mail-pd0-f177.google.com with SMTP id p10so6670003pdj.36 for ; Mon, 22 Jul 2013 04:19:15 -0700 (PDT) X-Received: by 10.68.186.193 with SMTP id fm1mr30003644pbc.163.1374491955145; Mon, 22 Jul 2013 04:19:15 -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.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:14 -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, Maxime Ripard Subject: [PATCH 1/8] iio: at91: Use devm_iio_device_alloc Date: Mon, 22 Jul 2013 16:32:54 +0530 Message-Id: <1374490981-24373-2-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: ALoCoQlr4oeR1mZ3VjL95ZCcUVuyqSnzm42e/itC7gllfIqEMPz5+31TiE5fgHoRTN2gpxzkHLWF X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 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: Maxime Ripard --- drivers/iio/adc/at91_adc.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index b6db6a0..423e079 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -589,11 +589,9 @@ static int at91_adc_probe(struct platform_device *pdev) struct resource *res; u32 reg; - idev = iio_device_alloc(sizeof(struct at91_adc_state)); - if (idev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state)); + if (!idev) + return -ENOMEM; st = iio_priv(idev); @@ -604,8 +602,7 @@ static int at91_adc_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "No platform data available.\n"); - ret = -EINVAL; - goto error_free_device; + return -EINVAL; } platform_set_drvdata(pdev, idev); @@ -618,16 +615,14 @@ static int at91_adc_probe(struct platform_device *pdev) st->irq = platform_get_irq(pdev, 0); if (st->irq < 0) { dev_err(&pdev->dev, "No IRQ ID is designated\n"); - ret = -ENODEV; - goto error_free_device; + return -ENODEV; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); st->reg_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(st->reg_base)) { - ret = PTR_ERR(st->reg_base); - goto error_free_device; + return PTR_ERR(st->reg_base); } /* @@ -642,7 +637,7 @@ static int at91_adc_probe(struct platform_device *pdev) idev); if (ret) { dev_err(&pdev->dev, "Failed to allocate IRQ.\n"); - goto error_free_device; + return ret; } st->clk = devm_clk_get(&pdev->dev, "adc_clk"); @@ -752,9 +747,6 @@ error_disable_clk: clk_disable_unprepare(st->clk); error_free_irq: free_irq(st->irq, idev); -error_free_device: - iio_device_free(idev); -error_ret: return ret; } @@ -769,7 +761,6 @@ static int at91_adc_remove(struct platform_device *pdev) clk_disable_unprepare(st->adc_clk); clk_disable_unprepare(st->clk); free_irq(st->irq, idev); - iio_device_free(idev); return 0; }