From patchwork Thu Oct 19 17:06:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116421 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp722147qgn; Thu, 19 Oct 2017 10:09:05 -0700 (PDT) X-Received: by 10.84.210.105 with SMTP id z96mr2002387plh.325.1508432945578; Thu, 19 Oct 2017 10:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432945; cv=none; d=google.com; s=arc-20160816; b=Y3L1aEXiWCsGTsXpXNHRGvtnMMjvHTCo4vYgVem0CEeB9wr6MEQ3D1gz8tOZz1gsgi kwVvAMCSzxyC6ubgeQkurAcIP9MuiSLQi7/GumegGdIFhf3/Kqs8bXKAyenWmfC7SecT eUCBmhhn/eiscOq3etqF1ywvLrDuvtymxLaDDSStnKPcvpxqjn0RUfdAowTmsmtJ6yxK Mi0ixCcWdhwnJKi2FAIxRsZQZl+3xp74PBaubRzs5+Mu5K1LCv2coauJIFdvn/Buucza T1CVutKBtrS4ey+Gk4pjwYjKy6kA1vm0FiGA69pEc7svrTUWeITZNoTerlNw+9eaO3UK LSrg== 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=xTJ+d1cAsk4Se0ihlbmKi6HWUcl7pxxwJLYnh4/1GMTwwb5zywlxZW3hQkimC61nRM 3ckbrVqDlV6GzATzezMhPEhOU3qD727H9ZEYX132H7w5yRzHjRNVuSOqzocL5yz1ojYW GIg8WTzm4aYRlhCy/o5UDZnpmoSPKtCyEH+mHx1cvgBRNtJbe/cEQ/GrVNHwmhMDlIYw 5eccRkVKgeSy1I1L7mtDqldSVSIYF37BWW5Oc/wr2pK/hV35KjwWMmVL7RBhdA9cC/Iq /tOGXACiP6Vh1yo061/0kw+/BX7lbfjmRnTpKd/fdVBtRIMVKdl9wXdJS0ZP2Z2LDT0Z NL0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esKQCEuQ; 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 w65si9601645pfk.197.2017.10.19.10.09.05; Thu, 19 Oct 2017 10:09:05 -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=esKQCEuQ; 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 S1755161AbdJSRJC (ORCPT + 27 others); Thu, 19 Oct 2017 13:09:02 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:57330 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755137AbdJSRI4 (ORCPT ); Thu, 19 Oct 2017 13:08:56 -0400 Received: by mail-wr0-f196.google.com with SMTP id r79so9047793wrb.13 for ; Thu, 19 Oct 2017 10:08:56 -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=esKQCEuQkqKEyEmF/eNmSVCnZ9S1XgTJ+/HBC+KL6t4XTTCqSus681IhFPqMaXFhng Vk7wW39xXRhiWK4KJmx8EMR/WJzMnRZz7POmHvxfm0qtNq4Pt5qne9pTuk26j1cxUvkl ZtwNn0lr7A5W0uxO6p2q4SjTsdRW9dJKp+sDg= 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=DuxMwxT96KYiV+aXhQec3c4Npo7G+IYp4lRG6zUXggpnfdRSPFyeKCVgZqyFuLXRm0 gBsfRCKEvq/6W0KWF6/KdVE3ekSk204i4IxP5uXGXnzuxks+nuAB/54Ns73I1/v3c9SZ vq9+86qil2A+JWFvpaZMEiN13Msbxk1EncB3BWMzwOqs9Pg6AOJCZDmvA0vxM3LPpamm +/BTzjofehuMB3Dq/KBBCJCy2V2hUrtr+Y+sA0nu2TpXT+EVfpXAz3f5EHrR8CY5IgRT +OVTT01ls+GwDhlZFTRP6IIMezsqtI1BFAC5wNd6vtmeYP2NXEzDgVClij5VN15/OEXW QT3w== X-Gm-Message-State: AMCzsaVSSxl7l+RndfxVi6hwSbIauz29Qm6myIS330CXUXXbgKglOYjJ mV5Zdsdj96c/QS8g+OIj80TlrA== X-Google-Smtp-Source: ABhQp+RmrvBcvjVSDvFXAROAr8cpS2srEEbHzwmFzyAFXXy/9tBuGAZdfnDlPkH2ruvdXvl1HAa71A== X-Received: by 10.223.177.143 with SMTP id q15mr2419344wra.269.1508432935285; Thu, 19 Oct 2017 10:08:55 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:54 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/18] thermal/drivers/qcom-spmi: Use devm_iio_channel_get Date: Thu, 19 Oct 2017 19:06:00 +0200 Message-Id: <1508432760-17847-18-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-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);