From patchwork Mon Sep 26 14:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988849 X-Patchwork-Delegate: geert@linux-m68k.org 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 2DA29C32771 for ; Mon, 26 Sep 2022 15:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236290AbiIZPVC (ORCPT ); Mon, 26 Sep 2022 11:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236461AbiIZPTS (ORCPT ); Mon, 26 Sep 2022 11:19:18 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2216782D33 for ; Mon, 26 Sep 2022 07:06:41 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id iv17so4581661wmb.4 for ; Mon, 26 Sep 2022 07:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=wWv1m+XXCoVQHb8PDskWeYfQYLfcMm1SCoVxR85JW/Ecblj4tvHkHfBE5gF13woWHW uGnvaL5vR1TiZeybhAcNf45ADUOyIierTlgELJRA30Qb2AD+9Cmt2TxTbfvsXf8/O4ti C2j7OY68Wg3u8lyMynjHPw/7ts8QcXTAs0pcDZNewijPNrpt7Fx2uskzRbZt8qIprK0r wKpXiNHKmOg8uWn5WfJGP7UloBuHgkVNYeLOtNiTR6unUWICLMaoDM9QIJDnUVtv7TGf hVy+AyEhmtH9nMzAv1pt29EyYAAgCoJ8N4dvLOepmayWa+z+YJRBCU9kn2Fyq+5v1jBB eKLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=w5u3YA4ynfzE9WAwZCXgsAyK27CcLyxcUE+oilRueNqHZCJT+W5DkbSDo5RnsDYBhn 44cDsOBzjFYmTOmyPgOc9nebMmctUVZ9m9vTCCCJrM+UTuu5H/N8QcIXTFo90wPLycN3 JfdQBGBW7bYqktgcqulXuBrNUczNTxnraGJka2KnzOxoYdbYyaP7yB7/6V4eiu2JH5hW fYmRYHHYfTgvEwruZvLxjO6fGFVbHKy+bVQBDStbgU6iMMbuPFQGGIArKICcjB3I6R/n TyQ6hBRFixvGC9adVhR+kg9gW6278U4nXoVyKcKhI5/Kn0b9o6mUOG8ECkfXfE84W/iL +HEw== X-Gm-Message-State: ACrzQf2VeSz+0xLUCJl2rXxlIEFjV56YqnzcAwhQzE6DkNnoXe6DwEBF c7uSRj0Cs1UkHfz46GL9XHJo6Q== X-Google-Smtp-Source: AMsMyM4XD9QOxU0BEk9+OLqsbpu/aWVwF7Yy9OQHxWQNqCOXN85C7JYpF2F4vQjYYL6iva8Dwj5c7g== X-Received: by 2002:a05:600c:3c89:b0:3b5:e3:bd0f with SMTP id bg9-20020a05600c3c8900b003b500e3bd0fmr15666943wmb.199.1664201199365; Mon, 26 Sep 2022 07:06:39 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:38 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, =?utf-8?q?Niklas_S=C3=B6derlund?= , =?utf-8?q?Niklas_S=C3=B6derlund?= , Amit Kucheria , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v5 16/30] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Date: Mon, 26 Sep 2022 16:05:50 +0200 Message-Id: <20220926140604.4173723-17-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The thermal core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Niklas Söderlund --- drivers/thermal/rcar_gen3_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 4c1c6f89aa2f..4ef927437842 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -529,7 +529,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) if (ret) goto error_unregister; - ret = of_thermal_get_ntrips(tsc->zone); + ret = thermal_zone_get_num_trips(tsc->zone); if (ret < 0) goto error_unregister; From patchwork Mon Sep 26 14:05:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988850 X-Patchwork-Delegate: geert@linux-m68k.org 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 6C082C07E9D for ; Mon, 26 Sep 2022 15:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236356AbiIZPVY (ORCPT ); Mon, 26 Sep 2022 11:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236061AbiIZPT1 (ORCPT ); Mon, 26 Sep 2022 11:19:27 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F212B832D4 for ; Mon, 26 Sep 2022 07:06:52 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id n10so10353346wrw.12 for ; Mon, 26 Sep 2022 07:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1g7iD3leIss4w6BJ5qO+L1jz4YwsNBVACOWMBVjZgpk=; b=tnnDjaBUtnc7oQrQbRebViXzmDjDdl9T/DEuZNUa9/JCDkDEp4iP53y1QtaSPi98g7 +vBxLVToAlC9nmdKHBjptrLQORY/qiSyHCq9wlVFLXOUH7A/iK8R9RyquHplpBVNBD8g ZrnGKD3wDUl4TdphCW7hwjPVqClPb4iH12hN/2srvVDBes1jZL/Ts/yUoapAQ+Du2hGk 0AWbJxxqH5Z9pBf7KLV9nVueV2+OYe19maKGCS30q5XXT9+KZaBu6Hx+35s4qyIR2mYf F+sGY0Slo13wCBkKp7Q7o6RFh2kwDAr1xMaMP4bLPChHOB39YLUJ6BTtuBvRUcINqmUg 5apg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=1g7iD3leIss4w6BJ5qO+L1jz4YwsNBVACOWMBVjZgpk=; b=ZzD9iQbdJrv44EZMqWkMUXNkFdEQJ0VV4g8qxVdB0ImpcgFWr5N6vvrlbSrPTHffrn Xi5M9NG/sx7PDtG4fNkmP1Iw33ZMKIJSb76ZPMnLd62COM67iPgNiKfW8LRQD0xFuM0N Y5DSk3g39Yl2QXsk4bjab467Uzpo9d+54dSO/qkIN+CxkFC9nGZc0IkOCDXNQpj0ss6f XGT2tyLA/7ttCZYAX9gRM496AwiMBjNcmSOguSmR6EqTt833rsjhZ6Oi55aMwQW50jXe ZqYCEHNcYCfAy746HcMqvQD4zZiEWYcERnXYcyMwUyGV1lxWGWc4mIDC+w9d0RRT3SAy y5tw== X-Gm-Message-State: ACrzQf0SSdKzeNQh/aLipr1BFoge6lnpNAOSIeNdrA4dZlKFflnMkcaj eSyLyLST/rFqZJwa6klUkMOb7w== X-Google-Smtp-Source: AMsMyM4IjuisRUSZFfhh5aV/d+IDBRRQK/plI/EtN4XB30ApYlP4YdMBrxfzv20ceoHjV3K0TdPGqA== X-Received: by 2002:a5d:6147:0:b0:22a:6035:a878 with SMTP id y7-20020a5d6147000000b0022a6035a878mr13189438wrt.528.1664201211500; Mon, 26 Sep 2022 07:06:51 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:50 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, =?utf-8?q?Niklas_S=C3=B6derlund?= , =?utf-8?q?Niklas_S=C3=B6derlund?= , Amit Kucheria , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v5 23/30] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:57 +0200 Message-Id: <20220926140604.4173723-24-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Niklas Söderlund --- drivers/thermal/rcar_thermal.c | 49 +++++----------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 4df42d70d867..003457810072 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -278,52 +278,16 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) return rcar_thermal_get_current_temp(priv, temp); } -static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, - int trip, enum thermal_trip_type *type) -{ - struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); - struct device *dev = rcar_priv_to_dev(priv); - - /* see rcar_thermal_get_temp() */ - switch (trip) { - case 0: /* +90 <= temp */ - *type = THERMAL_TRIP_CRITICAL; - break; - default: - dev_err(dev, "rcar driver trip error\n"); - return -EINVAL; - } - - return 0; -} - -static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, - int trip, int *temp) -{ - struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); - struct device *dev = rcar_priv_to_dev(priv); - - /* see rcar_thermal_get_temp() */ - switch (trip) { - case 0: /* +90 <= temp */ - *temp = MCELSIUS(90); - break; - default: - dev_err(dev, "rcar driver trip error\n"); - return -EINVAL; - } - - return 0; -} - static struct thermal_zone_device_ops rcar_thermal_zone_of_ops = { .get_temp = rcar_thermal_get_temp, }; static struct thermal_zone_device_ops rcar_thermal_zone_ops = { .get_temp = rcar_thermal_get_temp, - .get_trip_type = rcar_thermal_get_trip_type, - .get_trip_temp = rcar_thermal_get_trip_temp, +}; + +static struct thermal_trip trips[] = { + { .type = THERMAL_TRIP_CRITICAL, .temperature = 90000 } }; /* @@ -531,9 +495,8 @@ static int rcar_thermal_probe(struct platform_device *pdev) dev, i, priv, &rcar_thermal_zone_of_ops); } else { - priv->zone = thermal_zone_device_register( - "rcar_thermal", - 1, 0, priv, + priv->zone = thermal_zone_device_register_with_trips( + "rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv, &rcar_thermal_zone_ops, NULL, 0, idle);