From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05869CDB474 for ; Fri, 20 Oct 2023 17:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377885AbjJTROR (ORCPT ); Fri, 20 Oct 2023 13:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377855AbjJTROR (ORCPT ); Fri, 20 Oct 2023 13:14:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F14F4D6D; Fri, 20 Oct 2023 10:14:14 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DCEF143D; Fri, 20 Oct 2023 10:14:55 -0700 (PDT) Received: from [10.57.82.142] (unknown [10.57.82.142]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A27C3F5A1; Fri, 20 Oct 2023 10:14:13 -0700 (PDT) Message-ID: <63b7f4da-8ddb-443c-8074-66b7b0c6cd84@arm.com> Date: Fri, 20 Oct 2023 18:15:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 2/6] thermal: trip: Define for_each_trip() macro Content-Language: en-US To: "Rafael J. Wysocki" Cc: LKML , Daniel Lezcano , Srinivas Pandruvada , Zhang Rui , Linux PM References: <13365827.uLZWGnKmhe@kreacher> <8282829.T7Z3S40VBb@kreacher> From: Lukasz Luba In-Reply-To: <8282829.T7Z3S40VBb@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 10/6/23 18:41, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Define a new macro for_each_trip() to be used by the thermal core code > and thermal governors for walking trips in a given thermal zone. > > Modify for_each_thermal_trip() to use this macro instead of an open- > coded loop over trips. > > No intentional functional impact. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/thermal/thermal_core.h | 3 +++ > drivers/thermal/thermal_trip.c | 7 ++++--- > 2 files changed, 7 insertions(+), 3 deletions(-) > > Index: linux-pm/drivers/thermal/thermal_core.h > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_core.h > +++ linux-pm/drivers/thermal/thermal_core.h > @@ -116,6 +116,9 @@ void __thermal_zone_device_update(struct > enum thermal_notify_event event); > > /* Helpers */ > +#define for_each_trip(__tz, __trip) \ > + for (__trip = __tz->trips; __trip - __tz->trips < __tz->num_trips; __trip++) > + > void __thermal_zone_set_trips(struct thermal_zone_device *tz); > int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, > struct thermal_trip *trip); > Index: linux-pm/drivers/thermal/thermal_trip.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_trip.c > +++ linux-pm/drivers/thermal/thermal_trip.c > @@ -13,12 +13,13 @@ int for_each_thermal_trip(struct thermal > int (*cb)(struct thermal_trip *, void *), > void *data) > { > - int i, ret; > + struct thermal_trip *trip; > + int ret; > > lockdep_assert_held(&tz->lock); > > - for (i = 0; i < tz->num_trips; i++) { > - ret = cb(&tz->trips[i], data); > + for_each_trip(tz, trip) { > + ret = cb(trip, data); > if (ret) > return ret; > } > > > LGTM Reviewed-by: Lukasz Luba