From patchwork Fri Oct 27 23:54:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10030845 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 305D2601D2 for ; Fri, 27 Oct 2017 23:54:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13CEA28402 for ; Fri, 27 Oct 2017 23:54:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 003C728515; Fri, 27 Oct 2017 23:54:22 +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, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 DBF3428402 for ; Fri, 27 Oct 2017 23:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932490AbdJ0XyU (ORCPT ); Fri, 27 Oct 2017 19:54:20 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:53416 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932551AbdJ0XyR (ORCPT ); Fri, 27 Oct 2017 19:54:17 -0400 Received: by mail-pg0-f66.google.com with SMTP id s2so6377771pge.10; Fri, 27 Oct 2017 16:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=htdjxCuimTfM9/b4DP7u6MOBPoiDqjSmGl+lC4sFNIc=; b=SM+LC/o4II675bUKNPmHBEwLF2hvVotPgJLgPXE2c8ItSg1xJ7G065Dj+A+3AawCRv 1dFl/xilF8RF/R2/HUBmoNR8xnQzJPR59ywVIqIG2c9es6Mi9r/Gv9DH4EH1uQBYr+Rk DLJ8yqN78eu8b1+Y54Ow3Ka4bqNXVgzikMrjcfQ4+okghacbX+mTuYXvag0VNgzATdp5 wioq6ImLtbukVG45KAEcDUN/azeLvqYs6RAXFiqYA2iaWvyeb507BXzH0htnInvEB+sg mIPwbWtMd9GOR9FcS/gV8oMfE8balWzkzhXS0kUfnEAFMog/wNEGG5tqhFbtNVYoOYe9 gAfA== 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=htdjxCuimTfM9/b4DP7u6MOBPoiDqjSmGl+lC4sFNIc=; b=phtxsZZipM7OCaC5iPDDkCBnVefcsdnZlYnKZoEW5yIV6J2YJuhtbmAGwq7B0+JrPL q9Fu5iMRgKBtlIziEBShng338HTKh6J+q+XiNUQx6CZML2JAzhLIt3FIxDqshXi6JA1a azq+WkoQpn9b6zOGIpBaFrD8c5iH+efjiKPSg89QEqBH+8zn3sqkpHHm5/oREvGc1AgN a9fH3UKqCkLsMaSYi4cQBVEgvRDHqTWy7aKI9KVU0IYPldqoU+jKN47HEliMya9+t53S jOzTzG3WGS4W9yYw8Zpb+P3yXoLjui73V4I/pkj1ixXnBd3CENcaJvw+8yfBtqxvygqj v9FA== X-Gm-Message-State: AMCzsaU44/E5ECdXE035h12zWPsofVSDZhK+5Lm2CzCWWe2OXjfqKA40 heA/QI2JFv8+HQMvLHbhjWA= X-Google-Smtp-Source: ABhQp+TGJpmvyMm1+jZYYsiX5KVdUVuFbNvqJ+dmHSUMY4p/UOySaH55usZb6zeWJ6nw8cz98ETRBA== X-Received: by 10.159.253.9 with SMTP id p9mr1548003pls.344.1509148456672; Fri, 27 Oct 2017 16:54:16 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id 84sm16513975pfy.179.2017.10.27.16.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 16:54:16 -0700 (PDT) From: Nicolin Chen To: rui.zhang@intel.com, edubezval@gmail.com Cc: srikars@nvidia.com, thierry.reding@gmail.com, jonathanh@nvidia.com, linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: tegra: allow sensor registeration to fail Date: Fri, 27 Oct 2017 16:54:13 -0700 Message-Id: <1509148453-11388-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 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 Not all sensors may be used on a platform. So there could be some missing thermal zones in the Device Tree. However, the the driver now errors out whenever a sensor fails to register the thermal zone. Since the driver could live with other sensors, this change allows other sensors to continue the registerations even if one sensor fails to register. Signed-off-by: Nicolin Chen --- drivers/thermal/tegra/soctherm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 455b58c..73fcd48 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1280,7 +1280,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) struct tsensor_shared_calib shared_calib; struct resource *res; struct tegra_soctherm_soc *soc; - unsigned int i; + unsigned int i, e; int err; match = of_match_node(tegra_soctherm_of_match, pdev->dev.of_node); @@ -1377,7 +1377,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) soctherm_init(pdev); - for (i = 0; i < soc->num_ttgs; ++i) { + for (i = 0, e = 0; i < soc->num_ttgs; ++i) { struct tegra_thermctl_zone *zone = devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL); if (!zone) { @@ -1397,7 +1397,10 @@ static int tegra_soctherm_probe(struct platform_device *pdev) err = PTR_ERR(z); dev_err(&pdev->dev, "failed to register sensor: %d\n", err); - goto disable_clocks; + /* Check if all sensors failed to register */ + if (++e == soc->num_ttgs) + goto disable_clocks; + continue; } zone->tz = z; @@ -1459,6 +1462,9 @@ static int __maybe_unused soctherm_resume(struct device *dev) struct thermal_zone_device *tz; tz = tegra->thermctl_tzs[soc->ttgs[i]->id]; + if (!tz) + continue; + err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz); if (err) { dev_err(&pdev->dev,