From patchwork Wed Mar 8 21:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 13166482 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E3AEC678D5 for ; Wed, 8 Mar 2023 21:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AfCNISfHqykfhq8dMpjIaC1QtuIA5kcsHx+AiAqOPxY=; b=IS3UDumUTYhrQn 8Fitfzm7EI3yNM8h1mfUugADQHu8M27GNYOpKkERGb/Nw2j3RFDxcpJ8Akv361kVbMM46seOlpFny TVoe9vVwXSqMnfrDkPcJVhE6n6CSVLrZxdQx7POupA6mvgNHAA4FyS5kImbIcnvdqd7evYXXwNM8y 5O7HCsR410lJockd4qVAd8qgBt818yiku4I5Muidkq55+MDKLlx4BkgJmyJA0TNQLQLWhPFajKZ7K idwq9gdI2XgB8malttYyDAH43dUdjXT1RZlpV4vJcoVNMPkd+7A7b3nzmNpT0h9rW6DqHgHSkJcU5 hI+XOuw7ifmv/lE4sbjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pa1eR-006sXU-0v; Wed, 08 Mar 2023 21:48:47 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pa1eN-006sWm-Mo for linux-arm-kernel@lists.infradead.org; Wed, 08 Mar 2023 21:48:45 +0000 Received: by mail-wr1-x434.google.com with SMTP id h11so29949wrm.5 for ; Wed, 08 Mar 2023 13:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678312121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bSi6Beth8Hd606NS4V715NDwa0mm95xS/EhiukW+s4A=; b=l6+xSoB8aU6pf5jOSHIdYTf6mhvsf4dNHL0DDvpOnx020ewh76Hmaz37YLZZBOMHUL 6rZidRg2vYmnd1dliOQBg3N6gMokd+sv43Lq7yoc9/UA4XOtjKB5Y9eKPdwF/ZzPn6LE TNT0mSJC015lzvtsNG27OuKKJt/y0S0iNu9NGG5YdjsIOZXgpuzp2koitg62T2Hsyuhh rMF/os4aI/1JAHBSH+lx9F65yJHAGICp54WNlSrqTgWOklbqyb9PVMBweaA8Gw9d59YK 3NL7bdJzch8Udk7nUxyoxJ4V4d77BXnGts5Y2E6VMgESMDOnHOfWU7SFUt1UPUJ8p4h6 SKGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678312121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bSi6Beth8Hd606NS4V715NDwa0mm95xS/EhiukW+s4A=; b=vc3oFBdbYSxIVz+hlhQPnw/uW841fXDhWJtx/ldF8LQX00u1SmRe+0UdE7yyF7DAqz lEKPRojusIgAHkUzx+P/+b+tgGR83wr1hblKIm9coI9Ea2ggdsEL03GuhytkWTDDUlCW aRe/KY8/hBgDKb27d+SmzmzuRVsQC6DxBHCQXXeDrZj6dx1jPKTWAK3Tv3OfOj0rT79x HyQq7gg4C0Wi2WYx9wFU4N8bGznI4z5xVhZYlWdUU9opPpALCOVJ6rmOodU3QjhJNc+8 R4NTAuc3+uj32PnE86eTTQ8K2VkNsCstMjhjQc2Dr/qmBAyis3wfmFBRbeRlC2aHhmbS /kWQ== X-Gm-Message-State: AO0yUKX/FHxu0fdE5YDs7unhfK8ob5wUkGKFWfdcsBr/nv3USZbPTTi4 c70qDsIkuqWjtfy4hxBSclOLSA== X-Google-Smtp-Source: AK7set9vuN8INCmFZBDldnjaZzya3b21KVx/xTSSssDzxqlXf8GDST84z4Er4IgIf1dKoCZy3qx6pw== X-Received: by 2002:adf:df8f:0:b0:2c8:dc8f:3951 with SMTP id z15-20020adfdf8f000000b002c8dc8f3951mr12301392wrl.5.1678312119704; Wed, 08 Mar 2023 13:48:39 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:fbda:65f5:e873:7527]) by smtp.gmail.com with ESMTPSA id z6-20020adfd0c6000000b002c55efa9cbesm16065713wrh.39.2023.03.08.13.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 13:48:39 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE) Subject: [PATCH 2/2] thermal/drivers/imx: Use the thermal framework for the trip point Date: Wed, 8 Mar 2023 22:48:22 +0100 Message-Id: <20230308214822.1317086-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308214822.1317086-1-daniel.lezcano@linaro.org> References: <20230308214822.1317086-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_134843_764012_3721D238 X-CRM114-Status: GOOD ( 21.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The thermal framework provides an API to get the trip related to a trip point id. We want to consolidate the generic trip points code, thus preventing the different drivers to deal with the trip points after they registered them. The set_trip_temp ops will be changed regarding the above changes but first we need to rework a bit the different implementation in the drivers. The goal is to prevent using the trip id but use a trip point passed as parameter which will contain all the needed information. As we don't have the trip point passed as parameter yet, we get the trip point using the generic trip thermal framewrok APIs and use it to take exactly the same decisions. The difference with this change and the previous code is from where we get the thermal trip point (which is the same). No functional change intended. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 69ed482167f7..e4e82bdf34f1 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -330,26 +330,29 @@ static int imx_change_mode(struct thermal_zone_device *tz, return 0; } -static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, +static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) { struct imx_thermal_data *data = thermal_zone_device_priv(tz); + struct thermal_trip trip; int ret; ret = pm_runtime_resume_and_get(data->dev); if (ret < 0) return ret; + ret = __thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + return ret; + /* do not allow changing critical threshold */ - if (trip == IMX_TRIP_CRITICAL) + if (trip.type == THERMAL_TRIP_CRITICAL) return -EPERM; - + /* do not allow passive to be set higher than critical */ if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) return -EINVAL; - trips[IMX_TRIP_PASSIVE].temperature = temp; - imx_set_alarm_temp(data, temp); pm_runtime_put(data->dev);