From patchwork Thu Jul 25 22:18:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 169754 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12182264ilk; Thu, 25 Jul 2019 15:19:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYOVMC4luHhf0/kaKzGSz9v5rmHXV3JV0+48l55uq181rsjnvG1s+i6bnf/Hazx9mBxSBn X-Received: by 2002:a63:8f55:: with SMTP id r21mr87089710pgn.318.1564093147536; Thu, 25 Jul 2019 15:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564093147; cv=none; d=google.com; s=arc-20160816; b=InIb7Dwo6TeTlwsJ1pkFfXZ7AryrHnn6mCSceLDm9lQnf9hXSFDueftTPyCa1ecU0x D64GsOyiq44BPQzkDFb2kBq+8RBjRJgWOWkV9Vw4g2+Nl3bZ1Jj46FRl9i/V23z90YEg qnpKwg6X8qzfdqIulFXpbq0kUt/i5iy+hWOVU3lOrJ8s+6aKucmjxlbI+4O7FCdSWgGh Z9uqtKT91IWvm5sJsFiT3dGJ9wbsp3a0IgBboql20kYh3qkeyzLiAd1bSpZc9FM9ofYX Us628zF0qAyVyBYyZceD6uNcPZrp9E1/YAswNXFDvixpI130qgN5HsBMYXgARyIZBEbg VMSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=T23MbWVpdj6R89qBW0TPjQAQVoCPqSBMgv5aqOKE3hE=; b=C2D56uzxNDHlnAyVVar+pQGgKfB3QygnJkARuIwJyEBIg2WsaePOX0WyMuFw/nvat0 XT6bawLwTzmf7fb9rtGJBkD/NYleG7mxA6lPg5KG1S0SOCemquqndcrspi49r7ekK6pK eSIkM0/J0d9+zYkWkC7S6lbHc3RDoRVPVGgUSvCp2HBn6aAN03nYHxD/3zMTv0c6uhX+ aGVCGCE2LhT69C3QGY9dzWnBWWWXK2sG37d49GnANwQn2usWeXEy32vzAY1gn75UWC2Z IAo8ckkKxT+SSr7Mr9uhKu7/Z1VBBYjDezYKKZ7qznpdGWWqGrvKDxV3NWJ2nuoZqdAA JCnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v6GNbodf; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si18757369pfk.197.2019.07.25.15.19.07; Thu, 25 Jul 2019 15:19:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v6GNbodf; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1726757AbfGYWTF (ORCPT + 11 others); Thu, 25 Jul 2019 18:19:05 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41006 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726844AbfGYWTC (ORCPT ); Thu, 25 Jul 2019 18:19:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id m30so23445610pff.8 for ; Thu, 25 Jul 2019 15:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=T23MbWVpdj6R89qBW0TPjQAQVoCPqSBMgv5aqOKE3hE=; b=v6GNbodfdpptvKW4rjgl7pyeu2Vt5rYIFlxde1a1VK0ABaOJD+Pa4K0wwlwE6cQMIS /GqpkruBVriaSowoJUeGSCEGNGz9KB3E2Yk9x9LA2acINMqEEc8ClEpfLDQI5IFwqgsj qQgC1+kzNIwz8GRETInJAoQunCMiYxXpTXSSqEM9H7W0LNr3j9MM5XOa4JE0vFDgRtko gsRXKcOpr3c0K/tXQPkRTRbdcWEEO8C+jHVctIAyykf/uLDlXrAKKciUVkG2x3QA1gz8 T45Umprp6Nt6hVsIEAe1enB2DwJ0T3umlNaAbuR1LHabU+5skIPhUU6rsbCp1DBa3B2f vvhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=T23MbWVpdj6R89qBW0TPjQAQVoCPqSBMgv5aqOKE3hE=; b=pdRXxRjAhLjlyTB0DsfvNAZEwCiBvPKSnNf0T7b8dgB71K6NZ7XKko0k97KU+nirPo SjkP/HzMeR7O9nQiX/bNO6gUS3huuB1tn/mPL8sXxzNPSIVhu24WKgsKJunyocRF7Ctn 4ZjG28qN9epAu+CCAMEMwVRLi/liPJuNXQpNSHeb3Ws4ZwSTC0wZ9GyXYIgP58UUBQJA +2W/RGG9L8nHU7Jwx9HWT/iXxfygWx39M0wjFZa6eMw2dGV/GOsHEoo397xUXY7TZ08V X4yzx2kegtFGoe4PJOQAdq4G+ezsjBujOaWj+6owSSrtMZHbiRCSPN7kjG6ONPUo4wXu 4rFw== X-Gm-Message-State: APjAAAWHalIhTh4V/9XAYvSfgpxFuXceP7Mc8GnM+76yTaz7vMs/eR8l 8wIb+/R4/a/8ZgbfWd8MkovRnA== X-Received: by 2002:a62:18d4:: with SMTP id 203mr19031577pfy.165.1564093141620; Thu, 25 Jul 2019 15:19:01 -0700 (PDT) Received: from localhost ([49.248.170.216]) by smtp.gmail.com with ESMTPSA id v138sm58504769pfc.15.2019.07.25.15.19.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jul 2019 15:19:01 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH 01/15] drivers: thermal: tsens: Get rid of id field in tsens_sensor Date: Fri, 26 Jul 2019 03:48:36 +0530 Message-Id: <9dc86fa912d9b6e21857598ad81ff88564468e5d.1564091601.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There are two fields - id and hw_id - to track what sensor an action was to performed on. This was because the sensors connected to a TSENS IP might not be contiguous i.e. 1, 2, 4, 5 with 3 being skipped. This causes confusion in the code which uses hw_id sometimes and id other times (tsens_get_temp, tsens_get_trend). Switch to only using the hw_id field to track the physical ID of the sensor. When we iterate through all the sensors connected to an IP block, we use an index i to loop through the list of sensors, and then return the actual hw_id that is registered on that index. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-8960.c | 4 ++-- drivers/thermal/qcom/tsens-common.c | 16 +++++++++------- drivers/thermal/qcom/tsens.c | 11 +++++------ drivers/thermal/qcom/tsens.h | 10 ++++------ 4 files changed, 20 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 8d9b721dadb6..3e1436fda1eb 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -243,11 +243,11 @@ static inline int code_to_mdegC(u32 adc_code, const struct tsens_sensor *s) return adc_code * slope + offset; } -static int get_temp_8960(struct tsens_priv *priv, int id, int *temp) +static int get_temp_8960(struct tsens_sensor *s, int *temp) { int ret; u32 code, trdy; - const struct tsens_sensor *s = &priv->sensor[id]; + struct tsens_priv *priv = s->priv; unsigned long timeout; timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 528df8801254..c037bdf92c66 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -83,11 +83,12 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } -int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) +int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) { - struct tsens_sensor *s = &priv->sensor[i]; - u32 temp_idx = LAST_TEMP_0 + s->hw_id; - u32 valid_idx = VALID_0 + s->hw_id; + struct tsens_priv *priv = s->priv; + int hw_id = s->hw_id; + u32 temp_idx = LAST_TEMP_0 + hw_id; + u32 valid_idx = VALID_0 + hw_id; u32 last_temp = 0, valid, mask; int ret; @@ -123,12 +124,13 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) return 0; } -int get_temp_common(struct tsens_priv *priv, int i, int *temp) +int get_temp_common(struct tsens_sensor *s, int *temp) { - struct tsens_sensor *s = &priv->sensor[i]; + struct tsens_priv *priv = s->priv; + int hw_id = s->hw_id; int last_temp = 0, ret; - ret = regmap_field_read(priv->rf[LAST_TEMP_0 + s->hw_id], &last_temp); + ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); if (ret) return ret; diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 0627d8615c30..6ed687a6e53c 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -14,19 +14,19 @@ static int tsens_get_temp(void *data, int *temp) { - const struct tsens_sensor *s = data; + struct tsens_sensor *s = data; struct tsens_priv *priv = s->priv; - return priv->ops->get_temp(priv, s->id, temp); + return priv->ops->get_temp(s, temp); } static int tsens_get_trend(void *data, int trip, enum thermal_trend *trend) { - const struct tsens_sensor *s = data; + struct tsens_sensor *s = data; struct tsens_priv *priv = s->priv; if (priv->ops->get_trend) - return priv->ops->get_trend(priv, s->id, trend); + return priv->ops->get_trend(s, trend); return -ENOTSUPP; } @@ -86,8 +86,7 @@ static int tsens_register(struct tsens_priv *priv) for (i = 0; i < priv->num_sensors; i++) { priv->sensor[i].priv = priv; - priv->sensor[i].id = i; - tzd = devm_thermal_zone_of_sensor_register(priv->dev, i, + tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id, &priv->sensor[i], &tsens_of_ops); if (IS_ERR(tzd)) diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 2fd94997245b..d022e726d074 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -31,7 +31,6 @@ enum tsens_ver { * @priv: tsens device instance that this sensor is connected to * @tzd: pointer to the thermal zone that this sensor is in * @offset: offset of temperature adjustment curve - * @id: Sensor ID * @hw_id: HW ID can be used in case of platform-specific IDs * @slope: slope of temperature adjustment curve * @status: 8960-specific variable to track 8960 and 8660 status register offset @@ -40,7 +39,6 @@ struct tsens_sensor { struct tsens_priv *priv; struct thermal_zone_device *tzd; int offset; - unsigned int id; unsigned int hw_id; int slope; u32 status; @@ -61,13 +59,13 @@ struct tsens_ops { /* mandatory callbacks */ int (*init)(struct tsens_priv *priv); int (*calibrate)(struct tsens_priv *priv); - int (*get_temp)(struct tsens_priv *priv, int i, int *temp); + int (*get_temp)(struct tsens_sensor *s, int *temp); /* optional callbacks */ int (*enable)(struct tsens_priv *priv, int i); void (*disable)(struct tsens_priv *priv); int (*suspend)(struct tsens_priv *priv); int (*resume)(struct tsens_priv *priv); - int (*get_trend)(struct tsens_priv *priv, int i, enum thermal_trend *trend); + int (*get_trend)(struct tsens_sensor *s, enum thermal_trend *trend); }; #define REG_FIELD_FOR_EACH_SENSOR11(_name, _offset, _startbit, _stopbit) \ @@ -313,8 +311,8 @@ struct tsens_priv { char *qfprom_read(struct device *dev, const char *cname); void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 mode); int init_common(struct tsens_priv *priv); -int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp); -int get_temp_common(struct tsens_priv *priv, int i, int *temp); +int get_temp_tsens_valid(struct tsens_sensor *s, int *temp); +int get_temp_common(struct tsens_sensor *s, int *temp); /* TSENS target */ extern const struct tsens_plat_data data_8960; From patchwork Thu Jul 25 22:18:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 169753 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12182268ilk; Thu, 25 Jul 2019 15:19:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw700Q6ltyM1fKUA3V2v3/FoXwAq36Q1/ChBm5u6KxOyaGrJhH/Zo0L/az16207N3mUWzS6 X-Received: by 2002:a63:8a43:: with SMTP id y64mr87421172pgd.104.1564093147906; Thu, 25 Jul 2019 15:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564093147; cv=none; d=google.com; s=arc-20160816; b=FHK3OfA3iAybLZrq63MaSzSM9aN4L2/Xyib/JZGqsL1bAATKpEJKWWsZznXx8AQ90f ou1we6vjhjaPnvL8UawOJkzmGX4Sv4ZxEsKQ1o5e/I56ue9uRsEiSUoBavYGCOh8G93F Wwnm3JnUQ82uG5CgFn9FgL4T9ZsJqFtiNDp380VGPHlrb7ohFyDfRrbpTFNNSn/6ODBk oSdXL7aHukgMoyKcSY4yMPPurNyNNNwCEa3kRfVO5EShMp1gTtEDDT0TTw79tPpSIbUJ I/OLdWPuZ4byzkRtWcX0dlL6LvBLXr81imdltApozbg9UOvSMkAfilbk/ysRn5OyYoUm 8NZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=xgmSGdIDu0v4P5hRNEQENmsRjAPMzQvZ2XtfdY307wY=; b=ki3AylDAGNu8TZ0CRC1vtCwOIZiwyxjNhVlLYhHvoWhn/wC1gWfknb/+rVJpJL29pX YvfxTfsk8FBLMMGipgXiW6v41DcSlN4SlgJvGMNKawhHzexmkYAM9gb4fUi9oJb2Kvot 5D3mXldpcYz/JVi3XeQCOty7lDnfElU93wIhf9XjpC5T9bmYDM3T+Q0mA4RnIkrvTcnb oM9Hgrt+fFGes5/n50ya45SelZhm2ejMY+uCyaCjWc60Pj38XXbt8ZgKamCk6Yjy58Y+ cAjVPEW1X8teHrPC/tlsbXT7D4zfQ20QMiLr0ryzNG4j++eXVCzqQGhPpu5tznK3h9RB U0/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bjUFoDkw; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si18757369pfk.197.2019.07.25.15.19.07; Thu, 25 Jul 2019 15:19:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bjUFoDkw; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1726906AbfGYWTG (ORCPT + 11 others); Thu, 25 Jul 2019 18:19:06 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39150 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbfGYWTG (ORCPT ); Thu, 25 Jul 2019 18:19:06 -0400 Received: by mail-pf1-f194.google.com with SMTP id f17so19440651pfn.6 for ; Thu, 25 Jul 2019 15:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=xgmSGdIDu0v4P5hRNEQENmsRjAPMzQvZ2XtfdY307wY=; b=bjUFoDkwwtUAE9rjXGY/yoZmv4SUpw3zs28N86CLMnkSz3U+2bn3+TLJS+4walCtmB PVQpuIprCpvqgGD1hWDh4l6z7HtvdCGuNaShzu+KiztS8VV1ubwC6cMtXT9B8gqsYZpA sP3T9ywIr4mAS+PZ98Ckn5ZGC1sZ/ATKTqJeDkZ6+0YlEmEEbN14p+4uUcVmseHdfP5s DHmjxk72WKm+GFVr/biN9GvWyyvLqP7zztIloxDv1rrIieRYpNA9mjJheq0ihmCV9jNW CXiQyERh4pgRHH5XRbCVnmwwLYv4sqP3LBIHGx5fH3LcaAWNjeAgBfH788SsDqKtqjyb eLyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=xgmSGdIDu0v4P5hRNEQENmsRjAPMzQvZ2XtfdY307wY=; b=SqJ6HQELJrbBHx4eP5MNW3VusdtiRM0PL7hYer6mBYXiH5QY7q3VKVJTrj+WtCcMNZ Cy7VPwmzcA/Pf7qfTIp0mA2em2jtom383MaYvlJjAQ7lMi9hUo8fuq6a0FzIU8SWqiUW doELw+vuYsK5rqtiX7VFtG6m4cqKISbid1jILkMXzKiYedL6qkaJbiJ9/XsxBKBpOl7S GgR9GhUoidihjRNpeGWJXDLOxgn9t1uZy/axSC88KjDnqgaJqKncTa351g4DNqzp4yOn qYwm+XAJ/ufRH+gT6mS4/ZWSik4YNcbgqWdjoBU65L5a/wJsqP4rE+l6kk7fiM7MLT1Z czbg== X-Gm-Message-State: APjAAAV+n06sD3JLbP+yortCHs84du5Hx1WPc+RmxblZNN0dLJukXMhf Z5ROJeqOhy4aDWmLmQE7T9IXujac9rUVOA== X-Received: by 2002:a62:16:: with SMTP id 22mr19525541pfa.151.1564093145400; Thu, 25 Jul 2019 15:19:05 -0700 (PDT) Received: from localhost ([49.248.170.216]) by smtp.gmail.com with ESMTPSA id 21sm46989303pjh.25.2019.07.25.15.19.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jul 2019 15:19:04 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH 02/15] drivers: thermal: tsens: Simplify code flow in tsens_probe Date: Fri, 26 Jul 2019 03:48:37 +0530 Message-Id: <355cd15c91e02716140d7114fd403559487b66b6.1564091601.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Move platform_set_drvdata up to avoid an extra 'if (ret)' check after the call to tsens_register. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 6ed687a6e53c..542a7f8c3d96 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -149,6 +149,8 @@ static int tsens_probe(struct platform_device *pdev) priv->feat = data->feat; priv->fields = data->fields; + platform_set_drvdata(pdev, priv); + if (!priv->ops || !priv->ops->init || !priv->ops->get_temp) return -EINVAL; @@ -167,11 +169,7 @@ static int tsens_probe(struct platform_device *pdev) } } - ret = tsens_register(priv); - - platform_set_drvdata(pdev, priv); - - return ret; + return tsens_register(priv); } static int tsens_remove(struct platform_device *pdev) From patchwork Thu Jul 25 22:18:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 169755 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12182341ilk; Thu, 25 Jul 2019 15:19:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV749onlrDHbyQX/JP5ZMHkLx8rlc0PGfKRzipEs0UkfYf7Qr2hWrV54bBEJIbP7lZ0irn X-Received: by 2002:a17:90a:cb01:: with SMTP id z1mr93925698pjt.93.1564093153262; Thu, 25 Jul 2019 15:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564093153; cv=none; d=google.com; s=arc-20160816; b=GtIeZ/HKZTm2vtc7f58gribwsdiZzAaMTP4TjfGfGNvGG39KmoG7Fa1h5bFcbrB16n 66sDjCCAOt4qIaL6Na+ZnQIfZc2t9vpgU2PZQ/eX8DPpLsNQ5SYhftwmRcDkNhS20Sj0 9XuvsV2rpc2Z9CNYrS8fO/Y0dzjHSU+ySp9zuqqEXO5XKqHwHySTdc1Nu7EeIZSrfU54 VptfbdJgdtd+MAfpZQlTXopJY+EBRJGGMVyGYPwTKJQUauxGzP36GOKUm72l5Wm7VR1H CptVFWW6hzoVudmgKs8gxtdqFX0n76pCY5oE3KjBIN/ufEbDwg6FVHXXH9u0SMgVVzrN 2ChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=fkQr8KOslonbKlTQUlxHcW0SDWSAq6G6dYt76az0Euo=; b=zUv1aiR1Lr/nxRvOdo02Pvgc64OfDA13IHsG+O4p3OcawpkQm/grQfJZatR/V4sDu8 k5YcysGjz5qrzL49ZipNKVCa55Yjax0mNW2UewlfUgqu0HXmpoqnkx+6M0GkUUpM1r9N QZjc+cq2CsNSKUy/7C+RM9RIUp99Gad6AQ3iGtrb7Iz4f7QwooxSoMnW67dUEvcTY5D1 gf6jchlPkXYHYOuKH7zIG/tIdN5MYM6D+sbAwp2uhLeNZ24Si7cH7lEsMwGklcQeHNke rqz1LDXZfTJ+8wG97SII/pyjNeWj7+M8NSJXZHJ2u8pjfDJKUckslns//Zyk+FaMJWd9 oPJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BxTd+Mq8; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t70si22012880pgd.573.2019.07.25.15.19.13; Thu, 25 Jul 2019 15:19:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BxTd+Mq8; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1726693AbfGYWTM (ORCPT + 11 others); Thu, 25 Jul 2019 18:19:12 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44844 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbfGYWTK (ORCPT ); Thu, 25 Jul 2019 18:19:10 -0400 Received: by mail-pl1-f193.google.com with SMTP id t14so23898769plr.11 for ; Thu, 25 Jul 2019 15:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=fkQr8KOslonbKlTQUlxHcW0SDWSAq6G6dYt76az0Euo=; b=BxTd+Mq8DDlvZfySa7oB1wsL32KYMn9TQUJjJCdGruGdTTKSFUhdFmWcGZAj3MzgjL uH/Pywr11SI12qWyTVX/FDB6Vo2FGRH8GmXCO7AFjlOGjvk8TC2ML+TbSoVo2nFXpzEh veHGaw9P3N9+zOM86eHdLvF+VdVdnf96Y9z1ebmDS/pXzDO5WCrNREp4uyqhRty3WCpm Zn/SEP/gZnCzSs34VF1P2XZKZCH+oKWJGrQE8fmtax3pbeQwzQrEdOgAff/xD2rdotdH mNjPx0OGKbl8rgSs1lbMifu+H4kO/m0dbu0Yl606CXgw5/WxwihNO99yjIS2z3tu5DTg J9Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=fkQr8KOslonbKlTQUlxHcW0SDWSAq6G6dYt76az0Euo=; b=fFoivkBOfQEBHDDvRuhWNE8elnDtgCCNSOgbDP+ZI44PY5sHn//wHGchP57pfFNNml 1uj9k/llmq5VlfQNtIU9+c7gx900DxFB1BoSV3DNHeKLwfY3JqI4BD6vwKuZgryb3tiI oqub4JRPHI/Hni/cOdgigxOv2rKMLbk0qQKn03T1r6BEbLltLd22lVjI1f1uzzsgSF2a 1tCssbdHgWM11pCehP7ujUCRvxrZGqrVj6rKqHcXqAFkXrHjzOOqV+zYOxZSqf1M1FfT 1t1x8xdEcw8V7LkWf+19l3V9ImB7eS4t+IOc0FhVEWJxCPcrV3D9oNTXatWvvJZxcxx0 ppaQ== X-Gm-Message-State: APjAAAUl2tF3msnbd2oR4pI5zHZ+xils63HoqlvBAHBrfxAtNAk/cxTf iUeW0QJ7AHtFAq2mcRgHmXTKsQ== X-Received: by 2002:a17:902:e282:: with SMTP id cf2mr94194405plb.301.1564093149644; Thu, 25 Jul 2019 15:19:09 -0700 (PDT) Received: from localhost ([49.248.170.216]) by smtp.gmail.com with ESMTPSA id r12sm28050317pgb.73.2019.07.25.15.19.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jul 2019 15:19:09 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH 03/15] drivers: thermal: tsens: Add __func__ identifier to debug statements Date: Fri, 26 Jul 2019 03:48:38 +0530 Message-Id: <0f2027f458f8b7f17acb024cf47082052f416805.1564091601.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Printing the function name when enabling debugging makes logs easier to read. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 8 ++++---- drivers/thermal/qcom/tsens.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index c037bdf92c66..7437bfe196e5 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -42,8 +42,8 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1, for (i = 0; i < priv->num_sensors; i++) { dev_dbg(priv->dev, - "sensor%d - data_point1:%#x data_point2:%#x\n", - i, p1[i], p2[i]); + "%s: sensor%d - data_point1:%#x data_point2:%#x\n", + __func__, i, p1[i], p2[i]); priv->sensor[i].slope = SLOPE_DEFAULT; if (mode == TWO_PT_CALIB) { @@ -60,7 +60,7 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1, priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) - (CAL_DEGC_PT1 * priv->sensor[i].slope); - dev_dbg(priv->dev, "offset:%d\n", priv->sensor[i].offset); + dev_dbg(priv->dev, "%s: offset:%d\n", __func__, priv->sensor[i].offset); } } @@ -209,7 +209,7 @@ int __init init_common(struct tsens_priv *priv) if (ret) goto err_put_device; if (!enabled) { - dev_err(dev, "tsens device is not enabled\n"); + dev_err(dev, "%s: device not enabled\n", __func__); ret = -ENODEV; goto err_put_device; } diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 542a7f8c3d96..06c6bbd69a1a 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -127,7 +127,7 @@ static int tsens_probe(struct platform_device *pdev) of_property_read_u32(np, "#qcom,sensors", &num_sensors); if (num_sensors <= 0) { - dev_err(dev, "invalid number of sensors\n"); + dev_err(dev, "%s: invalid number of sensors\n", __func__); return -EINVAL; } @@ -156,7 +156,7 @@ static int tsens_probe(struct platform_device *pdev) ret = priv->ops->init(priv); if (ret < 0) { - dev_err(dev, "tsens init failed\n"); + dev_err(dev, "%s: init failed\n", __func__); return ret; } @@ -164,7 +164,7 @@ static int tsens_probe(struct platform_device *pdev) ret = priv->ops->calibrate(priv); if (ret < 0) { if (ret != -EPROBE_DEFER) - dev_err(dev, "tsens calibration failed\n"); + dev_err(dev, "%s: calibration failed\n", __func__); return ret; } } From patchwork Thu Jul 25 22:18:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 169765 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12182833ilk; Thu, 25 Jul 2019 15:19:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcEu5UbWf5MXHCxT1Ev3GtBYb6erPtMMAuDqMmlxvZPsgG961uBwjxftIIFo6luqQt+Rq4 X-Received: by 2002:a17:90a:a00d:: with SMTP id q13mr93180399pjp.80.1564093191017; Thu, 25 Jul 2019 15:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564093191; cv=none; d=google.com; s=arc-20160816; b=cbgCZbhDWtaUXsfh7qwFXPChq2IaY3DQpQuEwCuHVmDSKUfHA2ToM//1WnEHGoueAQ POjEpnJbvoJsMD7Ag7nvFsp1oTi/26evmIrDnwS7Ov6Qe9lPP9hcBJYRmdA3qqBSM1if +iJDxnA/syHt26MMzkYZysBN/A/9iBSufny5W808I3XDOWemZPgaGWqOS/Cz4VO86BIr wHZTiMe+9hU7NCcRdIgN2xSEO4VE4vstrlabEEygPuXjp5oRP2MzYhNcbKMWad0t83go XYf9jnQYVeVSNq3xgGpLZDbLCXAnmgghrl8Xllyn8kUV5W2w2fOqv/DRgQt6sOORd1BT 12Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=/nFT7aY+11WI394WPKOgkqXda4OYZ0oDO3kCARFs51M=; b=Wtc+GokCdBPNOBJkl6x/fEpoN2MmGagBQf6bH16uyPAVjePt1kxiA1l6XJ8nD/pgHW k5WYfYUfTvrguLimXYjnjkySLoy4+60qV+S96cOm/UqskpEnPGAP+xMKO9cuIOg+yMUd oFebdjgYDp1w1gw6JJyLqJlmf6GY3t4QfOVm/LJpzfm3WKQUBMJtEOpv+uZKZlkF3mMw Bv2ZJG6YX+dowsa00TwqMHIwmSpqqrw4AAO+wCS6bER3qM9w7kgNbCelwCGQqS9dmksP HKAQi1ug4N1nCSVbnzZPqNSx+alEzokYjFLQhsK2S+l2IBfMquGeJUHdqw8/J77/uRQG NoeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GWrdhk3b; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si16795514plx.412.2019.07.25.15.19.50; Thu, 25 Jul 2019 15:19:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GWrdhk3b; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1727328AbfGYWTt (ORCPT + 11 others); Thu, 25 Jul 2019 18:19:49 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35644 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727303AbfGYWTt (ORCPT ); Thu, 25 Jul 2019 18:19:49 -0400 Received: by mail-pg1-f193.google.com with SMTP id s1so17405063pgr.2 for ; Thu, 25 Jul 2019 15:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/nFT7aY+11WI394WPKOgkqXda4OYZ0oDO3kCARFs51M=; b=GWrdhk3bhTqlZTC/WMAEHdZVfSr4B1Pd39mel3VbpvzuIB7xxk5KSQqNv1k/8hPCJx 3hXikhSNXs+PC2xSDqGk7UIQSH3UikR06q3iKd3D7TufSYX1didtRDvQxH/u5NqzZJJF hUDdCjvIVyTruCcyBN11bd2QNuq2y68AEyi9N7mcuCVo11vSGFhOedZ6nllosGplJrR+ ikyvS5nf/xhL4TjFRg/6W4gmirbAXLWP2lk8Ex8HDBje033ejKifqvWQuqQrjIIsnPbr SDJGnuVk6ZcBawmxMIDMv5n3Y0870eXl03wLInNcxDa4wXaG6bdgCpiBjyoo/a4sTo+U 3QLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/nFT7aY+11WI394WPKOgkqXda4OYZ0oDO3kCARFs51M=; b=Ir6Xvcj4UaQLt0DcLgL2Dj4VOJSK2DDnQVk121wYTjsdmUtjii4fyCaRkc9XW33Peb FrllsS7rD9Ka6sP3KOKIz2GPScXR7apkWKnJ6n0ZaaGh90T7ZgWQWMFTzocth0P8yyX9 FXsgUi1hC1sKZ05pMYx5Epw/+iyo1sVVDVSwRn6X0WhEFLlDxIUHVZkfvfyAmZm0iqq+ /5ao/fwCiC4NgHXuFWkfGkG/Xf0suKevHInqIZttjCwhdglo32nzZhCG2CrxdQIw2u4a Yu0gCd3WbQ7m/e6ZvrFqZFAanCqO2PqbpseuSUYaQ+PB7VK5qbKsdxSMFPLRSU2uBGZ6 Tw3Q== X-Gm-Message-State: APjAAAXMjMq/lv9fcVCKcB16eWwCtCoNJQWZ/uyWrJPEksl9/Z2IJ1dx V5sDKpFxJekDkNzvBCp/PSTBQw== X-Received: by 2002:aa7:83ce:: with SMTP id j14mr18579789pfn.55.1564093188189; Thu, 25 Jul 2019 15:19:48 -0700 (PDT) Received: from localhost ([49.248.170.216]) by smtp.gmail.com with ESMTPSA id z6sm21560243pgk.18.2019.07.25.15.19.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jul 2019 15:19:47 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH 14/15] drivers: thermal: tsens: Create function to return sign-extended temperature Date: Fri, 26 Jul 2019 03:48:49 +0530 Message-Id: <07de61a57cf2362169d3b128405d7305eb20785f.1564091601.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Hide the details of how to convert values read from TSENS HW to mCelsius behind a function. All versions of the IP can be supported as a result. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 7ab2e740a1da..13a875b99094 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -84,13 +84,35 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } +/** + * tsens_hw_to_mC - Return properly sign extended temperature in mCelsius, + * whether in ADC code or deciCelsius depending on IP version. + * This function handles the different widths of the signed integer across IPs. + */ +static int tsens_hw_to_mC(char *str, struct tsens_sensor *s, int field, int temp) +{ + struct tsens_priv *priv = s->priv; + u32 mask; + + if (priv->feat->adc) { + /* Convert temperature from ADC code to milliCelsius */ + return code_to_degc(temp, s) * 1000; + } else { + mask = GENMASK(priv->fields[field].msb, + priv->fields[field].lsb) >> priv->fields[field].lsb; + dev_dbg(priv->dev, "%s: mask: %d\n", str, fls(mask)); + /* Convert temperature from deciCelsius to milliCelsius */ + return sign_extend32(temp, fls(mask) - 1) * 100; + } +} + int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) { struct tsens_priv *priv = s->priv; int hw_id = s->hw_id; u32 temp_idx = LAST_TEMP_0 + hw_id; u32 valid_idx = VALID_0 + hw_id; - u32 last_temp = 0, valid, mask; + u32 last_temp = 0, valid; int ret; ret = regmap_field_read(priv->rf[valid_idx], &valid); @@ -112,15 +134,7 @@ int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) if (ret) return ret; - if (priv->feat->adc) { - /* Convert temperature from ADC code to milliCelsius */ - *temp = code_to_degc(last_temp, s) * 1000; - } else { - mask = GENMASK(priv->fields[LAST_TEMP_0].msb, - priv->fields[LAST_TEMP_0].lsb); - /* Convert temperature from deciCelsius to milliCelsius */ - *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; - } + *temp = tsens_hw_to_mC("get_temp", s, LAST_TEMP_0, last_temp); return 0; }