From patchwork Thu May 25 14:01:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 685792 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 C79A7C77B7A for ; Thu, 25 May 2023 14:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241562AbjEYOCy (ORCPT ); Thu, 25 May 2023 10:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241530AbjEYOCr (ORCPT ); Thu, 25 May 2023 10:02:47 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706BFE76 for ; Thu, 25 May 2023 07:02:17 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3093a7b71fbso2102473f8f.2 for ; Thu, 25 May 2023 07:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023330; x=1687615330; 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=/ItegjrGGv11f7pKzf7OY/tEt56zaRuB7g6O2qnWaWE=; b=u602UsgORyj8+WQfir0DgKNegXC6dcDBBELHq8gxS5Ipba6T6z16yPBMdx4vPoBo4h uWOwJtDjijNAJ9aUxqnEd5aFg5s0qeM71KrD6G5bzvBux8r/qAUXVKPIGrYRVEXkJ7GD n0gItdYiBPi06mIzuh+DDyi5fH/73jIFpVR2zzCrA0u4NogeKM5sEzb8YNbN8kdeOQiu 08V2P6PVoPwZgWfvNOG3Doduihqpp+LGW1+sFQsiqmUd9VnpnnZDf1ERjOu75nivbcaZ ax1AFJa+Iy0UoHewlnsCQeMN3xufkW2xSvyI8KhvRqRCHK1Yyko8CfMHdlTGaTvwFpC/ ornQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023330; x=1687615330; 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=/ItegjrGGv11f7pKzf7OY/tEt56zaRuB7g6O2qnWaWE=; b=VRYvZ2dWHVOBWhzCz9EBvGKNZHyA4Fp6gf/sxEnovdKeQRGRu4wfjqto2wYEuzl2RX D30WgiZuzuEbxb5f8+5iOcp9W9UlZHeghzr+wPFXDM9dNXHydSSAcSohCmvx9STT5CKy nt2y4YlaTrGRLcLM4gepuOAdVBzRkQozJXoy8e4wX3NbewpMKnPI/8cQgsbgFXhV0Jmh pesdD62syEZw8UKBNw6ZXCu+V7l4agh2yfIIgfiUwObVDoKG+APHf+Hu22QlURirTb3a Fq9mEAoeAWqos2nSzFurs6rEYKGn5c8bwrFwnm/rGvIHbqEGWt36jv3SfN4A9VugiwVQ 3LJQ== X-Gm-Message-State: AC+VfDwY90MgYvF6Eli+XXOw+TjImYsxCGEPoVDl8vjw4nS83xr9+Qbc 6tbTy7GEZOVrZXT0QgmkbDjjgLE+qSQLdq1IVUg= X-Google-Smtp-Source: ACHHUZ5FJcIDH0IGIR9EZH+aqkLlq+kUdkJo9afvSvi2Qak2Ss7gX3cbcULnrr1M6Z0y+2mj+TFGog== X-Received: by 2002:a5d:694c:0:b0:30a:bae7:9848 with SMTP id r12-20020a5d694c000000b0030abae79848mr1766026wrw.13.1685023330426; Thu, 25 May 2023 07:02:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:09 -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 , Srinivas Pandruvada , Baolin Wang , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 7/8] thermal/drivers/int340x: Use thermal zone device trip update Date: Thu, 25 May 2023 16:01:34 +0200 Message-Id: <20230525140135.3589917-8-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 current code takes the thermal zone device lock to update the thermal trips. Now we have an API allowing to update the thermal trip directly, so use it and get ride of the thermal zone lock access. Take also the opportunity to use the zone>-type accessor. Signed-off-by: Daniel Lezcano --- .../int340x_thermal/int340x_thermal_zone.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 89cf007146ea..94697063f41e 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -58,7 +58,8 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, static void int340x_thermal_critical(struct thermal_zone_device *zone) { - dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type); + dev_dbg(thermal_zone_device(zone), "%s: critical temperature reached\n", + thermal_zone_device_type(zone)); } static struct thermal_zone_device_ops int340x_thermal_zone_ops = { @@ -215,13 +216,15 @@ EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) { struct acpi_device *zone_adev = int34x_zone->adev; - struct thermal_trip *zone_trips = int34x_zone->trips; - int trip_cnt = int34x_zone->zone->num_trips; + struct thermal_trip *zone_trips; + int trip_cnt = thermal_zone_get_num_trips(int34x_zone->zone); int act_trip_nr = 0; int i; - mutex_lock(&int34x_zone->zone->lock); - + zone_trips = kmemdup(int34x_zone->trips, sizeof(*zone_trips) * trip_cnt, GFP_KERNEL); + if (!zone_trips) + return; + for (i = int34x_zone->aux_trip_nr; i < trip_cnt; i++) { int temp, err; @@ -250,7 +253,9 @@ void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) zone_trips[i].temperature = temp; } - mutex_unlock(&int34x_zone->zone->lock); + if (!thermal_zone_trips_update(int34x_zone->zone, zone_trips, trip_cnt, + GENMASK_ULL((trip_cnt) - 1, 0))) + int34x_zone->trips = zone_trips; } EXPORT_SYMBOL_GPL(int340x_thermal_update_trips);