Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp940183imi; Fri, 22 Jul 2022 13:06:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzDgt7CQ5BszZ8ZlhRIwVJ1VfjMF/5gbZQA8SULEKMTMUc/8lpgwBvfGPydsKusb02fQgH X-Received: by 2002:a17:907:7637:b0:72b:3a3b:7d68 with SMTP id jy23-20020a170907763700b0072b3a3b7d68mr1118543ejc.566.1658520371348; Fri, 22 Jul 2022 13:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658520371; cv=none; d=google.com; s=arc-20160816; b=jwo+nqAzQpvPZzRkvgnowHIwYppUlbngiR5vkN4+b0zU+cVQhktONnpldnb17BskiL 8O8LowwogMwVqlPpVdKuSgu8je5I12ced8Q+DoPkIbL1zHMtiDmDkFUPGKnmtTTw2ufY tM7ELFjOF1XyMWy0bLInM3vq9EfyLCoD4ufRB1w+qBpZXNDMxAwjq28znU0cjDyONTai 2SDuvLngXXlmW4bbymW6UsZV2W7zY2DZGqmLYblWVxe2E8tcuFLWXMg0J26nMKnQbDxU +rKVhayvxbf4iGagazd8H+fhwh4qEiikVARQdsv4ApnuzpUKmwiFcCy/AvrV1c88uAkC vdkQ== 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=pfwxGREqovTLfBwtFWXl08zrAx/30xJr9AVKnnlYCfo=; b=kv86Wovm79qcRyCNDJWliyyUcGZwl21wuhb5TBpyWVpRkkp1hTwGvcQSCx6KuN0hrd CFeMiVLZU8ZfNGdHy2wSm/b4H7jL6kYN+2tbs/tk6576MS/8xJlUzflNaFulx2FFaIZX kAE/Fx4shMovpy6X7UDY1154mgJs0maFB/Nq16714KyQljdmNyAmCU3Ef7FgaQV5TLZ3 uXM5IcRoAE8g06/Nk/7uPEOQO/4BEx/29SUcPOtJ1+6wbjAroJ2UJSjko56fwoYbiHFN QkikJ7Y2efQdRwL2LRHXJIHFgoOZ43hNVcq6+egKFeod4tk6s2zU1Fyo9U26DT5L1elR Bg8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linexp-org.20210112.gappssmtp.com header.s=20210112 header.b=zJSYFS5f; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a056402280400b0043a8156e85esi861146ede.446.2022.07.22.13.05.43; Fri, 22 Jul 2022 13:06:11 -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=@linexp-org.20210112.gappssmtp.com header.s=20210112 header.b=zJSYFS5f; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236601AbiGVUBY (ORCPT + 99 others); Fri, 22 Jul 2022 16:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236643AbiGVUAx (ORCPT ); Fri, 22 Jul 2022 16:00:53 -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 90DEAAF739 for ; Fri, 22 Jul 2022 13:00:46 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso5800098wma.2 for ; Fri, 22 Jul 2022 13:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pfwxGREqovTLfBwtFWXl08zrAx/30xJr9AVKnnlYCfo=; b=zJSYFS5fqOUuCya5n62OeqA4ya4Gscqp7is8Zx78n9LnYWYblaz/WpbRvK+XQQBXMt XSvF+rh3linEnBgfwxtH3eZkyAJdF8+udYgAPglsouKNmurohJU3MHljgOga9PmwLuwN sri0tz8RHbVHnVAo77NBZ1dp6HqQwdXL4RuHqn8d8j+RY3nibtankXVQulB0v6SEdddI gU0pyJaiLuapSELCSkFVnE4Rs364N0YrjDEcXDAaqfzCnlitNbYKxqm7PhxMHdDQ0hWH 4bW/QuGKFGB3TPhTiyjoMIt1DYZYvsSpDrTCQBdrnMJN2xPaVzlHoYDsR7xUg+OpiX5S l5Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pfwxGREqovTLfBwtFWXl08zrAx/30xJr9AVKnnlYCfo=; b=ZoFFhXUMhkMvE7BeI42r/j+Du+yIw92FdEUJ2K9NSwQfxvEHbJ6JBMat0E4938spnO j47q0WaTlkkKkQCYO4xT0VvYx2HwviFuU7ioBQGaejf441qiIRLhBoJo+1QPmNwE11Mb Fj4iHevCxzt9uX4MkKhcxnIgMCS5g1Xc9uGNXWuU9xIN55Cs+fHNMIVvOw0F7+JJrvJk pz2LU1BYXem0YUYMesA3NNHkeev2/gIDIHOR3ut5+4umNPmzISI21Zy6r3tW88OgeC0Q PMTywA13Rxuh7TU3/lF5iGUiVaDBGpuRXKVx7N6IhVh7/YBOOdwE0FYGV47USCWw5wLS ekjQ== X-Gm-Message-State: AJIora/pI9mQEnIdIQhZhjxQiiikFCxS6Zb+Y5YIJ4cKUy1hJF4Zk3to tLlBdGC50sbVpKJBasScS1OtCA== X-Received: by 2002:a05:600c:4e4d:b0:3a3:1fe6:6b20 with SMTP id e13-20020a05600c4e4d00b003a31fe66b20mr864989wmq.197.1658520044641; Fri, 22 Jul 2022 13:00:44 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:957f:d36d:87f9:5c17]) by smtp.gmail.com with ESMTPSA id k23-20020a05600c1c9700b003a31b00c216sm6429008wms.0.2022.07.22.13.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:44 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, lukasz.luba@arm.com, Amit Kucheria Subject: [PATCH v6 09/10] thermal/of: Use thermal trips stored in the thermal zone Date: Fri, 22 Jul 2022 22:00:06 +0200 Message-Id: <20220722200007.1839356-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722200007.1839356-1-daniel.lezcano@linexp.org> References: <20220722200007.1839356-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Now that we have the thermal trip stored in the thermal zone in a generic way, we can rely on them and remove one indirection we found in the thermal_of code and do one more step forward the removal of the duplicated structures. Cc: Alexandre Bailon Cc: Kevin Hilman Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 53 +++++++++++------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index e187461dd396..b59eec4af0eb 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -118,12 +118,7 @@ static int of_thermal_set_trips(struct thermal_zone_device *tz, */ int of_thermal_get_ntrips(struct thermal_zone_device *tz) { - struct __thermal_zone *data = tz->devdata; - - if (!data || IS_ERR(data)) - return -ENODEV; - - return data->ntrips; + return tz->num_trips; } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); @@ -139,9 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); */ bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { - struct __thermal_zone *data = tz->devdata; - - if (!data || trip >= data->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return false; return true; @@ -161,12 +154,7 @@ EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); const struct thermal_trip * of_thermal_get_trip_points(struct thermal_zone_device *tz) { - struct __thermal_zone *data = tz->devdata; - - if (!data) - return NULL; - - return data->trips; + return tz->trips; } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); @@ -281,12 +269,10 @@ static int of_thermal_unbind(struct thermal_zone_device *thermal, static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip, enum thermal_trip_type *type) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; - *type = data->trips[trip].type; + *type = tz->trips[trip].type; return 0; } @@ -294,12 +280,10 @@ static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip, static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip, int *temp) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; - *temp = data->trips[trip].temperature; + *temp = tz->trips[trip].temperature; return 0; } @@ -309,7 +293,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, { struct __thermal_zone *data = tz->devdata; - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; if (data->ops && data->ops->set_trip_temp) { @@ -321,7 +305,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, } /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].temperature = temp; + tz->trips[trip].temperature = temp; return 0; } @@ -329,12 +313,10 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip, int *hyst) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; - *hyst = data->trips[trip].hysteresis; + *hyst = tz->trips[trip].hysteresis; return 0; } @@ -342,13 +324,11 @@ static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip, static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, int hyst) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->num_trips || trip < 0) return -EDOM; /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].hysteresis = hyst; + tz->trips[trip].hysteresis = hyst; return 0; } @@ -356,12 +336,11 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct __thermal_zone *data = tz->devdata; int i; - for (i = 0; i < data->ntrips; i++) - if (data->trips[i].type == THERMAL_TRIP_CRITICAL) { - *temp = data->trips[i].temperature; + for (i = 0; i < tz->num_trips; i++) + if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { + *temp = tz->trips[i].temperature; return 0; } -- 2.25.1