From patchwork Fri Sep 20 21:52:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 174156 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3031563ill; Fri, 20 Sep 2019 14:52:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqziqjtSYWyBQnQIEb5sroaR59OmXBL5Cqif2FSS5AKxo+8l6FcEkCfhJPeJ76AhpeQg8MP6 X-Received: by 2002:a17:906:3281:: with SMTP id 1mr2876707ejw.181.1569016365872; Fri, 20 Sep 2019 14:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569016365; cv=none; d=google.com; s=arc-20160816; b=PX7iBx7QPi7utHwDD3DQ7AwRB6UG1sOGsQ0dbQ7jJp9tfJVtybb4po0iemejaI/sCi cciqL4irhe80fAl2fWbAspFtMfeDZ0SFz5VbqVm624qhOmXQYIjvCMo++wdcH9RuERIT 2dY92+iOUd0exukqw2ocfB2EiQxRl1LiQD6AUX7ranUQOAlKb29JWj8/iy0zqf85SZwZ 3+SmhiuXkSZrymfyoVqoYVH5aAlzTR9aKlXwA4Ib+WP7SnkY2oUqlZPQllW1lr6z7+B1 D7pNbvK/xn4xkF1ze6OVBieN+ZilIeGun1oUJ9kTKPAyS3ApWR2G4v+PRuqBqlT0YWVj MUHw== 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=TYv2LRSteD77Ft4oMs2p5uadS2z0S5817oCjy76gUik=; b=yeodrPcY5k8+7xXIVuzA5uqRA5TRkZODugdUKmuncVkd6pCdroZ1VlOTBR2kpAHCIk 0x31c51n9D5qDzgo0FYpSlrV2bexuuSDHW4+b+tWq4hAu/jN7nc1Spr6F0Pov/hzvrBY fW/FJYVa588X2pXaiBPV9q1G00WJFh6IvESf1RAR6jbrngKRHofE9LwH24KL9+ZzD95U Y+B0fhFlwfq75kkrL42QO8u+kG1Vs0RACL0XG0lf0vG6xqshSx41By0nbs90ClH8qDly tWdovZrVJAJX69z+fo1WHqBAIbYK6xZb3ZRO0n/tNC5sl+WmSBFfkbPBUSU1/UKBo8VI loTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QQQDKExF; 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 e47si2295419ede.325.2019.09.20.14.52.45; Fri, 20 Sep 2019 14:52:45 -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=QQQDKExF; 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 S1727012AbfITVwo (ORCPT + 11 others); Fri, 20 Sep 2019 17:52:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42357 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726681AbfITVwn (ORCPT ); Fri, 20 Sep 2019 17:52:43 -0400 Received: by mail-pf1-f193.google.com with SMTP id q12so5387018pff.9 for ; Fri, 20 Sep 2019 14:52:43 -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=TYv2LRSteD77Ft4oMs2p5uadS2z0S5817oCjy76gUik=; b=QQQDKExFBGJZ564RhavJeD1jlNxhJW9kC+6kjUlmOarvXBMvhCqCzV2v6WRLbYIxAP Kjl4ke0F7MUhFYcQ3DGFKOaOY+9DqJr2PNVbmt1eyb5dCRBGDQAMBlNzNPlt/VIelb2f 3rp4EUiTznbBjwsbtIdbUGKyxEY/AT60ju7ETukuvipp2pMFniRyzsGgPk+plGFamx52 V7LGMCJosaybcOfdhut7ELEpPxN3ktzVcntuzVz9ugtyWBLqa6uiQlNMxH0vjFJ7YXov pLI3E9FOYU8l9IqMoy0S7RSYBSumMS/HkBOxG76/2QXLmFFOGe9+EQ1luzlWeg2T8tQT TmsA== 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=TYv2LRSteD77Ft4oMs2p5uadS2z0S5817oCjy76gUik=; b=bNHh2DhYQgm5QNwoy2QwLGTBmx0GP/fwsRhp/CPz+00wrrwd6wdTX0DchlUztQpziP kxOFkjKozikJpm8FFkhYZ0eQ6xjFYNADXP8BzWHAhQMHdc67V+MgugTjpuwTcyxXwXlW h8yZBO8mD+8Gc4sKLwQ/UtGK0tD+hG3XjvxfIkaPaRuIOQM10hA0xZrQEHdMnlw2RAgo 3ApkVkPfB7X6v0D+alIADMVJxl/IKZiDEnn2mzWaRgcTKsz2t65OPO5JKOnRhOG5zrWw 2mYgwDtw3FIJBN4ZTon8OrKuwoep9/yyaJu/EA127rnEj6T6VEH032pUY3WEbpuQM8RT vSfA== X-Gm-Message-State: APjAAAWfXOCv8U9FCRWc6PdXwjqRUwA4qVEt93kRIOhhQKHp+50zXVo4 EiyOZlKQJVXAINhLqcM6SckEug== X-Received: by 2002:a65:5a84:: with SMTP id c4mr17176432pgt.261.1569016362345; Fri, 20 Sep 2019 14:52:42 -0700 (PDT) Received: from localhost (wsip-98-175-107-49.sd.sd.cox.net. [98.175.107.49]) by smtp.gmail.com with ESMTPSA id p20sm2827072pgj.47.2019.09.20.14.52.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Sep 2019 14:52:41 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v4 01/15] drivers: thermal: tsens: Get rid of id field in tsens_sensor Date: Fri, 20 Sep 2019 14:52:16 -0700 Message-Id: <0ada60b1b216346e3e9e2429af8c2b7c9901c938.1569015835.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 Reviewed-by: Stephen Boyd Reviewed-by: Daniel Lezcano --- 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 Fri Sep 20 21:52:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 174157 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3031643ill; Fri, 20 Sep 2019 14:52:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgF2RlNCugyzt8j5xWkYoQ/clSTE5F7JILs3C3LDF5F80GYUlhChws5iLlh085XeHvhPHK X-Received: by 2002:a05:6402:696:: with SMTP id f22mr22477023edy.216.1569016370169; Fri, 20 Sep 2019 14:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569016370; cv=none; d=google.com; s=arc-20160816; b=HKReDuiSISMciSBUbugJqH1NJ9FFIEkFNztwg4TIJNGfMAegovyuL417JBvNutVvRf davu5JrFzKer1CcddSXDng4wTX5LOM7BwsUaLxQpOEOIVKorNcBEYOolg+rxgYj7PT7f mIA/sE53gnLT++GnNMG3uUy1Tb520INDaKIKGlokKervIyBxJ1mMW9x8UsLqKNRK1iHE ZopJ27HGRKq7HuNqPJyCIvOzJpg4DsvbqDZJX66oopY8Kz8LOprkR0bsDW4USxUWVI1G 3JYP3CGWSK6i+Lnohm8LWChXOhAKEX7wgjaSW/qjviqzM9fHTZldLKqgFRStmQ9e/6AM X5YQ== 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=4RhmNFrAjG8zCFd7O6KRoEzlzkP2xNrQ5XZHUG6WYMo=; b=rgxAsmamrP/1FywMDc4JQzF0Q+u0H+PkQ5h0OpTIvkGn7yRejLDp3J4J20gli5ovZY yH3vlqCWHtFGsGb21+57NEvnAqvB1pTIkkHhiKKAP8T13Cn5bvoIUbp8BaibardKXrmy 30ZDoIdQqpprrcFlcwjXbLhsejPZakh9hbozPy2FKVuREdBViZl2FHFQgedgg/+eaJ3f 6unwxqra2/y86aSGDaJdzRdRLQJs1+DqHk0aH0W4KcEVF/d6dMyOC40xHgSGuhMgKMKT q2vjARimC2NtP4CO97hxUXVBfv9LcLjNL9hcqtrQ2AQ6IyggMWE3wI0fgUyJY8mse4KS hTAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r+t6NZQ4; 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 d17si2225527eda.213.2019.09.20.14.52.50; Fri, 20 Sep 2019 14:52:50 -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=r+t6NZQ4; 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 S1727500AbfITVws (ORCPT + 11 others); Fri, 20 Sep 2019 17:52:48 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36604 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbfITVwr (ORCPT ); Fri, 20 Sep 2019 17:52:47 -0400 Received: by mail-pg1-f196.google.com with SMTP id h17so2027023pgb.3 for ; Fri, 20 Sep 2019 14:52:47 -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=4RhmNFrAjG8zCFd7O6KRoEzlzkP2xNrQ5XZHUG6WYMo=; b=r+t6NZQ4YCr3fX3XKm0sA+keyVNFZYkHuIoXQ1qZcmVHfcxF+mZCfCrEV7WaEMHvU6 ZpPYiz6N65E2lKZkGVlZT2tMfvvuD9reA4uDlvVXJsQ56iCvfS9mUXkf3hQF98FW6K9D 7C85yko7Ix+8mjJFLNXfXwtxTiK5hyDxJH1tnDa69ouo8MSkCedw2uDHWqjUsLu/j5qv 8Umx1z3Qam7igJcaOv95kEQgfH0QJfL1IiJbtM8gxHrgvCkwKpzb3Ne4uN+dDOd6Nzhy 8BjaDk98pAY+gYv5pKJxgLdqVdwGQ4E/CP337zXTilxWSS6sdxKuDLl5023hCvUXh1NU XkaQ== 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=4RhmNFrAjG8zCFd7O6KRoEzlzkP2xNrQ5XZHUG6WYMo=; b=B0Ldv12zRhir1EhkSgpbWnTfIPAXjmusFPISTiRM9pNwRYq1Ab3utuTx/yiB9puXpL IH3q1vwuE3apwaTYQKbznU1Ff3fnJ2YAgpWDH5EOxTChQALKdcE1zqkBW/J5yiO2rpZ6 ca7YepHecW/Si3UhO+cVu5cNrt7NTwKonIKozzn2V+diEH5Igz2SoFycaBBKf3jIbjm8 ln2DG0dyttgPVQu13RiS3MeWpOE950Zi+A6/cZFJaFfPF4cTrclt416HQ+fZzY5C75wX RnHr69IeyTKKIzuTOz+SvU0AW/Saq+c2Y7lHS96gP5pJWg8K7kYur/+tST/8/Wm9Feg5 Zt0Q== X-Gm-Message-State: APjAAAX4VDZbkZsISg5pcwTqKa09Bep6rL7cIHZ6vcGWhNGoPHWREfkB LXypmhnIqd92JmldcMbQwwztcA== X-Received: by 2002:a63:4e02:: with SMTP id c2mr1049906pgb.339.1569016367039; Fri, 20 Sep 2019 14:52:47 -0700 (PDT) Received: from localhost (wsip-98-175-107-49.sd.sd.cox.net. [98.175.107.49]) by smtp.gmail.com with ESMTPSA id f18sm2960808pgf.58.2019.09.20.14.52.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Sep 2019 14:52:46 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v4 03/15] drivers: thermal: tsens: Add __func__ identifier to debug statements Date: Fri, 20 Sep 2019 14:52:18 -0700 Message-Id: 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 Reviewed-by: Stephen Boyd Reviewed-by: Daniel Lezcano --- 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 Fri Sep 20 21:52:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 174166 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3032074ill; Fri, 20 Sep 2019 14:53:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl0XbeUgMcliwRa2xRomemVXN5YwzSLtI5UFlLy+j/q2hW+TxkaQ9K2S2icSew7AbOax6o X-Received: by 2002:a50:ed8e:: with SMTP id h14mr14542134edr.69.1569016393836; Fri, 20 Sep 2019 14:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569016393; cv=none; d=google.com; s=arc-20160816; b=0vXE3hjBXNZyBEz5G3txxWdG21Wx2gr6VwOnz4TbwhARgLNGFSKXKRH12ZE0apgxgp 4qjB7dJ2h5oryYUG8csrO1AESomoD11A1PoD6gNjPG6CH8aFZ3e7o6i9t+ym6MJMv8QB o4opu4DbL7cZxhlh1Pm3xDdC91dlYxlvMrVlEDG4Lii2/pcMfvjh5pPeEXq+7xKVUoZ1 ZnPHz5okS5f3evDrYkAdJFAa/bxg8RrRJEj4Du6g+bezwTwl/8Wl3pGEDP9+gIUJCJug SWI/0ySp1L2kRNfvZtSPCW4e+WCxiCQlFAMHBFuvC3sRbGnr/jT5uWCK7ajLDUNH8hAL MEJw== 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=3XLPlhPImWAomUfs/g8BXhfm3lVXoZB+dL/zQw9KVyY=; b=YL6q2JVUBbo0fJpAfIZIPHfIu49FMijwp5VEsxh+fXYhHWPCXDnuGIE5VtAYiXCBBS ctfCDm3MMfzwEIMRx/xhanAZmP/AXGOrGBYrgAqHmr5GlDwEg/bJPjT23DU+9Ks/CF+K 1syAWBIotSQ/vCDJD1+Fkp8VI3nJLmHdEZtFls7LZyR99IUY0x/sB+YwhzZh+9sIld60 QOeXRbywndzcXM5AO/GEoHQzyEcgnU9ldH+f4dFTMzBQSl8HMLvJ7JkFom4YqRPaHB88 Qyxgtjq1sceA3THDpyjC1PyxntNsXCiK0gZRhNCzJn/NPn2aCsBcNiYirIABS31rrmLo s6zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lEv2wwv0; 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 y1si1783567ejr.272.2019.09.20.14.53.13; Fri, 20 Sep 2019 14:53: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=lEv2wwv0; 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 S1729839AbfITVxM (ORCPT + 11 others); Fri, 20 Sep 2019 17:53:12 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33001 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730305AbfITVxM (ORCPT ); Fri, 20 Sep 2019 17:53:12 -0400 Received: by mail-pl1-f195.google.com with SMTP id d22so2489444pls.0 for ; Fri, 20 Sep 2019 14:53:11 -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=3XLPlhPImWAomUfs/g8BXhfm3lVXoZB+dL/zQw9KVyY=; b=lEv2wwv0SVuY/tTqDvXJSzksXwIRavTm9n2Rm3hSLNHJUGWIlejeRUEPY6e7vxqoTO QzS1uexKLsb/OFZ4LMMCx+wOmVjSQSKugPd55NX+3OIbRWvhfwfuMGqPxZH/7toTIDLY 9aIApMHudMQPQuRIAJB1bQAlQ5w6wnBBFnTo5lRViTCi6DbPEP2j7csIdp/myh69+iP0 3lQytGe46/oPFUcNaASXHAf4K3fYYaoA/Q/25txOFfi5I/WqoOXeaZ8vWk2MAkxpKvTr ob0tfgetkAZKjhxdJv3AAoGj9UF/Mew8l1Ilf7lv+UXuOXuAcJZTXAA3ugSTDvoVLIcq TjQA== 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=3XLPlhPImWAomUfs/g8BXhfm3lVXoZB+dL/zQw9KVyY=; b=tZXMscAamPE/vgWFB6uP4G0JH3guYgVuMIx1FN6zp4vQrLCpwZHTMPHyICgpczQSGp L12sa6M/lD8O5CI0ivOCgnuCETv5yGRzNAyiUsivs1/kriKzqYoEsHW5BpdlUA2wQG/7 Dy+a7gSMNAThTL1Yyg4qgY6LCN/TlHnOXuq6+a5du94OOeRFO9402VhbxwUZ86DSepvx DGfcv4NnXROFALRj2CmU8AoyEfkc5uee+URqjRH31rZuc71O1Fa60sGa+tYyYaVQEqNY xZ37UcVfAcSbtSPIiZxfgt1N2CYUPAImqk0MCNWy/GO2UCA8jyHwkp3/iPwhPrAUUL5O tPWg== X-Gm-Message-State: APjAAAUOJX6bfrlaUYGeWYrO/DDcUaX6mR1TR7/0NSIl1z9WQTFsEbau J4h1eQBryFLOnD6QZbZvdyFhkw== X-Received: by 2002:a17:902:aa03:: with SMTP id be3mr19569285plb.84.1569016391020; Fri, 20 Sep 2019 14:53:11 -0700 (PDT) Received: from localhost (wsip-98-175-107-49.sd.sd.cox.net. [98.175.107.49]) by smtp.gmail.com with ESMTPSA id b196sm35326pga.56.2019.09.20.14.53.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Sep 2019 14:53:10 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v4 14/15] drivers: thermal: tsens: Create function to return sign-extended temperature Date: Fri, 20 Sep 2019 14:52:29 -0700 Message-Id: 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 | 50 +++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index ea2c46cc6a66..6b6b3841c2d0 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -84,13 +84,46 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } +/** + * tsens_hw_to_mC - Return sign-extended temperature in mCelsius. + * @s: Pointer to sensor struct + * @field: Index into regmap_field array pointing to temperature data + * + * This function handles temperature returned in ADC code or deciCelsius + * depending on IP version. + * + * Return: Temperature in milliCelsius on success, a negative errno will + * be returned in error cases + */ +static int tsens_hw_to_mC(struct tsens_sensor *s, int field) +{ + struct tsens_priv *priv = s->priv; + u32 resolution; + u32 temp = 0; + int ret; + + resolution = priv->fields[LAST_TEMP_0].msb - + priv->fields[LAST_TEMP_0].lsb; + + ret = regmap_field_read(priv->rf[field], &temp); + if (ret) + return ret; + + /* Convert temperature from ADC code to milliCelsius */ + if (priv->feat->adc) + return code_to_degc(temp, s) * 1000; + + /* deciCelsius -> milliCelsius along with sign extension */ + return sign_extend32(temp, resolution) * 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 valid; int ret; ret = regmap_field_read(priv->rf[valid_idx], &valid); @@ -108,19 +141,7 @@ int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) } /* Valid bit is set, OK to read the temperature */ - ret = regmap_field_read(priv->rf[temp_idx], &last_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(s, temp_idx); return 0; } @@ -310,6 +331,7 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } } + for (i = 0, j = VALID_0; i < priv->feat->max_sensors; i++, j++) { priv->rf[j] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[j]);