Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2692921imu; Thu, 29 Nov 2018 08:48:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjqtJBS7LHeiqAca7nuFQio5FDpkWO+Ka4is8XMFstbMDMwKQEVXlQvTKyAljtm3Su7Dxm X-Received: by 2002:a62:de06:: with SMTP id h6mr2164428pfg.158.1543510131645; Thu, 29 Nov 2018 08:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543510131; cv=none; d=google.com; s=arc-20160816; b=l69EzHxd853J9pJUPFU41HyLexc+N+GuV/Hm3cn7EcJbN3GwGsneNvzUynWPSmXAhw j9Jjy5xwri4HNYwCCVlMtfDFqMRJg/o0Gk9U790bFcxFA86oMU5dgn+Ngs1omLe9hmi2 2CYoBKvOLrftt7UHZDm+x40dTauUiDfgZ5KmFHuyMiA5szxNYO4cYdJqFqEY+eCCOiHV ZzC2Ij8mXIP7n36JkTgu+TRD4+RoSNcfBkDwgiX4+IhAwNer2vVa7F1Td9tULboJxpNo 3Zxa/Ip8SNS7MYhxsFcuAJCspFYBLRrbzyJ+khYmZ0DKxDshKkNbfBh1MO8BR6Xk5gnH 0DdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WOGNP/MLlwgoMS8VRQbSZ42i8ibki5FYlLRL+d6ulzI=; b=xzmgYbjx/LYUwD0zUulE4CGyn8xlnEAEIZtYBwxRas+vkzYqjkygV4G2ugKG72w6HA ZMcl+hbbPYBqCzdh2aOGQC7SEI+sksQnVUunvV+vCAiLp/d7ikGffND0Kpu1XNavOY2H Ku5CVD91UjxZp+0yUoPQnvZHpsMizOE/6Yo92eWnyesOe34WoMylWXBPSh6Fikpue3Kk 0Qn6Zv84FJ2426SB2AAxEnMv7X4Z605rI2Cv77IoIe4RnVXi/gLvggYYSebwaTg40ufg p55o2KravekmOAFOgg3ZFRbqq/rR27uVcOAhihn5gcVSVlb6B7uvDmc0u8NAblHDJgS1 YTqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Z0rkc/8T"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63si1950167pla.65.2018.11.29.08.48.28; Thu, 29 Nov 2018 08:48:51 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="Z0rkc/8T"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729799AbeK3DxA (ORCPT + 99 others); Thu, 29 Nov 2018 22:53:00 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33039 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729576AbeK3Dw7 (ORCPT ); Thu, 29 Nov 2018 22:52:59 -0500 Received: by mail-pf1-f195.google.com with SMTP id c123so1303101pfb.0; Thu, 29 Nov 2018 08:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WOGNP/MLlwgoMS8VRQbSZ42i8ibki5FYlLRL+d6ulzI=; b=Z0rkc/8TCY17P2tEJWbx+Q/frA1aEJZdWIBFwb/lxYl/iZ3v1tex66VKG1QzphZJCG rIiQiZeoRfVt02ZnWN9YAZ/w2neQdd8qg3KWgVYcr1L6vi7jp2njKbQiWdReiG9v9zmx l03CoLUu6eH8uAXxfmAkR6kctWbLWj+BeylgiwZZQOKVDggIEUJuL7r/69Ra7+PeAycl 3fcgcFEsq5KhSxeUYX9XmQtLqH1pcJH6hjPoU+J6qtdzchMYkgcSjGyItflM9lE1Ja4i AmVJveuUhyYTVqbjBsjKAQUtS8LhzAKkAw3d2dcue6sa7W7cTBNy3wUnU/OoOGwvKIXX iEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WOGNP/MLlwgoMS8VRQbSZ42i8ibki5FYlLRL+d6ulzI=; b=Fnv5rnjQx4mdErXTm1CFTs4kLJF+4CVY87pV6wqnOFMvA0bVcSZjWiN4cYXjvS+G0Q quay6SF1yobQBE1OMg9oD0YXdfMLVNbGGD6IMc61VQufp8TNIMZbzSX1GLn75TGgNgCr DaDy0xu1bPsyNKnmczKMQU5AMzSFzkVtIXy1ff2BXpkZOTH3IRuuQK1/4XrnA3oai1W6 dfjlFgZ5HWwjJBDPOez/eVEBSyfGo/cBbkbiVstIrwrQ4O4ysNxikTKeA+Jjnkc6Zo84 ANZHHSXvg7VTpqeOtfLP9tQLucXq9RENT44AgDJTNap+UKl9LXztIdeYz7fxJAnyAiGe afyw== X-Gm-Message-State: AA+aEWZuDSZWC8NlMFloTjy9BzrC334XhQwwUQRLgEDi9wU7BZtGaSmE /6QPUnCsZ4iL5MYLd3F8MvY= X-Received: by 2002:a63:8441:: with SMTP id k62mr1821063pgd.392.1543510020204; Thu, 29 Nov 2018 08:47:00 -0800 (PST) Received: from localhost.localdomain ([2601:644:8201:32e0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id 8sm4360104pfr.55.2018.11.29.08.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 08:46:59 -0800 (PST) Date: Thu, 29 Nov 2018 08:46:57 -0800 From: Eduardo Valentin To: Wei Ni Cc: thierry.reding@gmail.com, daniel.lezcano@linaro.org, linux-tegra@vger.kernel.org, rui.zhang@intel.com, srikars@nvidia.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/3] thermal: tegra: parse sensor id before sensor register Message-ID: <20181129164656.GA2688@localhost.localdomain> References: <1543486183-2868-1-git-send-email-wni@nvidia.com> <1543486183-2868-4-git-send-email-wni@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1543486183-2868-4-git-send-email-wni@nvidia.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 06:09:43PM +0800, Wei Ni wrote: > Since different platforms may not support all 4 > sensors, so the sensor registration may be failed. > Add codes to parse dt to find sensor id which > need to be registered. So that the registration > can be successful on all platform. > > Signed-off-by: Wei Ni > --- > drivers/thermal/tegra/soctherm.c | 46 ++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 44 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c > index 375cadbc24cd..bdc660f2794a 100644 > --- a/drivers/thermal/tegra/soctherm.c > +++ b/drivers/thermal/tegra/soctherm.c > @@ -1224,6 +1224,42 @@ static void soctherm_init(struct platform_device *pdev) > tegra_soctherm_throttle(&pdev->dev); > } > > +static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id) > +{ > + bool ret = false; > + struct of_phandle_args sensor_specs; > + struct device_node *np, *sensor_np; > + > + np = of_find_node_by_name(NULL, "thermal-zones"); > + if (!np) > + return ret; > + > + sensor_np = of_get_next_child(np, NULL); > + for_each_available_child_of_node(np, sensor_np) { > + if (of_parse_phandle_with_args(sensor_np, "thermal-sensors", > + "#thermal-sensor-cells", > + 0, &sensor_specs)) > + continue; > + > + if (sensor_specs.args_count != 1) { > + WARN(sensor_specs.args_count != 1, > + "%s: wrong cells in sensor specifier %d\n", > + sensor_specs.np->name, sensor_specs.args_count); > + continue; > + } > + > + if (sensor_specs.args[0] == sensor_id) { > + ret = true; > + break; > + } > + } > + > + of_node_put(np); > + of_node_put(sensor_np); > + > + return ret; > +} > + > static const struct of_device_id tegra_soctherm_of_match[] = { > #ifdef CONFIG_ARCH_TEGRA_124_SOC > { > @@ -1365,13 +1401,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev) > zone->sg = soc->ttgs[i]; > zone->ts = tegra; > > + if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id)) > + continue; > + Instead of matching driver id with DT id presence, wouldnt make sense to simply have DT with the sensors that makes sense for that platform? I am failing to understand why you need to go over and find ids. > z = devm_thermal_zone_of_sensor_register(&pdev->dev, > soc->ttgs[i]->id, zone, > &tegra_of_thermal_ops); > if (IS_ERR(z)) { > err = PTR_ERR(z); > - dev_err(&pdev->dev, "failed to register sensor: %d\n", > - err); > + dev_err(&pdev->dev, "failed to register sensor %s: %d\n", > + soc->ttgs[i]->name, err); > goto disable_clocks; > } > > @@ -1434,6 +1473,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, > -- > 2.7.4 >