From patchwork Tue Sep 26 23:50:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 114298 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4408870qgf; Tue, 26 Sep 2017 16:53:39 -0700 (PDT) X-Received: by 10.98.34.149 with SMTP id p21mr12444130pfj.322.1506470019701; Tue, 26 Sep 2017 16:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506470019; cv=none; d=google.com; s=arc-20160816; b=nF/5aT8EcvVHzN2k6/KPIeMQBeXMJq2NdfDq+JatDUtx+SlN1odteiq1Et1jc0qPDt 5+K85bpqGwGgL6oqqLMBNCmL4uzPUS+r0Ll50ihAQFhf3SCqdLjWKQI6Y87fzY6/y15+ QhjEgqdKygBdldWIYHhKNrSv/pTan6GMeowwKuvFM1FAhgdHbGXaL4MENQwYjkjVaXdd UYwqCFQ4TYNIqQIm6kihwQVzqNOyv2gaGjYuwaaiL+nLvXseEbnqzlaVNumQZoDS0+5w yKkPE8sParCDDDb0dIcamKLsyYpTEm5AChAAZtK0RIsTeykMV8Vq2dt9kHps1KSJbWhK QZJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=g5oQMW6s7JjqpIzcanOC6wTSPH7uwdCVbMjUlNQ70M44FxRzMTnjtQYHYMC5IdPYN5 IgynkoMrqR4Mws0hu1Urj/7geB7KJgrmrY4fD9pSz+vsnu7dEguMkfDxEGgmSHjJu53w uNQSQ1c+n3dBZpK5P1D/0TPMyRGo6XO7pOOuSCu9dNcEdAX9+EPjnM8eAVTM4uKrk2i7 hJzgaUj4oUOksPWJx/+RYz4a+HSKUP/54snsG3DlKaZ9ZpN9pLUo+iQwNlBX03v/nVqF zsxJGbOwdricCS1E8QNhFOyG/yRDOTcwUC6BuOHVXWdrd7v0z5ftRoiD/c6+D2rkzXrG eOzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aR0fmMQe; 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 g5si6198818pgo.612.2017.09.26.16.53.39; Tue, 26 Sep 2017 16:53:39 -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=aR0fmMQe; 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 S1032719AbdIZXxh (ORCPT + 26 others); Tue, 26 Sep 2017 19:53:37 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:47264 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966844AbdIZXxg (ORCPT ); Tue, 26 Sep 2017 19:53:36 -0400 Received: by mail-wm0-f54.google.com with SMTP id r136so12715978wmf.2 for ; Tue, 26 Sep 2017 16:53:35 -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; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=aR0fmMQe41yaXqOrdBx0qhEhSvCr5+p15vxjHzZQAYq2SMJ7NxhsKWeKYYw1aNWzrI kZ3G4yiyZjTQYm4KLb6JWNy+RPuGy+R1n2BTBnPK6u1v8ncfmJOhjoP2mGCUtteBMTD0 azEUQtkrSWLCq8rkyOQn/CAOIqjxRlo/WNjkQ= 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; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=B30PgJSukRnr/aBkL6YNJeILv45cfdopgXU9mydqHlks5n8h1cQj5frDSz3dLWMWr9 sWX+nUnpeam9tUDfiuilcmdaH6g5wOuv3sHHllUd0zG9188sDg5RapC0gGccuBZSGTOl GhgLdAb4UosiAeIqW8sfM+Tw6FnhDaCdm3/cAFqFjbOf8K2ejcUIF1Mlo7sGYcAcW7o/ GiZ2RinZDEOGlRPgXPINviZiC2aTL0bu8TmuO2j12OjBXKteNjiRTOm7OnswAGWhHzmk nqEqqJtUpxtFa6h+w1iX2YIN5VyV8QvmNqAAbHuefYBTOXyAg9j3XSK0dqQwClsuNFQh 3Fdg== X-Gm-Message-State: AMCzsaWBcU0l0JE4TagT/MXhILTxf3IG5+pgRWsc2REkwBEOVGN99wtq mnKErYmmLtV6t33JPbquijNLTw== X-Google-Smtp-Source: AOwi7QAJyreNo1K282DaV4fB1Qwxs6lPA5x8YBQvYOnlEIcmGIX9TJxxjAFdIVPViHh0rxXlNQrEyw== X-Received: by 10.28.30.22 with SMTP id e22mr16911wme.121.1506470014847; Tue, 26 Sep 2017 16:53:34 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:901b:4425:ce24:a9c0]) by smtp.gmail.com with ESMTPSA id x185sm2313745wmx.35.2017.09.26.16.53.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 16:53:33 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: Zhang Rui , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] thermal/drivers/qcom-spmi: Use devm_iio_channel_get Date: Wed, 27 Sep 2017 01:50:55 +0200 Message-Id: <1506469855-12497-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 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);