From patchwork Mon Aug 12 13:51:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 819346 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F012433DD; Mon, 12 Aug 2024 14:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723471266; cv=none; b=sWFl7468Mx9eW2E0bIdOS1ziLnGAZIPRM5yxBi9Dqq136GnI/aKX5LdqJ2V64tOKdD2cO/2toT3ep3KPtJex3NCVIWYy/yk/Q9Y2xcCLBvrqev4VMTecUU22aIZ/OIDFK6Zaq72xrJscOFK7nvkM7skZfyayKnidSzoZ2avQKpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723471266; c=relaxed/simple; bh=lEitmw+Di5Nqi42iq1sGdwj1UjJmu6Qt90qN7h7cG7g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s8/myNwtOgTEcMMnWCnT3zdQkdJTMdfaBZxzd0r5VdYp2iaUYTomOFjpLk9oMiyQ5eGQkP66SpnB/wnT0e6Jpfg/WTPrjpacYFd1aDOrBRmpnN42/6JSsUeZtIzRB3ajdhIDltAnGVye2IG9Vc8Fk6ptW8HT2XchPkEp2TCOOyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=oLEdBUFU reason="signature verification failed"; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="oLEdBUFU" 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 6.2.0) id 7e5bbe2d74f7db53; Mon, 12 Aug 2024 16:01:02 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (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 cloudserver094114.home.pl (Postfix) with ESMTPSA id C447C6F0D63; Mon, 12 Aug 2024 16:01:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1723471262; bh=lEitmw+Di5Nqi42iq1sGdwj1UjJmu6Qt90qN7h7cG7g=; h=From:Subject:Date; b=oLEdBUFUZUBbokkGDPZy5Q4OCht8uECOUg/oh50EO9UVm5m0RsJDyD1zetSWD98Ol KPpR41aw5Jiyaz83PixPDkmnXi5M9g/e9DrCsyz5OIUGHdZAwwacVpgm8NV+MVPqhK 8GCJq7f3NFnxM77UnBpgQI1P9R+7Aj057Oxql/PJf5ZrBottWN+K+KJUd7i/gWGrvp HyGmFXzMXBfe8kWlxrHU+VJOsTM5Yr/tf5avqrdRPmYvpNL7TMy1EAyWcEylDyZYf2 0av2aNxozC91JLvKVWTfH+OeS8mK11fwKScPks36AJMy62r5RJ/PT6y6jukhdntItg 8DKHnF22+PKYg== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Lukasz Luba , Zhang Rui Subject: [PATCH v2 01/17] thermal: core: Fold two functions into their respective callers Date: Mon, 12 Aug 2024 15:51:38 +0200 Message-ID: <2400231.NG923GbCHz@rjwysocki.net> In-Reply-To: <114901234.nniJfEyVGO@rjwysocki.net> References: <114901234.nniJfEyVGO@rjwysocki.net> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: spam:low X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgjedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuphgrmhfkphculdeftddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuufhprghmkfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=15 Fuz1=15 Fuz2=15 From: Rafael J. Wysocki Fold bind_cdev() into __thermal_cooling_device_register() and bind_tz() into thermal_zone_device_register_with_trips() to reduce code bloat and make it somewhat easier to follow the code flow. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- v1 -> v2: No changes --- drivers/thermal/thermal_core.c | 55 ++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -991,20 +991,6 @@ void print_bind_err_msg(struct thermal_z tz->type, cdev->type, ret); } -static void bind_cdev(struct thermal_cooling_device *cdev) -{ - int ret; - struct thermal_zone_device *pos = NULL; - - list_for_each_entry(pos, &thermal_tz_list, node) { - if (pos->ops.bind) { - ret = pos->ops.bind(pos, cdev); - if (ret) - print_bind_err_msg(pos, cdev, ret); - } - } -} - /** * __thermal_cooling_device_register() - register a new thermal cooling device * @np: a pointer to a device tree node. @@ -1100,7 +1086,13 @@ __thermal_cooling_device_register(struct list_add(&cdev->node, &thermal_cdev_list); /* Update binding information for 'this' new cdev */ - bind_cdev(cdev); + list_for_each_entry(pos, &thermal_tz_list, node) { + if (pos->ops.bind) { + ret = pos->ops.bind(pos, cdev); + if (ret) + print_bind_err_msg(pos, cdev, ret); + } + } list_for_each_entry(pos, &thermal_tz_list, node) if (atomic_cmpxchg(&pos->need_update, 1, 0)) @@ -1338,25 +1330,6 @@ void thermal_cooling_device_unregister(s } EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister); -static void bind_tz(struct thermal_zone_device *tz) -{ - int ret; - struct thermal_cooling_device *pos = NULL; - - if (!tz->ops.bind) - return; - - mutex_lock(&thermal_list_lock); - - list_for_each_entry(pos, &thermal_cdev_list, node) { - ret = tz->ops.bind(tz, pos); - if (ret) - print_bind_err_msg(tz, pos, ret); - } - - mutex_unlock(&thermal_list_lock); -} - static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) { *delay_jiffies = msecs_to_jiffies(delay_ms); @@ -1554,13 +1527,23 @@ thermal_zone_device_register_with_trips( } mutex_lock(&thermal_list_lock); + mutex_lock(&tz->lock); list_add_tail(&tz->node, &thermal_tz_list); mutex_unlock(&tz->lock); - mutex_unlock(&thermal_list_lock); /* Bind cooling devices for this zone */ - bind_tz(tz); + if (tz->ops.bind) { + struct thermal_cooling_device *cdev; + + list_for_each_entry(cdev, &thermal_cdev_list, node) { + result = tz->ops.bind(tz, cdev); + if (result) + print_bind_err_msg(tz, cdev, result); + } + } + + mutex_unlock(&thermal_list_lock); thermal_zone_device_init(tz); /* Update the new thermal zone and mark it as already updated. */