Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp833780imu; Tue, 20 Nov 2018 07:39:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UIBwXMzz9X5XccxJ/tgP4WQKti7N9A+8z1GTlF2kpm/TTGbyoDTOFk/O2nePaWRyROpZN7 X-Received: by 2002:a63:ea15:: with SMTP id c21mr2208000pgi.361.1542728382565; Tue, 20 Nov 2018 07:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542728382; cv=none; d=google.com; s=arc-20160816; b=E77LDmoeVPLL08EhPu8LTTq7Pbp24tQIxJxw4IAyfgr3IWrM4ZjR+hyQ0e8+hVDKwG 9ahJ4cwD36/7cbgwN2qpbK3yjBbitz6HaR9sZw2w/pmo7gIT006PKxx6tBWxN7g76Gou 5aZiMkgBmAm/lscpj5SHAw1pxlsD8URGnzioHHpXMA6yszRQNVIa7NZ2DOwrpV1q2DOm acHAtDyVko/OCWcN1pMDiIInkv8lidJHO1aVjmwBtzo7H2pzampcnZztG7Ze5pLfzqnx ZEvRkuvy4kxNQjQC9rTGZ3PpDvRZLOkeK7MBUz6haaXFuX+5vWMv3HuvOBxjp+plhA78 PLSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4CkKGnCggiihM41OdlZ/ssZOHgdRJWyUZ5YWiGRK8HU=; b=oVIlgkIY+JwIf6tTCv1rAr6O4nc6HNt5FCVAjKiPb5HWWiJ6kfFl+Hi/CHvhXc85Bf U6KyTdFRsIpipGpZdVb1mvP8itv84R8/p/OtTpyvV+TUV0Ouobzw5wmHEyA4WYBppZJO RENfZKPrzK39Xin0Y8778X8c77rS7rDnPgAV3ZW3NyelSqPcpazIgxE4UZ1z6/0fy1Zz j1FllHvQWAozxLCG5x/AKj7RUUdJwx+f2aJUcSlaMdFsvedOEFSTAEvMqBeZ1wpctoll T+Eazd7AjLoq6MobcM+TcCnbgVzvZI94md5y7NsGJBDUM3ZWk/uTdZIw02Hwtv8pYUgh I4cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KvZw8zG+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a70si42267598pge.421.2018.11.20.07.39.26; Tue, 20 Nov 2018 07:39:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KvZw8zG+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726588AbeKUCIV (ORCPT + 99 others); Tue, 20 Nov 2018 21:08:21 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:39133 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbeKUCIV (ORCPT ); Tue, 20 Nov 2018 21:08:21 -0500 Received: by mail-ed1-f66.google.com with SMTP id b14so2306015edt.6; Tue, 20 Nov 2018 07:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4CkKGnCggiihM41OdlZ/ssZOHgdRJWyUZ5YWiGRK8HU=; b=KvZw8zG+Ea69tGy0mLudgTra8PqVwZvign1XYOqaTiHv2hDz4pKIesqlRLHfk5K9QH E8LKXBqgeKvBOnDArtffYonegU4sIrUh3SPKxgHMPZysdP6Txpv/2TbbVTR7nnHMpZ2n xABSIed0ZLBtr9bhB4DYQdTKDLOrWhaxyZmAFBNFL6nJ3dAFxU4dEFySyXP/mw7eHkD1 Y4RdRQON3qG9hz3L2oonkQZGI7QThGq1jEFBsNmLU7LAR7AVDyYN/S4ERxxBU0wyZ1lK 7pwc21UndVoLjkDNQR9POSnXabeOebyvBgoCJnkAOIihOyaWaRBWWtafNAIiH/TReahg km9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4CkKGnCggiihM41OdlZ/ssZOHgdRJWyUZ5YWiGRK8HU=; b=Yjvr3aeSUHTZXKFhUSxVlHueWmwRlFv/zdKHe4ZwrpVBWceIQICYYJiUfS7Va+HEVz WT+kDokhsPhuB7URYLaLZtunagflIV+irPy2tyRq4nvbYxlPlfQPWx+uIigDKWpNuob1 9qmxU2qEtKW66JDzYSZVY3cZLST1L32reECA0ll6BNd4/ZJWd/jgJdy15kTC5bQCPAw0 JRfF920i8th/HHTRm6NF6bs9/Z+GAQtD09x8pGP7qMZdWyRStyNt7By0tJZpjDjoK2V0 pDSpoS+L7qRMqDNt9AJ71CCYT90x2+Wt64687tIM5IyMYJoZTEoVXxOPESH2/k3nIbWz UUPA== X-Gm-Message-State: AGRZ1gLWP9NYaDEv+JWVXiM5zRidTOQoHupZimvm7FL8lxGR57It+v/g x9fEXlRuNQOE3zLWqHRTij9w3XPi X-Received: by 2002:a17:906:4e82:: with SMTP id v2-v6mr2301797eju.149.1542728315499; Tue, 20 Nov 2018 07:38:35 -0800 (PST) Received: from localhost (pD9E511F8.dip0.t-ipconnect.de. [217.229.17.248]) by smtp.gmail.com with ESMTPSA id r8-v6sm7297619ejb.52.2018.11.20.07.38.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Nov 2018 07:38:34 -0800 (PST) Date: Tue, 20 Nov 2018 16:38:33 +0100 From: Thierry Reding To: Wei Ni Cc: daniel.lezcano@linaro.org, linux-tegra@vger.kernel.org, rui.zhang@intel.com, edubezval@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] thermal: tegra: add get_trend ops Message-ID: <20181120153833.GB28796@ulmo> References: <1542705077-29697-1-git-send-email-wni@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UHN/qo2QbUvPLonB" Content-Disposition: inline In-Reply-To: <1542705077-29697-1-git-send-email-wni@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --UHN/qo2QbUvPLonB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 20, 2018 at 05:11:17PM +0800, Wei Ni wrote: > Add support for get_trend ops that allows soctherm > sensors to be used with the step-wise governor. >=20 > Signed-off-by: Wei Ni > --- > drivers/thermal/tegra/soctherm.c | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) >=20 > diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soc= therm.c > index ed28110a3535..d2951fbe2b7c 100644 > --- a/drivers/thermal/tegra/soctherm.c > +++ b/drivers/thermal/tegra/soctherm.c > @@ -488,9 +488,43 @@ static int tegra_thermctl_set_trip_temp(void *data, = int trip, int temp) > return 0; > } > =20 > +static int tegra_thermctl_get_trend(void *data, int trip, > + enum thermal_trend *trend) > +{ > + struct tegra_thermctl_zone *zone =3D data; > + struct thermal_zone_device *tz =3D zone->tz; > + int trip_temp, temp, last_temp, ret; > + > + if (!tz) > + return -EINVAL; > + > + ret =3D tz->ops->get_trip_temp(zone->tz, trip, &trip_temp); > + if (ret) > + return ret; > + > + mutex_lock(&tz->lock); > + temp =3D tz->temperature; > + last_temp =3D tz->last_temperature; > + mutex_unlock(&tz->lock); > + > + if (temp > trip_temp) { > + if (temp >=3D last_temp) > + *trend =3D THERMAL_TREND_RAISING; > + else > + *trend =3D THERMAL_TREND_STABLE; > + } else if (temp < trip_temp) { > + *trend =3D THERMAL_TREND_DROPPING; > + } else { > + *trend =3D THERMAL_TREND_STABLE; > + } > + > + return 0; > +} This looks like a reimplementation of the get_tz_trend() helper. Is seems like that helper already has everything we need. Perhaps this isn't working because of-thermal installs of_thermal_get_trend(), a function that returns -EINVAL if the driver doesn't implement the ->get_trend() callback. Perhaps a better way would be to do something like this in thermal_zone_of_add_sensor(): if (ops->get_trend) tzd->ops->get_trend =3D of_thermal_get_trend; That's similar to how ->set_trips() and ->set_emul_temp() are set up and should make sure that get_tz_trend() will do the right thing for all drivers that don't implement a special ->get_trend(). Thierry --UHN/qo2QbUvPLonB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlv0KnkACgkQ3SOs138+ s6FoDw//UG4y7JbUCh7i9E6+FBy3aReerfGVH6JVQUw3M7bi0oIlfXumecDdq8Mn BcP781sws3DgLFXl4wJ1pFhPLWpxuV8ArNS0cRL+Cw53oTQ5WeUXipVTKaC6+wRb j7aGgABz3FfWdCJpFlSrNHbfd3S+FS2Gq+Uo96cUKDGiLCtOx/Bzt5HC8MuQBl4p T+Q4wdzNy+Zfha4kdGFtGvuuVU8sZsJgEFoRhA1AyD/cOSNnfq0KghTGZZ+SWiol rZPuNcWivE7UsrW+f9RNGOJG1yWKb/XS3OArUDo1nIRv94HUxODA/2isIO2HOT7A pRUpynXJ++Wjo46pwdCJYMkF1nrzyHlfY02VDIWopVf5dsfBuhYz979RF5S3bmQT +nXP8EIZU8l3chdGwHPTQCfE8yRHhcNSEvrTqqLKEdJ7xCkpXQZCaLnanlfO5K3D xq/o9Uh1PNTGKEcXypeK93o9HRE3BrcxXXV7Bp4vjnz1MNa4R0NDU12+/IPC6uCC WnykaKgFI+OqCdTqhV70mUKg3YN3BvGtX9oi0oKKdc9OV8dtOfSKMh1uJJuJi0SS Py6k3ZUI8BsMxCvdr9sY946byCLej6oNkMD0WbzpqHY+clDCZp3uBL4Z9K9jffRI +URAjV9fVZAVrdLWr8O+hbSCmO9hPryuJRRI85s8kQ05BHwqjWQ= =JRWz -----END PGP SIGNATURE----- --UHN/qo2QbUvPLonB--