From patchwork Thu Jul 26 10:33:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 10545587 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70E7C14BC for ; Thu, 26 Jul 2018 10:33:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60032285FC for ; Thu, 26 Jul 2018 10:33:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 541BC2A74C; Thu, 26 Jul 2018 10:33:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8586285FC for ; Thu, 26 Jul 2018 10:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729308AbeGZLts (ORCPT ); Thu, 26 Jul 2018 07:49:48 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36491 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729155AbeGZLts (ORCPT ); Thu, 26 Jul 2018 07:49:48 -0400 Received: by mail-wr1-f66.google.com with SMTP id h9-v6so1200800wro.3 for ; Thu, 26 Jul 2018 03:33:35 -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=LlTjF7iTHMsf57iFeH6E85/+9b8NIV2YUPikYA5LJe8=; b=GR4XghGin49xYSALOShEfosJa0gs/9O2sxviVln6NkAacwYKHQ+bk5pAuxLdXxHz4s qCaei9mwgM/oAsD8CK23kAy5DvOa26Q9QGSIaTf0EcJMJv+pgc2QbGnCmkWPgDTCu10Q 09UYU7+Wn5GLF4aokTqvXzaKZIT+iBaGixhYA= 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=LlTjF7iTHMsf57iFeH6E85/+9b8NIV2YUPikYA5LJe8=; b=WvKsq6h/I1ZFUp+shot2VH/1kL9IBJ2Z3R7lGHdxCKFPWZaGNnwL/9HyS+6hZ8o8j1 O+121JDGZJfT1UqSqqJGYWkjljo7Iy2e/wSOjZgMalY8u/YYZIKBwWQnfJodODKaEJ3v vcC/OiCYKOVsAc2ONkHYApxtu5NwosKmf5ozfIpOpPFj/EjtM11AnXOTYbFsGzmTzuiC FuwKSS/Gb9H5h0eZp5T+aRePjg8UZ9+bC+B0n4dVebktzIKLEly12bixZst+SIawwjgG Y7MyAtkRKwbGzp/9pVDaKWQuJnhawGQVhq+69qE7+nK1b53PTJGNYvrbyH482iIsLiWC fPpg== X-Gm-Message-State: AOUpUlF1eGCmNY4yZD6KO2xHblLTraZi0FpsiEKNzIbLyyZvea2iVt/m jNGebvXkwR7ZIGBpWI26zqXBpg== X-Google-Smtp-Source: AAOMgpd28a9hNsoPhDnrIvIv28+mI/kincmZms0Us/D/3iTdR8PzkZxaebj++yDyQN2E3z7KG4rR8A== X-Received: by 2002:adf:a197:: with SMTP id u23-v6mr1210365wru.50.1532601214477; Thu, 26 Jul 2018 03:33:34 -0700 (PDT) Received: from localhost ([49.248.197.57]) by smtp.gmail.com with ESMTPSA id x62-v6sm1458087wmg.1.2018.07.26.03.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 03:33:33 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, smohanad@codeaurora.org, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v2 1/3] thermal: tsens: Rename variable Date: Thu, 26 Jul 2018 16:03:08 +0530 Message-Id: <5160b58d1d14b87b84ea49adc804afbefb792c34.1532600791.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.GIT 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 X-Virus-Scanned: ClamAV using ClamSMTP We're actually reading the temperature from the status register. Fix the variable name to reflect that. Signed-off-by: Amit Kucheria Reviewed-by: Matthias Kaehlcke Reviewed-by: Bjorn Andersson --- drivers/thermal/qcom/tsens-common.c | 6 +++--- drivers/thermal/qcom/tsens-v2.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index c22dc18c7c65..25e7f247b027 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -104,11 +104,11 @@ int get_temp_common(struct tsens_device *tmdev, int id, int *temp) { struct tsens_sensor *s = &tmdev->sensor[id]; u32 code; - unsigned int sensor_addr; + unsigned int status_reg; int last_temp = 0, ret; - sensor_addr = S0_ST_ADDR + s->hw_id * SN_ADDR_OFFSET; - ret = regmap_read(tmdev->map, sensor_addr, &code); + status_reg = S0_ST_ADDR + s->hw_id * SN_ADDR_OFFSET; + ret = regmap_read(tmdev->map, status_reg, &code); if (ret) return ret; last_temp = code & SN_ST_TEMP_MASK; diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index f40150fd7eae..908e3dcb2d5c 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -16,11 +16,11 @@ static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp) { struct tsens_sensor *s = &tmdev->sensor[id]; u32 code; - unsigned int sensor_addr; + unsigned int status_reg; int last_temp = 0, last_temp2 = 0, last_temp3 = 0, ret; - sensor_addr = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 4; - ret = regmap_read(tmdev->map, sensor_addr, &code); + status_reg = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 4; + ret = regmap_read(tmdev->map, status_reg, &code); if (ret) return ret; last_temp = code & LAST_TEMP_MASK; @@ -28,7 +28,7 @@ static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp) goto done; /* Try a second time */ - ret = regmap_read(tmdev->map, sensor_addr, &code); + ret = regmap_read(tmdev->map, status_reg, &code); if (ret) return ret; if (code & STATUS_VALID_BIT) { @@ -39,7 +39,7 @@ static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp) } /* Try a third/last time */ - ret = regmap_read(tmdev->map, sensor_addr, &code); + ret = regmap_read(tmdev->map, status_reg, &code); if (ret) return ret; if (code & STATUS_VALID_BIT) { From patchwork Thu Jul 26 10:33:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 10545593 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19B87112B for ; Thu, 26 Jul 2018 10:33:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 066B1285FC for ; Thu, 26 Jul 2018 10:33:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF0D22A4B5; Thu, 26 Jul 2018 10:33:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E6572A7E8 for ; Thu, 26 Jul 2018 10:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbeGZLt4 (ORCPT ); Thu, 26 Jul 2018 07:49:56 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43911 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729152AbeGZLt4 (ORCPT ); Thu, 26 Jul 2018 07:49:56 -0400 Received: by mail-wr1-f68.google.com with SMTP id b15-v6so1183662wrv.10 for ; Thu, 26 Jul 2018 03:33:42 -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=7pdKkXszJl0Y74TWXh6gdA8KIIImBRTHTJ1Z9RN0dvg=; b=Fhi4Ct/bj4yBxlkbsu/bgpQOl38iLOTF6THsInYunPXq3OR8wghp/qpuILwTIc/7ls usASnw3IVoVeBZvGIfqRJLAc6KRMJULsxnKne8r9HGPv6PvX5gib4c8KhjQ8uDGMFqIF XMmk78yAf6eBbPx1OfM+Vgww16XG9Bm5jluFo= 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=7pdKkXszJl0Y74TWXh6gdA8KIIImBRTHTJ1Z9RN0dvg=; b=Yw8zt5/vLSVHw1i+3ZFtlwtpgxEt6vMRp+nTp4oG4BBz5zZ7nRQwjHUw2mNTWPovM7 BXZW2cWBflJokXhuPGRChNqU7zBRsx6BqhRRS2awZmSdBM9aVApG0FxBaIrRLNe5Oo2h xB096+P5ahXNspMioeHJYymGxBsKbb9qoNYVVETtYhUKVPV5azdqiZfY1NazoKqnlUhB ypBadq3Zf2IRogoVTxtUJHxvE5gxfiaX6JiELHuOBoJ202/DzPtjhHgGlvXLL+BFTzEn LN3QoozajlvLhWiug7rfbLx6GIXWPlLiX9nH5Qx9rqBy7VLY73QteV8nl8uGgy9gKNr+ kv9Q== X-Gm-Message-State: AOUpUlH/1eC+T0JYDHdyL2ItKv3zuyeYCeheyVMZWMXci7PMQc53Bght bW/q9mUu98hirebqqiGCYkSI/Q== X-Google-Smtp-Source: AAOMgpf0xMjlSxZene1uZ8E1PEOaAydk+2kAI+x7mnHgUpvHTxRBxEKH5gT+ApiiGP0FCPRVniipDA== X-Received: by 2002:a5d:6841:: with SMTP id o1-v6mr1124857wrw.159.1532601222160; Thu, 26 Jul 2018 03:33:42 -0700 (PDT) Received: from localhost ([49.248.197.57]) by smtp.gmail.com with ESMTPSA id b6-v6sm1520458wru.66.2018.07.26.03.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 03:33:41 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, smohanad@codeaurora.org, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v2 2/3] thermal: tsens: switch from of_iomap() to devm_ioremap_resource() Date: Thu, 26 Jul 2018 16:03:09 +0530 Message-Id: X-Mailer: git-send-email 2.17.GIT 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 X-Virus-Scanned: ClamAV using ClamSMTP devm_ioremap_resources() automatically requests resources (so that the I/O region shows up in /proc/iomem) and devm_ wrappers do better error handling and unmapping of the I/O region when needed. Signed-off-by: Amit Kucheria Reviewed-by: Matthias Kaehlcke Reviewed-by: Bjorn Andersson --- drivers/thermal/qcom/tsens-common.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 25e7f247b027..6207d8d92351 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -127,13 +127,11 @@ static const struct regmap_config tsens_config = { int __init init_common(struct tsens_device *tmdev) { void __iomem *base; + struct resource *res; struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); if (!op) return -EINVAL; - base = of_iomap(tmdev->dev->of_node, 0); - if (!base) - return -EINVAL; /* The driver only uses the TM register address space for now */ if (op->num_resources > 1) { @@ -143,11 +141,14 @@ int __init init_common(struct tsens_device *tmdev) tmdev->tm_offset = 0x1000; } + res = platform_get_resource(op, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&op->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config); - if (IS_ERR(tmdev->map)) { - iounmap(base); + if (IS_ERR(tmdev->map)) return PTR_ERR(tmdev->map); - } return 0; } From patchwork Thu Jul 26 10:33:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 10545595 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5605214BC for ; Thu, 26 Jul 2018 10:34:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44D29285FC for ; Thu, 26 Jul 2018 10:34:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F4812A95B; Thu, 26 Jul 2018 10:34:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5D9E2B008 for ; Thu, 26 Jul 2018 10:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729435AbeGZLuG (ORCPT ); Thu, 26 Jul 2018 07:50:06 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53216 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729271AbeGZLuF (ORCPT ); Thu, 26 Jul 2018 07:50:05 -0400 Received: by mail-wm0-f66.google.com with SMTP id o11-v6so1449222wmh.2 for ; Thu, 26 Jul 2018 03:33:51 -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=LnuO8mINuH/6zEhwieXU1MyQ1uhrZQBRKE+R5lMhY9U=; b=JHfy94uO0KUBlye3Ri4yZvHQKKeISc0CUzRbZtwLlgsPJ8Gt1oItxh7O0vvX/q5ZAz w9peiRZXhYQ5G3OY/LXCJ+3Cdu5XFGeltKLjqkGemvBU6WQKIXahhcM1WefrHclDiU9e e4wZBgkr6uxqW8nxQM5F86ZPCJbeMxytR8JlM= 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=LnuO8mINuH/6zEhwieXU1MyQ1uhrZQBRKE+R5lMhY9U=; b=bvbmgIS98vkHtx/2UlfxgwtlXGk2DTgm8ixEim0LdwYarY4DLvVeVf7clEoBUK3JeV OwFC//vNu/CiPGya2L0231+r95F9oTCkc7NQxXxa5gN/ezM4r6yXPKgzEocb9BBW/hLF zKkG5OKJpxag1h/a9Z3gqQ3pEMZ/QB//23L2mnld67j2fGZL1VgdP4pxxs1Rus/D1wfV lKx4GE0jPrwO7tZiguDthuOmQlK78eUSTUQsBaDl0DwFMNZZ2y/qrKSg01qHdMNoHn8Z hDTNZHFSNKG5vmOu1ORcvGxQir+opZDTgSR7m35gGMkFmb3w/vENPzWLD5iy2f1FLXfH pOAA== X-Gm-Message-State: AOUpUlHGfvZqY6WnPIhYK9GxzkbOUq3zvOQ/42mjoT2C0kfAvPsAAW+2 2y0abygUKDqn6zgW2xIwnJVLSw== X-Google-Smtp-Source: AAOMgpdP0M7RJmFn5l+qENdZ5+AaglRgxQhkkw2EnTT7Ql/qK1wNx6lQuhzWhpqxt79RuzqJx8dT8w== X-Received: by 2002:a1c:7d47:: with SMTP id y68-v6mr1149937wmc.62.1532601230918; Thu, 26 Jul 2018 03:33:50 -0700 (PDT) Received: from localhost ([49.248.197.57]) by smtp.gmail.com with ESMTPSA id i125-v6sm2357906wmd.23.2018.07.26.03.33.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 03:33:50 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, smohanad@codeaurora.org, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v2 3/3] thermal: tsens: Fix negative temperature reporting Date: Thu, 26 Jul 2018 16:03:10 +0530 Message-Id: <52516c287c9455676e7cbde4a4fa94282d73367f.1532600791.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.GIT 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 X-Virus-Scanned: ClamAV using ClamSMTP The current code will always return 0xffffffff in case of negative temperatures due to a bug in how the binary sign extension is being done. Use sign_extend32() instead. Signed-off-by: Amit Kucheria Reviewed-by: Matthias Kaehlcke Reviewed-by: Bjorn Andersson --- drivers/thermal/qcom/tsens-v2.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index 908e3dcb2d5c..44da02f594ac 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -5,19 +5,20 @@ */ #include +#include #include "tsens.h" #define STATUS_OFFSET 0xa0 #define LAST_TEMP_MASK 0xfff #define STATUS_VALID_BIT BIT(21) -#define CODE_SIGN_BIT BIT(11) static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp) { struct tsens_sensor *s = &tmdev->sensor[id]; u32 code; unsigned int status_reg; - int last_temp = 0, last_temp2 = 0, last_temp3 = 0, ret; + u32 last_temp = 0, last_temp2 = 0, last_temp3 = 0; + int ret; status_reg = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 4; ret = regmap_read(tmdev->map, status_reg, &code); @@ -54,12 +55,8 @@ static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp) else if (last_temp2 == last_temp3) last_temp = last_temp3; done: - /* Code sign bit is the sign extension for a negative value */ - if (last_temp & CODE_SIGN_BIT) - last_temp |= ~CODE_SIGN_BIT; - - /* Temperatures are in deciCelicius */ - *temp = last_temp * 100; + /* Convert temperature from deciCelsius to milliCelsius */ + *temp = sign_extend32(last_temp, fls(LAST_TEMP_MASK) - 1) * 100; return 0; }