From patchwork Tue Sep 26 12:52:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 114263 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3794240qgf; Tue, 26 Sep 2017 05:53:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBM8XsN7o7uxW6mK7nxGAjZLWepdYCHkze0czQBzXgQ0O7Z4+PCXP49qiEd2uKC9ztvaOne X-Received: by 10.98.21.150 with SMTP id 144mr10755285pfv.188.1506430382632; Tue, 26 Sep 2017 05:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506430382; cv=none; d=google.com; s=arc-20160816; b=CY4OkLyLGn8tMtt85NzVH6qqD02q231Lo1ONRsTZX6NZF1aCZeW2zZxSwjdY3j5K2C yeRwdTBR+qWOKw4xeIF7euVmJqkkff1PYZ+oJax974DXSkRY523xrdl18HjdUBfSpESE v7UxqKpFoGKIa4RksduzbIML+UsDwPxlu0jVTxa2WzQYLGgdvbLdRKHDDeBUQ4Ff9mLQ u2kFaqSaqfVikqbkSqoLhzSe+4aSz8f//VckKhAcxINBN9CRS+uDE5+Wf8+rRV1H5qfP g1Cus+PlBMObh8yY2l110xzlpSza3QNaty/1VHikVEA+Ku1tex/3eZzjw1u28IVLR+2L X4nw== 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 :arc-authentication-results; bh=w60vgkidURL4wPEr+wDA8sAitYyfvftkA68RWf2jP20=; b=J2HiqXVLd5eKWLRkiQmQ67bTqQbFPmC1KkzK9ZP7kmt3wHPS4ij0HlFpcnhXpZ2kIc F1yz/A/QRItKP+1Q7qnIdT2oHUxa7zTadi1Y0NzOr4lYOUppUPS9JtizZCRPT9lM17sr cwgUv1S6p+eh6zayBq9eZnufnGZipTEOGP1ff3gCn4JF2g2C+WnFQCYM2I009wbrJ5IQ jSBsQRIsMczsheIzymKAc6kTdOU0WMDGtVQIM8WeMyaid+D1ErZTMdeDEi/5KVczYRIM YhzPFfGIb5WNeAQbfsCYOTGE9PFUexeJ+iJrnnM2r6jJ00tIJImXOPH20Ys8WjG0+jsy 71bA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s185si5816853pgb.399.2017.09.26.05.53.02; Tue, 26 Sep 2017 05:53:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968860AbdIZMws (ORCPT + 26 others); Tue, 26 Sep 2017 08:52:48 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:53546 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966144AbdIZMwp (ORCPT ); Tue, 26 Sep 2017 08:52:45 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 93F54208DE; Tue, 26 Sep 2017 14:52:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 41D212074A; Tue, 26 Sep 2017 14:52:33 +0200 (CEST) From: Quentin Schulz To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, maxime.ripard@free-electrons.com, wens@csie.org Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, thomas.petazzoni@free-electrons.com, icenowy@aosc.io, Quentin Schulz Subject: [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Date: Tue, 26 Sep 2017 14:52:18 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver has a get_temp function used by the thermal framework that uses pm functions. However, the driver isn't registered in pm before it is registered in thermal framework, resulting in the pm_resume not being called and thus the IP not enabled. When the IP is disabled, the raw temp value is always 0. With the devices currently supported, it isn't a problem since with their respective formula, they return a really cold SoC temperature which isn't a problem for the thermal framework. But for future SoC that have a different formula, it could return a critically hot temperature, forcing the thermal framework to shutdown the board. Signed-off-by: Quentin Schulz --- drivers/iio/adc/sun4i-gpadc-iio.c | 34 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) base-commit: 1f183459b5144384e2669a3f757d36bacab108cf -- git-series 0.9.1 diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 137f577..392d47f 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -529,17 +529,10 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, return ret; } - if (!IS_ENABLED(CONFIG_THERMAL_OF)) - return 0; + if (IS_ENABLED(CONFIG_THERMAL_OF)) + info->sensor_device = &pdev->dev; - info->sensor_device = &pdev->dev; - info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0, - info, &sun4i_ts_tz_ops); - if (IS_ERR(info->tzd)) - dev_err(&pdev->dev, "could not register thermal sensor: %ld\n", - PTR_ERR(info->tzd)); - - return PTR_ERR_OR_ZERO(info->tzd); + return 0; } static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, @@ -586,15 +579,6 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, * return the temperature. */ info->sensor_device = pdev->dev.parent; - info->tzd = thermal_zone_of_sensor_register(info->sensor_device, - 0, info, - &sun4i_ts_tz_ops); - if (IS_ERR(info->tzd)) { - dev_err(&pdev->dev, - "could not register thermal sensor: %ld\n", - PTR_ERR(info->tzd)); - return PTR_ERR(info->tzd); - } } else { indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels_no_temp); @@ -664,6 +648,18 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) pm_runtime_set_suspended(&pdev->dev); pm_runtime_enable(&pdev->dev); + if (IS_ENABLED(CONFIG_THERMAL_OF)) { + info->tzd = thermal_zone_of_sensor_register(info->sensor_device, + 0, info, + &sun4i_ts_tz_ops); + if (IS_ERR(info->tzd)) { + dev_err(&pdev->dev, + "could not register thermal sensor: %ld\n", + PTR_ERR(info->tzd)); + return PTR_ERR(info->tzd); + } + } + ret = devm_iio_device_register(&pdev->dev, indio_dev); if (ret < 0) { dev_err(&pdev->dev, "could not register the device\n"); From patchwork Tue Sep 26 12:52:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 114262 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3794104qgf; Tue, 26 Sep 2017 05:52:52 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDh4LVgJ6FGMSqRMj+try2N6iGBrAH4Z2K25Lj7yvL7qo6cVFlda2Jvc2dFvpue848l5Lkt X-Received: by 10.98.163.153 with SMTP id q25mr10614841pfl.183.1506430372825; Tue, 26 Sep 2017 05:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506430372; cv=none; d=google.com; s=arc-20160816; b=om5EFl9bZAn3HllZe//dUkiSvOb+H3alh29ZGCr20aBQfzUf2WJzmds/XffwaGdsP1 s2xK5SXRK4t7SJCZw2Md4sI3CZ5lImDyGOLeaNwNtTuD4SSY/42C1XJ18xlkfmwnt84t OKSCJxkokAdt5MfyXLhADmY2Gin1dxC8DVsdg6vyViIAQrAI6ng8d7xBvc2xoNz/aq0E 3GcZ2oe66xf5zvYzpkeXTasXJC0rJXJH/zKepJljY8c84AKi2GxGaskZTRBXqFY5nL+N EhFXi5QkGSAY1BwpZVeS7UU76gOvSrUU6rLYgxy1Cvjj1VilT5d+MXeD19m5hv7rPHOW Zkhg== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2SYNdJEyXHOclWt9t0E3rsInIPtijom7pkyHM5IT9ns=; b=nInl/DCJYtSYYPaOsDvRiPzYJp+blwLQHJKIfkRlS0kCaFs9S2JoADV2tm1CeMLTiB AjDBVyIXEh4cvJyd36lCyyk383ueuqnxahh9wwYH2XkE7tuyCz7dyUTh7AYUsQlczCC8 dz+bqNFADbW1SIvAu8aZZdqIpt+Ewx5LbgS0Cb0weSHxD3tbZgag0EpWmt5gI3WurzVb ZDKdb4qLOLuuOJ3V8nceCK2ZZo6gr/CDyZOujLzJBVhLLzglKYjRajQe5pubO+ILEvCp hiEkP9VXMBzyyKYuYQnYEqtaXG1U9QCHJbpKqoTc779sebwi+htqvY1LS2hOwPwoq23z BMfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s185si5816853pgb.399.2017.09.26.05.52.52; Tue, 26 Sep 2017 05:52:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968874AbdIZMwt (ORCPT + 26 others); Tue, 26 Sep 2017 08:52:49 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:53557 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968843AbdIZMwp (ORCPT ); Tue, 26 Sep 2017 08:52:45 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id D8D50208EB; Tue, 26 Sep 2017 14:52:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 86194208D0; Tue, 26 Sep 2017 14:52:33 +0200 (CEST) From: Quentin Schulz To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, maxime.ripard@free-electrons.com, wens@csie.org Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, thomas.petazzoni@free-electrons.com, icenowy@aosc.io, Quentin Schulz Subject: [PATCH 2/2] iio: adc: sun4i-gpadc-iio: do not fail probing when no thermal DT node Date: Tue, 26 Sep 2017 14:52:19 +0200 Message-Id: <160cf183a167ef841c96c5626f42e23b7195effa.1506430136.git-series.quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before this patch, forgetting to put a thermal-zones DT node would result in the driver failing to probe. It should be perfectly acceptable to have the driver probe even if no thermal-zones DT is found. However, it shouldn't want to fail if the thermal registering fail for any other reason (waiting for other drivers for example) so check on ENODEV only. Signed-off-by: Quentin Schulz --- drivers/iio/adc/sun4i-gpadc-iio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- git-series 0.9.1 Acked-by: Maxime Ripard diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 392d47f..46fe0b5 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -652,7 +652,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0, info, &sun4i_ts_tz_ops); - if (IS_ERR(info->tzd)) { + /* + * Do not fail driver probing when failing to register in + * thermal because no thermal DT node is found. + */ + if (IS_ERR(info->tzd) && PTR_ERR(info->tzd) != -ENODEV) { dev_err(&pdev->dev, "could not register thermal sensor: %ld\n", PTR_ERR(info->tzd));