From patchwork Mon Jul 22 11:02:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 18509 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D4E7225E1F for ; Mon, 22 Jul 2013 11:19:25 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf1987897vcb.3 for ; Mon, 22 Jul 2013 04:19:25 -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=gcoEM2KZ0od9qZJC7lzvN93mOr6ZVNWRRMyx6Etqxco=; b=asPxJqnYL7tEcywcs+Oqwd4gvFdrwTzYHS3nbgWu/x0L3DgmQHXmOrxAtS3/D6uOwS kGe5omUncAz6BKZmJlDiBWwNzrncKqjkYBDgJ1tafpiWLKJNTPuMe2y0IOiWzhqz8A8n 5wvtEGB5sVyZmD45LtffaNg7kJOhP9EPESuUW4TurUZiaFoeRvunpo6c2MftTDeGPcRJ vl8XdyR/LwhgfcNQy1LuCLOWJ+p5aNlD1XhGI45WPEseZOChFwJJfU5SU4DP3HVw1oqx BunsyJA4bWjRlWH12ZZ0j6tJt9EHG5MLPGlkqj2CItgJRimbu4AfD0uKsPkoz7UVFLCG 6CSg== X-Received: by 10.236.91.4 with SMTP id g4mr15552272yhf.30.1374491965408; Mon, 22 Jul 2013 04:19:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.117.231 with SMTP id kh7ls2485713qeb.26.gmail; Mon, 22 Jul 2013 04:19:25 -0700 (PDT) X-Received: by 10.58.249.236 with SMTP id yx12mr9212271vec.25.1374491965299; Mon, 22 Jul 2013 04:19:25 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id ff3si6907365vcb.20.2013.07.22.04.19.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 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.181; Received: by mail-vc0-f181.google.com with SMTP id lf10so323893vcb.26 for ; Mon, 22 Jul 2013 04:19:25 -0700 (PDT) X-Received: by 10.220.17.206 with SMTP id t14mr9157794vca.15.1374491965233; Mon, 22 Jul 2013 04:19:25 -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 yu8csp50164veb; Mon, 22 Jul 2013 04:19:24 -0700 (PDT) X-Received: by 10.68.106.67 with SMTP id gs3mr30224983pbb.126.1374491964417; Mon, 22 Jul 2013 04:19:24 -0700 (PDT) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id ol10si18506434pbb.34.2013.07.22.04.19.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id rq2so6920774pbb.5 for ; Mon, 22 Jul 2013 04:19:24 -0700 (PDT) X-Received: by 10.68.191.231 with SMTP id hb7mr28466566pbc.82.1374491964036; Mon, 22 Jul 2013 04:19:24 -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.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:23 -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 Subject: [PATCH 3/8] iio: max1363: Use devm_iio_device_alloc Date: Mon, 22 Jul 2013 16:32:56 +0530 Message-Id: <1374490981-24373-4-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: ALoCoQkQ0wHf2AiHS1uTNep2GCfZHddxJg0chto4DgZnTAiCxv27gkw3DJNAQ1sMxqhYJHzHoGmg X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 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 --- drivers/iio/adc/max1363.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index f148d00..4fb35d1 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct regulator *vref; - indio_dev = iio_device_alloc(sizeof(struct max1363_state)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_out; - } + indio_dev = devm_iio_device_alloc(&client->dev, + sizeof(struct max1363_state)); + if (!indio_dev) + return -ENOMEM; indio_dev->dev.of_node = client->dev.of_node; ret = iio_map_array_register(indio_dev, client->dev.platform_data); if (ret < 0) - goto error_free_device; + return ret; st = iio_priv(indio_dev); @@ -1590,9 +1589,6 @@ error_disable_reg: regulator_disable(st->reg); error_unregister_map: iio_map_array_unregister(indio_dev); -error_free_device: - iio_device_free(indio_dev); -error_out: return ret; } @@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client) regulator_disable(st->vref); regulator_disable(st->reg); iio_map_array_unregister(indio_dev); - iio_device_free(indio_dev); return 0; }