From patchwork Thu May 25 14:01:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 685793 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 06E00C77B7A for ; Thu, 25 May 2023 14:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241502AbjEYOCd (ORCPT ); Thu, 25 May 2023 10:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241495AbjEYOCc (ORCPT ); Thu, 25 May 2023 10:02:32 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ABA1E64 for ; Thu, 25 May 2023 07:02:08 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3094910b150so2109566f8f.0 for ; Thu, 25 May 2023 07:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023326; x=1687615326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3wdkc7RVIiuUcIo6x94zTHppu2nSL2mGFfMHnbXI87Y=; b=j68NHVr1A3FrdpKdp18jpST9Sx6UadVozGKrTknOB3eBJ4WeHJSoaNWhCxAnQZHxcO OK+lkClFJqErAGSG1mMvT9dGU+HaTk1QBPscxFzumfxrz4FPkDJEmYKt42BlBk9Yk8r5 Ig7mwdOQox1TXqzCJCSyywxNTjRyS8rnqbVUyhLzv9iCzmfqtVMXV/t//hAbIUD2jcAM 6k5gkFmClpoOCIvH4k9xZy4DJq1MECkXNSIB60sXzV4WpdBNA8/+OW8+Zo7mySzgU/9m t0QRWL6rRBEaA6oqq7G2RsRZS7okaKvcE7VQ4x5AmMMVaKJo/zAfk3gcmKL+qSyYBf/M 3Y0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023326; x=1687615326; 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:message-id:reply-to; bh=3wdkc7RVIiuUcIo6x94zTHppu2nSL2mGFfMHnbXI87Y=; b=RsSApaEYl0e9XYTBXlBMnU6fB3+faV0Fi33g4FW8ejefXqJCtVV10NvjD2oWUfyqYF g3PO0EiF8bkPgUUDc6iG8Y65YENjsH8UwVefq2andsQWXdUaG6ZFN86/fNw8ceoeoYNW 9EO8FxS/+lY8L/fEyUJ6ddyIKSuKIl2v1Rll/trqSZGCYKtossrJnK8+zyCIzVDK4v82 /WLLTl2ZTWMxOq2eM17zP/E6XCeg4HWEEXBcHXrQ1Z51kpIZ8UadaeM4Lx2ThdiK3LHs Dd/xgaZHqYgiFIgqH80lf3wn4l7+5dpKJvkiVGCWJ8RSszmVqearT2/9j4NCM3p8kGEC xKmQ== X-Gm-Message-State: AC+VfDwg1WCgUjsqgtDyG7JtA9ANgF8OmxXh6pylW0FCS+UtJO5MPDtT RVgVnNsPrN2z7QKhD1VI8bCk4w== X-Google-Smtp-Source: ACHHUZ4HXcVqrErnKOD0gX1c0NtHgLr7aNYM4nVVOMMcdXEkN7kok08EYdZSFXbqboyZhUMV95dbKA== X-Received: by 2002:adf:eec4:0:b0:2ef:eb54:4dc0 with SMTP id a4-20020adfeec4000000b002efeb544dc0mr2504739wrp.51.1685023326212; Thu, 25 May 2023 07:02:06 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:05 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , Jernej Skrabec , Baolin Wang , AngeloGioacchino Del Regno , Srinivas Pandruvada , "Lee, Chun-Yi" , ye xingchen , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 5/8] thermal/drivers/int3400: Use thermal zone device wrappers Date: Thu, 25 May 2023 16:01:32 +0200 Message-Id: <20230525140135.3589917-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver is accessing the thermal zone device structure but the accessors are already existing and we want to consolidate the thermal core code by preventing accesses to the internals from the drivers. Let's use these accessors. On the other side, the code is getting directly the temperature from tz->temperature, but the temperature is a faked on, so we can replace this access by the fake temp and remove the thermal zone device structure access. Signed-off-by: Daniel Lezcano --- .../thermal/intel/int340x_thermal/int3400_thermal.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 810231b59dcd..66e34241b33a 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -15,6 +15,7 @@ #define INT3400_THERMAL_TABLE_CHANGED 0x83 #define INT3400_ODVP_CHANGED 0x88 #define INT3400_KEEP_ALIVE 0xA0 +#define INT3400_FAKE_TEMP (20 * 1000) /* faked temp sensor with 20C */ enum int3400_thermal_uuid { INT3400_THERMAL_ACTIVE = 0, @@ -453,6 +454,7 @@ static void int3400_notify(acpi_handle handle, void *data) { struct int3400_thermal_priv *priv = data; + struct device *dev; char *thermal_prop[5]; int therm_event; @@ -475,12 +477,14 @@ static void int3400_notify(acpi_handle handle, return; } - thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", priv->thermal->type); - thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", priv->thermal->temperature); + dev = thermal_zone_device(priv->thermal); + + thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", thermal_zone_device_type(priv->thermal)); + thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", INT3400_FAKE_TEMP); thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP="); thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", therm_event); thermal_prop[4] = NULL; - kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE, thermal_prop); + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, thermal_prop); kfree(thermal_prop[0]); kfree(thermal_prop[1]); kfree(thermal_prop[2]); @@ -490,7 +494,7 @@ static void int3400_notify(acpi_handle handle, static int int3400_thermal_get_temp(struct thermal_zone_device *thermal, int *temp) { - *temp = 20 * 1000; /* faked temp sensor with 20C */ + *temp = INT3400_FAKE_TEMP; return 0; }