Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp794544imw; Fri, 8 Jul 2022 11:51:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uKXQRUjVH15v3Cd7Is5CoQ+eAtu0JNZcxG417b7ma8xKmJON3W6AyXY2bMX6+mq6U1SgxX X-Received: by 2002:a17:907:1c09:b0:726:b834:1a21 with SMTP id nc9-20020a1709071c0900b00726b8341a21mr4851917ejc.518.1657306298052; Fri, 08 Jul 2022 11:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657306298; cv=none; d=google.com; s=arc-20160816; b=feJ06OE+oiwrGTWjQ0j/TlJeEIBfrZVlNI7OQEJxpZauvXAbr3C13oLOepvuad6EZp gIlnCj509fV7cinXY/nkJrXtNgb/Yo2CcmHRbelgelKGgSY5VUd7kKO51gPnarfMNO7a AnxsuuuOWOXEohq4QBTFy/gkMoxqi+VGViqprdP1vfFaXGySQcOPUHt2Y841I0yILwip /R7jmRhpK8E87ErgCaWqRusmhym2dhd9vqRJlwPmpv3+ewF6B58IFP0pTcqwOf5UkfO3 jLhshdldDvtbhro2J+pSm/MAh45Dv8Zeny3tVuccdTEQVYts1c+90N0odvekVHwz16JD J9Vw== 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=8W1S2KUuL89TqEwWGa5XSTCs1irHk/zbJh1P5bOgERI=; b=B6zMYXOyCQfjYf7ZLSTt820HF+SicjCYjeH56fMX2RFfKjC/qXOos49H827c9dMd94 xEDCPmG+mqco/egIuYPYrySZ9SwSiQVIjZTnGdKXOQKOn/EDv4gX9v+Ss4f9ltcW7g8l EuobIeNrPrMM70VlmhB43NqOIZIzZZq7XbQ6YHrRGbJv3nf8joJqpxX5xgUQtTanLPJW P2nYBsXrxf/z2YFpuA2Y9FBBHi5/K3Bn3cIhcv4I/EPbSir3YPr6BttLNpreMJ4I6jzO ArS10uT7uF43rO+mgQ/KbDGSWIr+rtV2vBqpd3dSbJsI7Ii9hhybssuk3rO4n9P9wp2r MTNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B0BNs4nO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a17090679c700b00722e85dcd91si24280066ejo.175.2022.07.08.11.51.13; Fri, 08 Jul 2022 11:51:38 -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; dkim=pass header.i=@linaro.org header.s=google header.b=B0BNs4nO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiGHScj (ORCPT + 99 others); Fri, 8 Jul 2022 14:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238757AbiGHScW (ORCPT ); Fri, 8 Jul 2022 14:32:22 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76B9822F for ; Fri, 8 Jul 2022 11:32:21 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id ay25so3179456wmb.1 for ; Fri, 08 Jul 2022 11:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8W1S2KUuL89TqEwWGa5XSTCs1irHk/zbJh1P5bOgERI=; b=B0BNs4nOwOtWXpSnh0Sk8e0/yhMsisqXUANXdlv4wV9Ln/BjUKPy5vQf9TWj3QQQ8t Z2tzvB+kZ6ohiPy4eh881B/569E7ujYz3jhxrvuAboW0cEXuOqaKc6UbzEf1d1XfIpcU cLeBVZ2j96Z+9k52a78bHdo4k7SuvKHoRXfalILLU12WA0eqXstzz2rRJxzsfu6Jhc20 7FJtbcylNwMGBLTWpxNPbix5P+hS3aUJDdlsiBHjbPACXeqy5ISqlJP8XoAKpnGQs8DQ oule4vZpMp4nmQ1Kpw18JHtIOxKILK6dqlxpQHx1OxjVsZI1l7zvwgga5CIVcuegkFDw uXbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8W1S2KUuL89TqEwWGa5XSTCs1irHk/zbJh1P5bOgERI=; b=WcdSV3kZHeAsak7VfRaDpGrQa2tb7m5/B77ZQhctyQ/4UoHlK0c3eacOx+XKtokt9J gn18k5pOl0hSRyMqizfaenrX0de3g3YkK8PIWYStCzvp+wuUj/ykoPERJvF5XT3PC6v4 hWpeoO1PxcLTK5lAHbYb8B40XH38NeP+Os7jy/Qxs57UuDiuuW2tjsOJqhxAa0JsTBGk wBP3U2MCg7ML4z8q+KCNi8mlfXUB4HQE21bgpyKr5Gqp3OrdUZovyT7l2xOsnxL6hBUH RH9rgqNwu4s5z0o6rXKUyy7+UZzxTf4Z2yOQQdpZ6eDBu6p5pdO4pLtGxWguuuPw1HoJ ekcQ== X-Gm-Message-State: AJIora8Tj6L5YFlbuzlsRKxcQ0JlxTATMBkX7Z83ohD+K1boRrJi1GPr 1jaUkaGdtuv8svdA2lhsK1f+sQ== X-Received: by 2002:a05:600c:22da:b0:3a0:4e7b:4237 with SMTP id 26-20020a05600c22da00b003a04e7b4237mr1159282wmg.101.1657305139981; Fri, 08 Jul 2022 11:32:19 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id t9-20020adfeb89000000b0021d887f9468sm4292073wrn.25.2022.07.08.11.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 11:32:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: quic_manafm@quicinc.com, rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 1/3] thermal/core: Encapsulate the trip point crossed function Date: Fri, 8 Jul 2022 20:32:07 +0200 Message-Id: <20220708183210.1334839-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 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); -- 2.25.1