Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4219477imw; Tue, 12 Jul 2022 04:16:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vU2KlpMZaEMDzqeGmzPnqRYr+bfbuxQ9Rk7vdr3cAGAbo4W5FXMf46P6oHF8VgmNeP+3Tp X-Received: by 2002:a17:902:da87:b0:16c:56d7:e002 with SMTP id j7-20020a170902da8700b0016c56d7e002mr5224553plx.27.1657624609603; Tue, 12 Jul 2022 04:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657624609; cv=none; d=google.com; s=arc-20160816; b=Ga3HzgQ3VM3PbUquHR5qeNETrm1sqHb379TF2NL4uuIEHWAMu+VvQPxioHq5G40pEr acm9uMg+a4A82P6R5ZoJj9Re4aUJ5pu2H/RbD34DEONIpnR5hNKf6uPkEL7KY81+evLv Gk23TfNctKheIe58UFlbMFrJ6SG3wV1+YGhebxuxkFsvlHYzYQk5lQSx2J6QjU65v4Ab pGHLQpP9H8MY8fdnkmb6n39qqGCWGuv4sewpkQvBseBNmJF18UcIcgbKkP5VRkgc3ooH XX09L4Lb1WsIsfko4bFHwFOM+ibAIVup8Ksks/TFrLHt+ZldfeJYomhU/WA2x4r5/UvI HMIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=4sto5+sLYjRYY0yTo646GGdausea5FG5cbs8LjC4fGk=; b=RcSySDpXWgALql/5tA5/idWxSJz+PgRFN83q5nKkUA0D8E5RkHbyUrKwe/786MM7ad +NXugwwFgcYwb+i6hOm2YWMEPzvOTRJQ7L4NIfv4m2J0vafw/xhA+EMnOEf6jeTO6da+ /hlYvOyQNNscr4EEujbdAOcaaa5pF9IYB6B+9MQJEIjOCJ9PiZvbLipG5L9gh42R9KdG fhEzDqHmPJh7Wk4s1imNzoif+Ogq6qnT5x+l5Nbb3W4UH3jYudbsQpWmzRdgy2oSsuCI 6syPMsNvYYULR3iNcG7y1JrIjRP0EMNfp0UGJhYzDGvW+/EbmwlVli7Flf+7m/dtdQ2f l/cQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mr11-20020a17090b238b00b001ea91760f6esi14167236pjb.79.2022.07.12.04.16.20; Tue, 12 Jul 2022 04:16:49 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232888AbiGLLP0 (ORCPT + 99 others); Tue, 12 Jul 2022 07:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232671AbiGLLPA (ORCPT ); Tue, 12 Jul 2022 07:15:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 66627B1852; Tue, 12 Jul 2022 04:14:04 -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 8E8E11515; Tue, 12 Jul 2022 04:13:52 -0700 (PDT) Received: from [10.57.13.42] (unknown [10.57.13.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA44A3F70D; Tue, 12 Jul 2022 04:13:50 -0700 (PDT) Message-ID: Date: Tue, 12 Jul 2022 12:13:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2 1/3] thermal/core: Encapsulate the trip point crossed function Content-Language: en-US To: Daniel Lezcano Cc: quic_manafm@quicinc.com, rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , rafael@kernel.org References: <20220708183210.1334839-1-daniel.lezcano@linaro.org> From: Lukasz Luba In-Reply-To: <20220708183210.1334839-1-daniel.lezcano@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 7/8/22 19:32, Daniel Lezcano wrote: > The routine where the trip point crossed is detected is a strategic > place where different processing will happen. Encapsulate the code in > a function, so all specific actions related with a trip point crossed > can be grouped. > > Signed-off-by: Daniel Lezcano > --- > drivers/thermal/thermal_core.c | 30 ++++++++++++++++++++---------- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index cdc0552e8c42..d9f771b15ed8 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -358,6 +358,25 @@ static void handle_critical_trips(struct thermal_zone_device *tz, > tz->ops->critical(tz); > } > > +static void handle_thermal_trip_crossed(struct thermal_zone_device *tz, int trip, > + int trip_temp, int trip_hyst, enum thermal_trip_type trip_type) > +{ > + if (tz->last_temperature == THERMAL_TEMP_INVALID) > + return; > + > + if (tz->last_temperature < trip_temp && > + tz->temperature >= trip_temp) { > + thermal_notify_tz_trip_up(tz->id, trip, > + tz->temperature); > + } > + > + if (tz->last_temperature >= trip_temp && > + tz->temperature < (trip_temp - trip_hyst)) { > + thermal_notify_tz_trip_down(tz->id, trip, > + tz->temperature); > + } > +} > + > static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) > { > enum thermal_trip_type type; > @@ -372,16 +391,7 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) > if (tz->ops->get_trip_hyst) > tz->ops->get_trip_hyst(tz, trip, &hyst); > > - if (tz->last_temperature != THERMAL_TEMP_INVALID) { > - if (tz->last_temperature < trip_temp && > - tz->temperature >= trip_temp) > - thermal_notify_tz_trip_up(tz->id, trip, > - tz->temperature); > - if (tz->last_temperature >= trip_temp && > - tz->temperature < (trip_temp - hyst)) > - thermal_notify_tz_trip_down(tz->id, trip, > - tz->temperature); > - } > + handle_thermal_trip_crossed(tz, trip, trip_temp, hyst, type); > > if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT) > handle_critical_trips(tz, trip, type); LGTM Reviewed-by: Lukasz Luba