From patchwork Mon Jul 22 11:02:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 18510 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 4D2E225E1F for ; Mon, 22 Jul 2013 11:19:29 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha12sf8498955vcb.8 for ; Mon, 22 Jul 2013 04:19:29 -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=Xdsq/CqVWhdCMNH6QFca0aoOdWTdxedKbvo+TCbnbHk=; b=Am2bHOLe0P3wgziuMTiNKp9BAeabbzziZUvsKOfoGlWHfyy+5tE9rffyCVA/PCp60X Iz8qs5dT22lu22xHr4JmTyL+9TYnEaBXfdBSNv8MVruh+RrFOb3/wsccFaidl671Qjw9 xHPf4KcZrwrzZayGmb/T5WXZL4oWS0bqk+CWHWXIfYwvYAepU0K0qqOvWeqDZOG3HqMw aY+QMFACuc2xAXyJUyngzXCjUVlQ9nMa3ueMugqR3o1f9RmOikwZPL13o8QsANaJY5jf c0ShIAKNTmhmCMoyt5+Tc9uaOv5IL2QWqdW+icUtkU5rekt74Gl5hXinK+CYGvx4ppgO H/zQ== X-Received: by 10.236.150.82 with SMTP id y58mr15696293yhj.5.1374491968988; Mon, 22 Jul 2013 04:19:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.73.137 with SMTP id l9ls2634131qev.0.gmail; Mon, 22 Jul 2013 04:19:28 -0700 (PDT) X-Received: by 10.52.165.12 with SMTP id yu12mr7688240vdb.40.1374491968896; Mon, 22 Jul 2013 04:19:28 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id gr9si6899244vec.111.2013.07.22.04.19.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 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.169; Received: by mail-vc0-f169.google.com with SMTP id ib11so2911673vcb.14 for ; Mon, 22 Jul 2013 04:19:28 -0700 (PDT) X-Received: by 10.58.119.233 with SMTP id kx9mr9313714veb.3.1374491968812; Mon, 22 Jul 2013 04:19:28 -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 yu8csp50166veb; Mon, 22 Jul 2013 04:19:28 -0700 (PDT) X-Received: by 10.66.253.195 with SMTP id ac3mr31663786pad.107.1374491967917; Mon, 22 Jul 2013 04:19:27 -0700 (PDT) Received: from mail-pb0-f43.google.com (mail-pb0-f43.google.com [209.85.160.43]) by mx.google.com with ESMTPS id pf2si19567254pac.186.2013.07.22.04.19.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.43 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.43; Received: by mail-pb0-f43.google.com with SMTP id md12so6933010pbc.16 for ; Mon, 22 Jul 2013 04:19:27 -0700 (PDT) X-Received: by 10.68.228.201 with SMTP id sk9mr30324911pbc.4.1374491967467; Mon, 22 Jul 2013 04:19:27 -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.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Jul 2013 04:19:26 -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, Michael Hennerich Subject: [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs Date: Mon, 22 Jul 2013 16:32:57 +0530 Message-Id: <1374490981-24373-5-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: ALoCoQmmEXDEg5KRi0sXG3+A42RzwAvYQbZ82whwyrRs9ImmBGLiuH1Tg9oZXkRlTlVfqzHWkfhT X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 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: , devm_* APIs are device managed and make code simpler. This also takes care of missing clk_put function calls implicitly. Signed-off-by: Sachin Kamat Cc: Michael Hennerich --- drivers/iio/frequency/adf4350.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index a4157cd..a7b30be 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c @@ -515,7 +515,7 @@ static int adf4350_probe(struct spi_device *spi) } if (!pdata->clkin) { - clk = clk_get(&spi->dev, "clkin"); + clk = devm_clk_get(&spi->dev, "clkin"); if (IS_ERR(clk)) return -EPROBE_DEFER; @@ -524,17 +524,17 @@ static int adf4350_probe(struct spi_device *spi) return ret; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + goto error_disable_clk; } spi_set_drvdata(spi, indio_dev); @@ -564,7 +564,8 @@ static int adf4350_probe(struct spi_device *spi) memset(st->regs_hw, 0xFF, sizeof(st->regs_hw)); if (gpio_is_valid(pdata->gpio_lock_detect)) { - ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name); + ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect, + indio_dev->name); if (ret) { dev_err(&spi->dev, "fail to request lock detect GPIO-%d", pdata->gpio_lock_detect); @@ -576,29 +577,21 @@ static int adf4350_probe(struct spi_device *spi) if (pdata->power_up_frequency) { ret = adf4350_set_freq(st, pdata->power_up_frequency); if (ret) - goto error_free_gpio; + goto error_disable_reg; } ret = iio_device_register(indio_dev); if (ret) - goto error_free_gpio; + goto error_disable_reg; return 0; -error_free_gpio: - if (gpio_is_valid(pdata->gpio_lock_detect)) - gpio_free(pdata->gpio_lock_detect); - error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - +error_disable_clk: if (clk) clk_disable_unprepare(clk); - iio_device_free(indio_dev); return ret; } @@ -619,14 +612,8 @@ static int adf4350_remove(struct spi_device *spi) if (!IS_ERR(reg)) { regulator_disable(reg); - regulator_put(reg); } - if (gpio_is_valid(st->pdata->gpio_lock_detect)) - gpio_free(st->pdata->gpio_lock_detect); - - iio_device_free(indio_dev); - return 0; }