From patchwork Fri Mar 3 19:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 64062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp589029wrd; Fri, 3 Mar 2023 11:28:14 -0800 (PST) X-Google-Smtp-Source: AK7set/bo3pmSK8fM/XM3I+QZsKX1jDJbMatj5U/8AoGtx/SOksOffwdQ9KAtowjNqNx18K5D27z X-Received: by 2002:a17:906:3141:b0:8b1:7b10:61d5 with SMTP id e1-20020a170906314100b008b17b1061d5mr3054216eje.33.1677871694087; Fri, 03 Mar 2023 11:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677871694; cv=none; d=google.com; s=arc-20160816; b=Q+JIc64jcF3nfUbIL68iD7kBuX4r1UCbU2d7gRQkGh2XKRaz5iJDTk8bAQxTjCch59 HAzqiRYqV2tDBiM6SMg2skn8thYXmBcOM6tlB/WOkywcM0xsptrstU9+87RdesCPiA+V cmwHb7spWZgKHCD2BkeYVS5+prTcxTi+PvLSbgGxU0GAEsckOBDUwhEX+v0k7rOfxXpe s7PJeXk7faNC0PloECZM47eHT32N0AqiNWCS7gn2QH/RD3Eur50D7lFwoQEd9nnGd8hQ bbM+fZO+wZraKsvGejgnYBpCx39ALJoazRX/c3zAgX0G+2GR8dtEQ7chfdAyV69ixn/T yimA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yY3WfF3Ux9nVkbyB+2BQvkGZi+zjQaYjCntadpPuFSQ=; b=vXeCCNydyAdBOgWgoQiBzAx2rtLKfTbuJ/tizQ4ASgX+4/n6HLe9+/P/lWFO3atdA1 HbHPMYrXfg0ehLGZkxt2RVUKLicMOc8Ux3aMXqW8u9beirreUhBsdXrdgfQ59fPKkr9c mNKF0sgBucgbwKMF5WypZvnu6DCObfNAjlKvtxpEBYTsyrN3bmujTxpraibleVj5/uFG TLuf/u5JbADXDl9acsSoUf8wnDCQoAI4bA197d2S+4hDbVLOs/3G1Lkow+3AFJ0tnTPu E4plQkis9xzL9Bc/BsO5S9ekAOszVARxtiM/weVODrXrsaskPylUJX8f+m/LQxhj4Opc 6+Wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be5-20020a1709070a4500b008b7eed5fa1bsi663653ejc.737.2023.03.03.11.27.51; Fri, 03 Mar 2023 11:28:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbjCCTYV (ORCPT + 99 others); Fri, 3 Mar 2023 14:24:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231458AbjCCTYO (ORCPT ); Fri, 3 Mar 2023 14:24:14 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DEDE10408; Fri, 3 Mar 2023 11:24:12 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id e1cba538225a2803; Fri, 3 Mar 2023 20:24:11 +0100 Received: from kreacher.localnet (unknown [213.134.183.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 714E020619DE; Fri, 3 Mar 2023 20:24:10 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: Zhang Rui , Linux ACPI , LKML , Daniel Lezcano , Srinivas Pandruvada , Viresh Kumar , Quanxian Wang Subject: [PATCH v1 2/4] thermal: core: Introduce thermal_cooling_device_present() Date: Fri, 03 Mar 2023 20:21:29 +0100 Message-ID: <3237406.44csPzL39Z@kreacher> In-Reply-To: <2148907.irdbgypaU6@kreacher> References: <2148907.irdbgypaU6@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.183.41 X-CLIENT-HOSTNAME: 213.134.183.41 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrudelledguddukecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekfedrgedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekfedrgedupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeekpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthho pegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759375989667364329?= X-GMAIL-MSGID: =?utf-8?q?1759375989667364329?= From: Rafael J. Wysocki Introduce a helper function, thermal_cooling_device_present(), for checking if the given cooling device is in the list of registered cooling devices to avoid some code duplication in a subsequent patch. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -1045,6 +1045,18 @@ devm_thermal_of_cooling_device_register( } EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register); +static bool thermal_cooling_device_present(struct thermal_cooling_device *cdev) +{ + struct thermal_cooling_device *pos; + + list_for_each_entry(pos, &thermal_cdev_list, node) { + if (pos == cdev) + return true; + } + + return false; +} + static void __unbind(struct thermal_zone_device *tz, int mask, struct thermal_cooling_device *cdev) { @@ -1067,20 +1079,17 @@ void thermal_cooling_device_unregister(s int i; const struct thermal_zone_params *tzp; struct thermal_zone_device *tz; - struct thermal_cooling_device *pos = NULL; if (!cdev) return; mutex_lock(&thermal_list_lock); - list_for_each_entry(pos, &thermal_cdev_list, node) - if (pos == cdev) - break; - if (pos != cdev) { - /* thermal cooling device not found */ + + if (!thermal_cooling_device_present(cdev)) { mutex_unlock(&thermal_list_lock); return; } + list_del(&cdev->node); /* Unbind all thermal zones associated with 'this' cdev */