From patchwork Wed Jul 27 21:02:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 594279 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 8491CC19F29 for ; Wed, 27 Jul 2022 21:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237467AbiG0VGZ (ORCPT ); Wed, 27 Jul 2022 17:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237275AbiG0VFt (ORCPT ); Wed, 27 Jul 2022 17:05:49 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DF0261B14 for ; Wed, 27 Jul 2022 14:04:25 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id h8so26065394wrw.1 for ; Wed, 27 Jul 2022 14:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NA8ooyNHoaigd+w7aJNo47HL4zS61/xJOAD4qh1CGLU=; b=Nn4DbpxPaQKZRIZBoIdp7blR84wd/J1xKB+gsPyzkNCoispCTW6iDyPssreTDkjx+N 53s+zMgLY8nUfYIaQ16kdrxrymRvWZlb6J8josfOA7Z7kgrvXkruBlW6JXMRrwuhOlr8 7cYe8UVUXsfNGWMIQm2/PKj3KHISrxd1PQmfMl//3S8auCgPwb+h5WPMa+MdYo/T4rux 04rlphfLcXBea8nGzub+p+aunnDbrGlTTXchJM2Hz8NSM2jb8QB3ionr4Kx5AxL94a9R PGAGylarQLQ2inGBoFnJ8zxsKF6n6a4uSWXB10LS1RjjFvU3tG65CBkJ3o5tg9JmlCfC WSNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NA8ooyNHoaigd+w7aJNo47HL4zS61/xJOAD4qh1CGLU=; b=7RAiSzHQgdayPLivTCQArbcv867nMp7QpcAXZqzSDjA0Zh/92/2ZZIQEPb/H7xabBv 90+dK1nl9DgpWSmw8dEk1+spv57CeHy12KHpNrrH47u564f6dV7xVYC3mptidgRm1OBe vbbFwKU1GnDPgVD9Krs4YbKcFFFNDE/x6ncm2E41Bz+ZzgZ/+Mz/OA5cVIZ56e8rpg6B M2tE1r9Wbo0jal5lkzs2BwUH4yNqQ/lkCWXlOIXbo4AUPTmEysVhFtld5dDUKKHaVUBx CR4KzkzS/QmM+a1KfkvuM7N3AdYEtdZY9+Muf+yhPkwZ/2MYDae8CAuYBpfe+1QS/pxb iPCQ== X-Gm-Message-State: AJIora9p6DFVmAzkvzTVUgf9cUPrD9mQXukppQ7qdOO0xzzoBLFnkZqq lO24/2vBWZLPuIpFdlodbe2SVw== X-Google-Smtp-Source: AGRyM1sKohM2nCiXC7Bbzx/UqVwJJuMirKOGWmzxCdKyRMyTX7rtCRaP7yhMjKeMgvsfKG3A+o5ELA== X-Received: by 2002:a5d:4811:0:b0:21e:3d86:a2df with SMTP id l17-20020a5d4811000000b0021e3d86a2dfmr15965520wrq.633.1658955864592; Wed, 27 Jul 2022 14:04:24 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:65a8:ebd8:4098:d9d0]) by smtp.gmail.com with ESMTPSA id h6-20020a05600c350600b003a38606385esm37908wmq.3.2022.07.27.14.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 14:04:24 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, broonie@kernel.org, damien.lemoal@opensource.wdc.com, heiko@sntech.de, hayashi.kunihiko@socionext.com, mhiramat@kernel.org, talel@amazon.com, thierry.reding@gmail.com, digetx@gmail.com, jonathanh@nvidia.com, anarsoul@gmail.com, tiny.windzz@gmail.com, baolin.wang7@gmail.com, f.fainelli@gmail.com, bjorn.andersson@linaro.org, mcoquelin.stm32@gmail.com, glaroque@baylibre.com, miquel.raynal@bootlin.com, shawnguo@kernel.org, niklas.soderlund@ragnatech.se, matthias.bgg@gmail.com, j-keerthy@ti.com, Amit Kucheria Subject: [PATCH v3 31/32] thermal/core: Move set_trip_temp ops to the sysfs code Date: Wed, 27 Jul 2022 23:02:52 +0200 Message-Id: <20220727210253.3794069-32-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727210253.3794069-1-daniel.lezcano@linexp.org> References: <20220727210253.3794069-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Given the trip points can be set in the thermal zone structure, there is no need of a specific OF function to do that. Move the code in the place where it is generic, in the sysfs set_trip_temp storing function. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 23 ----------------------- drivers/thermal/thermal_sysfs.c | 5 ++++- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 07bde07ddc04..403064fed438 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -288,28 +288,6 @@ static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip, return 0; } -static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, - int temp) -{ - struct __thermal_zone *data = tz->devdata; - - if (trip >= tz->num_trips || trip < 0) - return -EDOM; - - if (data->ops && data->ops->set_trip_temp) { - int ret; - - ret = data->ops->set_trip_temp(data->sensor_data, trip, temp); - if (ret) - return ret; - } - - /* thermal framework should take care of data->mask & (1 << trip) */ - tz->trips[trip].temperature = temp; - - return 0; -} - static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip, int *hyst) { @@ -350,7 +328,6 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, static struct thermal_zone_device_ops of_thermal_ops = { .get_trip_type = of_thermal_get_trip_type, .get_trip_temp = of_thermal_get_trip_temp, - .set_trip_temp = of_thermal_set_trip_temp, .get_trip_hyst = of_thermal_get_trip_hyst, .set_trip_hyst = of_thermal_set_trip_hyst, .get_crit_temp = of_thermal_get_crit_temp, diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 5018459e8dd9..3c513561d346 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, int temperature, hyst = 0; enum thermal_trip_type type; - if (!tz->ops->set_trip_temp) + if (!tz->ops->set_trip_temp && !tz->trips) return -EPERM; if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1) @@ -128,6 +128,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, if (ret) return ret; + if (tz->trips) + tz->trips[trip].temperature = temperature; + if (tz->ops->get_trip_hyst) { ret = tz->ops->get_trip_hyst(tz, trip, &hyst); if (ret)