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: 115427 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4039249qgn; Tue, 10 Oct 2017 11:05:21 -0700 (PDT) X-Received: by 10.84.232.203 with SMTP id x11mr12845408plm.396.1507658721250; Tue, 10 Oct 2017 11:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507658721; cv=none; d=google.com; s=arc-20160816; b=IJqWrLuYZAf7wuazwdEHg7AqdPdnwBpU+KNS8TgMVmhC1aGTKFDSqMqwDHrGrDGE8k 5AXuDCHChve5IHCkvKaONZQoMFBHGJJHZc4q+KOcrt3IHQiEOQBe5Lryo3jvXidU1HqH IYFzoor/NaQwB0ZEb4LJDXACrRLBfrWtOEGUxMJAeH44a7v2XDCW9iYr8nomdBh0IceY 083XEL1DYc0Vss9ld5IbTlK/XAEWJJKMJy+eU5UVzjxhwurd6+CIcrWxnJr6fvzciv+V 2NGRmo1I/nM3lo4pK+D9ZHtgFmB/NSvfMQVuH7ROdkYEHhkMEXbMwQOZEzLM/rm7n7hY oa8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=TVAlhvP4B9pjX9tFXDxHBKT8IxNJ3xyEo1+WTPp/0UTizOLBuBGLGAXVp0Ts/2HGWA QrR+HYvOEnbgh0uV+ZGojVUYlFSrWpjMs+e06FmLou2MG4z9rNu3csoaERufh4G+0uzZ p6DJm7bwJjmWle1TKYLsOSLK33IIs/Jl+J2g02469W2ozphFWFrdDLevDYJxYzRCCp3j tTZtFOjUcnm3GcA83Lan8poAW6q5khbfrJ9gGSzZooMiXxua7X+ryaJp3Cop830Hl4uw YlGgPnln98+ee06zur5aZLSy96WE4QOq+Wi/KsOp0Bgft6pyyEs4kBZMT8B9XOeRCrkL uHOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SnKfND9d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si8828206plp.584.2017.10.10.11.05.20; Tue, 10 Oct 2017 11:05:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SnKfND9d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932670AbdJJSFS (ORCPT + 26 others); Tue, 10 Oct 2017 14:05:18 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:50790 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932623AbdJJSFN (ORCPT ); Tue, 10 Oct 2017 14:05:13 -0400 Received: by mail-wm0-f49.google.com with SMTP id u138so7493455wmu.5 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=gbFagaTzwgkHTz1Clya201H9VGxONxJs4ZeHdt0BlCTTyDYtLjA0W2C78rYxnJ+76q zB1Jd3TDOfu0Znn979jqdAdXY1wmPmzcD7rSSLaCgtVFmrItLw0L6OhIoxy6L0JLrhVP CEzVyhapWVP6z9ES4ohOr7Ee4RJviP5YW3039HUtB2xCH7FY4BrBIGnSFCrh0FmtH23d 2n8qFyWstxiBI2r5k++KgwwTE5UnO44VNujyTd+zv525HuaNZl6vGoHD3Y8awx2QOBHj olMxgPN3cfRYNf4F6PJWDubOQ30s6SDw5Xj+agdmBv6wet/Xv40YPmQJdjUWwlvNu7ue Ireg== X-Gm-Message-State: AMCzsaXJxJr9QLuPR3rbDfeh7KrZwg2M5CmfY9OrRT3rUT8sIt85wt2l YykpQvdLq+ATEi32JS2+paLMbg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 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);