From patchwork Wed Sep 28 21:00:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610148 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 E34B5C32771 for ; Wed, 28 Sep 2022 21:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233675AbiI1VCA (ORCPT ); Wed, 28 Sep 2022 17:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233049AbiI1VBm (ORCPT ); Wed, 28 Sep 2022 17:01:42 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50534DB0E for ; Wed, 28 Sep 2022 14:01:17 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 130-20020a1c0288000000b003b494ffc00bso1520974wmc.0 for ; Wed, 28 Sep 2022 14:01:17 -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=abNjzxC9KSYgYlQOmWQSgo4rKZqyrGSmTM4tjbmhmc8=; b=ebXZQzqLFM7RjEoQM6zsVXA6jDMD2WgjwN4nDLGZW8mHkCrbK4eH36HuGUvha7R+QY DfEisBb7GpqVukgcqjj2/XF6op9qUciWVIPdLSVv+zlAvbpGUaVCAvDem3AR548FA2Ro vCTH4UAIB1px1Sdw+yPZ2GHw4k79F6Qham0iaoih9HhM5wjfogpaw5aRx/qco0+C8rYY ikU7zGP/0YNCaxTcpYV3N0ddABmPOXzUXmyl4ZoEVYqwf1ccMbXBj9jyksltxH0M90QH h/ulB0oOJdmRLK7hZn4fcDvkkyKF9S+omn2RWC7DCTryAQptRYS78wuCwsQtChsXFJoX MGhw== 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=abNjzxC9KSYgYlQOmWQSgo4rKZqyrGSmTM4tjbmhmc8=; b=Wi6Yxmr8HVg3LuxokW+S7lUItKU9V+GMu9IqvZgDiManzkgr6WV+LcwWqr6VYJ/pWp yhNLSTmixXnIjs3Zb9rit3ZotE9JtmdW1sJrV0B3NitJmm2vXLaL8LAzDVsaQiJ9wmEc msIgXMfeRhh5ZDNz5Ntj/iJVlJ5Y73XdAccvk1/w9CCTj97qiU0qO5H6MmyTR1IQqMya aVOxA/78UAquoW0vnlJP1skPZMZKXZcLxdQBG6IigX1MjKP62UZ9RK0nPyvstGInxc6a EjDBYJGTkCIItoxsuqnk4mMKsPgaBcjwJB1UOJsDIg++io6eJSgcvXeSuNq0+lV0vOut SnZA== X-Gm-Message-State: ACrzQf2xHjCyy/NKJdqO+Wfm3VJ02yMrMfpqFPahEzIr9h2JfkBukxg8 nyY7UDBSQYRqUP8sklQ1m542bg== X-Google-Smtp-Source: AMsMyM44FrfuMgclUbeBL+zv+v8tEfa13hMyWrP2ZUn1Nnam2wRAnNABfXvDzhNBoZcFcyOd37P02w== X-Received: by 2002:a05:600c:34c2:b0:3b4:76f2:9c3b with SMTP id d2-20020a05600c34c200b003b476f29c3bmr8102729wmq.179.1664398876092; Wed, 28 Sep 2022 14:01:16 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:15 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 02/29] thermal/sysfs: Always expose hysteresis attributes Date: Wed, 28 Sep 2022 23:00:32 +0200 Message-Id: <20220928210059.891387-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Instead of avoiding to expose the hysteresis attributes of a thermal zone when its get_trip_hyst() operation is not defined, which is confusing, expose them always and use the default thermal_zone_get_trip() function returning 0 hysteresis when that operation is not present. The hysteresis of 0 is perfectly valid, so this change should not introduce any backwards compatibility issues. Signed-off-by: Daniel Lezcano Acked-by: Rafael J. Wysocki --- drivers/thermal/thermal_sysfs.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index d093d7aa64c6..6c45194aaabb 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -426,23 +426,20 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) return -ENOMEM; } - if (tz->ops->get_trip_hyst) { - tz->trip_hyst_attrs = kcalloc(tz->num_trips, - sizeof(*tz->trip_hyst_attrs), - GFP_KERNEL); - if (!tz->trip_hyst_attrs) { - kfree(tz->trip_type_attrs); - kfree(tz->trip_temp_attrs); - return -ENOMEM; - } + tz->trip_hyst_attrs = kcalloc(tz->num_trips, + sizeof(*tz->trip_hyst_attrs), + GFP_KERNEL); + if (!tz->trip_hyst_attrs) { + kfree(tz->trip_type_attrs); + kfree(tz->trip_temp_attrs); + return -ENOMEM; } attrs = kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) - kfree(tz->trip_hyst_attrs); + kfree(tz->trip_hyst_attrs); return -ENOMEM; } @@ -475,9 +472,6 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) } attrs[indx + tz->num_trips] = &tz->trip_temp_attrs[indx].attr.attr; - /* create Optional trip hyst attribute */ - if (!tz->ops->get_trip_hyst) - continue; snprintf(tz->trip_hyst_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_hyst", indx); @@ -514,8 +508,7 @@ static void destroy_trip_attrs(struct thermal_zone_device *tz) kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) - kfree(tz->trip_hyst_attrs); + kfree(tz->trip_hyst_attrs); kfree(tz->trips_attribute_group.attrs); } From patchwork Wed Sep 28 21:00:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610147 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 59E69C6FA86 for ; Wed, 28 Sep 2022 21:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234061AbiI1VCQ (ORCPT ); Wed, 28 Sep 2022 17:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233642AbiI1VB6 (ORCPT ); Wed, 28 Sep 2022 17:01:58 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D70C6FA20 for ; Wed, 28 Sep 2022 14:01:23 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id v28so8771404wrd.3 for ; Wed, 28 Sep 2022 14:01:23 -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=9zOcMpxX0c9YFao1IzO9/jsibY90yPALAUf8D0IY2Z0=; b=u4hgAIjVQmqRVbJl2YwpmcVTuoCM3GTsQPCA6eMv0b7rvn/rnckzvuR6ofPbiB1TJa ZlLjDKrwPpeEiBv9PTh/1Xx3Gfnr4q6mJdNzz3d1tm6Ei9ZiQgxLl+D5Pc8NX6luUnW1 /TLZkfk8bhl4YshKjiTFE9/EP0ofhw9lzZEkdxpZjdiIIAqWQ5tiMrFIHDXw7tgPHucZ cXYTKmH/JgO8SV98mQItNLeuxUny4ZGefSx0zpKoKcLkW0kJ3RvKp3hbMGznHHoviuPX C6XLIxFEfyJ/FQmcIyr1wE2qQZ/OSpqqtjq/XK7ApKKUxx6Ka0r17s5nkwr1A6pjV9Mf xkOA== 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=9zOcMpxX0c9YFao1IzO9/jsibY90yPALAUf8D0IY2Z0=; b=XfzkFDE8BeEAKs0wk6Lw3wdKjamNEyx2E67JdHYtUQpAkbsWvsyHU0hTsN6i83GJ9i mGWvlX2247DPIl0SZXcz09q67vfX+0N4VZDI9w+O5o39XabSPsacvKgNpUJWnM7aOsar cPGIeBC3/7j6EWvjADpQ55jL+LPwO3lbZISmLEBMtzFmEb/j/694qyjYwjx0vAmOz4Xy Uui3wNvm0osqmsOdiLu5nJmntF6tj801XA0R3AIlRuwRLTml97vhBoc6INuvdE7cOTfV tnuhK3P+/8I1P2z5jvbEMJF16a19QlbGKow5BnfZqQ+7ynSv8grz1uasOSLuZz2+oQL2 oJbw== X-Gm-Message-State: ACrzQf18WbKYTC1HcdMwirnTq0KByEVMEbp/2yFbD+ZTXmsCIxb7qu87 //OMtptFH5C/9bU+oIMNTDtIEA== X-Google-Smtp-Source: AMsMyM5xePk56cyq/1R6ENrMpBOJY2bWbc8YwNLW3DMmUcXMBs4hQ5N+oNlEZ3X3sFO/p4SYxTdujg== X-Received: by 2002:adf:d0cd:0:b0:22b:1ade:7980 with SMTP id z13-20020adfd0cd000000b0022b1ade7980mr20970919wrh.265.1664398882979; Wed, 28 Sep 2022 14:01:22 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:22 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 04/29] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Date: Wed, 28 Sep 2022 23:00:34 +0200 Message-Id: <20220928210059.891387-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The governors are using the ops->get_trip_* functions, Replace these calls with thermal_zone_get_trip(). Signed-off-by: Daniel Lezcano Reviewed-by: Zhang Rui Reviewed-by: Lukasz Luba # IPA Acked-by: Rafael J. Wysocki --- drivers/thermal/gov_bang_bang.c | 39 +++++++++++--------- drivers/thermal/gov_fair_share.c | 18 ++++------ drivers/thermal/gov_power_allocator.c | 51 ++++++++++++--------------- drivers/thermal/gov_step_wise.c | 22 ++++++------ 4 files changed, 62 insertions(+), 68 deletions(-) diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c index a08bbe33be96..af7737ec90c3 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -13,26 +13,28 @@ #include "thermal_core.h" -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) +static int thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id) { - int trip_temp, trip_hyst; + struct thermal_trip trip; struct thermal_instance *instance; + int ret; - tz->ops->get_trip_temp(tz, trip, &trip_temp); - - if (!tz->ops->get_trip_hyst) { - pr_warn_once("Undefined get_trip_hyst for thermal zone %s - " - "running with default hysteresis zero\n", tz->type); - trip_hyst = 0; - } else - tz->ops->get_trip_hyst(tz, trip, &trip_hyst); + ret = __thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) { + pr_warn_once("Failed to retrieve trip point %d\n", trip_id); + return ret; + } + + if (!trip.hysteresis) + dev_info_once(&tz->device, + "Zero hysteresis value for thermal zone %s\n", tz->type); dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n", - trip, trip_temp, tz->temperature, - trip_hyst); + trip_id, trip.temperature, tz->temperature, + trip.hysteresis); list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip != trip) + if (instance->trip != trip_id) continue; /* in case fan is in initial state, switch the fan off */ @@ -50,10 +52,10 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) * enable fan when temperature exceeds trip_temp and disable * the fan in case it falls below trip_temp minus hysteresis */ - if (instance->target == 0 && tz->temperature >= trip_temp) + if (instance->target == 0 && tz->temperature >= trip.temperature) instance->target = 1; else if (instance->target == 1 && - tz->temperature <= trip_temp - trip_hyst) + tz->temperature <= trip.temperature - trip.hysteresis) instance->target = 0; dev_dbg(&instance->cdev->device, "target=%d\n", @@ -63,6 +65,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) instance->cdev->updated = false; /* cdev needs update */ mutex_unlock(&instance->cdev->lock); } + + return 0; } /** @@ -95,10 +99,13 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) static int bang_bang_control(struct thermal_zone_device *tz, int trip) { struct thermal_instance *instance; + int ret; lockdep_assert_held(&tz->lock); - thermal_zone_trip_update(tz, trip); + ret = thermal_zone_trip_update(tz, trip); + if (ret) + return ret; list_for_each_entry(instance, &tz->thermal_instances, tz_node) thermal_cdev_update(instance->cdev); diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c index a4ee4661e9cc..bca60cd21655 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -21,16 +21,12 @@ */ static int get_trip_level(struct thermal_zone_device *tz) { - int count = 0; - int trip_temp; - enum thermal_trip_type trip_type; - - if (tz->num_trips == 0 || !tz->ops->get_trip_temp) - return 0; + struct thermal_trip trip; + int count; for (count = 0; count < tz->num_trips; count++) { - tz->ops->get_trip_temp(tz, count, &trip_temp); - if (tz->temperature < trip_temp) + __thermal_zone_get_trip(tz, count, &trip); + if (tz->temperature < trip.temperature) break; } @@ -38,10 +34,8 @@ static int get_trip_level(struct thermal_zone_device *tz) * count > 0 only if temperature is greater than first trip * point, in which case, trip_point = count - 1 */ - if (count > 0) { - tz->ops->get_trip_type(tz, count - 1, &trip_type); - trace_thermal_zone_trip(tz, count - 1, trip_type); - } + if (count > 0) + trace_thermal_zone_trip(tz, count - 1, trip.type); return count; } diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 2d1aeaba38a8..eafb28839281 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -125,16 +125,15 @@ static void estimate_pid_constants(struct thermal_zone_device *tz, u32 sustainable_power, int trip_switch_on, int control_temp) { + struct thermal_trip trip; + u32 temperature_threshold = control_temp; int ret; - int switch_on_temp; - u32 temperature_threshold; s32 k_i; - ret = tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); - if (ret) - switch_on_temp = 0; + ret = __thermal_zone_get_trip(tz, trip_switch_on, &trip); + if (!ret) + temperature_threshold -= trip.temperature; - temperature_threshold = control_temp - switch_on_temp; /* * estimate_pid_constants() tries to find appropriate default * values for thermal zones that don't provide them. If a @@ -520,10 +519,10 @@ static void get_governor_trips(struct thermal_zone_device *tz, last_passive = INVALID_TRIP; for (i = 0; i < tz->num_trips; i++) { - enum thermal_trip_type type; + struct thermal_trip trip; int ret; - ret = tz->ops->get_trip_type(tz, i, &type); + ret = __thermal_zone_get_trip(tz, i, &trip); if (ret) { dev_warn(&tz->device, "Failed to get trip point %d type: %d\n", i, @@ -531,14 +530,14 @@ static void get_governor_trips(struct thermal_zone_device *tz, continue; } - if (type == THERMAL_TRIP_PASSIVE) { + if (trip.type == THERMAL_TRIP_PASSIVE) { if (!found_first_passive) { params->trip_switch_on = i; found_first_passive = true; } else { last_passive = i; } - } else if (type == THERMAL_TRIP_ACTIVE) { + } else if (trip.type == THERMAL_TRIP_ACTIVE) { last_active = i; } else { break; @@ -633,7 +632,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz) { int ret; struct power_allocator_params *params; - int control_temp; + struct thermal_trip trip; ret = check_power_actors(tz); if (ret) @@ -659,13 +658,12 @@ static int power_allocator_bind(struct thermal_zone_device *tz) get_governor_trips(tz, params); if (tz->num_trips > 0) { - ret = tz->ops->get_trip_temp(tz, - params->trip_max_desired_temperature, - &control_temp); + ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, + &trip); if (!ret) estimate_pid_constants(tz, tz->tzp->sustainable_power, params->trip_switch_on, - control_temp); + trip.temperature); } reset_pid_controller(params); @@ -695,11 +693,11 @@ static void power_allocator_unbind(struct thermal_zone_device *tz) tz->governor_data = NULL; } -static int power_allocator_throttle(struct thermal_zone_device *tz, int trip) +static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_id) { - int ret; - int switch_on_temp, control_temp; struct power_allocator_params *params = tz->governor_data; + struct thermal_trip trip; + int ret; bool update; lockdep_assert_held(&tz->lock); @@ -708,13 +706,12 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip) * We get called for every trip point but we only need to do * our calculations once */ - if (trip != params->trip_max_desired_temperature) + if (trip_id != params->trip_max_desired_temperature) return 0; - ret = tz->ops->get_trip_temp(tz, params->trip_switch_on, - &switch_on_temp); - if (!ret && (tz->temperature < switch_on_temp)) { - update = (tz->last_temperature >= switch_on_temp); + ret = __thermal_zone_get_trip(tz, params->trip_switch_on, &trip); + if (!ret && (tz->temperature < trip.temperature)) { + update = (tz->last_temperature >= trip.temperature); tz->passive = 0; reset_pid_controller(params); allow_maximum_power(tz, update); @@ -723,16 +720,14 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip) tz->passive = 1; - ret = tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature, - &control_temp); + ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, &trip); if (ret) { - dev_warn(&tz->device, - "Failed to get the maximum desired temperature: %d\n", + dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d\n", ret); return ret; } - return allocate_power(tz, control_temp); + return allocate_power(tz, trip.temperature); } static struct thermal_governor thermal_gov_power_allocator = { diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index cdd3354bc27f..31235e169c5a 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -95,30 +95,28 @@ static void update_passive_instance(struct thermal_zone_device *tz, tz->passive += value; } -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id) { - int trip_temp; - enum thermal_trip_type trip_type; enum thermal_trend trend; struct thermal_instance *instance; + struct thermal_trip trip; bool throttle = false; int old_target; - tz->ops->get_trip_temp(tz, trip, &trip_temp); - tz->ops->get_trip_type(tz, trip, &trip_type); + __thermal_zone_get_trip(tz, trip_id, &trip); - trend = get_tz_trend(tz, trip); + trend = get_tz_trend(tz, trip_id); - if (tz->temperature >= trip_temp) { + if (tz->temperature >= trip.temperature) { throttle = true; - trace_thermal_zone_trip(tz, trip, trip_type); + trace_thermal_zone_trip(tz, trip_id, trip.type); } dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", - trip, trip_type, trip_temp, trend, throttle); + trip_id, trip.type, trip.temperature, trend, throttle); list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip != trip) + if (instance->trip != trip_id) continue; old_target = instance->target; @@ -132,11 +130,11 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) /* Activate a passive thermal instance */ if (old_target == THERMAL_NO_TARGET && instance->target != THERMAL_NO_TARGET) - update_passive_instance(tz, trip_type, 1); + update_passive_instance(tz, trip.type, 1); /* Deactivate a passive thermal instance */ else if (old_target != THERMAL_NO_TARGET && instance->target == THERMAL_NO_TARGET) - update_passive_instance(tz, trip_type, -1); + update_passive_instance(tz, trip.type, -1); instance->initialized = true; mutex_lock(&instance->cdev->lock); From patchwork Wed Sep 28 21:00:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610146 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 1A16FC6FA82 for ; Wed, 28 Sep 2022 21:03:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234402AbiI1VC7 (ORCPT ); Wed, 28 Sep 2022 17:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234023AbiI1VCP (ORCPT ); Wed, 28 Sep 2022 17:02:15 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C082D796BD for ; Wed, 28 Sep 2022 14:01:31 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id c11so21550827wrp.11 for ; Wed, 28 Sep 2022 14:01:31 -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=crQJQSZoczKrIegK5IuceoLZkv1wMF3jvS/SHAicAiM=; b=ZPNedZc0ya6AjAvsHsa24IMC9mx5sUCW8whw6/SzxRcVVlJIXvNLq5+J6mnU0gT3G8 Y/njQQDU8hluZuBa/nL0kpU4sPL0tKfMOtZqer5ymTJqE1ZBMau/fCovrh/t97nMmK/x UxJeMDidPoRoJ3i860Zc4U18EFZTmj4c1BYNTiHt0r6hV47M7SRsKJsd4iNqsrIrOOyT F/SVIdAFRrGMuO9WUlRfMl6SfN0oKOvCZP5z47DStcbzm/sy9GVyopdZRwQPyXNrlpww /rfQeXKbDjT25JfjZwG5VFTy7aHEiw4/+68JBPhFOrWwiFXy351eugZI8FZYyCtQxMXh E8YQ== 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=crQJQSZoczKrIegK5IuceoLZkv1wMF3jvS/SHAicAiM=; b=o0Sff75+Yas9ER+Q5wglc/PqjEHVPgIuP1iOlC4adGR5QMsZ2M67OOmjCOu9rkErWS 48GcOLqTus+uxfSPbx4yJ1J3KkG1CBkJY25Tib5sn3qIS4mkXg6YAe+4aBrCY7StDSVV XZ+yC6WOs6QeDrbDDsIcdgN7aaYxczZUpT3S6m0WrY1BVtu2hUzj4apfvj0Kfu4qEKEz 5ffn4g4l2Jz98hU1lTxA65SaIXfLSM5qfy45fXRzMRLyRQgQSRLReZvFIVOA1k3/pGgn 7LJlZp/wRyoSq8qeuzYP6Pj7psSkyiyVH10IoM/XZeFo10/jRZMHfcb6iT6Sic+TliYe +Miw== X-Gm-Message-State: ACrzQf3pCi8QAuqJ1cNehHI2ZHmTc84r/RG584orhVZcNgg0hwAI0g/L wobKHsvj+1JQd6JEAtRD4w3HUQ== X-Google-Smtp-Source: AMsMyM7/6/PPW85yEQ9rN+vMDpDnawA8N8Bq6mG6Irc0z9hgIi0NIHlwwDQOg+bQ9Tc8mrLBjhWvvg== X-Received: by 2002:a05:6000:1241:b0:226:d999:a2df with SMTP id j1-20020a056000124100b00226d999a2dfmr21529402wrx.19.1664398889821; Wed, 28 Sep 2022 14:01:29 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:29 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 06/29] thermal/of: Remove unused functions Date: Wed, 28 Sep 2022 23:00:36 +0200 Message-Id: <20220928210059.891387-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Remove the dead code: of_thermal_get_trip_points() Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 7 ------- drivers/thermal/thermal_of.c | 17 ----------------- 2 files changed, 24 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 879e91a48435..c5990a3fcf8a 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -141,8 +141,6 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, #ifdef CONFIG_THERMAL_OF int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); -const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *); #else static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) { @@ -153,11 +151,6 @@ static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, { return false; } -static inline const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *tz) -{ - return NULL; -} #endif int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 5cce83639085..2f533fc94917 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -54,23 +54,6 @@ bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) } EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); -/** - * of_thermal_get_trip_points - function to get access to a globally exported - * trip points - * - * @tz: pointer to a thermal zone - * - * This function provides a pointer to trip points table - * - * Return: pointer to trip points table, NULL otherwise - */ -const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *tz) -{ - return tz->trips; -} -EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, int hyst) { From patchwork Wed Sep 28 21:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610145 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 20B4BC04A95 for ; Wed, 28 Sep 2022 21:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234449AbiI1VDT (ORCPT ); Wed, 28 Sep 2022 17:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233610AbiI1VCT (ORCPT ); Wed, 28 Sep 2022 17:02:19 -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 65B4F7B784 for ; Wed, 28 Sep 2022 14:01:37 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id o20-20020a05600c4fd400b003b4a516c479so1663132wmq.1 for ; Wed, 28 Sep 2022 14:01:37 -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=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=iO99VIKHWYZYBlxXZM1jzIJMfEfORGWVLH/D9fAJIa9XTCA2APEE3foUE6yxpgPUMt hUpD1xxGo8T/jRXApM5vX//kT08IM4VQK0Rj+4SUUXjOt6E7OCtTg2EvzT+OloATSxrb AMVtbswzimKkVX38J7zrh1gu+g4IPXwNyZwjVeZjMzoUMGKEo2MicrPwzZ+Wuj+13MU1 MZ2tZ8Pd5m09Be6fJvU6Cg7qUUv8mMOrAQpvpOfUX8gJP6r+qwIUXNn19ciYVTOsC2G2 0Snr/2jw0AThqvViyVXk3bdqMfCbxTPl6YWnsaBFJF75BDjDsPK9Z4eb0WqCbAcLPkey eHUA== 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=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=ZoUz6MgJKSg+ccXoyqlTsWSoRyjPvK3MKxrKBj7NgKAirtprhBwGNdAlOEiMNvCiVx eM346ce8BQDr03gFFPGh+jQmyeDfSfF5p4wrI4MtUF8c34fDesJeVOSFU8IHgEghPgMj 3ESE7ZtkztJlbH+PrzNmWhpl+syH8z/9UE3v7rflFKX7lvoHlBqPc2orhKyFTcU9IITL QkT43mn2JWCvjgh2L7p3JemEGCT/ow7asSBa0HoZvAY+o+T4KRfzEzumkoJtH0Pupp3a srykpPcsJPGFNgjhfl11ihq3QU185EcYoxevdStKMCRfFUjyxMOYWzIVs1se5dB2McAr stuw== X-Gm-Message-State: ACrzQf0fh0pC3Df8T+GFWn6sTQ8Th3OoJwZQPysmLHahGOygul0NT42f XnKLabUF1fOz5e6hK6PJZjKm5w== X-Google-Smtp-Source: AMsMyM4ITZqbEf7px76LAp3GLIX7OAhNKg3gPyo5XOnk+Yq0pjW5AK0BL6hOkr6xDm7u5omilI2pWg== X-Received: by 2002:a05:600c:5486:b0:3b4:7e47:e19 with SMTP id iv6-20020a05600c548600b003b47e470e19mr3880wmb.12.1664398896261; Wed, 28 Sep 2022 14:01:36 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:35 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 08/29] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Wed, 28 Sep 2022 23:00:38 +0200 Message-Id: <20220928210059.891387-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 0e33d32a9d2e..91e6860b5ec4 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,6 +260,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tzd = data->tzd; + int num_trips = thermal_zone_get_num_trips(tzd); unsigned int status; int ret = 0, temp; @@ -271,12 +272,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev) goto out; } - if (of_thermal_get_ntrips(tzd) > data->ntrip) { + if (num_trips > data->ntrip) { dev_info(&pdev->dev, "More trip points than supported by this TMU.\n"); dev_info(&pdev->dev, "%d trip points should be configured in polling mode.\n", - (of_thermal_get_ntrips(tzd) - data->ntrip)); + num_trips - data->ntrip); } mutex_lock(&data->lock); @@ -289,7 +290,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ret = -EBUSY; } else { int i, ntrips = - min_t(int, of_thermal_get_ntrips(tzd), data->ntrip); + min_t(int, num_trips, data->ntrip); data->tmu_initialize(pdev); From patchwork Wed Sep 28 21:00:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610144 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 2B5F0C04A95 for ; Wed, 28 Sep 2022 21:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbiI1VDp (ORCPT ); Wed, 28 Sep 2022 17:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233818AbiI1VC3 (ORCPT ); Wed, 28 Sep 2022 17:02:29 -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 2AF2BA2AB1 for ; Wed, 28 Sep 2022 14:01:44 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id x18so21606164wrm.7 for ; Wed, 28 Sep 2022 14:01:43 -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=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=cczLCJu9MTJRQTpXDuR+G9MWjzPOx4NISZUE1EELl15S+ZowmtG+jvuGSgYVu2WPhy GARCspgkPOxBtZ0yLZNiM6gD58TZ3Swuknx87oeDIWhgHp8EkKHTaqIm6qp7EnsAwNYu V5F34Hs4IJwg7ov/EmiQnB4rzvnSje9dH2YTyE+KcKDY+e9Vbu654+BRZYHBNzNhjWPo reUX9dTlSvXl6NxC54g3pcm2qJE6YsZAK4FT+EjCKwEoNPnBirtRAwGEuWQioJXRH4tj 2PXnptDEOqua3yIuzu8bqex9MMcaqivQQ8oPvHW1XTm2gOoOgiWnH401tgPrMneq8mbi 5hZw== 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=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=BxcFXx5U0FAhyZpr0SmGgRlQXdFa1x5TdpHQGGyCJ5Wc6gnHCgF0vbFTi/DF3VIKVW PqZ/TbNFhJIOpYaDIYMhPUVvYAnds2cf2/3BE2/vhfEEz+XhdcxlMPe22HPnhYwZCBRL UGm38ujILH/utDq4nniaDifcG0XckHCs5Gt4frM4gAFKFVBXHLVvAmcvOXeVypQNAd2U w6JAYCt4P2wt52ymrabNQxUTHrzz/SLn4P8JgPUw7khKj9Vanps3w4y1tojCuY/7KBXP P3Gqn3U+6HmCAu6/NYMgkCx3wbPzhP327WGzW70+zEo7xdSd0GiqoPcAiiBvmJf19Msf w87g== X-Gm-Message-State: ACrzQf22R+alcn6wXQjYu66fqgqAktVJlXA1fcDKBSlSab1SS5y2pooG z8a42s2f9m/GBZcIygCu3u4MlQ== X-Google-Smtp-Source: AMsMyM7aIhPLPr02I5P+/Nf1yWlWYFDWmhmwBEDPW4A3+jbqfnnB16/IRIiqB6Q17nE5OcGzytz4ow== X-Received: by 2002:adf:f804:0:b0:228:62fd:6e9a with SMTP id s4-20020adff804000000b0022862fd6e9amr22603162wrp.697.1664398903564; Wed, 28 Sep 2022 14:01:43 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:43 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 10/29] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:40 +0200 Message-Id: <20220928210059.891387-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Replace a single call to thermal_zone_get_trip() to get a trip point instead of calling the different ops->get_trip* Signed-off-by: Daniel Lezcano --- drivers/thermal/tegra/soctherm.c | 33 +++++++++++-------------- drivers/thermal/tegra/tegra30-tsensor.c | 17 ++++++------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 1efe470f31e9..96b541458ccd 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -582,23 +582,23 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id) return temp; } -static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp) +static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) { struct tegra_thermctl_zone *zone = tz->devdata; struct tegra_soctherm *ts = zone->ts; + struct thermal_trip trip; const struct tegra_tsensor_group *sg = zone->sg; struct device *dev = zone->dev; - enum thermal_trip_type type; int ret; if (!tz) return -EINVAL; - ret = tz->ops->get_trip_type(tz, trip, &type); + ret = thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; - if (type == THERMAL_TRIP_CRITICAL) { + if (trip.type == THERMAL_TRIP_CRITICAL) { /* * If thermtrips property is set in DT, * doesn't need to program critical type trip to HW, @@ -609,7 +609,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip else return 0; - } else if (type == THERMAL_TRIP_HOT) { + } else if (trip.type == THERMAL_TRIP_HOT) { int i; for (i = 0; i < THROTTLE_SIZE; i++) { @@ -620,7 +620,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip continue; cdev = ts->throt_cfgs[i].cdev; - if (get_thermal_instance(tz, cdev, trip)) + if (get_thermal_instance(tz, cdev, trip_id)) stc = find_throttle_cfg_by_name(ts, cdev->type); else continue; @@ -687,25 +687,20 @@ static const struct thermal_zone_device_ops tegra_of_thermal_ops = { .set_trips = tegra_thermctl_set_trips, }; -static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp) +static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int *temp) { - int ntrips, i, ret; - enum thermal_trip_type type; + int i, ret; + struct thermal_trip trip; - ntrips = of_thermal_get_ntrips(tz); - if (ntrips <= 0) - return -EINVAL; + for (i = 0; i < thermal_zone_get_num_trips(tz); i++) { - for (i = 0; i < ntrips; i++) { - ret = tz->ops->get_trip_type(tz, i, &type); + ret = thermal_zone_get_trip(tz, i, &trip); if (ret) return -EINVAL; - if (type == THERMAL_TRIP_HOT) { - ret = tz->ops->get_trip_temp(tz, i, temp); - if (!ret) - *trip = i; - return ret; + if (trip.type == THERMAL_TRIP_HOT) { + *trip_id = i; + return 0; } } diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegra/tegra30-tsensor.c index c34501287e96..cbaad2245f1d 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -316,18 +316,17 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd, *hot_trip = 85000; *crit_trip = 90000; - for (i = 0; i < tzd->num_trips; i++) { - enum thermal_trip_type type; - int trip_temp; + for (i = 0; i < thermal_zone_get_num_trips(tzd); i++) { - tzd->ops->get_trip_temp(tzd, i, &trip_temp); - tzd->ops->get_trip_type(tzd, i, &type); + struct thermal_trip trip; - if (type == THERMAL_TRIP_HOT) - *hot_trip = trip_temp; + thermal_zone_get_trip(tzd, i, &trip); + + if (trip.type == THERMAL_TRIP_HOT) + *hot_trip = trip.temperature; - if (type == THERMAL_TRIP_CRITICAL) - *crit_trip = trip_temp; + if (trip.type == THERMAL_TRIP_CRITICAL) + *crit_trip = trip.temperature; } /* clamp hardware trips to the calibration limits */ From patchwork Wed Sep 28 21:00:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610143 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 A552FC6FA86 for ; Wed, 28 Sep 2022 21:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234550AbiI1VET (ORCPT ); Wed, 28 Sep 2022 17:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbiI1VDA (ORCPT ); Wed, 28 Sep 2022 17:03:00 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB9ACAA3F0 for ; Wed, 28 Sep 2022 14:01:51 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id u16-20020a05600c211000b003b5152ebf09so2050911wml.5 for ; Wed, 28 Sep 2022 14:01:51 -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=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=QZVTEavlb0VBg8L+KAfL+BOqtjYbh1+jB9Y5bUh35EsJFclMDgQB/cnzLIkhjKULq6 iMvXMTQZj/AJiXJc9g8rM87WL8pA7/y2kjI9UsMIqx+oS9Mwna/zWjCQGQK70zvKRwz8 Rh2PHR/1eLPmSGiCdH7pvUzFB9kzs7AWnI20etsSr4gDPY2rNFuN6IgRnQghaVI914v9 2Ev8DpH5JY3GC9Zw2AVeyh9gfiQW4TfCyrdYELjAJy2A9KB0/Ty6Y08EOGqRtEReR+vA TCVpksKLmd7bRuBfrLQI0ehzJq7D5xDcEQBwFfvhSj9PN7Jx2bsU2RE+g6N6elKDRSX+ 3Mrw== 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=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=If4SxssnhmbxkkkROkW5CcG8INqS+MLGmxaTyj1FO/IV6jvPqxiDrb07ieYOxMU4Lo AOZpZF7MBvZCiab+mdQOWwaWfCp0Cf5vZfWPCowD7uyLDQtK7YGv+aTGvEPGuSB+o8VB d0ael9p/sh2bnSkO11MTtmUHado/Jg4Fu26L4UV0BnNUP74E9DwPMgaRxJgf1aZ85oUb 1HaNn5oXbWuIV1N94BvsZEbNauEYxv9wpjuBlrZVsoXEsmh7H/7fCbSDiBYrHj2ZDXm4 hqWyD0tIHzlzf0kAPvnO+CurcMy5+pGyRO5Ce8pGuHMQ8qpMKfGuiBcNdKA/FCWh+pUw bcXQ== X-Gm-Message-State: ACrzQf2fJGvqhHTuVLPDHy7b7rl/N3ggU3YVHvMyxIqHIrTGfLHgBBTn HyDUulmmxnHr7EMAxoTVg41uog== X-Google-Smtp-Source: AMsMyM7QvHqUQ1S+SgNjtj7GQM2yaKFsz7JbtjgJAJADe6BEH5W/12xq0l6cSINbqxL7sPoGQsMdsg== X-Received: by 2002:a05:600c:4f56:b0:3b4:b6b0:42d4 with SMTP id m22-20020a05600c4f5600b003b4b6b042d4mr8234359wmq.143.1664398909983; Wed, 28 Sep 2022 14:01:49 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:49 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 12/29] thermal/drivers/hisi: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:42 +0200 Message-Id: <20220928210059.891387-13-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 --- drivers/thermal/hisi_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index d6974db7aaf7..45226cab466e 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -482,7 +482,7 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, struct hisi_thermal_sensor *sensor) { int ret, i; - const struct thermal_trip *trip; + struct thermal_trip trip; sensor->tzd = devm_thermal_of_zone_register(&pdev->dev, sensor->id, sensor, @@ -495,11 +495,12 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, return ret; } - trip = of_thermal_get_trip_points(sensor->tzd); + for (i = 0; i < thermal_zone_get_num_trips(sensor->tzd); i++) { - for (i = 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { - if (trip[i].type == THERMAL_TRIP_PASSIVE) { - sensor->thres_temp = trip[i].temperature; + thermal_zone_get_trip(sensor->tzd, i, &trip); + + if (trip.type == THERMAL_TRIP_PASSIVE) { + sensor->thres_temp = trip.temperature; break; } } From patchwork Wed Sep 28 21:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610142 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 D9A20C6FA92 for ; Wed, 28 Sep 2022 21:04:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234495AbiI1VEp (ORCPT ); Wed, 28 Sep 2022 17:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234509AbiI1VDp (ORCPT ); Wed, 28 Sep 2022 17:03:45 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 897F5DB958 for ; Wed, 28 Sep 2022 14:01:58 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id r7so21631950wrm.2 for ; Wed, 28 Sep 2022 14:01:57 -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=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=tNlS7wZDICNPcYcfX9y/qrmvuzI+t2UKOHXKgSLuebRqObT3aj4tT5S6IiGu5MYX35 opoh7Qoh6SkXfeDmrJeU6HEfNsw59JgDhdFFeu4PwwrLxCHyyY4lL5ofzvZzRzKjsITW O+wGJSYJ+w719A2IKjTNORWIBWSOAjLH6I/EbKRXKPgxp/qque7j3qcBR3mf2gl0U1UR AfM5PYMbMvEtMHZN9GxSeaKcGytkkcKZh6Yc9YFFUUqa0t7AfdklkSi4voeSZDtwNcvA gxGpg1k1MXlUW2xJ5ArBExWqRRZgtg5QdQQib/EZgIAoeVkTVRTsHLsZ39Iocw9pueVL 6CDw== 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=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=miXhZNij2wpkmUBqSepFy2dpgk2FacZEihyr2891kPqtiOqOix+wuEL6EF+QXc6opp a5gc5gobugUQGEvUN8LJHgt5Ec6zbr2mJVxArbRwggIJWnULD9DH/JxXLStYAfXtFZDQ PsmBdcxZGJKRP6H0O3P5Q0agQPqNO9gpusN1uQ0Oxj6U4AH7Dukq5yU8WfktqXK56vpb mUWQFrogHixzsI9fN1mV+/+yMsV+aIBtQx+kgbkyoSfkEeONZ84/0e5nenDzUbdf6UB4 Ro6BsHj8SQlDu+546LTvfL9fBLwlKqRszl5tI3eokUmL5MyEC2JDhdwKOXu1SHSDTGe+ O8SQ== X-Gm-Message-State: ACrzQf1n0tkiSOripeGikqoVi3ajpnWVN3Dz1MtywhZYiiNTpghedR7m 2ZMC2RGNkYMImI1J5AQduhCrew== X-Google-Smtp-Source: AMsMyM4s3o0aSeNSGBLlu3h+81Marh+BgkSkEozT+ZlQ+nMIErKNwCvlzNZ8Td+vcS2kyteBMRogcQ== X-Received: by 2002:a05:6000:1204:b0:22b:3359:4112 with SMTP id e4-20020a056000120400b0022b33594112mr21948792wrx.700.1664398916163; Wed, 28 Sep 2022 14:01:56 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:55 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 14/29] thermal/drivers/armada: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:44 +0200 Message-Id: <20220928210059.891387-15-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 --- drivers/thermal/armada_thermal.c | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index 52d63b3997fe..9444e5a22ca0 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -785,33 +785,34 @@ static int armada_configure_overheat_int(struct armada_thermal_priv *priv, int sensor_id) { /* Retrieve the critical trip point to enable the overheat interrupt */ - const struct thermal_trip *trips = of_thermal_get_trip_points(tz); + struct thermal_trip trip; int ret; int i; - if (!trips) - return -EINVAL; - - for (i = 0; i < of_thermal_get_ntrips(tz); i++) - if (trips[i].type == THERMAL_TRIP_CRITICAL) - break; + for (i = 0; i < thermal_zone_get_num_trips(tz); i++) { - if (i == of_thermal_get_ntrips(tz)) - return -EINVAL; + ret = thermal_zone_get_trip(tz, i, &trip); + if (ret) + return ret; + + if (trip.type != THERMAL_TRIP_CRITICAL) + continue; - ret = armada_select_channel(priv, sensor_id); - if (ret) - return ret; + ret = armada_select_channel(priv, sensor_id); + if (ret) + return ret; + + armada_set_overheat_thresholds(priv, trip.temperature, + trip.hysteresis); + priv->overheat_sensor = tz; + priv->interrupt_source = sensor_id; - armada_set_overheat_thresholds(priv, - trips[i].temperature, - trips[i].hysteresis); - priv->overheat_sensor = tz; - priv->interrupt_source = sensor_id; + armada_enable_overheat_interrupt(priv); - armada_enable_overheat_interrupt(priv); + return 0; + } - return 0; + return -EINVAL; } static int armada_thermal_probe(struct platform_device *pdev) From patchwork Wed Sep 28 21:00:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610141 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 16E83C32771 for ; Wed, 28 Sep 2022 21:05:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233641AbiI1VF2 (ORCPT ); Wed, 28 Sep 2022 17:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234567AbiI1VEW (ORCPT ); Wed, 28 Sep 2022 17:04:22 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE20DDDA6 for ; Wed, 28 Sep 2022 14:02:04 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id cc5so21618378wrb.6 for ; Wed, 28 Sep 2022 14:02:04 -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=G/YO0fJeKfkSzRqdgqFU3ij4yJaDOnZPHmbsRpXJf/A=; b=SHso3cVk3QtQMcsPDoM7lPq2tpaKy5MkF2SAkytxXbqLl8v5pzT2ebw4HBjehLTvmh ZDkWG48CUmKv+XYQKHEZSOKNimHSX1KV7ZcPj0w087qCfdS2Zvj86MwNnOZ7vZ4zNDGn 56ZjCwef7LGV520iEaGUwq3MfNjnJnKUVBdZUnRLVU5XFS5TPJegbdsQWiRVVBI2lKr2 2zTTfuAv7myPLtGLVlZRM9uCd3oXpGR5r8WKSUQnIda0JIl0h39nvme4kb8PTRAmWD67 WdOd6XrdeJdO+OKBadlWHhqx8WffNLRoBAmLDHJFgFQyIeLd+vDrqy+cBqfLOjQCazqH nhsw== 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=G/YO0fJeKfkSzRqdgqFU3ij4yJaDOnZPHmbsRpXJf/A=; b=KkqRxS1tnWTlZNnnsD2mUBG4XAom1Qv+6ZpD6rS0j+BgTr+4eQJDx3Qw551+UmUoL/ 70qYZIq9nmGe1a+95IlpuGH1F8QH9YNtL0teR37kHqmNS9e4maXKYfa4kycDwHaVZAZJ K2X0DGXXWAwFEiVCye61MkGk5cCYQyVhXVtI2OSaugLK2jT61y1HUpx6qnoWGb+Ehob6 MQfcBDGtwHAbVHO7GIHCXoG3XTU0kuof+PhSEL4EW6sVoDZPpRpyARIA8xUTDF7k5h50 v7K/Y9SUjI+SygSv/JEc5Dx/UCGmeQyoCXbiGeIl5xNW1Kp4o2KnckvHqtTJKSzDKIPN nvXg== X-Gm-Message-State: ACrzQf0n8zFh2JQejKFPVjAyeszyXAb9uzvyRw5KqE2dhNhrIM/a/Edm SAaGNnwXmX6f3mMxRdSBjhPhqw== X-Google-Smtp-Source: AMsMyM6bFmcicVOI9SxuyJWDy7FpVZr8wzikTTGMXTqH39j5FGBXFUMzuCDu3baej/qxwhlgmoztzg== X-Received: by 2002:adf:fb50:0:b0:22a:e4e9:a6b3 with SMTP id c16-20020adffb50000000b0022ae4e9a6b3mr21666572wrs.467.1664398922583; Wed, 28 Sep 2022 14:02:02 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:02 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 16/29] thermal/of: Remove of_thermal_get_ntrips() Date: Wed, 28 Sep 2022 23:00:46 +0200 Message-Id: <20220928210059.891387-17-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The thermal OF code uses the generic trip points to initialize the thermal zone. Consequently thermal_zone_get_num_trips() can be used and the of_thermal_get_ntrips() is no longer needed. Remove it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 5 ----- drivers/thermal/thermal_of.c | 16 ---------------- 2 files changed, 21 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index c5990a3fcf8a..b00fc1913734 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -139,13 +139,8 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, /* device tree support */ #ifdef CONFIG_THERMAL_OF -int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); #else -static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) -{ - return 0; -} static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 2f533fc94917..89afa59c4915 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,22 +19,6 @@ #include "thermal_core.h" -/** - * of_thermal_get_ntrips - function to export number of available trip - * points. - * @tz: pointer to a thermal zone - * - * This function is a globally visible wrapper to get number of trip points - * stored in the local struct __thermal_zone - * - * Return: number of available trip points, -ENODEV when data not available - */ -int of_thermal_get_ntrips(struct thermal_zone_device *tz) -{ - return tz->num_trips; -} -EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); - /** * of_thermal_is_trip_valid - function to check if trip point is valid * From patchwork Wed Sep 28 21:00:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610140 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 3D52AC6FA90 for ; Wed, 28 Sep 2022 21:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234714AbiI1VFw (ORCPT ); Wed, 28 Sep 2022 17:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234293AbiI1VE7 (ORCPT ); Wed, 28 Sep 2022 17:04:59 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E842DDF067 for ; Wed, 28 Sep 2022 14:02:10 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id s14so21694683wro.0 for ; Wed, 28 Sep 2022 14:02:10 -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=KY22MjtoUlIwWIKxWwfuHh0wn9QBG3Vjtz/Dduvf6bU=; b=WyUQmG+dikM/2KB56J+eG4Y/B0GNeeumoWKaKhxJmcGkJp547dIcc914gSP+T7Y5jh WdtE9db/kqIizzIp3NNCL2h/Yp6vsZcaOChwsZD7xcH3HLegIduohrZ3bhRh2DEw3v6i oDdQVM0kklN9XW3aFRMIXsX7LbR+tbJ22tfmj2fpPBte+6PruziVTxqfI5Wz3ARaIKcF bcoHLngWnbprMwjhDgPvqcnPqC1C43xHZ0Z5XPhMnaT8O0FQ6zOJteHtaSlX5QOSrTBf nkPRm0nPWAk6zhdt1LNavzCBHxFKzRgZ9oOAYP6nsCUP/xedkvuJz5mUwA63uONAUnIo EJLw== 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=KY22MjtoUlIwWIKxWwfuHh0wn9QBG3Vjtz/Dduvf6bU=; b=DEn7EchJEy/FYBizlIafghyIEJidlvBPYTblzZWUm4ANTFiZE0p2c/iKwrpYX+UCG2 0QA922qQhCyhirC9IlPQkYhRWXFBDgR4rONO5Eojn0IwP7tiOui4dsxMdFwhp/lE9ABX 5sTkpI47iMKKM+zYaMumSVrK7QL0f0MRLeAPbjlguLBU3NvUeMwiPyuAgVzuvCkrcR7E kix+i8L5hR0J20PfXMRehbTGUJmh2nmGNCmzmlcPx+bq9kgmvZnrUthTw4PlmU0yftS0 He4rp7dU7IwHLCb7UP8Jkyid1FANB81tlUT0AuHeR1gR0KMmdKJScGRtMQt9k0fEIJnl 7gMg== X-Gm-Message-State: ACrzQf0B7i90HboY+wFxjdfDQ+SdBGNoJeZWHvhVGHdb3Z44WkWMPRLb DxSZZbzHQ2CPjCH7wAuRUYlYbw== X-Google-Smtp-Source: AMsMyM4P1lUyKTcMIxqnoNZG7083LyGfwCK5ra6P2JSFm3+Dil1W9PWEHPQlRPPylMW65T2kcBp1qA== X-Received: by 2002:a5d:64c2:0:b0:228:cb2b:f38d with SMTP id f2-20020a5d64c2000000b00228cb2bf38dmr22043755wri.491.1664398928756; Wed, 28 Sep 2022 14:02:08 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:08 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 18/29] thermal/of: Remove of_thermal_set_trip_hyst() Date: Wed, 28 Sep 2022 23:00:48 +0200 Message-Id: <20220928210059.891387-19-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The thermal core is providing the generic thermal_zone_set_trip() function which does exactly what the OF ops function is doing. It is pointless to define our own version, just remove the ops and the thermal_zone_set_trip() will take care of it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 4e54d62720dc..494e9c319541 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,18 +19,6 @@ #include "thermal_core.h" -static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, - int hyst) -{ - if (trip >= tz->num_trips || trip < 0) - return -EDOM; - - /* thermal framework should take care of data->mask & (1 << trip) */ - tz->trips[trip].hysteresis = hyst; - - return 0; -} - static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { @@ -541,7 +529,6 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, goto out_kfree_trips; } - of_ops->set_trip_hyst = of_ops->set_trip_hyst ? : of_thermal_set_trip_hyst; of_ops->get_crit_temp = of_ops->get_crit_temp ? : of_thermal_get_crit_temp; of_ops->bind = thermal_of_bind; of_ops->unbind = thermal_of_unbind; From patchwork Wed Sep 28 21:00:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610139 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 A9623C6FA86 for ; Wed, 28 Sep 2022 21:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234658AbiI1VGQ (ORCPT ); Wed, 28 Sep 2022 17:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234100AbiI1VFM (ORCPT ); Wed, 28 Sep 2022 17:05:12 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C24B78BF1 for ; Wed, 28 Sep 2022 14:02:17 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id e18so9255198wmq.3 for ; Wed, 28 Sep 2022 14:02:16 -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=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=kl/8HYut/BjVRmiajQhWuVah/Mvave2DkDTk4QV/mUZ1d4NlWRZCsC6Xv9fcT3d/KL JUrm02i6Luax2k5pJwH2VhcIZkcBy8IUiskfMWh1xjyAQ6i9wHeXaNJwnV+EzDZHN+Xw o3xsI5ukbSLfyWZIaS1v7ddFSjtKEDnlJBSPA+7JDpI7LMy3+C7dGap4n9ZPVe2vOUgy 3T0IbepxHzZTjp9U4paondALuYszOBiAzGAM6/axVED1PbbjtmBh5YTUzWc3WP7Zwe+t B1sMuQHHSNKyc63WeDK18OmSo67QA7s3hKh12OG2m/gcOVC8l8dS/yr71TqrK9LdF6pR FuWw== 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=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=Gj5QonWZK0+4uJ/GXYLbI6eAE4onlZKrceccX5Dm3QsIkBoFJVDQnC1vVm0bUvwiPh 0A9iQ8miGsXKwg2CvxTrm/PzsQBKf1HC7HVvgKewlZcgUuSjEbwRZWysNtZcKKeddcdT 3jDba4P1YQgnHDzW6ky30NCboIfwe+f2qNaV7wAbqUv7V4tfyl/pOPR8c34tWcHDaxbx ouv6NDkoaQkXIAR3Di/AO4Pu9prxxdnJU/e7r8eb2DI+VCKPSLrV7Nxsi9w/kJDrSnVj vYSYY4NrF7TE+IgAE7zbA16hKAafVNACczqZxa/cpgY5bUc4wA8yCqe4olUl+s8fKP7a IHJA== X-Gm-Message-State: ACrzQf2jjM7X2eAHNmp2UPii2h4u+3rgHORLi6M62jZFxPW7WcMPAbEv qLr4Hjeu8DiBecxGMADIDnHEug== X-Google-Smtp-Source: AMsMyM5K8vkfK6hWdLr2LZ3GtQ4fx5dLCY6ISD3do6qZEgSP8VlZjWNQZzj1xqRQ2EJU8mb8ObOs6w== X-Received: by 2002:a05:600c:5128:b0:3b5:d6:eb8f with SMTP id o40-20020a05600c512800b003b500d6eb8fmr8477661wms.65.1664398935481; Wed, 28 Sep 2022 14:02:15 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:15 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 20/29] thermal/drivers/st: Use generic trip points Date: Wed, 28 Sep 2022 23:00:50 +0200 Message-Id: <20220928210059.891387-21-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 to the generic trip points Signed-off-by: Daniel Lezcano --- drivers/thermal/st/st_thermal.c | 47 +++++---------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c index 1276b95604fe..c0d45cdd1c2f 100644 --- a/drivers/thermal/st/st_thermal.c +++ b/drivers/thermal/st/st_thermal.c @@ -134,48 +134,12 @@ static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature) return 0; } -static int st_thermal_get_trip_type(struct thermal_zone_device *th, - int trip, enum thermal_trip_type *type) -{ - struct st_thermal_sensor *sensor = th->devdata; - struct device *dev = sensor->dev; - - switch (trip) { - case 0: - *type = THERMAL_TRIP_CRITICAL; - break; - default: - dev_err(dev, "invalid trip point\n"); - return -EINVAL; - } - - return 0; -} - -static int st_thermal_get_trip_temp(struct thermal_zone_device *th, - int trip, int *temp) -{ - struct st_thermal_sensor *sensor = th->devdata; - struct device *dev = sensor->dev; - - switch (trip) { - case 0: - *temp = mcelsius(sensor->cdata->crit_temp); - break; - default: - dev_err(dev, "Invalid trip point\n"); - return -EINVAL; - } - - return 0; -} - static struct thermal_zone_device_ops st_tz_ops = { .get_temp = st_thermal_get_temp, - .get_trip_type = st_thermal_get_trip_type, - .get_trip_temp = st_thermal_get_trip_temp, }; +static struct thermal_trip trip; + int st_thermal_register(struct platform_device *pdev, const struct of_device_id *st_thermal_of_match) { @@ -238,9 +202,12 @@ int st_thermal_register(struct platform_device *pdev, polling_delay = sensor->ops->register_enable_irq ? 0 : 1000; + trip.temperature = sensor->cdata->crit_temp; + trip.type = THERMAL_TRIP_CRITICAL; + sensor->thermal_dev = - thermal_zone_device_register(dev_name(dev), 1, 0, sensor, - &st_tz_ops, NULL, 0, polling_delay); + thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, 0, sensor, + &st_tz_ops, NULL, 0, polling_delay); if (IS_ERR(sensor->thermal_dev)) { dev_err(dev, "failed to register thermal zone device\n"); ret = PTR_ERR(sensor->thermal_dev); From patchwork Wed Sep 28 21:00:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610138 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 C42FDC04A95 for ; Wed, 28 Sep 2022 21:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234318AbiI1VGm (ORCPT ); Wed, 28 Sep 2022 17:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234150AbiI1VFr (ORCPT ); Wed, 28 Sep 2022 17:05:47 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3601E11C9 for ; Wed, 28 Sep 2022 14:02:23 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id i203-20020a1c3bd4000000b003b3df9a5ecbso2063715wma.1 for ; Wed, 28 Sep 2022 14:02:23 -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=9Ogs5/BdK1Y/lDDyEmjA88qgr/D6i26XcRmp1g6reCg=; b=sp7djfhEgyu/JAfxAWEO2Bll2o1465QHYaS491Yivzn8m1nnT0QMkfOS8YXY3MA65r N77IhZf6+lUkYYoU6iv7y5fTvA1zF8bSIY7asjOCG8TN5EEelBP7ckHhcoOUYSNAQOhz WHAWgeZbIXEPhs5K8TBT9IrtD7LvUwQLNGD2SsaGWxZR+68NoY014d26cfw4dI/g7UlN 2+udMGfsDvJkvRFANg0ChhKMddvLK2dwCIjbKN0j7T2NUyXSwh5S++vfhO2kt+nUZR/v BIygzwUDhhwnm23r/CQoNA3DkXkzTt8F0YsbOdLJvOqSQ+bp2A2qv4DjsMLTyu16pp/f 9amg== 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=9Ogs5/BdK1Y/lDDyEmjA88qgr/D6i26XcRmp1g6reCg=; b=5MZXBRxrTafCslFL+cTxrLaz1xasqdAJwYy6WsYG45qqjoVlCJCwk8couF1B307M3p HeumCYC8LXPGJzns9DujByGNH9ixDxyf+Pxkjd0R4A58JeCzUbiIU5LgzIFHir74QqCY azsdb85BWArtH6K9+nPv95hwTM0lD0KJY1coVK+I3q76D1kCYVXCEBpbnFYqO8TemfuB ez2Y97q4GPm/gDHAipkP5WUMGIkVB06tncnx1v1q8jSB3XELPOHLstjn6Q4/+hxo36xP 2WRz1vkw/kbkRP2TgjaOfazr+qJzBuGIvYomQh624GpIzXlu/2VttFdLzKyVj7HzatDd gNoQ== X-Gm-Message-State: ACrzQf3pt0Fc3vNauayyJzlysV6XMnt4ZDWjvD8XGofKL0lnjwUoOXby iDZbt3kAAI4GoSFvOgMgPiUt/w== X-Google-Smtp-Source: AMsMyM7mzRIjN9webiMgP619XA4XEf4B8RQdVA3RYkqQ9nBPy4L+nN/8PqRh43YqGyIkFtuK180z6g== X-Received: by 2002:a05:600c:3d0e:b0:3b4:9bd1:10be with SMTP id bh14-20020a05600c3d0e00b003b49bd110bemr8163991wmb.101.1664398941515; Wed, 28 Sep 2022 14:02:21 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:21 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= Subject: [PATCH v7 22/29] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:52 +0200 Message-Id: <20220928210059.891387-23-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 | 53 ++++------------------------------ 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 61c2b8855cb8..436f5f9cf729 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -278,52 +278,12 @@ 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 const struct thermal_zone_device_ops rcar_thermal_zone_of_ops = { +static struct thermal_zone_device_ops rcar_thermal_zone_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 } }; /* @@ -529,11 +489,10 @@ static int rcar_thermal_probe(struct platform_device *pdev) if (chip->use_of_thermal) { priv->zone = devm_thermal_of_zone_register( dev, i, priv, - &rcar_thermal_zone_of_ops); + &rcar_thermal_zone_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); From patchwork Wed Sep 28 21:00:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610137 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 D3946C04A95 for ; Wed, 28 Sep 2022 21:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234795AbiI1VHD (ORCPT ); Wed, 28 Sep 2022 17:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234299AbiI1VFz (ORCPT ); Wed, 28 Sep 2022 17:05:55 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E205D76765 for ; Wed, 28 Sep 2022 14:02:28 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id e18so9255414wmq.3 for ; Wed, 28 Sep 2022 14:02:28 -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=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=APVn4dXmHh0VL1bYW0D8A0gkQIgbVZICxuf7zzjzrolMiRMMu1FBMa0zeIuO6UTHvj iDBC7Au7/0lgy2BU7kDN33qQdY3BZq/D1lBjOVruEZfHF1kwqqFOE0TzUYsnubOZhXzX jB4N6CzVmqPpUMFPKiHFYd50lLXSIydlc+XNsES2DLp4Q+rGXylW0dVmcMISb6xbkl5t 3B6Pzk/499Yt++NyBHtCQfjS7fEiA1PTkPi//X8SL84EBgxC56M8yvygFFYWWClf03Cr gKcxVrwZwh9tZ09C8OxprnzQERe9UDWzhIvEvatFyLQfuA0qytpgTyA7KBQYxE0jKnDL lt5Q== 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=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=EFA1sPGw9bNRP1qoD4ZpqWufXEA1xCVgqJ/kfFOILXIet6CE8pVHVTv94aWpPKQ6Qz Or6GnCYGaciDCOqylwDMF6Zo0sejoVOuCPPJEvy4gnbw8qJrmhOfMTjnsSz2UvBx/YNi ImTA8MiJ5ZuPpMa5P5qQKrqP8xFuKdy9EytGC/SQ0KIRrA1CaVUCj/9IrZIar1txndkw jGFNluJYCRvn04pRb3lRbCRbI8J9UDz/p1BHy6fwy1zlsbuinQ5TFFTWRCgw75M8DeoD 9Z+gSnNE5EGoKhNDt/KoavB4uznm1HblhSFVVu1VoDp84anMeV6GiyWQxr24AfwmS8Uf /38w== X-Gm-Message-State: ACrzQf1kYfffj+oSxEBp+dalzYbk34d030cHABRywnc5d44veb0FEcWr j5qW6z4aOojrjxJSIqRqgkzBpw== X-Google-Smtp-Source: AMsMyM5GvcWAzGZmekWSNDrFzuKlkAqRXxLhQshbvN01tdUdSS/K7H2munVSIRk1u/+1XzIGAUHBFA== X-Received: by 2002:a05:600c:34c2:b0:3b4:76f2:9c3b with SMTP id d2-20020a05600c34c200b003b476f29c3bmr8105576wmq.179.1664398948318; Wed, 28 Sep 2022 14:02:28 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:27 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Adam Ward Subject: [PATCH v7 24/29] thermal/drivers/da9062: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:54 +0200 Message-Id: <20220928210059.891387-25-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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: Adam Ward --- drivers/thermal/da9062-thermal.c | 52 +++++--------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c index 180edec34e07..1e163e90d6b6 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -120,44 +120,6 @@ static irqreturn_t da9062_thermal_irq_handler(int irq, void *data) return IRQ_HANDLED; } -static int da9062_thermal_get_trip_type(struct thermal_zone_device *z, - int trip, - enum thermal_trip_type *type) -{ - struct da9062_thermal *thermal = z->devdata; - - switch (trip) { - case 0: - *type = THERMAL_TRIP_HOT; - break; - default: - dev_err(thermal->dev, - "Driver does not support more than 1 trip-wire\n"); - return -EINVAL; - } - - return 0; -} - -static int da9062_thermal_get_trip_temp(struct thermal_zone_device *z, - int trip, - int *temp) -{ - struct da9062_thermal *thermal = z->devdata; - - switch (trip) { - case 0: - *temp = DA9062_MILLI_CELSIUS(125); - break; - default: - dev_err(thermal->dev, - "Driver does not support more than 1 trip-wire\n"); - return -EINVAL; - } - - return 0; -} - static int da9062_thermal_get_temp(struct thermal_zone_device *z, int *temp) { @@ -172,8 +134,10 @@ static int da9062_thermal_get_temp(struct thermal_zone_device *z, static struct thermal_zone_device_ops da9062_thermal_ops = { .get_temp = da9062_thermal_get_temp, - .get_trip_type = da9062_thermal_get_trip_type, - .get_trip_temp = da9062_thermal_get_trip_temp, +}; + +static struct thermal_trip trips[] = { + { .temperature = DA9062_MILLI_CELSIUS(125), .type = THERMAL_TRIP_HOT }, }; static const struct da9062_thermal_config da9062_config = { @@ -228,10 +192,10 @@ static int da9062_thermal_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); mutex_init(&thermal->lock); - thermal->zone = thermal_zone_device_register(thermal->config->name, - 1, 0, thermal, - &da9062_thermal_ops, NULL, pp_tmp, - 0); + thermal->zone = thermal_zone_device_register_with_trips(thermal->config->name, + trips, ARRAY_SIZE(trips), 0, thermal, + &da9062_thermal_ops, NULL, pp_tmp, + 0); if (IS_ERR(thermal->zone)) { dev_err(&pdev->dev, "Cannot register thermal zone device\n"); ret = PTR_ERR(thermal->zone); From patchwork Wed Sep 28 21:00:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610136 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 62718C6FA92 for ; Wed, 28 Sep 2022 21:07:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233601AbiI1VHd (ORCPT ); Wed, 28 Sep 2022 17:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234419AbiI1VGg (ORCPT ); Wed, 28 Sep 2022 17:06:36 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE5DE3EEA for ; Wed, 28 Sep 2022 14:02:36 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso1664925wmq.2 for ; Wed, 28 Sep 2022 14:02:36 -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=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=L5f9iOBIAoRnJCv+lfwuiLoQIvnG9PTyoZ0i3maDkQLFYv8Bp+U9MnoFqWrApl7Rc4 K5VNe7FOeR2sdOxbRk7PK8dgP4tmiS22PsVSscjEwJyneUQUuzLlpQp57Dde1w47sFaY zKlMP6az+fglbXWq8qQUetundKQkanAEqzaEQcLwkIc51NBQ/Cv2bDRf8OtkRLcKZXyA tBy0uzAsRPo+lhjS/tL6VYQIINDf7p944yYfKYMZKJoQjszwAMgMWDNuf290Jw65c0+w yTN3p69/bXqVEQML1OTNamWftsbie8I4L+/xznpCgyIG2QmW+C6eOcOr1K14bgXxGrA5 7YeA== 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=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=NBVUwLyL6xkGhQpcdUEFdchk1glHo87S3JOEQQu1x04QuXuyDME5vj+eMoMw4Q4URf PMbIlotZlGGBl01+5T35ds1yoTTOa0uJmETepfCAQeMzeTwbN7wvVaxvyVNNWILoIChU gja2GvyjNKQlE9b09b4eP2Atj0KGiaH6HwRSjjRDmH8IqFYQXdKheV0dpRSFPfsE+2h0 IFzuVHk8Nou4ocWhX60+BadHyWqPQLVxmhXFuduHaED2Lr9vH2Cy+odRX8sZ7L73qpju d+wRXfiTUjD/mDvYVK/p4+XJKAZS1921lKZHLtU0AhRPZBuquIZvVnimxq0zjHC4KeGP sdfw== X-Gm-Message-State: ACrzQf2BIp51mpf205wpnLQvW+t01KnVZ9U0V/QMdrQ9wW0gP74UUQHl sb03RsKVEHqcdtUkezTeLLyxMA== X-Google-Smtp-Source: AMsMyM6Qxf1jkYL0Su8cpzGizIIyNN/Q4Wbrf4hMWhmPkk9wgk8m1MCTMqwg6TbkXvpppKdSan5b8w== X-Received: by 2002:a05:600c:a185:b0:3b4:ffb5:63b7 with SMTP id id5-20020a05600ca18500b003b4ffb563b7mr8487241wmb.169.1664398955092; Wed, 28 Sep 2022 14:02:35 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:34 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 26/29] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:56 +0200 Message-Id: <20220928210059.891387-27-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 Acked-by: Hans de Goede Acked-by: Peter Kästle --- drivers/platform/x86/acerhdf.c | 73 ++++++++++++---------------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 3463629f8764..a7407aa032ba 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -46,6 +46,8 @@ * measured by the on-die thermal monitor are within 0 <= Tj <= 90. So, * assume 89°C is critical temperature. */ +#define ACERHDF_DEFAULT_TEMP_FANON 60000 +#define ACERHDF_DEFAULT_TEMP_FANOFF 53000 #define ACERHDF_TEMP_CRIT 89000 #define ACERHDF_FAN_OFF 0 #define ACERHDF_FAN_AUTO 1 @@ -70,8 +72,8 @@ static int kernelmode; #endif static unsigned int interval = 10; -static unsigned int fanon = 60000; -static unsigned int fanoff = 53000; +static unsigned int fanon = ACERHDF_DEFAULT_TEMP_FANON; +static unsigned int fanoff = ACERHDF_DEFAULT_TEMP_FANOFF; static unsigned int verbose; static unsigned int list_supported; static unsigned int fanstate = ACERHDF_FAN_AUTO; @@ -137,6 +139,15 @@ struct ctrl_settings { int mcmd_enable; }; +static struct thermal_trip trips[] = { + [0] = { .temperature = ACERHDF_DEFAULT_TEMP_FANON, + .hysteresis = ACERHDF_DEFAULT_TEMP_FANON - ACERHDF_DEFAULT_TEMP_FANOFF, + .type = THERMAL_TRIP_ACTIVE }, + + [1] = { .temperature = ACERHDF_TEMP_CRIT, + .type = THERMAL_TRIP_CRITICAL } +}; + static struct ctrl_settings ctrl_cfg __read_mostly; /* Register addresses and values for different BIOS versions */ @@ -326,6 +337,15 @@ static void acerhdf_check_param(struct thermal_zone_device *thermal) fanon = ACERHDF_MAX_FANON; } + if (fanon < fanoff) { + pr_err("fanoff temperature (%d) is above fanon temperature (%d), clamping to %d\n", + fanoff, fanon, fanon); + fanoff = fanon; + }; + + trips[0].temperature = fanon; + trips[0].hysteresis = fanon - fanoff; + if (kernelmode && prev_interval != interval) { if (interval > ACERHDF_MAX_INTERVAL) { pr_err("interval too high, set to %d\n", @@ -424,43 +444,6 @@ static int acerhdf_change_mode(struct thermal_zone_device *thermal, return 0; } -static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip, - enum thermal_trip_type *type) -{ - if (trip == 0) - *type = THERMAL_TRIP_ACTIVE; - else if (trip == 1) - *type = THERMAL_TRIP_CRITICAL; - else - return -EINVAL; - - return 0; -} - -static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip, - int *temp) -{ - if (trip != 0) - return -EINVAL; - - *temp = fanon - fanoff; - - return 0; -} - -static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip, - int *temp) -{ - if (trip == 0) - *temp = fanon; - else if (trip == 1) - *temp = ACERHDF_TEMP_CRIT; - else - return -EINVAL; - - return 0; -} - static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal, int *temperature) { @@ -474,13 +457,9 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = { .unbind = acerhdf_unbind, .get_temp = acerhdf_get_ec_temp, .change_mode = acerhdf_change_mode, - .get_trip_type = acerhdf_get_trip_type, - .get_trip_hyst = acerhdf_get_trip_hyst, - .get_trip_temp = acerhdf_get_trip_temp, .get_crit_temp = acerhdf_get_crit_temp, }; - /* * cooling device callback functions * get maximal fan cooling state @@ -710,10 +689,10 @@ static int __init acerhdf_register_thermal(void) if (IS_ERR(cl_dev)) return -EINVAL; - thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL, - &acerhdf_dev_ops, - &acerhdf_zone_params, 0, - (kernelmode) ? interval*1000 : 0); + thz_dev = thermal_zone_device_register_with_trips("acerhdf", trips, ARRAY_SIZE(trips), + 0, NULL, &acerhdf_dev_ops, + &acerhdf_zone_params, 0, + (kernelmode) ? interval*1000 : 0); if (IS_ERR(thz_dev)) return -EINVAL; From patchwork Wed Sep 28 21:00:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 610135 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 235BAC6FA90 for ; Wed, 28 Sep 2022 21:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234299AbiI1VHz (ORCPT ); Wed, 28 Sep 2022 17:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233812AbiI1VHE (ORCPT ); Wed, 28 Sep 2022 17:07:04 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B06C6E7C1F for ; Wed, 28 Sep 2022 14:02:45 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so1660858wms.3 for ; Wed, 28 Sep 2022 14:02:45 -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=pY49ET3ZIgq2w00tEafAmFrW/5GVD2UTvB8HzlNbQv0=; b=nTdQfUJjPpojQz2Nbc4J2g9gexOSo5X/EGGJZY0wvvpjydlpHzqm914JlvRZBP/tIe j8RqrOs/sGihKLrrRS8X8ZXrqmqLCnqmjI4FbLtBFRr5HLuVhPENyFOxzypANmoTB3RT l06n0FCMqR8PAIlkF3ghyCSQJtzsAiWYBEpyvVTmZxIKKPuPgBEi6+7HXhxpLptOVLJo wwyrjJmeQ71+Szbc0SjQ7+xbLUOghswFslE3VQvffYO6zdDKDo/UiSU+LKRxJ/gaZZKQ Ao4yAGeO6elgN81P/A/x5lg+i4VIJSgsUp02f7erxu5Yfi5Xnml/ZmrkLk6UCtQqfdPM K7JA== 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=pY49ET3ZIgq2w00tEafAmFrW/5GVD2UTvB8HzlNbQv0=; b=NOJLgzK1/o+lMMY2Igr/NrHnHsVoJc+fGJ2/hLMMPgCDNkckxc/aKh9tOcEeoAwP9f e0L4UXbM1J+3W7+JLCraDgRLzZcDY7NMc9IvOqT2TNUygmwouKAk0oEnY/D2CoE+yB6l b+w9mn3l1kkfSv69+SF8/hh0r1IQDYtmctoAl2T5XKp5Mk7XzhqQBWbnqzgCf4A4PKdx kN4nrXKAhchLHWUqn+hi6TJLSK8blw39xjq0TwLSXY0BoAZFdFCWBttvGGg4pFl1uhsl iKxyXnbr/VwhIjjYcAEcKcpBbSUILZPxX7rizxwuJgM/Z1i+Ts1E/uvXojzrcU9J1+WJ W7hQ== X-Gm-Message-State: ACrzQf241YorI5cQNDfGSmUZy14iXm4WrLdbePR89/2WkAp1arE1o1UG ToFDjJzF/OWt6YY4c9QNoVZuKg== X-Google-Smtp-Source: AMsMyM6Vl0ltGiZH0yN/HZ+WbAICwey0tZez3hQy/16HwYzfSolDLmG+C1hwBTX6JK+/Y80Hja99zQ== X-Received: by 2002:a05:600c:4f56:b0:3b4:b6b0:42d4 with SMTP id m22-20020a05600c4f5600b003b4b6b042d4mr8236336wmq.143.1664398963608; Wed, 28 Sep 2022 14:02:43 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:02:43 -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, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v7 28/29] thermal/intel/int340x: Replace parameter to simplify Date: Wed, 28 Sep 2022 23:00:58 +0200 Message-Id: <20220928210059.891387-29-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In the process of replacing the get_trip_* ops by the generic trip points, the current code has an 'override' property to add another indirection to a different ops. Rework this approach to prevent this indirection and make the code ready for the generic trip points conversion. Actually the get_temp() is different regarding the platform, so it is pointless to add a new set of ops but just create dynamically the ops at init time. Signed-off-by: Daniel Lezcano Reviewed-by: Srinivas Pandruvada --- .../int340x_thermal/int340x_thermal_zone.c | 33 +++++++++---------- .../int340x_thermal/int340x_thermal_zone.h | 4 +-- .../processor_thermal_device.c | 10 ++---- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 62c0aa5d0783..66cd50e0b50a 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -18,9 +18,6 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, unsigned long long tmp; acpi_status status; - if (d->override_ops && d->override_ops->get_temp) - return d->override_ops->get_temp(zone, temp); - status = acpi_evaluate_integer(d->adev->handle, "_TMP", NULL, &tmp); if (ACPI_FAILURE(status)) return -EIO; @@ -46,9 +43,6 @@ static int int340x_thermal_get_trip_temp(struct thermal_zone_device *zone, struct int34x_thermal_zone *d = zone->devdata; int i; - if (d->override_ops && d->override_ops->get_trip_temp) - return d->override_ops->get_trip_temp(zone, trip, temp); - if (trip < d->aux_trip_nr) *temp = d->aux_trips[trip]; else if (trip == d->crt_trip_id) @@ -79,9 +73,6 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone, struct int34x_thermal_zone *d = zone->devdata; int i; - if (d->override_ops && d->override_ops->get_trip_type) - return d->override_ops->get_trip_type(zone, trip, type); - if (trip < d->aux_trip_nr) *type = THERMAL_TRIP_PASSIVE; else if (trip == d->crt_trip_id) @@ -112,9 +103,6 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, acpi_status status; char name[10]; - if (d->override_ops && d->override_ops->set_trip_temp) - return d->override_ops->set_trip_temp(zone, trip, temp); - snprintf(name, sizeof(name), "PAT%d", trip); status = acpi_execute_simple_method(d->adev->handle, name, millicelsius_to_deci_kelvin(temp)); @@ -134,9 +122,6 @@ static int int340x_thermal_get_trip_hyst(struct thermal_zone_device *zone, acpi_status status; unsigned long long hyst; - if (d->override_ops && d->override_ops->get_trip_hyst) - return d->override_ops->get_trip_hyst(zone, trip, temp); - status = acpi_evaluate_integer(d->adev->handle, "GTSH", NULL, &hyst); if (ACPI_FAILURE(status)) *temp = 0; @@ -217,7 +202,7 @@ static struct thermal_zone_params int340x_thermal_params = { }; struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, - struct thermal_zone_device_ops *override_ops) + int (*get_temp) (struct thermal_zone_device *, int *)) { struct int34x_thermal_zone *int34x_thermal_zone; acpi_status status; @@ -231,8 +216,17 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, return ERR_PTR(-ENOMEM); int34x_thermal_zone->adev = adev; - int34x_thermal_zone->override_ops = override_ops; + int34x_thermal_zone->ops = kmemdup(&int340x_thermal_zone_ops, + sizeof(int340x_thermal_zone_ops), GFP_KERNEL); + if (!int34x_thermal_zone->ops) { + ret = -ENOMEM; + goto err_ops_alloc; + } + + if (get_temp) + int34x_thermal_zone->ops->get_temp = get_temp; + status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt); if (ACPI_FAILURE(status)) trip_cnt = 0; @@ -262,7 +256,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, acpi_device_bid(adev), trip_cnt, trip_mask, int34x_thermal_zone, - &int340x_thermal_zone_ops, + int34x_thermal_zone->ops, &int340x_thermal_params, 0, 0); if (IS_ERR(int34x_thermal_zone->zone)) { @@ -281,6 +275,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); err_trip_alloc: + kfree(int34x_thermal_zone->ops); +err_ops_alloc: kfree(int34x_thermal_zone); return ERR_PTR(ret); } @@ -292,6 +288,7 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone thermal_zone_device_unregister(int34x_thermal_zone->zone); acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); + kfree(int34x_thermal_zone->ops); kfree(int34x_thermal_zone); } EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h index 3b4971df1b33..e28ab1ba5e06 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h @@ -29,13 +29,13 @@ struct int34x_thermal_zone { int hot_temp; int hot_trip_id; struct thermal_zone_device *zone; - struct thermal_zone_device_ops *override_ops; + struct thermal_zone_device_ops *ops; void *priv_data; struct acpi_lpat_conversion_table *lpat_table; }; struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *, - struct thermal_zone_device_ops *override_ops); + int (*get_temp) (struct thermal_zone_device *, int *)); void int340x_thermal_zone_remove(struct int34x_thermal_zone *); int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone); diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c index a8d98f1bd6c6..317703027ce9 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c @@ -207,10 +207,6 @@ static int proc_thermal_get_zone_temp(struct thermal_zone_device *zone, return ret; } -static struct thermal_zone_device_ops proc_thermal_local_ops = { - .get_temp = proc_thermal_get_zone_temp, -}; - static int proc_thermal_read_ppcc(struct proc_thermal_device *proc_priv) { int i; @@ -285,7 +281,7 @@ int proc_thermal_add(struct device *dev, struct proc_thermal_device *proc_priv) struct acpi_device *adev; acpi_status status; unsigned long long tmp; - struct thermal_zone_device_ops *ops = NULL; + int (*get_temp) (struct thermal_zone_device *, int *) = NULL; int ret; adev = ACPI_COMPANION(dev); @@ -304,10 +300,10 @@ int proc_thermal_add(struct device *dev, struct proc_thermal_device *proc_priv) /* there is no _TMP method, add local method */ stored_tjmax = get_tjmax(); if (stored_tjmax > 0) - ops = &proc_thermal_local_ops; + get_temp = proc_thermal_get_zone_temp; } - proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops); + proc_priv->int340x_zone = int340x_thermal_zone_add(adev, get_temp); if (IS_ERR(proc_priv->int340x_zone)) { return PTR_ERR(proc_priv->int340x_zone); } else