From patchwork Fri Sep 19 18:05:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Gurav X-Patchwork-Id: 4939161 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 725E8BEEA5 for ; Fri, 19 Sep 2014 18:05:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DEF92020E for ; Fri, 19 Sep 2014 18:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA6F0201FA for ; Fri, 19 Sep 2014 18:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757587AbaISSFZ (ORCPT ); Fri, 19 Sep 2014 14:05:25 -0400 Received: from smtp93.ord1c.emailsrvr.com ([108.166.43.93]:35453 "EHLO smtp93.ord1c.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756107AbaISSFY (ORCPT ); Fri, 19 Sep 2014 14:05:24 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp4.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id B32E518077C; Fri, 19 Sep 2014 14:05:23 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp4.relay.ord1c.emailsrvr.com (Authenticated sender: pramod.gurav-AT-smartplayin.com) with ESMTPSA id 67C08180793; Fri, 19 Sep 2014 14:05:21 -0400 (EDT) X-Sender-Id: pramod.gurav@smartplayin.com Received: from localhost.localdomain ([UNAVAILABLE]. [27.7.162.117]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:465 (trex/5.2.10); Fri, 19 Sep 2014 18:05:23 GMT From: Pramod Gurav To: linux-kernel@vger.kernel.org Cc: Pramod Gurav , Eduardo Valentin , Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH] thermal: ti-soc-thermal: Switch to using managed resources Date: Fri, 19 Sep 2014 23:35:09 +0530 Message-Id: <1411149909-13007-1-git-send-email-pramod.gurav@smartplayin.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change switches to managed resource APIs to allocated resources such as irq, clock. Hence does away with release statements of the same resorces in error lables and remove function. Cc: Eduardo Valentin Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Signed-off-by: Pramod Gurav --- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 46 ++++++++--------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index 634b6ce..e068dd5 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -1060,7 +1060,7 @@ static int ti_bandgap_tshut_init(struct ti_bandgap *bgp, int status; /* Request for gpio_86 line */ - status = gpio_request(gpio_nr, "tshut"); + status = devm_gpio_request(&pdev->dev, gpio_nr, "tshut"); if (status < 0) { dev_err(bgp->dev, "Could not request for TSHUT GPIO:%i\n", 86); return status; @@ -1071,11 +1071,12 @@ static int ti_bandgap_tshut_init(struct ti_bandgap *bgp, return status; } - status = request_irq(gpio_to_irq(gpio_nr), ti_bandgap_tshut_irq_handler, - IRQF_TRIGGER_RISING, "tshut", NULL); + status = devm_request_irq(&pdev->dev, gpio_to_irq(gpio_nr), + ti_bandgap_tshut_irq_handler, + IRQF_TRIGGER_RISING, "tshut", NULL); if (status) { - gpio_free(gpio_nr); dev_err(bgp->dev, "request irq failed for TSHUT"); + return status; } return 0; @@ -1104,7 +1105,7 @@ static int ti_bandgap_talert_init(struct ti_bandgap *bgp, dev_err(&pdev->dev, "get_irq failed\n"); return bgp->irq; } - ret = request_threaded_irq(bgp->irq, NULL, + ret = devm_request_threaded_irq(&pdev->dev, bgp->irq, NULL, ti_bandgap_talert_irq_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "talert", bgp); @@ -1212,21 +1213,17 @@ int ti_bandgap_probe(struct platform_device *pdev) } } - bgp->fclock = clk_get(NULL, bgp->conf->fclock_name); - ret = IS_ERR(bgp->fclock); - if (ret) { + bgp->fclock = devm_clk_get(NULL, bgp->conf->fclock_name); + if (IS_ERR(bgp->fclock)) { dev_err(&pdev->dev, "failed to request fclock reference\n"); - ret = PTR_ERR(bgp->fclock); - goto free_irqs; + return PTR_ERR(bgp->fclock); } - bgp->div_clk = clk_get(NULL, bgp->conf->div_ck_name); - ret = IS_ERR(bgp->div_clk); - if (ret) { + bgp->div_clk = devm_clk_get(NULL, bgp->conf->div_ck_name); + if (IS_ERR(bgp->div_clk)) { dev_err(&pdev->dev, "failed to request div_ts_ck clock ref\n"); - ret = PTR_ERR(bgp->div_clk); - goto free_irqs; + return PTR_ERR(bgp->div_clk); } for (i = 0; i < bgp->conf->sensor_count; i++) { @@ -1251,7 +1248,6 @@ int ti_bandgap_probe(struct platform_device *pdev) clk_rate <= 0) { ret = -ENODEV; dev_err(&pdev->dev, "wrong clock rate (%d)\n", clk_rate); - goto put_clks; } ret = clk_set_rate(bgp->div_clk, clk_rate); @@ -1357,14 +1353,6 @@ remove_sensors: disable_clk: if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) clk_disable_unprepare(bgp->fclock); -put_clks: - clk_put(bgp->fclock); - clk_put(bgp->div_clk); -free_irqs: - if (TI_BANDGAP_HAS(bgp, TSHUT)) { - free_irq(gpio_to_irq(bgp->tshut_gpio), NULL); - gpio_free(bgp->tshut_gpio); - } return ret; } @@ -1388,16 +1376,6 @@ int ti_bandgap_remove(struct platform_device *pdev) if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) clk_disable_unprepare(bgp->fclock); - clk_put(bgp->fclock); - clk_put(bgp->div_clk); - - if (TI_BANDGAP_HAS(bgp, TALERT)) - free_irq(bgp->irq, bgp); - - if (TI_BANDGAP_HAS(bgp, TSHUT)) { - free_irq(gpio_to_irq(bgp->tshut_gpio), NULL); - gpio_free(bgp->tshut_gpio); - } return 0; }