Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp912880imk; Sun, 3 Jul 2022 12:01:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sX9un95lAzjbiR8YFrfvQ9bjtNz2UMWe13k+0Y/nr4yo7KxNTQd56rNMadzqQM0vY7cFUJ X-Received: by 2002:a17:907:9706:b0:726:2cf4:6698 with SMTP id jg6-20020a170907970600b007262cf46698mr24369354ejc.619.1656874918984; Sun, 03 Jul 2022 12:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656874918; cv=none; d=google.com; s=arc-20160816; b=feVwyeNiEWXvPnwxAnfh/fNHiQhc83BgUYFH0EW2ycBxWRc3dl/LLLS/icjmW54Aow XvAV2vT43AY+e40rzKVwxsQ03nuOGw0GZAlyUjBp6MJ6f3YN0jrCZXQlchn6YaIHmdE7 zRh+p0Jjrp4JO/sTdr7XlDJERJk2Vu8UOm80C/D+TH9cbpdkprkk+Ewr6K/OnGcDxmcJ WgoeBUYtF81JsqCwjTHuDFMv1kIfbzqN6JjwbXuwDvrF4oIJspp3LojGFqMqzd4iMotV igxGeKJ9gvm5SKcY8QyrQ9msR9Cg8aohzZ5xie/cW3KzyQJn89bX0sH9YHWDP5/RkYvR r5zQ== 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=igJaz5Xt/+d7nGudD2jGwH6ZHxfxarZoPjKAaCPJvZE=; b=ye16g+HFAZ1dVzCxFs/Tku3wYxSrGgNJM6RQy6rf6x5zqnue1cHRLankbJrsrNAdwr nx/HxFjjjm4RPGHp7K2M3ZbalLKnSsUaVeNIOKQjBbslgbhrKb13rgU9h98Xawps+r+2 XsKpu/qCluGyEhyn4lrkBaJWNf+ylC7O1dpd2doTyf7dEoK8ljlbtn3Dla1vJBXtQ/Ew ohCTsN2PdGprqtuD5Xc8ce68W2l8VAUOJCZQoBjDgPtZSfDKlibQkS4qomieUMtZRycJ 91ixdnllL4AJ2PMBuDBI1qU4NqZ61DHG3iIFeScs7ajXhv3KCfiA6f+cw0H5WQiMK4KV +bwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linexp-org.20210112.gappssmtp.com header.s=20210112 header.b=0OGrfuFH; 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 v12-20020aa7d80c000000b0043a52317e54si989004edq.391.2022.07.03.12.01.33; Sun, 03 Jul 2022 12:01:58 -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=0OGrfuFH; 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 S232790AbiGCScO (ORCPT + 99 others); Sun, 3 Jul 2022 14:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232795AbiGCSbz (ORCPT ); Sun, 3 Jul 2022 14:31:55 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89B355B6 for ; Sun, 3 Jul 2022 11:31:43 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id z12so818162wrq.7 for ; Sun, 03 Jul 2022 11:31:43 -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=igJaz5Xt/+d7nGudD2jGwH6ZHxfxarZoPjKAaCPJvZE=; b=0OGrfuFHbEacgs7IB/4qdSQVFUJOoB329OhFBXD8zJtblB0VPgWLRD81v8s9qKZ/1i JCBYsr9vfzoaIKTFkYNPSOWmQoSXA52MvIYZEn9GVh9piTEPbCqj+5Y+oKpA7zFhArjj rLleGOELYJfP5eyiqEZs3iFPiycMOmm5YLh1na/8X4M677Y4jvParw4MgkUJYVdrUCUD 5OOUnrIf1W9i8Ez4k3m4WROL7BSMtZog85mnAuT5nq0KF5MUP19kPKWtkLxH+dC/PcmA kFwGeIqq88kgd/iRwcImuXkz21Max3HA3eCG0t248G3BHTHIfJdvofpnAg8vLntOa4wC 3qqw== 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=igJaz5Xt/+d7nGudD2jGwH6ZHxfxarZoPjKAaCPJvZE=; b=vX7ermh1eClxBwsjt3Ay7Y5Zl10290qn9j63H4+STCrL43o/P/CFzsl+A3lB93g3Dr Fd1aR7xBBDl8zxeu2Tye8ICBkGYTbQnnZ8qUIMQY5kumir7JInuYwbONPFnvXgTZPLmx 8LAMKjx2NK/g2s09+IGTN3PHDqrz8SKYq4qF1TbiHCMlwD6fpcc2i42SiPCm8hgYg7KE D9qbBsGvGf2JOMP8WTep2JXP6Q3pnap4lChtIw0cMk9Bg9HXTl0ehX8Nf7J3JqkFDo16 3j8g4K1VvtM+JlZOOv1FKBGKHGGDTgxrJKDPf0n5jrVEZi78/SgpZ+IgxHp+GiSaSgZ6 B2AQ== X-Gm-Message-State: AJIora9ivi4drn2m/ML8q1mnonFvRk66gguIwjJDTnGJeakBxnZ1LoHg tYfV1P9enwuH4a7fSb9M3l3Yig== X-Received: by 2002:a5d:4205:0:b0:21b:89ea:b5e3 with SMTP id n5-20020a5d4205000000b0021b89eab5e3mr21887921wrq.103.1656873102109; Sun, 03 Jul 2022 11:31:42 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id x10-20020a5d54ca000000b0021b85664636sm27504258wrv.16.2022.07.03.11.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 11:31:41 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, abailon@baylibre.com, Amit Kucheria , Zhang Rui Subject: [PATCH v3 11/12] thermal/of: Use thermal trips stored in the thermal zone Date: Sun, 3 Jul 2022 20:30:58 +0200 Message-Id: <20220703183059.4133659-12-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703183059.4133659-1-daniel.lezcano@linexp.org> References: <20220703183059.4133659-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, T_SCC_BODY_TEXT_LINE 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 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 Cc; Eduardo Valentin 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 16b6b90a2390..bc885729bf23 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->ntrips; } 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->ntrips || 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->ntrips || 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->ntrips || 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->ntrips || 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->ntrips || 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->ntrips || 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->ntrips; i++) + if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { + *temp = tz->trips[i].temperature; return 0; } -- 2.25.1