Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2448008yba; Fri, 17 May 2019 17:49:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrfYqs0VAPF0/ewjJhQmihvpWAeQ7Pr8VG1ycRnp5Eud7ByGOUdd9GpXO+gguNm0A+7don X-Received: by 2002:a62:604:: with SMTP id 4mr64462703pfg.38.1558140560009; Fri, 17 May 2019 17:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558140560; cv=none; d=google.com; s=arc-20160816; b=fxf6iTd/CYchd5L3mbIFoYirqWHxHXdEFpmte8wqMV/LC3VXSlmULSw8O9rKn2yOk+ 61sp9ulUJemkZjjlcs+CVBf8m60Z5IZNMMlBLBiFIlukm2zVk8BpAgRNt86iwcy4sFSt fyQ/gA4gJsQ/HQFzCM2vJ0pJMakbvKN3NFnwGC7/4t0fwFAgawD7b+uxvC5wGPJspJGA 0KUJw2l8PxJSFw41QWCNvvjVPn9wb9SzrN1GTJ3XEYEE03wBrj3QvfEUxOThJF0fsG24 xJya1QroYMI/mQg24yciIPsDan5q1krHC5A/Kkf6GJdf5lw3s1+AfGSubVFBYNTw0/Zt 0mTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QSZH7MhgQ8SSN2c5tgT5vfhoIO9KJ/7q3qvVPDIomGI=; b=Ud/M9r+BbeawHQk+unZI7uJ7yooAdKCh6tyJO5e4/I7PVm8s1JgXmqb8i4OklKneJQ S6oiIEXBosCe7WC8AF3D9ynvSyC3Rhdb80Xt3ZRj25N8FSSivuJzOKsdXRzY5jUPXBBt gDVZJmsI1Xwzgyc8Ko1vewoXkVtQ4N8W41nypFvoNqCFw9czzp9V3sOIjyPsJ6cbpNkq 1l2tqV1czOuoQADG2iTzjWRM0Q91jZr3l9l3DFkvHtzEBu22r1G/PlN8WhjlfkV1ovcL jJwv/SpNn/DQ8vYecQnBLMzzg+/EINnVrMuCvIDKZowZbJIYgyGu/LHH+Gnu4UesSIYd FNfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=Amt6e+kH; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19si2946609pfh.141.2019.05.17.17.48.52; Fri, 17 May 2019 17:49:19 -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=@amazon.com header.s=amazon201209 header.b=Amt6e+kH; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728592AbfEQXNp (ORCPT + 99 others); Fri, 17 May 2019 19:13:45 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:28776 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbfEQXNp (ORCPT ); Fri, 17 May 2019 19:13:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1558134824; x=1589670824; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QSZH7MhgQ8SSN2c5tgT5vfhoIO9KJ/7q3qvVPDIomGI=; b=Amt6e+kH6pK0zqLLpJ7EFizKb+Zn5fud+cWFcp9tlkRxzvxA3WYpf/XN aBBOrGgeJ3ahwkDIB5F8PEQ5m2mkPEX75tJOoP8ATcYLAlUWWKqjJBheN 8SD4enVKsRNJsfuqNweQxxHsdE0prFHNITVkTuwjEZJgpis1/1Pv8qHqx o=; X-IronPort-AV: E=Sophos;i="5.60,481,1549929600"; d="scan'208";a="800301467" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 May 2019 23:13:41 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x4HNDXfM127436 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 17 May 2019 23:13:40 GMT Received: from EX13D05UWB004.ant.amazon.com (10.43.161.208) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 17 May 2019 23:13:40 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D05UWB004.ant.amazon.com (10.43.161.208) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 17 May 2019 23:13:39 +0000 Received: from localhost (10.94.216.44) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 17 May 2019 23:13:39 +0000 From: Eduardo Valentin To: Guenter Roeck CC: Eduardo Valentin , Jean Delvare , , Subject: [PATCH 1/2] hwmon: core: add thermal sensors only if dev->of_node is present Date: Fri, 17 May 2019 16:13:36 -0700 Message-ID: <20190517231337.27859-2-eduval@amazon.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190517231337.27859-1-eduval@amazon.com> References: <20190517231337.27859-1-eduval@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers may register to hwmon and request for also registering with the thermal subsystem (HWMON_C_REGISTER_TZ). However, some of these driver, e.g. marvell phy, may be probed from Device Tree or being dynamically allocated, and in the later case, it will not have a dev->of_node entry. Registering with hwmon without the dev->of_node may result in different outcomes depending on the device tree, which may be a bit misleading. If the device tree blob has no 'thermal-zones' node, the *hwmon_device_register*() family functions are going to gracefully succeed, because of-thermal, *thermal_zone_of_sensor_register() return -ENODEV in this case, and the hwmon error path handles this error code as success to cover for the case where CONFIG_THERMAL_OF is not set. However, if the device tree blob has the 'thermal-zones' entry, the *hwmon_device_register*() will always fail on callers with no dev->of_node, propagating -EINVAL. If dev->of_node is not present, calling of-thermal does not make sense. For this reason, this patch checks first if the device has a of_node before going over the process of registering with the thermal subsystem of-thermal interface. And in this case, when a caller of *hwmon_device_register*() with HWMON_C_REGISTER_TZ and no dev->of_node will still register with hwmon, but not with the thermal subsystem. If all the hwmon part bits are in place, the registration will succeed. Cc: Jean Delvare Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/hwmon/hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index fcdbac4a56e3..6b3559f58b67 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -619,7 +619,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, if (err) goto free_hwmon; - if (dev && chip && chip->ops->read && + if (dev && dev->of_node && chip && chip->ops->read && chip->info[0]->type == hwmon_chip && (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) { const struct hwmon_channel_info **info = chip->info; -- 2.21.0