From patchwork Sun Feb 19 14:36:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 59176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp880482wrn; Sun, 19 Feb 2023 06:57:50 -0800 (PST) X-Google-Smtp-Source: AK7set/BegwriyiCTAorZ8SsrOBeDJN8qwJc7I119NmYfC8kugplT1MA4QF0P3CgiJG0sCGgXYUY X-Received: by 2002:aa7:c2c7:0:b0:4ab:5ce9:9f83 with SMTP id m7-20020aa7c2c7000000b004ab5ce99f83mr1876391edp.23.1676818670520; Sun, 19 Feb 2023 06:57:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676818670; cv=none; d=google.com; s=arc-20160816; b=LH54QhrruwaAYG15tJIaG1+fsCCvyGgBVVzJB0+TviCDr/dTfXRO7bjziYyIwDw77t YUPbOMz17+FGbE5rkN81LiHGgENVavI/uiSzLL3ZM3dvzdtwFOJsbDQWC16Ssdovx2ik wOxnSS0mN2qYHbZMhEjp3e8FZ6UJCt9zwZn2kHa089EQjv4YSagwESsReipgM5qDYgc4 NTcbAzd59cxrryYgT05LgiBn1ZWtwKF+YflgXNOfVa3ix65YdsYxCj0TADYcgJWYw6ua Cy5j3Zx8Upufi/xuRkYH8lTj0KkVefQUfaS4BUjgd8/+PcbGZ1UQhxzcDX1mvA4h6ON+ NpZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nwIPDKt1NKah2ZF5gKdn4z7lJuGWL0P0jWTGeT+NApM=; b=pOPG2IRE78iw+m6CDW8jDPNbpp7BmvAMMCCxPCfB1S9luHdxqXR2Sf4iN2MIgiAyRP 7XpRWuEYXDWXvEZRCl8Mr81Uiqsah8f4e6xHCY8Qvgb4Q75MRobPVVyYx582gXHQ4Rzj aeTvdEAJ/s6YqKGGAOktmU8kh7UctwqhhObnitbkg3yzA+DEP7fJVCGHqINM2Ra4bail FAIfbc0faVk/3AUXX0N2oIYL7tZ4ADccBamFLpGDO0ToOckPjHyrfx9RnhkRgU2yeJA3 KvIF1rXb0tEPRg1bto85p/YtP9DPPVh/hDisSnYjJI2Nx1VJ3TOVcsVo1B9jBBb83Qjh ByAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rko85JpP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020a50fb0e000000b004acbcf2585asi12223241edq.614.2023.02.19.06.57.28; Sun, 19 Feb 2023 06:57:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rko85JpP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbjBSOjT (ORCPT + 99 others); Sun, 19 Feb 2023 09:39:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbjBSOia (ORCPT ); Sun, 19 Feb 2023 09:38:30 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A2388A7A for ; Sun, 19 Feb 2023 06:38:03 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id e2so659060wri.12 for ; Sun, 19 Feb 2023 06:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=nwIPDKt1NKah2ZF5gKdn4z7lJuGWL0P0jWTGeT+NApM=; b=rko85JpPzkGDr7nw73V9ShJorcL22/szXUgHF7fomf0L9Bob5r/SBQe8DivWZpHPck Id/3qKIAZml1QfPMTJZ2R1/VJtkPrWSNKnZcxxWVMsr3NfvSyZ7vZ+9hT1qQrWpD8L02 3+FTd2fM/jBmJ2DnKNzHPWtCDiWFdbnunspXRUpvnT9MaSsrsnA4GOJwe1wGsWZtu6lE BVqtDot0lXNUpNhiQBmXYZ1k0/uTuVWmUZWCnfOog6O+dNuY1D8YE99I84dcK+U93VRv jiQPOcC1/h6aKO3XlyM5GSXsh5Eu4UiZV/TmsXsf//6js1Qqs4PGyggSk8WRvQqyJkmn UMhg== 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 :subject:date:message-id:reply-to; bh=nwIPDKt1NKah2ZF5gKdn4z7lJuGWL0P0jWTGeT+NApM=; b=wHmRfKdiqvXC4ZnXx3w2aJZFLvX+ZoH0aeM7n7QnLhyyf172xjOp7x3EvupYH3O4fq SG4W6yr/0QpIHGfJafpxA95WzbsEQZHd0a9BNa6QES97bpP+z6CqaAk2dEtDItse2Z8i /cXA8/jzrvxOFe33AeciMMp9HXBQ3eijpv6ICP8HaekcW4hq84EHN/cwLvOng+jf1iu+ m+4nGGN91liFlhe/AQIZ/fjFqdlqSadhRfeW4z1OQfkCHvyb/9JAnIsOU2/Wj1TpjpUO DDmmtp+akmHVJXZOO8pWGf1v0pI+1dNaddU4f/7Mbv9P3EBwZDWS1Kbd6vtr3gwOY9u5 MiFA== X-Gm-Message-State: AO0yUKX4Y/SmAEGSiW3F4ZLLsDclE0ruGAaRhCSq4lAWZJ4LnMZ6dt7m qudbRk5ca+wlkjB+clzoru5qLA== X-Received: by 2002:a5d:6906:0:b0:2c3:e7d8:245c with SMTP id t6-20020a5d6906000000b002c3e7d8245cmr1145326wru.13.1676817482798; Sun, 19 Feb 2023 06:38:02 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:6f43:b92:7670:463]) by smtp.gmail.com with ESMTPSA id a18-20020adfe5d2000000b002be505ab59asm86176wrn.97.2023.02.19.06.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 06:38:02 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v1 07/17] thermal/hwmon: Use the thermal API instead tampering the internals Date: Sun, 19 Feb 2023 15:36:47 +0100 Message-Id: <20230219143657.241542-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230219143657.241542-1-daniel.lezcano@linaro.org> References: <20230219143657.241542-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758271814326146246?= X-GMAIL-MSGID: =?utf-8?q?1758271814326146246?= In this function, there is a guarantee the thermal zone is registered. The sysfs hwmon unregistering will be blocked until we exit the function. The thermal zone is unregistered after the sysfs hwmon is unregistered. When we are in this function, the thermal zone is registered. We can call the thermal_zone_get_crit_temp() function safely and let the function use the lock which is private the thermal core code. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_hwmon.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index bc02095b314c..15158715b967 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -77,15 +77,7 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, char *buf) int temperature; int ret; - mutex_lock(&tz->lock); - - if (device_is_registered(&tz->device)) - ret = tz->ops->get_crit_temp(tz, &temperature); - else - ret = -ENODEV; - - mutex_unlock(&tz->lock); - + ret = thermal_zone_get_crit_temp(tz, &temperature); if (ret) return ret;