From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932314AbdJQEiG (ORCPT ); Tue, 17 Oct 2017 00:38:06 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:56753 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753083AbdJQEiE (ORCPT ); Tue, 17 Oct 2017 00:38:04 -0400 X-Google-Smtp-Source: AOwi7QASfJ0g9s02ap1gSuTgvCDtvYVZ8nu+qcyrxmieP05xetSqFqR5LAqpWzSvpmGvVgyrOy+kxg== Date: Mon, 16 Oct 2017 21:38:01 -0700 From: Eduardo Valentin To: Daniel Lezcano Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kevin.wangtao@linaro.org Subject: Re: [PATCH 22/25] thermal/drivers/hisi: Add support for multi temp threshold Message-ID: <20171017043800.GD7954@localhost.localdomain> References: <79a5f10c-0fb7-3e4f-caac-c1625904b137@linaro.org> <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> <1507658570-32675-22-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1507658570-32675-22-git-send-email-daniel.lezcano@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 10, 2017 at 08:02:47PM +0200, Daniel Lezcano wrote: > From: Kevin Wangtao > > The next patches will provide the support for the hi3660 where the temperature > sensor can have multiple alarm levels. In order to set the scene to support it, > we have to convert the current code to be able to support multiple threshold > values. > > [Daniel Lezcano: Restated the log] CHECK: Prefer kernel type 'u32' over 'uint32_t' #113: FILE: drivers/thermal/hisi_thermal.c:54: + uint32_t thres_temp[MAX_THRES_NUM]; total: 0 errors, 1 warnings, 1 checks, 67 lines checked > > Signed-off-by: Kevin Wangtao > Signed-off-by: Daniel Lezcano > --- > drivers/thermal/hisi_thermal.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c > index b5a7159..e87ca6c 100644 > --- a/drivers/thermal/hisi_thermal.c > +++ b/drivers/thermal/hisi_thermal.c > @@ -46,10 +46,12 @@ > > #define HI6220_DEFAULT_SENSOR 2 > > +#define MAX_THRES_NUM 2 > + > struct hisi_thermal_sensor { > struct thermal_zone_device *tzd; > uint32_t id; > - uint32_t thres_temp; > + uint32_t thres_temp[MAX_THRES_NUM]; > }; > > struct hisi_thermal_data { > @@ -244,7 +246,7 @@ static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data) > hi6220_thermal_set_lag(data->regs, HI6220_TEMP_LAG); > > /* enable for interrupt */ > - hi6220_thermal_alarm_set(data->regs, sensor->thres_temp); > + hi6220_thermal_alarm_set(data->regs, sensor->thres_temp[0]); > > hi6220_thermal_reset_set(data->regs, HI6220_TEMP_RESET); > > @@ -303,7 +305,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp) > *temp = data->get_temp(data); > > dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", > - sensor->id, *temp, sensor->thres_temp); > + sensor->id, *temp, sensor->thres_temp[0]); > > return 0; > } > @@ -322,16 +324,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) > > hisi_thermal_get_temp(data, &temp); > > - if (temp >= sensor->thres_temp) { > + if (temp >= sensor->thres_temp[0]) { > dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", > - temp, sensor->thres_temp); > + temp, sensor->thres_temp[0]); > > thermal_zone_device_update(data->sensor.tzd, > THERMAL_EVENT_UNSPECIFIED); > > } else { > dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", > - temp, sensor->thres_temp); > + temp, sensor->thres_temp[0]); > } > > return IRQ_HANDLED; > @@ -341,7 +343,7 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, > struct hisi_thermal_data *data, > struct hisi_thermal_sensor *sensor) > { > - int ret, i; > + int ret, i, thres_idx = 0; > const struct thermal_trip *trip; > > sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, > @@ -359,8 +361,9 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, > > for (i = 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { > if (trip[i].type == THERMAL_TRIP_PASSIVE) { > - sensor->thres_temp = trip[i].temperature; > - break; > + sensor->thres_temp[thres_idx++] = trip[i].temperature; > + if (thres_idx >= MAX_THRES_NUM) > + break; > } > } > > -- > 2.7.4 >