Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1088277rwd; Thu, 25 May 2023 07:55:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ngBvD+R/r8+IZoZsfHpzsh/+BcRceY6E+o1LR/nTk1wmpAUy+gJQa1lRlcilqgPtM7wTt X-Received: by 2002:a05:6a21:790:b0:10c:ef18:7473 with SMTP id mg16-20020a056a21079000b0010cef187473mr6823342pzb.56.1685026555599; Thu, 25 May 2023 07:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685026555; cv=none; d=google.com; s=arc-20160816; b=vmO8ECbFYv1U0NsiRvQ89b3NL+Z6X7MIw3ojNqCnqIiU66JvMOuzH4igZQC3Irn/fz aO8qJe4z4PPmE9WfHo/E2trPWDKBhZykm1BykQfvVpxGibid7ZBiqvitm/EAtxDKPRmB brHcri+uOgC7DzwZgECpoyc+JQ4RbtCpVDC38Oy8gydib+XX130W7I+Y9kyiK62dEJIr /ZXF6GTa6WTpdmpVBK1teSLxNCcnNKMQG3HKW1hZMz7JBvcHZSXluCx/sztVGs3CiXc9 FEZxX80VmMc+WhraweEh0YmfKocHKk4ycEgVz0z0v9NpIlRmooSmOG4ZjI0AvPNtbwLg /S/g== 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=/ItegjrGGv11f7pKzf7OY/tEt56zaRuB7g6O2qnWaWE=; b=iKw50nXwVemI7fOLakN/jp+HuDh7dIoVyGAUyLvwzd8ZIQn83UR2w9YcxXmpYKYr9b Q7diwpFwosYEO9W0OhF6ls3ZmBiB+RUvc7t154I6AOyIWKhb7G2o0Aga09LqaNcKltSu E+cconEdOyq11AO5XD5C3Dyo+50jCCLUt9W3q2wEpvlD26/Mo7rOZVXi78aKJd5XNogf FG+LER/yNwywrNSsMG4VnPlgtKxw+dBCImzRRPXccWylpP9httkvHCI811EeU7HuSn2w bmcSYUTaAsBGY0y8tW/3ygFYLu+P619UQ387lB3zsV2aVprHpNj8F9DnEQa+PTCZNAD2 0O4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u602UsgO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020aa794b6000000b0064d7336c80dsi1626214pfl.385.2023.05.25.07.55.43; Thu, 25 May 2023 07:55:55 -0700 (PDT) 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=u602UsgO; 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 S241575AbjEYOC6 (ORCPT + 99 others); Thu, 25 May 2023 10:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241523AbjEYOCn (ORCPT ); Thu, 25 May 2023 10:02:43 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD2B6E6F for ; Thu, 25 May 2023 07:02:16 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3078d1c8828so2099709f8f.3 for ; Thu, 25 May 2023 07:02:16 -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=abTjiqSAFw6lAKbHUll8ol97NoddfDnwU9qFnLcQFYpI98++p5qrYMqvtyEued3/zK tr0wdRYIefrMCObiNbfQ0rgXJJk07HmAd9J8eVbljPewkYRN9sJ9BsiCHslrdlrehq1d Jw1kevNJyXvoWa5IDp+O57DwgCnpyrrS14Beu2Ht5bHsKKN8lQb64MsPPswAips0Z++V di0Zsd03mp+cKDys8V6o4SZzx8AE2Ua4ZEbyDqo5MvYfbhl9J01eMtXkApsYtR3GSTQn oOTZgFPMNBTPzAv/0HyOasjow8nPChJIXdjBvMjtDLW/TesAvTJvvJrvrKRJ6kYkSFzN re7Q== X-Gm-Message-State: AC+VfDw5/J/p9oeSw7r+kjRPJdCqDI//fbKpNPPPnYXVNJN1BVQKpK9A UxwLfOMU6M4MdybIftHopcxxLw== 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 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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); -- 2.34.1