Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp187266imw; Mon, 4 Jul 2022 07:26:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uUgHo+njshnEaCrRJoH/rrP+JeMdUnb+yy/nyUQ5k1f/mkYfTLV4BLAvDBD3oqBu0xhcyj X-Received: by 2002:a05:6402:448e:b0:435:9926:1acc with SMTP id er14-20020a056402448e00b0043599261accmr38825752edb.179.1656944765379; Mon, 04 Jul 2022 07:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656944765; cv=none; d=google.com; s=arc-20160816; b=W2TLcmx5S66y/7cRP8lnHywlFK+RONe+kCrYbSQr4bjK/Y1Ge94bQ5I6roBKj8ue8v 2wr7LGi6FZFbbpirTCpEwSObzxPvshvNadNPSTcu9TW/gsjARDi+Ku5es9sz8dXL64S0 HC3pTpVw9T897F16xM3w5SKImElbxjxLL1mbU9axs2EUVACPBoCf9RHRy6GDyUS2vQvB Kc8RA+oeWe6d/cllDAjUPvlHpXGZGDK5ykn4j4rJtOT91i9KaXAgPoA91jKGZMjqKls4 5y+jrrZ1lF4uenjizigPZ5nzHJqCxeiqE3bWEAxTflqRZtppWGH4xvsP/xfOrynr8I7G CEjQ== 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:date:cc:to:from:subject:message-id :dkim-signature; bh=JFW45JM5EEGZLz2WYG3WyYT95utECUgpy0io/w4EHD8=; b=g8019HyeWWi9HJ7K/yx9NmihPGX04k7LgwNyv8Ngiu4mJDZ6ahc0wqMbyQV/JCHf7y 48oX+3kf4y14wIli8lyxSRVFrU8zBCs7RftybBVC6gxrPBWiBPENPuJmrf2+62qTDz2B DajGYTvqR5wYu8kwJiNTM+g5jDI1GayS/DZynYqk/HRN33mOJMPZ2ic4XcMV4d76+kdU /GRhpPutLCMd4brnFe5WjXMSvpDkRqDdFRwrzJu4VnNRVy+SmLwR2K2zJq5f4WHtjwW1 PeOm7kF0gf9Sk5CtfFVReEU8Bsi9EJBjHvXi3eU6d1RGQsb0MZNrsfHC6kce2fLl93/N fDlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gq57rsME; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a056402275300b0042e1a7667f7si14519063edd.613.2022.07.04.07.25.41; Mon, 04 Jul 2022 07:26:05 -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=@intel.com header.s=Intel header.b=gq57rsME; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233761AbiGDOO3 (ORCPT + 99 others); Mon, 4 Jul 2022 10:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233101AbiGDOO1 (ORCPT ); Mon, 4 Jul 2022 10:14:27 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F4FA46A; Mon, 4 Jul 2022 07:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656944066; x=1688480066; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=6UMBiXhSqErP3pi5q319t7EpuHzOc0nnsBjCZ1WVXns=; b=gq57rsMEbtaF8KPGFgmU90eLffjMU58neR+uv3R6SSLROMF+/BWpq9gL V+XQGctLCCzaqASmNrdqdAY4xyL9dFsde0YMVyTqUUhhHJMDwVtm0qdZA /4bVxwOVh3i8Maiy9KLNF/9mVKzkY2ioL5prMtiOwzN2HwVBIm0r/Mu5A gUS0RQqUOfUoSwC4miJL56i5+Pu/0Jqvp0dMaUgFqeWlw3nU6uT1AnTjy cMcigquVi/t055i558vNb1qYnbsBSIADqthIW23fVxLybcsKleDADMErD hf19QmVrabg6eZSZQGrrVRFz4c/npEr1gpty7EMq2X24vgivHQpGpKQEg g==; X-IronPort-AV: E=McAfee;i="6400,9594,10397"; a="284249422" X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="284249422" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 07:14:25 -0700 X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="590087581" Received: from bbao3-mobl1.ccr.corp.intel.com ([10.249.173.150]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 07:14:23 -0700 Message-ID: <6c7e1865e7e68ac0f035680044eb878ced715a1b.camel@intel.com> Subject: Re: [PATCH v3 11/12] thermal/of: Use thermal trips stored in the thermal zone From: Zhang Rui To: Daniel Lezcano , 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 Date: Mon, 04 Jul 2022 22:14:21 +0800 In-Reply-To: <20220703183059.4133659-12-daniel.lezcano@linexp.org> References: <20220703183059.4133659-1-daniel.lezcano@linexp.org> <20220703183059.4133659-12-daniel.lezcano@linexp.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 On Sun, 2022-07-03 at 20:30 +0200, Daniel Lezcano wrote: > 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); what is the difference between of_thermal_get_ntrips/of_thermal_get_trip_points and thermal_zone_get_ntrips/thermal_zone_get_trips as introduced in this patch series? we need to remove the duplications. thanks, rui > > @@ -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; > } >