From patchwork Mon Apr 10 20:53:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 672051 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 59C7DC77B74 for ; Mon, 10 Apr 2023 20:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbjDJUxs (ORCPT ); Mon, 10 Apr 2023 16:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbjDJUxo (ORCPT ); Mon, 10 Apr 2023 16:53:44 -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 DBE9C1BDD for ; Mon, 10 Apr 2023 13:53:41 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id gw13so3420525wmb.3 for ; Mon, 10 Apr 2023 13:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681160020; x=1683752020; 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=+VZk/Xuf/BecNwwdsFB/838vQVCvaje2TQnFopmd7IM=; b=FxLeg2sTLVYKL6SFHQGx1FS/5j5eNFIakBq/wmiT/7z73ycZpRJOGN+zVK4lR2cyyC wIBkdAHRc+p5/f9InR3Q7uSswONpKuDg0e55ZkON7Efl7JAQhwTXV5ExsDMUlTHgcatG dox8L7LfD1XszOKEVApR/6iS6vIl3Cs8z15bNYqPgc+vw+YiRfQ7F9jTKm+FyP+sWfcx mdTngflLgrvi+IZw7iCa30iJrdCHbr5luYlbDMiS5P4iOxWhCTu+0v7uzlnXejf3ewPv 8iSNvewqgw+hmJjaW2OnBwLuC97r80s9WDZm5i0QvZt1n4xpcCEzNiaF4ldhzyLPiVa0 BT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681160020; x=1683752020; 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=+VZk/Xuf/BecNwwdsFB/838vQVCvaje2TQnFopmd7IM=; b=03K0zdtekF+3kqGCyTkFrZS9hMWQaHG6F0BdrPT5/vUAUImZg8B8xruVYU7DsubimE 7qlAxsSWZWeuugLCDm/DqpfiYnSh3UT/95woMt8AeQIAIozGIbU055WRDPaK5FBBVqqk mc/vMrPk+Jcqra93FkdwCbbY41kvecfi/a0U4vmhdR+2fskmWjOdam3L3l8RZvsUH7N5 wVCiXwrnfLYm1kfy2JwuwmosOZ9tfE+uVuYoA8MZ09V/1hApAyhFwtZ+v+pJZcwOnHve x8zPXd+HWQiLB3VAVflzFUQUHpd83p2eIliQUxQIhiND2+SAfS+B6/xGPB7XGZ2/Chvc vySg== X-Gm-Message-State: AAQBX9dWeoga/G8UM0JtVefc+HiuYys8ZoMd7wVt9WLTpIZd2mqI2+ne eXFjrO2+IukMCtAdFIXLGxtSoA== X-Google-Smtp-Source: AKy350ZAg2sXku/us3SLa/ABKLmYyW0fS/CTYnxWdO5C7YlSREmAzH6R6thKVE6yeBcN/q2cJ/AASw== X-Received: by 2002:a05:600c:ce:b0:3f0:39ab:347c with SMTP id u14-20020a05600c00ce00b003f039ab347cmr5368542wmm.23.1681160020330; Mon, 10 Apr 2023 13:53:40 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:2611:592:3b9e:d2ae]) by smtp.gmail.com with ESMTPSA id e17-20020adffc51000000b002ef2e148d59sm11966789wrs.16.2023.04.10.13.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 13:53:40 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Len Brown , linux-acpi@vger.kernel.org (open list:ACPI THERMAL DRIVER) Subject: [PATCH v2 3/7] thermal/drivers/acpi: Use thermal_zone_device() Date: Mon, 10 Apr 2023 22:53:01 +0200 Message-Id: <20230410205305.1649678-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230410205305.1649678-1-daniel.lezcano@linaro.org> References: <20230410205305.1649678-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In order to get the device associated with the thermal zone, let's use the wrapper thermal_zone_device() instead of accessing directly the content of the thermal zone device structure. Signed-off-by: Daniel Lezcano --- drivers/acpi/thermal.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 255efa73ed70..5763db4528b8 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -789,6 +789,7 @@ static struct thermal_zone_device_ops acpi_thermal_zone_ops = { static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) { + struct device *tzdev; int trips = 0; int result; acpi_status status; @@ -820,12 +821,14 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) if (IS_ERR(tz->thermal_zone)) return -ENODEV; + tzdev = thermal_zone_device(tz->thermal_zone); + result = sysfs_create_link(&tz->device->dev.kobj, - &tz->thermal_zone->device.kobj, "thermal_zone"); + &tzdev->kobj, "thermal_zone"); if (result) goto unregister_tzd; - result = sysfs_create_link(&tz->thermal_zone->device.kobj, + result = sysfs_create_link(&tzdev->kobj, &tz->device->dev.kobj, "device"); if (result) goto remove_tz_link; @@ -849,7 +852,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) acpi_bus_detach: acpi_bus_detach_private_data(tz->device->handle); remove_dev_link: - sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); + sysfs_remove_link(&tzdev->kobj, "device"); remove_tz_link: sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); unregister_tzd: @@ -860,8 +863,10 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) { + struct device *tzdev = thermal_zone_device(tz->thermal_zone); + sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); - sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); + sysfs_remove_link(&tzdev->kobj, "device"); thermal_zone_device_unregister(tz->thermal_zone); tz->thermal_zone = NULL; acpi_bus_detach_private_data(tz->device->handle);