From patchwork Tue Oct 10 18:02:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 9996929 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4ADD660216 for ; Tue, 10 Oct 2017 18:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F2A1286C6 for ; Tue, 10 Oct 2017 18:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 313AA28710; Tue, 10 Oct 2017 18:08:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8B71286C6 for ; Tue, 10 Oct 2017 18:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932640AbdJJSFP (ORCPT ); Tue, 10 Oct 2017 14:05:15 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:47353 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932625AbdJJSFN (ORCPT ); Tue, 10 Oct 2017 14:05:13 -0400 Received: by mail-wm0-f41.google.com with SMTP id t69so7542500wmt.2 for ; Tue, 10 Oct 2017 11:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=SnKfND9dB0H32TgbjSezsGJ2n+9jJGYjyFYrpctqLz8IiMZvm82iEvxBu9FqaS+UGC hS394lWiIyGn6X5fYHD4bE/aj4jxPordp4TuA+zji7ViV8jhdi23ljrmLFpHV+UDw+ay 4WFXfZba8VuA3yMWBY++mhBu+qPoW4InWUQjo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=dyM6qw1YNxXYPRak0WUAxMHl4LzMJK59+LuLy9b8RJ0oefES80dc6A+V4+Dt1NexKl 2Qeu0w8FxB3nCoBFOZQVbvNQ1Uel+AduWGP30ov7Gyy4jnwHg8iAt8ZEYULaMnkcfcw7 1caqtLSw8ltIsO3EoCMvIKvo3D4lHhmsr/+QLDC5IuiMDeybTfF388luPEHCcSDH8Tns LRba7MlxHooWZoiMyfqXNJk9GVhVQbI+vBYo5dgiZFlnxX3T7VviOPPt2mOZBKGzFQCJ Rn3nCosQz3xiIioOYbTE4SDCC8ltznYSF24vWVGAeP2IyG6C2l0oQ95jfuoANWr2qpt9 +eRg== X-Gm-Message-State: AMCzsaX0QUrBVs58/7EE/fZtjWEu5DWnH9x5ScmJYpuBAeP4rsOG7Mwx PsGC0BT3KCIusjo+E7Jd/IyM0WDUYhA= X-Google-Smtp-Source: AOwi7QA37LAtp3K+Cuz006KWwc1KkdC5ETF3nU08aPqU6Cu+QKXEiv7KX59ndYKaA0Frr4E4W62VWQ== X-Received: by 10.28.197.201 with SMTP id v192mr12924380wmf.52.1507658712553; Tue, 10 Oct 2017 11:05:12 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:4f9:3ae1:43d2:31ae]) by smtp.gmail.com with ESMTPSA id l73sm12513428wmd.47.2017.10.10.11.05.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:05:12 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kevin.wangtao@linaro.org Subject: [PATCH 16/25] thermal/drivers/qcom-spmi: Use devm_iio_channel_get Date: Tue, 10 Oct 2017 20:02:41 +0200 Message-Id: <1507658570-32675-16-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> References: <79a5f10c-0fb7-3e4f-caac-c1625904b137@linaro.org> <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The iio_channel_get() function has now its devm_ version. Use it and remove all the rollback code for iio_channel_release() as well as the .remove ops. [Compiled tested only] Signed-off-by: Daniel Lezcano --- drivers/thermal/qcom-spmi-temp-alarm.c | 43 +++++++++++----------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/thermal/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom-spmi-temp-alarm.c index f502419..95f987d 100644 --- a/drivers/thermal/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom-spmi-temp-alarm.c @@ -125,7 +125,7 @@ static int qpnp_tm_get_temp(void *data, int *temp) if (!temp) return -EINVAL; - if (IS_ERR(chip->adc)) { + if (!chip->adc) { ret = qpnp_tm_update_temp_no_adc(chip); if (ret < 0) return ret; @@ -224,67 +224,53 @@ static int qpnp_tm_probe(struct platform_device *pdev) return irq; /* ADC based measurements are optional */ - chip->adc = iio_channel_get(&pdev->dev, "thermal"); - if (PTR_ERR(chip->adc) == -EPROBE_DEFER) - return PTR_ERR(chip->adc); + chip->adc = devm_iio_channel_get(&pdev->dev, "thermal"); + if (IS_ERR(chip->adc)) { + ret = PTR_ERR(chip->adc); + chip->adc = NULL; + if (ret == -EPROBE_DEFER) + return ret; + } chip->base = res; ret = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, &type); if (ret < 0) { dev_err(&pdev->dev, "could not read type\n"); - goto fail; + return ret; } ret = qpnp_tm_read(chip, QPNP_TM_REG_SUBTYPE, &subtype); if (ret < 0) { dev_err(&pdev->dev, "could not read subtype\n"); - goto fail; + return ret; } if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) { dev_err(&pdev->dev, "invalid type 0x%02x or subtype 0x%02x\n", type, subtype); - ret = -ENODEV; - goto fail; + return -ENODEV; } ret = qpnp_tm_init(chip); if (ret < 0) { dev_err(&pdev->dev, "init failed\n"); - goto fail; + return ret; } ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr, IRQF_ONESHOT, node->name, chip); if (ret < 0) - goto fail; + return ret; chip->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, chip, &qpnp_tm_sensor_ops); if (IS_ERR(chip->tz_dev)) { dev_err(&pdev->dev, "failed to register sensor\n"); - ret = PTR_ERR(chip->tz_dev); - goto fail; + return PTR_ERR(chip->tz_dev); } return 0; - -fail: - if (!IS_ERR(chip->adc)) - iio_channel_release(chip->adc); - - return ret; -} - -static int qpnp_tm_remove(struct platform_device *pdev) -{ - struct qpnp_tm_chip *chip = dev_get_drvdata(&pdev->dev); - - if (!IS_ERR(chip->adc)) - iio_channel_release(chip->adc); - - return 0; } static const struct of_device_id qpnp_tm_match_table[] = { @@ -299,7 +285,6 @@ static struct platform_driver qpnp_tm_driver = { .of_match_table = qpnp_tm_match_table, }, .probe = qpnp_tm_probe, - .remove = qpnp_tm_remove, }; module_platform_driver(qpnp_tm_driver);