From nobody Sat Apr 11 22:45:41 2026 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 6A5F4C25B06 for ; Thu, 4 Aug 2022 22:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240377AbiHDWwm (ORCPT ); Thu, 4 Aug 2022 18:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240109AbiHDWwO (ORCPT ); Thu, 4 Aug 2022 18:52:14 -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 4106539BB5 for ; Thu, 4 Aug 2022 15:52:12 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id bv3so1355234wrb.5 for ; Thu, 04 Aug 2022 15:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=vJqB3DsidiN9nPhS4su/6uSlvLZimTeb9ZrCY8jA13M=; b=ywNDi5DlzfdiSw+Wek8UweNt+1cORGZIl0TiY0LahA+zegr97zHUu1bMR9080FcqEU dSqFgcdJIxpBUNjA0i5szx8JLSn1UWQwhbyHZpUTNje0bugjrSHgqa4sj0pXpchDR1F3 FyqYK4bPVnJk43ZWZLXj0qL1k9DIxzcTPUYRlHix8KSpYuOD8ZtdTGiz+7XxYnWVYNQO z3THZH8BwKyb7I2IV4BulTi76NYra85R4u/SnLuQZ0ChfGgLD+aIJoyfPtI0ddsvgI9z lYRhO4eku4GSwSukfJqeuXyHqIpZKkJ2qRxoNI+9aUKGno6OZdVl/j2lziBqtm23XnZS 9svg== 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; bh=vJqB3DsidiN9nPhS4su/6uSlvLZimTeb9ZrCY8jA13M=; b=BC0YobK2ggTfbykWhNMEwT9GZtZQlnsmo6u3dYGbhjUGNI5ADI8jBmUOH8gj6I6hNc IV0B3sVeZA5HCC0aj/DKelilxN2XqJfqMvi4X0aZqwAAVObQRuN9qbVsUwz8nvxltNc4 rK+KYbzjh8OQb3LvsvIRkIWMYm/GKP3oW1dJz3GLnlTiO9GDiJD46ZziSno0XVgZXupO NWFfR5QD6RooAluW7bd8svHT+kzOtWdh9ibkwSfrGsYUloYWivcs8yrV7yoJTv0AnzK7 4HhjWWcK0pWQg/61sFomEJaQZdTn9qPYqqTIJS5G6qa6cZYY9H5gLjcfYQaCruDApDKO WSwQ== X-Gm-Message-State: ACgBeo0/WEp7tAdmrdzE1inJ+ilvQlvugBc73wJZXI+KaTvE/2Ueh+uw CIMY66bOIoLlhCkASu7qOhbdJQ== X-Google-Smtp-Source: AA6agR4gPK2BFTS+f/e1TuM189EKCXODMRpapXlBFbhupBNMZ+wRdcTkc60a5Q4HLqzrKYg1t8mhxw== X-Received: by 2002:adf:fe42:0:b0:21f:8df:2239 with SMTP id m2-20020adffe42000000b0021f08df2239mr2524925wrs.644.1659653530594; Thu, 04 Aug 2022 15:52:10 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:31aa:ed2c:3f7:19d]) by smtp.gmail.com with ESMTPSA id a16-20020a056000051000b0021f87e8945asm2495906wrf.12.2022.08.04.15.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 15:52:10 -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 , Mikko Perttunen , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v5 07/33] thermal/drivers/tegra: Switch to new of API Date: Fri, 5 Aug 2022 00:43:23 +0200 Message-Id: <20220804224349.1926752-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804224349.1926752-1-daniel.lezcano@linexp.org> References: <20220804224349.1926752-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code. Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops. Signed-off-by: Daniel Lezcano Tested-by: Dmitry Osipenko # Nexus7 --- drivers/thermal/tegra/soctherm.c | 21 ++++++++++----------- drivers/thermal/tegra/tegra-bpmp-thermal.c | 19 ++++++++++++------- drivers/thermal/tegra/tegra30-tsensor.c | 12 ++++++------ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/socth= erm.c index 825eab526619..1efe470f31e9 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -421,9 +421,9 @@ static int translate_temp(u16 val) return t; } =20 -static int tegra_thermctl_get_temp(void *data, int *out_temp) +static int tegra_thermctl_get_temp(struct thermal_zone_device *tz, int *ou= t_temp) { - struct tegra_thermctl_zone *zone =3D data; + struct tegra_thermctl_zone *zone =3D tz->devdata; u32 val; =20 val =3D readl(zone->reg); @@ -582,10 +582,9 @@ static int tsensor_group_thermtrip_get(struct tegra_so= ctherm *ts, int id) return temp; } =20 -static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp) +static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, in= t trip, int temp) { - struct tegra_thermctl_zone *zone =3D data; - struct thermal_zone_device *tz =3D zone->tz; + struct tegra_thermctl_zone *zone =3D tz->devdata; struct tegra_soctherm *ts =3D zone->ts; const struct tegra_tsensor_group *sg =3D zone->sg; struct device *dev =3D zone->dev; @@ -657,9 +656,9 @@ static void thermal_irq_disable(struct tegra_thermctl_z= one *zn) mutex_unlock(&zn->ts->thermctl_lock); } =20 -static int tegra_thermctl_set_trips(void *data, int lo, int hi) +static int tegra_thermctl_set_trips(struct thermal_zone_device *tz, int lo= , int hi) { - struct tegra_thermctl_zone *zone =3D data; + struct tegra_thermctl_zone *zone =3D tz->devdata; u32 r; =20 thermal_irq_disable(zone); @@ -682,7 +681,7 @@ static int tegra_thermctl_set_trips(void *data, int lo,= int hi) return 0; } =20 -static const struct thermal_zone_of_device_ops tegra_of_thermal_ops =3D { +static const struct thermal_zone_device_ops tegra_of_thermal_ops =3D { .get_temp =3D tegra_thermctl_get_temp, .set_trip_temp =3D tegra_thermctl_set_trip_temp, .set_trips =3D tegra_thermctl_set_trips, @@ -2194,9 +2193,9 @@ static int tegra_soctherm_probe(struct platform_devic= e *pdev) zone->sg =3D soc->ttgs[i]; zone->ts =3D tegra; =20 - z =3D devm_thermal_zone_of_sensor_register(&pdev->dev, - soc->ttgs[i]->id, zone, - &tegra_of_thermal_ops); + z =3D devm_thermal_of_zone_register(&pdev->dev, + soc->ttgs[i]->id, zone, + &tegra_of_thermal_ops); if (IS_ERR(z)) { err =3D PTR_ERR(z); dev_err(&pdev->dev, "failed to register sensor: %d\n", diff --git a/drivers/thermal/tegra/tegra-bpmp-thermal.c b/drivers/thermal/t= egra/tegra-bpmp-thermal.c index 5affc3d196be..eb84f0b9dc7c 100644 --- a/drivers/thermal/tegra/tegra-bpmp-thermal.c +++ b/drivers/thermal/tegra/tegra-bpmp-thermal.c @@ -30,9 +30,9 @@ struct tegra_bpmp_thermal { struct tegra_bpmp_thermal_zone **zones; }; =20 -static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp) +static int __tegra_bpmp_thermal_get_temp(struct tegra_bpmp_thermal_zone *z= one, + int *out_temp) { - struct tegra_bpmp_thermal_zone *zone =3D data; struct mrq_thermal_host_to_bpmp_request req; union mrq_thermal_bpmp_to_host_response reply; struct tegra_bpmp_message msg; @@ -60,9 +60,14 @@ static int tegra_bpmp_thermal_get_temp(void *data, int *= out_temp) return 0; } =20 -static int tegra_bpmp_thermal_set_trips(void *data, int low, int high) +static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int= *out_temp) { - struct tegra_bpmp_thermal_zone *zone =3D data; + return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp); +} + +static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, in= t low, int high) +{ + struct tegra_bpmp_thermal_zone *zone =3D tz->devdata; struct mrq_thermal_host_to_bpmp_request req; struct tegra_bpmp_message msg; int err; @@ -157,7 +162,7 @@ static int tegra_bpmp_thermal_get_num_zones(struct tegr= a_bpmp *bpmp, return 0; } =20 -static const struct thermal_zone_of_device_ops tegra_bpmp_of_thermal_ops = =3D { +static const struct thermal_zone_device_ops tegra_bpmp_of_thermal_ops =3D { .get_temp =3D tegra_bpmp_thermal_get_temp, .set_trips =3D tegra_bpmp_thermal_set_trips, }; @@ -200,13 +205,13 @@ static int tegra_bpmp_thermal_probe(struct platform_d= evice *pdev) zone->idx =3D i; zone->tegra =3D tegra; =20 - err =3D tegra_bpmp_thermal_get_temp(zone, &temp); + err =3D __tegra_bpmp_thermal_get_temp(zone, &temp); if (err < 0) { devm_kfree(&pdev->dev, zone); continue; } =20 - tzd =3D devm_thermal_zone_of_sensor_register( + tzd =3D devm_thermal_of_zone_register( &pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops); if (IS_ERR(tzd)) { if (PTR_ERR(tzd) =3D=3D -EPROBE_DEFER) diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index 05886684f429..c34501287e96 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -159,9 +159,9 @@ static void devm_tegra_tsensor_hw_disable(void *data) tegra_tsensor_hw_disable(ts); } =20 -static int tegra_tsensor_get_temp(void *data, int *temp) +static int tegra_tsensor_get_temp(struct thermal_zone_device *tz, int *tem= p) { - const struct tegra_tsensor_channel *tsc =3D data; + const struct tegra_tsensor_channel *tsc =3D tz->devdata; const struct tegra_tsensor *ts =3D tsc->ts; int err, c1, c2, c3, c4, counter; u32 val; @@ -217,9 +217,9 @@ static int tegra_tsensor_temp_to_counter(const struct t= egra_tsensor *ts, int tem return DIV_ROUND_CLOSEST(c2 * 1000000 - ts->calib.b, ts->calib.a); } =20 -static int tegra_tsensor_set_trips(void *data, int low, int high) +static int tegra_tsensor_set_trips(struct thermal_zone_device *tz, int low= , int high) { - const struct tegra_tsensor_channel *tsc =3D data; + const struct tegra_tsensor_channel *tsc =3D tz->devdata; const struct tegra_tsensor *ts =3D tsc->ts; u32 val; =20 @@ -240,7 +240,7 @@ static int tegra_tsensor_set_trips(void *data, int low,= int high) return 0; } =20 -static const struct thermal_zone_of_device_ops ops =3D { +static const struct thermal_zone_device_ops ops =3D { .get_temp =3D tegra_tsensor_get_temp, .set_trips =3D tegra_tsensor_set_trips, }; @@ -516,7 +516,7 @@ static int tegra_tsensor_register_channel(struct tegra_= tsensor *ts, tsc->id =3D id; tsc->regs =3D ts->regs + 0x40 * (hw_id + 1); =20 - tsc->tzd =3D devm_thermal_zone_of_sensor_register(ts->dev, id, tsc, &ops); + tsc->tzd =3D devm_thermal_of_zone_register(ts->dev, id, tsc, &ops); if (IS_ERR(tsc->tzd)) { if (PTR_ERR(tsc->tzd) !=3D -ENODEV) return dev_err_probe(ts->dev, PTR_ERR(tsc->tzd), --=20 2.25.1