Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp250020rdb; Thu, 2 Nov 2023 02:33:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyEHI4gemaUYPjKxmIyQjEKIYlfh6jghh0kPzoKum4J9kcBGbY3iXhVoiPzDF44dWs0WEL X-Received: by 2002:a92:ce4f:0:b0:359:7d0:256a with SMTP id a15-20020a92ce4f000000b0035907d0256amr12121329ilr.7.1698917638643; Thu, 02 Nov 2023 02:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698917638; cv=none; d=google.com; s=arc-20160816; b=kVALOvUOLYGB+nLowrOsXBqgzNrlSoqQ7pDgn8Oa06GyYXeqYduScAwjgW0EMdpwkE /YHBvIclMIYQnzXHISEi5yylBqq5sGaHCENmMgEt/HOdC3CVWYmUwNuUSsTkxAtZ8UOJ FyaOgT2yM73U5vW+0PbCS6M5LsJZ0tDZJNDy43Fn9OMON2gdxjJAKxg0PdzMJ1liBTnO Ype/AQengbwNT1NzN2VSivn2hAn7aa5b72yd7+Pnp9rOgXJ2gsmWwJ9Ien23YXZgqbI9 bN6T41amgy8GdRMoxQaA/aVoChNAGOfTPZjvqOk23zQDfTKqOCdSlZKJm6L2a/xdPIzo S6+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Yl2RNYa6wlW4u+3YKDs7TAIJG8OkxNjGFmYJ+LCMi/c=; fh=VJpceQ/xQhKRnutzLuDLYPoVFj7hXu1t0Ndzv2fl6Lo=; b=tDuzXHl3CLKblqQ3aWDrDJ2V81OBNevAysdQPxqWaoeZi2VWGNhgbH6+LKPk++K2S2 6PckPCZQVylcD+saNiC4EZLXpM9LvZ9AcMmE0AT/ueQMHwokQioyCQ72NlhiPwZTRAG+ pfQ/yeWRz3WMby3xgCMROIQCiw/EWKOxjjNb3okyIyl+pWUATYYkVB7GR+a91s5OwWAu wDyecDmagxt5fRuqQouZGUByvfKRwngotBydDWEK+CpTVf1fodejgyP42H3S3SzN8lAk 2a36JE4LaK9H11bPuqHK/Nr6vChUeuRGP2me+B4cyAqkm+Yyzdzuoxi+3FEmYvWzRgQR AoIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cMTdUm16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u20-20020a056a00159400b006be2ee8929csi3264577pfk.313.2023.11.02.02.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 02:33:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cMTdUm16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B2BE781FD9C4; Thu, 2 Nov 2023 02:33:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345500AbjKBJds (ORCPT + 99 others); Thu, 2 Nov 2023 05:33:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjKBJdr (ORCPT ); Thu, 2 Nov 2023 05:33:47 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1CC132; Thu, 2 Nov 2023 02:33:44 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1cc9391884aso361885ad.2; Thu, 02 Nov 2023 02:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698917624; x=1699522424; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Yl2RNYa6wlW4u+3YKDs7TAIJG8OkxNjGFmYJ+LCMi/c=; b=cMTdUm16+ZuKCmGFXtHZHYItZ8FSZtIFKx1U67jc3h8wbS6wGijBpQhQPC0TdmsEQV hG2XzZDIjnbpaefhKwctisygT4+hXhVtAO9F/cFLwf+xcP00pbNcydoETykLZBKXbwUH 3jXyCoNTo8z6BzVh5M0lKG9nCQ5j4rSlsANl43r26heTcD/mmirFiDt4sye9q2+HIWn4 mxf8x0tU2brEnVNHAcREnwwQIb2V2fq0+3Ys2o4XQy1BWahWgUW9CQE0l9KhZvTQ3Yp7 WkAf50iLPhmeWwsyWjpWsc0o5eBBX+KdrMTc3NHbyUuz2qH/j6R8Hjpv2Lg/QV2sP53Y JDAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698917624; x=1699522424; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Yl2RNYa6wlW4u+3YKDs7TAIJG8OkxNjGFmYJ+LCMi/c=; b=WVQ0botbuseVv31hNdnVKR7lFhcooyiPJ92q2aDq+/Zs3EvFGVc+hTmVe050cyMciE nYU6CF8854zSr4d2e7jMgHn0TP3hO3oFZCBVb8NrgDA4d4DOm+66/fz+4JEz4TeWsbVJ S5ESaPC8V5fQ25JYdk2QKHTqV9SyF2b5uIcbzVoEK9510+6eQl9qrVUchyderSmBJU/h K5yR4dUHN0XWW95l5IgQDnG1ZgXYb9WiGayKXPfAd2ABLXXepNFWjk8TOHcBvgylqWtP 6TneGG/82NW2NHiBal6UBXi0k9UcbaCXvzgPkUEe3L4vcmYnVIriD5pBYIAEQQ01GS0h gK6g== X-Gm-Message-State: AOJu0Yx13dvhEGlYkNVGmgSRRH3yNLSXfgsGll3MyziFCU7989LCC92T N/oSgwb8DOFbP0rmOPveh80= X-Received: by 2002:a17:902:cecb:b0:1cc:4ff3:c837 with SMTP id d11-20020a170902cecb00b001cc4ff3c837mr10989033plg.68.1698917623615; Thu, 02 Nov 2023 02:33:43 -0700 (PDT) Received: from localhost.localdomain ([58.48.52.254]) by smtp.gmail.com with ESMTPSA id i14-20020a17090332ce00b001c9ccbb8fdasm2675212plr.260.2023.11.02.02.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 02:33:43 -0700 (PDT) From: "xinglong.yang" X-Google-Original-From: "xinglong.yang" To: xinglong.yang@cixtech.com, rafael@kernel.org, daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] driver: thermal: simplify the traverse of sensor in thermal_zone. Date: Thu, 2 Nov 2023 17:33:34 +0800 Message-ID: <20231102093334.1363324-1-xinglong.yang@cixtech.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 02 Nov 2023 02:33:56 -0700 (PDT) The number of sensor in a thermal zone needs to be greater than zero and equal to one. Add the opinion when the number of sensor is greater than one in a thermal zone. There is also no need to traverse the sensor in the thermal zone, because there is only one sensor on one thermal zone. Signed-off-by: xinglong.yang --- drivers/thermal/thermal_of.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index e615f735f4c0..c800599e7ebd 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -185,7 +185,8 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int */ for_each_available_child_of_node(np, tz) { - int count, i; + int count; + int ret; count = of_count_phandle_with_args(tz, "thermal-sensors", "#thermal-sensor-cells"); @@ -193,26 +194,25 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int pr_err("%pOFn: missing thermal sensor\n", tz); tz = ERR_PTR(-EINVAL); goto out; + } else if (count > 1) { + pr_err("%pOFn: number of thermal sensor greater than one\n", tz); + tz = ERR_PTR(-EINVAL); + goto out; } - for (i = 0; i < count; i++) { - - int ret; - - ret = of_parse_phandle_with_args(tz, "thermal-sensors", - "#thermal-sensor-cells", - i, &sensor_specs); - if (ret < 0) { - pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret); - tz = ERR_PTR(ret); - goto out; - } + ret = of_parse_phandle_with_args(tz, "thermal-sensors", + "#thermal-sensor-cells", + 0, &sensor_specs); + if (ret < 0) { + pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret); + tz = ERR_PTR(ret); + goto out; + } - if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? - sensor_specs.args[0] : 0)) { - pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz); - goto out; - } + if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? + sensor_specs.args[0] : 0)) { + pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz); + goto out; } } tz = ERR_PTR(-ENODEV); -- 2.42.0