From patchwork Thu Sep 12 01:29:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11141993 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70761912 for ; Thu, 12 Sep 2019 01:29:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 442BE214DE for ; Thu, 12 Sep 2019 01:29:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="izFFHNSK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726842AbfILB3k (ORCPT ); Wed, 11 Sep 2019 21:29:40 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42599 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbfILB3k (ORCPT ); Wed, 11 Sep 2019 21:29:40 -0400 Received: by mail-pg1-f193.google.com with SMTP id z12so923079pgp.9; Wed, 11 Sep 2019 18:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/VJy9i5pIbM5WNGgof53pW2sqA3Pbpe145dB7ml+l1o=; b=izFFHNSKXEvD/z+1VtUk2pWkt+Nw7qu9AdqbgJ/ORutcw2oAkpkVLrqCk1PaNJYE1n toszDkDjwvt8dyvkaaWbAeNqLIAiJZzpEW770dmzObOPydQ1bbvVqvGpr1m/oA9eKV2g kbx7Vh2tIWH4Ng6Z1V3Tdpa0YQBmY1SdSJ2HmfpnmXK1oNhGNnyhhqvzx2kl03YgLYhg derYNSF354CR7GtdMA2gz7auNwg0mYfOJRqkAlaAPc1u8NStZ9X0yOMXEJE1xUArnasM khw73pM8rCKGP1ZyU99GjrWggz6JOMqO/Nb6taN67FP1045UuCNdwZCCNc0+bT8C8nV0 fEkw== 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:mime-version:content-transfer-encoding; bh=/VJy9i5pIbM5WNGgof53pW2sqA3Pbpe145dB7ml+l1o=; b=ZEuz0q5+ThqCS0AHsGX9F5DU9KSbocpK6Zw+Ue5j13YEaOWoUpIPeDXt+S14VMdERH +fZqMFFyQo6VqhHSDYuCZzJ+W4j6bBUBu1BVPpMfLPRKXxDlyMWCe4s4zrdF2i7RvLqn WVK49mMzXmoC5NismvHmTDYSJvGkpqyQEOFmCNJEXe+o4puQ+CaeIx50nXBs/IsPNwLs 3WMFLUD3fGhpip7x5Sp3v8SbAq1MugyeP+exA3iM5DEvOCeH/kXy97103OB6yenjskAN jCszk0fh8G9o+loJ4lQyiWn7OkBgzww7huqDHascCIwc52cH+hRj9LBZypql1dESXzRn 9lPg== X-Gm-Message-State: APjAAAUjJJwI6zQT8DkKBFRqInNM2SGEhydILFgkOq8hT2yOziBRV7OS ddRMLxqmwkC0moJtM0KSvQU= X-Google-Smtp-Source: APXvYqxwfFsxJG8YLlAlSab0VGffBXj7Rxlfopl95n5LXHm+9R9euoL2j4wSwehIq3yrVVpDugO5ag== X-Received: by 2002:a63:2a87:: with SMTP id q129mr36582485pgq.101.1568251779423; Wed, 11 Sep 2019 18:29:39 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id u4sm20781699pfh.55.2019.09.11.18.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:29:38 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 01/12] thermal: qoriq: Add local struct device pointer Date: Wed, 11 Sep 2019 18:29:09 -0700 Message-Id: <20190912012920.29601-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use a local "struct device *dev" for brevity. No functional change intended. Signed-off-by: Andrey Smirnov Acked-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 39542c670301..5df6267a5da0 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -194,8 +194,9 @@ static int qoriq_tmu_probe(struct platform_device *pdev) int ret; struct qoriq_tmu_data *data; struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; - data = devm_kzalloc(&pdev->dev, sizeof(struct qoriq_tmu_data), + data = devm_kzalloc(dev, sizeof(struct qoriq_tmu_data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -206,17 +207,17 @@ static int qoriq_tmu_probe(struct platform_device *pdev) data->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(data->regs)) { - dev_err(&pdev->dev, "Failed to get memory region\n"); + dev_err(dev, "Failed to get memory region\n"); return PTR_ERR(data->regs); } - data->clk = devm_clk_get_optional(&pdev->dev, NULL); + data->clk = devm_clk_get_optional(dev, NULL); if (IS_ERR(data->clk)) return PTR_ERR(data->clk); ret = clk_prepare_enable(data->clk); if (ret) { - dev_err(&pdev->dev, "Failed to enable clock\n"); + dev_err(dev, "Failed to enable clock\n"); return ret; } @@ -228,7 +229,7 @@ static int qoriq_tmu_probe(struct platform_device *pdev) ret = qoriq_tmu_register_tmu_zone(pdev); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register sensors\n"); + dev_err(dev, "Failed to register sensors\n"); ret = -ENODEV; goto err; } From patchwork Thu Sep 12 01:29:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11141995 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DFF214E5 for ; Thu, 12 Sep 2019 01:29:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C4E72087E for ; Thu, 12 Sep 2019 01:29:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PUnEMn0P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728762AbfILB3m (ORCPT ); Wed, 11 Sep 2019 21:29:42 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44421 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbfILB3l (ORCPT ); Wed, 11 Sep 2019 21:29:41 -0400 Received: by mail-pf1-f196.google.com with SMTP id q21so14823869pfn.11; Wed, 11 Sep 2019 18:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ymu8f8cvhmZmTX/wIizpAWbB6vsQLcw46eunxAg5tiw=; b=PUnEMn0PYut00Ae6LfA+TkLSo4AUtnp4uaubaCT0QOhJAKPz/tY3sqcgtiJNaDZc2T 16gZBqGMnb4xC9qnJERSoFP2jI4icCZ4HPfAzpte1LJyEPGaashudufer+eg5vsYzZSF PbZyaKHdiCcE37H65l10s/6eYOGqeFIYUIGKnB4TPz6nNWZthx/AsA60D8jp3OmRt5qX Shrdn5d+lFNJMhtmpEAG6H+yj53pUxvFyFfI+M2j22ccxFwAk/smYLUxGvQc4ghMbdIt hpCuk38jFobz+6uFW+2xVYZMlQeHxdevw6bTVfBXmtF2Zb/A8ADQqz4VQU/uHQSVU+RT y/SA== 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:mime-version:content-transfer-encoding; bh=ymu8f8cvhmZmTX/wIizpAWbB6vsQLcw46eunxAg5tiw=; b=XflWWFgWsKTrZ6P0v0OZVrmgnHl1Q30jleiJ7zavQPiMEa7BUxF0zY30IUUxKeRdb2 wEjq7kk8585aCBeE2E+sLgKgHHS/O9ObhfXBWwIjUNs3TbJ5/PvJ64I2TnBR/iG8RwaN 3sa8ZRMQZVjRdzkWj81tatEGLe38ni7VPBTxF28NFc0OlKTsNo07juNbociMGfJ2qQr4 ZJBi7c/bASgUCzM3/jSrngYUOQBiqrtV+xjxOJLsKWG4MzpWbmmiQNY+YVqximClt1Nt 65lhS4YtPLByr8KrKjtdmj3cUBrpfQG2URC8cPoQOw4Usm+8BYHe0BIyWHr0Q7xEMcSj UsiA== X-Gm-Message-State: APjAAAV5QGGbSRJ5i6BHiwAW4HXDaCY+t93jET+DqtrtvlfItfPYzGpi 6X+73u/3pblylKVQv90jkHc= X-Google-Smtp-Source: APXvYqyD06mHM5o5I8BgYBm+gOCD0UOsGAnoGHpqgMLQB3caY3hgF4fyKketVvdrEq0Vd5IQ1ZxBtA== X-Received: by 2002:a63:6c02:: with SMTP id h2mr36998260pgc.61.1568251780768; Wed, 11 Sep 2019 18:29:40 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id u4sm20781699pfh.55.2019.09.11.18.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:29:39 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 02/12] thermal: qoriq: Don't store struct thermal_zone_device reference Date: Wed, 11 Sep 2019 18:29:10 -0700 Message-Id: <20190912012920.29601-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Struct thermal_zone_device reference stored as sensor's private data isn't really used anywhere in the code. Drop it. Signed-off-by: Andrey Smirnov Acked-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 5df6267a5da0..b471c226f06b 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -66,7 +66,6 @@ struct qoriq_tmu_data; * Thermal zone data */ struct qoriq_sensor { - struct thermal_zone_device *tzd; struct qoriq_tmu_data *qdata; int id; }; @@ -116,6 +115,9 @@ static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev) int id, sites = 0; for (id = 0; id < SITES_MAX; id++) { + struct thermal_zone_device *tzd; + int ret; + qdata->sensor[id] = devm_kzalloc(&pdev->dev, sizeof(struct qoriq_sensor), GFP_KERNEL); if (!qdata->sensor[id]) @@ -123,13 +125,16 @@ static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev) qdata->sensor[id]->id = id; qdata->sensor[id]->qdata = qdata; - qdata->sensor[id]->tzd = devm_thermal_zone_of_sensor_register( - &pdev->dev, id, qdata->sensor[id], &tmu_tz_ops); - if (IS_ERR(qdata->sensor[id]->tzd)) { - if (PTR_ERR(qdata->sensor[id]->tzd) == -ENODEV) + + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id, + qdata->sensor[id], + &tmu_tz_ops); + ret = PTR_ERR_OR_ZERO(tzd); + if (ret) { + if (ret == -ENODEV) continue; else - return PTR_ERR(qdata->sensor[id]->tzd); + return ret; } sites |= 0x1 << (15 - id); From patchwork Thu Sep 12 01:29:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142003 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 251F216B1 for ; Thu, 12 Sep 2019 01:30:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0275920872 for ; Thu, 12 Sep 2019 01:30:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tnsQq+od" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728837AbfILB3o (ORCPT ); Wed, 11 Sep 2019 21:29:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45164 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728836AbfILB3o (ORCPT ); Wed, 11 Sep 2019 21:29:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id y72so14802068pfb.12; Wed, 11 Sep 2019 18:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ZI89W7IaixNfucadKsVf0r9M2xz9qgAVdHmzWYig2g=; b=tnsQq+odE1etiRE++QpDdmxAK4vcon3IKW+D+GDGYqPpHweEpAtCme3odhqcXgcKbc coNngI4dzWjsIzN5t2myh+6NR5AOqhd1Frq7aE68r5c8jFXNz5IS+wBo65YhXmjrNBps jIuoKCyriqZEsXq1XJgF1LQXBIb+S7NiHqA5NvFOZf7Of1/imaYzGtb+tsZZbriEFdIh CUp2Id5Welqts73ueLpVL7e/wFfeaAXfClkKtcZSqZjrDtZDfGN1g9Xrr0BL5zjhmW3P 1RlNoL4EUAadSJf3G+MJwv3Lg5v4R853IhNxzTZ7/izQoKAnDvZUEt3blbEckUdE2sai mCOQ== 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:mime-version:content-transfer-encoding; bh=9ZI89W7IaixNfucadKsVf0r9M2xz9qgAVdHmzWYig2g=; b=KC3HZ7Yu0j5w1qVobxkk6e3eNMAkjssnJ5qCgn4LkcrfIB7tQYl45Z/rkDgdpv5F9J HCExcA55Yq1hHTb1B/ZORvE+YRWIW53Js+KOhxvJX1g8zPxzrFYY0QnBZR4yD0rQGoNC sICwCc84tb0neXHi++y6v95pmJ1oUwWA1jTmf0BgMXHF3U+EznSWGYSr2TsrNQOQy16g xYFMBTkkmazwb720YZYd7yfDYnnqebGlpLglV3xe1KmVAnfNf57Bqg4QihTHTovWfEqm fmOUOV8AJzkKxOn3CbyANhBg86dyec5c8HJczxq7E9UqLwvf0d0YoizHQTVeIF5A+k8N P7Tg== X-Gm-Message-State: APjAAAWXr+x/aZtrYUa/yAQt6tvD437NmWNhxhEgp2j+/Ksjhdg5ltgr X0LnFhALPE3Ze7TB4+XMP4Y= X-Google-Smtp-Source: APXvYqwJp6ormbc2GCjZy26O2TiA17rS5z52ROWSpn0v5oD7kGDFK3Y+kYtCdkq1vXYqvHsxkZ2ogw== X-Received: by 2002:a63:5402:: with SMTP id i2mr35600956pgb.414.1568251782137; Wed, 11 Sep 2019 18:29:42 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id u4sm20781699pfh.55.2019.09.11.18.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:29:41 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Chris Healy , Lucas Stach , Eduardo Valentin , Daniel Lezcano , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 03/12] thermal: qoriq: Add local struct qoriq_sensor pointer Date: Wed, 11 Sep 2019 18:29:11 -0700 Message-Id: <20190912012920.29601-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add local struct qoriq_sensor pointer in qoriq_tmu_register_tmu_zone() for brevity. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index b471c226f06b..ae22836c471d 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -116,18 +116,22 @@ static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev) for (id = 0; id < SITES_MAX; id++) { struct thermal_zone_device *tzd; + struct qoriq_sensor *sensor; int ret; - qdata->sensor[id] = devm_kzalloc(&pdev->dev, - sizeof(struct qoriq_sensor), GFP_KERNEL); + sensor = devm_kzalloc(&pdev->dev, + sizeof(struct qoriq_sensor), + GFP_KERNEL); if (!qdata->sensor[id]) return -ENOMEM; - qdata->sensor[id]->id = id; - qdata->sensor[id]->qdata = qdata; + qdata->sensor[id] = sensor; + + sensor->id = id; + sensor->qdata = qdata; tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id, - qdata->sensor[id], + sensor, &tmu_tz_ops); ret = PTR_ERR_OR_ZERO(tzd); if (ret) { From patchwork Thu Sep 12 01:29:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142001 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11C3914E5 for ; Thu, 12 Sep 2019 01:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2FFD2087E for ; Thu, 12 Sep 2019 01:29:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZcKKJm8F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728895AbfILB3p (ORCPT ); Wed, 11 Sep 2019 21:29:45 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34266 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbfILB3o (ORCPT ); Wed, 11 Sep 2019 21:29:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id r12so14876941pfh.1; Wed, 11 Sep 2019 18:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OR6DWQhTypRBQHla5x+NK6izgQjlqJvyqAknMpBOllI=; b=ZcKKJm8FaDFbn0QfMEd8lIidM69k4WK9BSHKdg8nZNQtq+Nle2LTESZhRGOorSfFIh 4qGL+RZ15HRjmHQTS/E2KvTotuQAKpUbF6hfpCheDtUBC/TGanwrPek2jtnTp9UVU6lI eFRqxtArPy7fEmeNxj2ScXfpP8LePMXGx0vTiV/+vDA+rbILSykWZWw0hHH6e4d/wHSN ja9fKwqCvTZpWm6YjqQ+q3CmpmzjqRk7xzbRWMDHE/v/8B4imJ74nlcmggH96SfhILDp ukum5NCzTHWGoUPZqp/pojDNjf2owzcrInMW8nR7whEdFzOQplfS/0iHDMGEGzOa77GD Ob9A== 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:mime-version:content-transfer-encoding; bh=OR6DWQhTypRBQHla5x+NK6izgQjlqJvyqAknMpBOllI=; b=ZpM3r0tOCDb9fw+em31b2Z6mfrluHoAeUj3EovHVn8slkLFmLwoG67j/atE3W8mwGR EnM47SA1aOJ5xEVnqE4MiaocA9BF5nSNrqSuwDfgw+4TtkdsKC92vUZIKUT0b/E3pSVM qXmM3UR1d5APGG4lUXiMNCZSpU6lBEMpEh9XxjCtGmQQwnkaZT+ryIO/I28IfCOvSuCb LqCjVkUMf3Bmzdd1i0IULDGNpb43txb9jqUZPPleKTzpS+0WwQeg/HBBmC8Zaf48EWml Rru3jox1v4xv0ZDSuo+/fvkV3lalkzdqT2YiVfEPHdIumpHd8xeexbnqJjx0XsCpY0AT qqaw== X-Gm-Message-State: APjAAAX7MdmhXtISO3JyKw3w3RU9dVrnV/etQkCFp0JkTTHF1MC9QNmQ 8dLeXg52IEmhmfqLHLdlwtM= X-Google-Smtp-Source: APXvYqxz6Ycf+vKYiZPhzTMgmz9HOyCTLFAamUMrRD89fVPwIiAZlSJiCY6h6oSQVnzysASKZvOqGg== X-Received: by 2002:a63:ee08:: with SMTP id e8mr36194656pgi.70.1568251783401; Wed, 11 Sep 2019 18:29:43 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id u4sm20781699pfh.55.2019.09.11.18.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:29:42 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Chris Healy , Lucas Stach , Eduardo Valentin , Daniel Lezcano , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 04/12] thermal: qoriq: Embed per-sensor data into struct qoriq_tmu_data Date: Wed, 11 Sep 2019 18:29:12 -0700 Message-Id: <20190912012920.29601-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Embed per-sensor data into struct qoriq_tmu_data so we can drop the code allocating it. This also allows us to get rid of per-sensor back reference to struct qoriq_tmu_data since now its address can be calculated using container_of(). Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index ae22836c471d..f8f5228d83af 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -60,13 +60,10 @@ struct qoriq_tmu_regs { u32 ttr3cr; /* Temperature Range 3 Control Register */ }; -struct qoriq_tmu_data; - /* * Thermal zone data */ struct qoriq_sensor { - struct qoriq_tmu_data *qdata; int id; }; @@ -74,9 +71,14 @@ struct qoriq_tmu_data { struct qoriq_tmu_regs __iomem *regs; struct clk *clk; bool little_endian; - struct qoriq_sensor *sensor[SITES_MAX]; + struct qoriq_sensor sensor[SITES_MAX]; }; +static struct qoriq_tmu_data *qoriq_sensor_to_data(struct qoriq_sensor *s) +{ + return container_of(s, struct qoriq_tmu_data, sensor[s->id]); +} + static void tmu_write(struct qoriq_tmu_data *p, u32 val, void __iomem *addr) { if (p->little_endian) @@ -96,7 +98,7 @@ static u32 tmu_read(struct qoriq_tmu_data *p, void __iomem *addr) static int tmu_get_temp(void *p, int *temp) { struct qoriq_sensor *qsensor = p; - struct qoriq_tmu_data *qdata = qsensor->qdata; + struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor); u32 val; val = tmu_read(qdata, &qdata->regs->site[qsensor->id].tritsr); @@ -116,19 +118,10 @@ static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev) for (id = 0; id < SITES_MAX; id++) { struct thermal_zone_device *tzd; - struct qoriq_sensor *sensor; + struct qoriq_sensor *sensor = &qdata->sensor[id]; int ret; - sensor = devm_kzalloc(&pdev->dev, - sizeof(struct qoriq_sensor), - GFP_KERNEL); - if (!qdata->sensor[id]) - return -ENOMEM; - - qdata->sensor[id] = sensor; - sensor->id = id; - sensor->qdata = qdata; tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id, sensor, From patchwork Thu Sep 12 01:29:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11141997 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87C4A16B1 for ; Thu, 12 Sep 2019 01:29:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6724C2087E for ; Thu, 12 Sep 2019 01:29:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tgE/XhYx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728978AbfILB3q (ORCPT ); Wed, 11 Sep 2019 21:29:46 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45170 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728926AbfILB3p (ORCPT ); Wed, 11 Sep 2019 21:29:45 -0400 Received: by mail-pf1-f196.google.com with SMTP id y72so14802132pfb.12; Wed, 11 Sep 2019 18:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7A3LgznRtqP7+oj98IopNyB7NhpOkF3e2xGfR20W9Jk=; b=tgE/XhYxInBshm09b8VR1hQyQIOlarEvYnCG0u76UcIrqvn1b6L/7dTQD/hE82GAuU 8X10oJ/wijYa+aMWcmjPpMzwME5oq3Evc60+kVXg5DNn/Ss1Ubl3VVZL821JMB2tGEoL olNGSJF6KnfeDJJtHG5VeVWdCZKVSUDo6nTw7nmHfeo693jYO15vVJhk5dg0VMwllVm7 yEGh/Up9U51upw8NhAFCwvDHncltye/BzQb1Py+JxklOixXSo5/sIK1us70TUaD/x7jL X6lGU4E5u5iwCFE7Uv/MFf92ynOZoXLBXNMp/KZqM6wkLOyZv/kH+vX4aNlMdBB6SxU7 prVg== 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:mime-version:content-transfer-encoding; bh=7A3LgznRtqP7+oj98IopNyB7NhpOkF3e2xGfR20W9Jk=; b=A6azdNWOGFLLZuKH+Szn0TdxQEeQHRueNgAwwmGGr5FbZKECJ5IYtsPwYtTTqDERH2 FsSpJUHKaYXvhDv45gVCodrW5soEG2b6E/2SpDnWv7VJ9rRiFJsCY83KSRA4ca/qikHJ Zngxb16QXNm2OTB862UMGnBcEiEV/LV02by6KqCW/PXpf42AeA5fQ0p+B/odI8aq+Z0z H5BORpeghw+giGGWHr3cDFjrTqniQMUN1RnVGfkWPtbhthFdCvaivZSGq1NIQFaPTrTN bNGixvEH4d/nt4qggqRsgA8V2kiPGRQY4RVKV7kZnsrQTG5w/lPHnrT/4VbYslN1InMa WuIw== X-Gm-Message-State: APjAAAVx+ah7fj8fLDgZwSHAQ/s+9z+OGIplw6zEgQaqBbwKhMYuAayY PYh+lIbl024J001XlyOeehE= X-Google-Smtp-Source: APXvYqyXuEZYGsXT+NYIjec2ZLo1RXxejSNUh0wQ7LsWPOqfDB74MRmPdR8cVoFWsXgBnADv5ghz6g== X-Received: by 2002:a63:6c43:: with SMTP id h64mr10554345pgc.106.1568251784804; Wed, 11 Sep 2019 18:29:44 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id u4sm20781699pfh.55.2019.09.11.18.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:29:43 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 05/12] thermal: qoriq: Pass data to qoriq_tmu_register_tmu_zone() directly Date: Wed, 11 Sep 2019 18:29:13 -0700 Message-Id: <20190912012920.29601-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Pass all necessary data to qoriq_tmu_register_tmu_zone() directly instead of passing a platform device and then deriving it. This is done as a first step to simplify resource deallocation code. Signed-off-by: Andrey Smirnov Acked-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index f8f5228d83af..5b9f2a31d275 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -111,9 +111,9 @@ static const struct thermal_zone_of_device_ops tmu_tz_ops = { .get_temp = tmu_get_temp, }; -static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev) +static int qoriq_tmu_register_tmu_zone(struct device *dev, + struct qoriq_tmu_data *qdata) { - struct qoriq_tmu_data *qdata = platform_get_drvdata(pdev); int id, sites = 0; for (id = 0; id < SITES_MAX; id++) { @@ -123,7 +123,7 @@ static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev) sensor->id = id; - tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id, + tzd = devm_thermal_zone_of_sensor_register(dev, id, sensor, &tmu_tz_ops); ret = PTR_ERR_OR_ZERO(tzd); @@ -229,7 +229,7 @@ static int qoriq_tmu_probe(struct platform_device *pdev) if (ret < 0) goto err; - ret = qoriq_tmu_register_tmu_zone(pdev); + ret = qoriq_tmu_register_tmu_zone(dev, data); if (ret < 0) { dev_err(dev, "Failed to register sensors\n"); ret = -ENODEV; From patchwork Thu Sep 12 01:29:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11141999 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B293912 for ; Thu, 12 Sep 2019 01:29:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38FA920CC7 for ; Thu, 12 Sep 2019 01:29:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c2BUH1/W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729017AbfILB3s (ORCPT ); Wed, 11 Sep 2019 21:29:48 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39241 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728926AbfILB3s (ORCPT ); Wed, 11 Sep 2019 21:29:48 -0400 Received: by mail-pf1-f194.google.com with SMTP id i1so5992617pfa.6; Wed, 11 Sep 2019 18:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s4mUcB54nLpC+ZyoXZt/bHFq0eABhEI73lwHSpgg/qk=; b=c2BUH1/WZdaQ/0RJOJAOzl530zehwT5imK4EkAXnf9SvCSQ5hCz/xqzkmkep7rst0C 5x8ww8SV2SHzUzs2ahS4PcXA8PotgVTsBg7p+1aIscyRx3I8Eel7zZceEkQeK6pa31wn 3Di/hLdmw7hnmw97++7XoOyU6FKeRM9LHEWN4WBgwwTznkF9XTHS/nKpZ8lhAH1k81dt 8CJZKiR7UOSIRqgg7ubOgluknL2MhGYgm2Dg8UkP4ZMSmMRUaLLx/FBvYFTEeKL0NKfn 5P6nn38Vz1YpiYvG5bVPm6Pwoc+QvwcMfdO2nK5DyENO9iqgalDhyG0TKPcbfmZdZ9qc TbRg== 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:mime-version:content-transfer-encoding; bh=s4mUcB54nLpC+ZyoXZt/bHFq0eABhEI73lwHSpgg/qk=; b=mOOc/uzzy6oxij06fSna7drgOB/h7nRAEyKUu60cj7x75iTGwS7GFpc6T8PKFCwuaT B9i8eVLV0I+CxIXQs5YkErphHJn1v4KG0ct6OUZlS9GrIj6ydNy8ppbX4LHamF5OpXcK pzlZu6QOAhwp8Fm3rDgMVtFKoGxXpCvIDPel+d+1TX6jEbJb+XYBhL1arf7ZemlIhQc0 lTnpdw90FM43XAbulj01VC5aHM8HRUtB7+sner6RsIu6qjNnXURlFUq9Ru7smCOXFP/L 83Q5mxiqJlYqpuoOkUouRDcUiC+r7/J6cI/ja52/6srlydsLy1I/hKGGq+paRSU6xwOW OG8g== X-Gm-Message-State: APjAAAVZ4CieVoK4EdG9YWahioiyYXfw8ImU5D4KmFyUl7BLuYNfUsnr b/6nbFGz5s9pTYyj+/gb/xE= X-Google-Smtp-Source: APXvYqwEwXi3Rjrj05uOLgVAxkeT8p3RCn3kmIDEqM4ou4ZhBLSaJ/+GEuEFklwR3CUFZ9M2yL2LGQ== X-Received: by 2002:a17:90a:37d1:: with SMTP id v75mr8907481pjb.33.1568251787307; Wed, 11 Sep 2019 18:29:47 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id u4sm20781699pfh.55.2019.09.11.18.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:29:46 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 06/12] thermal: qoriq: Pass data to qoriq_tmu_calibration() directly Date: Wed, 11 Sep 2019 18:29:14 -0700 Message-Id: <20190912012920.29601-7-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We can simplify error cleanup code if instead of passing a "struct platform_device *" to qoriq_tmu_calibration() and deriving a bunch of pointers from it, we pass those pointers directly. This way we won't be force to call platform_set_drvdata() as early in qoriq_tmu_probe() and need to have "platform_set_drvdata(pdev, NULL);" in error path. Signed-off-by: Andrey Smirnov Reviewed-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 5b9f2a31d275..af596c3342d0 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -144,16 +144,16 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, return 0; } -static int qoriq_tmu_calibration(struct platform_device *pdev) +static int qoriq_tmu_calibration(struct device *dev, + struct qoriq_tmu_data *data) { int i, val, len; u32 range[4]; const u32 *calibration; - struct device_node *np = pdev->dev.of_node; - struct qoriq_tmu_data *data = platform_get_drvdata(pdev); + struct device_node *np = dev->of_node; if (of_property_read_u32_array(np, "fsl,tmu-range", range, 4)) { - dev_err(&pdev->dev, "missing calibration range.\n"); + dev_err(dev, "missing calibration range.\n"); return -ENODEV; } @@ -165,7 +165,7 @@ static int qoriq_tmu_calibration(struct platform_device *pdev) calibration = of_get_property(np, "fsl,tmu-calibration", &len); if (calibration == NULL || len % 8) { - dev_err(&pdev->dev, "invalid calibration data.\n"); + dev_err(dev, "invalid calibration data.\n"); return -ENODEV; } @@ -203,8 +203,6 @@ static int qoriq_tmu_probe(struct platform_device *pdev) if (!data) return -ENOMEM; - platform_set_drvdata(pdev, data); - data->little_endian = of_property_read_bool(np, "little-endian"); data->regs = devm_platform_ioremap_resource(pdev, 0); @@ -225,7 +223,7 @@ static int qoriq_tmu_probe(struct platform_device *pdev) qoriq_tmu_init_device(data); /* TMU initialization */ - ret = qoriq_tmu_calibration(pdev); /* TMU calibration */ + ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */ if (ret < 0) goto err; @@ -236,11 +234,12 @@ static int qoriq_tmu_probe(struct platform_device *pdev) goto err; } + platform_set_drvdata(pdev, data); + return 0; err: clk_disable_unprepare(data->clk); - platform_set_drvdata(pdev, NULL); return ret; } From patchwork Thu Sep 12 01:34:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142007 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BF00912 for ; Thu, 12 Sep 2019 01:34:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03C1420872 for ; Thu, 12 Sep 2019 01:34:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QDwdEnFY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbfILBez (ORCPT ); Wed, 11 Sep 2019 21:34:55 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41303 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfILBez (ORCPT ); Wed, 11 Sep 2019 21:34:55 -0400 Received: by mail-pf1-f193.google.com with SMTP id b13so14826482pfo.8; Wed, 11 Sep 2019 18:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XAw3ZgfIAbV+DLrxuqn76+3d6iL0+a1iD8Du/3M3fWo=; b=QDwdEnFYOEjquzyvaZLLrev8sqjiI67CJmzTJoMStwWOKuXMenWkbHXyiUGr/MFY5+ HPsXalNV/KvGQiwuaE6CVmeyeGcxopkzi5IAcyl4pj8YWIe+6w95KjqimeD2c5jGRTIf UzogCb4mDQb95Zcd3W7uhT+9PH/QJnhjQS4lgNm2aeiGnOlwjyKp5RqEyjkMiHaiM2L7 nXfUxnyRC24FeCGkaxGfV0WVfdWaMUrPMBU8+oM/cOOzvg/gbZZyvn/dC1Czoh9vOd7J iBEgJoUqvdX+T7ReFCFMdPFH2NJruQHTIiXk09sKED3b/vHc+iE9IyHHaV8j7LRSCjX3 6Jmg== 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:mime-version:content-transfer-encoding; bh=XAw3ZgfIAbV+DLrxuqn76+3d6iL0+a1iD8Du/3M3fWo=; b=uXyaYFr8qhNYx0IeYKax8PFJ/PWGu+WKzaZqAwikD60p2eQC5QHPpD9lNTnMb2ljO5 G13z7mj/8t2aHgvblNQ5FrNgqleyLk0NoL+wJMmVwZSsqbiDzZJZDHUjwJgpIKHTN80G pb4cKCQxYgSHGVCAkILIe2iT+Bk7jpoBslGVBBiJlUVx6cGNbxVSkoxk07n+/r+Ks7DH gWx5Brut8RvSgeMfFdZCVv1kE/D4eARWoMdEJ30g156DglgDv7I9fKVrf+I369ke3GKN WcjZyGMWPlbaJVATMGjmg2ZAr2VbekLOj8B8Ejlc4Bs2cR/tmNVF50XZCAU4aA2/TZtY K2CQ== X-Gm-Message-State: APjAAAUjdE3D19sbDJ5dxk6CbH+jMZGeoOJBCMZcOLWAHNa+sokyM9Ax tTHb1L67WDl+IyGWQQe1RPE= X-Google-Smtp-Source: APXvYqx7w5SdqbtZit/UJOQvKzOUmxY1sHB8IATpV9+rVYda5jx/hshNibVFAh0Ea5E5Fo9o24xS8g== X-Received: by 2002:a17:90a:2464:: with SMTP id h91mr9248861pje.9.1568252094496; Wed, 11 Sep 2019 18:34:54 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id b126sm35248236pfa.177.2019.09.11.18.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:34:53 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Chris Healy , Lucas Stach , Eduardo Valentin , Daniel Lezcano , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 07/12] thermal: qoriq: Drop unnecessary drvdata cleanup Date: Wed, 11 Sep 2019 18:34:42 -0700 Message-Id: <20190912013447.2977-1-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912012920.29601-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Driver data of underlying struct device will be set to NULL by Linux's driver infrastructure. Clearing it here is unnecessary. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index af596c3342d0..8a28a4433d44 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -253,8 +253,6 @@ static int qoriq_tmu_remove(struct platform_device *pdev) clk_disable_unprepare(data->clk); - platform_set_drvdata(pdev, NULL); - return 0; } From patchwork Thu Sep 12 01:34:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142009 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9918A924 for ; Thu, 12 Sep 2019 01:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6455C20872 for ; Thu, 12 Sep 2019 01:35:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TIWO9z1y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728298AbfILBfA (ORCPT ); Wed, 11 Sep 2019 21:35:00 -0400 Received: from mail-pg1-f182.google.com ([209.85.215.182]:44714 "EHLO mail-pg1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfILBfA (ORCPT ); Wed, 11 Sep 2019 21:35:00 -0400 Received: by mail-pg1-f182.google.com with SMTP id i18so12469731pgl.11; Wed, 11 Sep 2019 18:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A/iLWd49EumACfVrmrrNo36J3HAn0AfKJ4UQXuVqJXM=; b=TIWO9z1y48vLwJpsX+rJbGXXfT4hzT2292VzfZbWi2vbZDLolbOyHjKjkuinH+HoxO bznMWm8iAYC37DcArpOLu0y6UDbikxF7qs9zmoQs9Ejpc31c6jPZgCT3WNzEJOrQNe3s kNovhfjwxTwtEzqi9H3WpuDgaLK/ddOMCIZt43HVxRmIwNm/QcxOEaNoCKInjqiQp5ue Ujd8f7clWRKKldqd7WFSeA3H+yA+sb2gn78KdOSZkQv7VuM1/NpNjDeYfd8XXlByd1fU OTTriwXgWFigTa1Rig13ZIFS9dWjpwSBJVE+IEACywVHQK4xrGkwLs0qSxK6/DcKBWGt 6nqg== 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:mime-version:content-transfer-encoding; bh=A/iLWd49EumACfVrmrrNo36J3HAn0AfKJ4UQXuVqJXM=; b=Qlagy7nTnrNVf91YxvPO8mCIZPpfsSkU1HxRxgeT4Ccpu0hFWB8toSHyk5pxJxWWko GmDu66Jg7K4cZwtw0RmXip7gQLH5ZoimU9XNS7WPxBJSrtHtMtpZQrH3a59W7hPAOZOE Qen8qcoTGdrF+SEge0hDKc7sKg3IEB6n3mU5+nQ0A3KhzrSmA10+fmYnQdyTahKOUGgO qc0VzqKR16npPiOrGwC6nvV5uXQi70P7qSx3jGGF+V1j62oxhhznIjeGFx/7qe0Lbu+e J1igs+ufACa/z5mArlZv7nSVR2lvTysAZny8geN2nsgr9yv3EZRCGtSCcPgnzaGuRJOG OBLw== X-Gm-Message-State: APjAAAXQgLeZCcPx2CzzuyJJxGPxDI838PJB/m6VViyw61FCZsqd86Do GtKrJBqg8W4atpgPLx4eCAg= X-Google-Smtp-Source: APXvYqw6Pj6eCE4mHLNalGicIkhmdRBoJUzlNRXsXEtbhV8YvHCMMo90N2zpwgkMKMKJTBTklmh3og== X-Received: by 2002:a63:e20a:: with SMTP id q10mr34990935pgh.24.1568252099203; Wed, 11 Sep 2019 18:34:59 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id b126sm35248236pfa.177.2019.09.11.18.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:34:58 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 08/12] thermal: qoriq: Convert driver to use regmap API Date: Wed, 11 Sep 2019 18:34:43 -0700 Message-Id: <20190912013447.2977-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912013447.2977-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> <20190912013447.2977-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Convert driver to use regmap API, drop custom LE/BE IO helpers and simplify bit manipulation using regmap_update_bits(). This also allows us to convert some register initialization to use loops and adds convenient debug access to TMU registers via debugfs. Signed-off-by: Andrey Smirnov Reviewed-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 153 +++++++++++++++----------------- 1 file changed, 72 insertions(+), 81 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 8a28a4433d44..32bf5ed57f5c 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "thermal_core.h" @@ -18,48 +19,27 @@ /* * QorIQ TMU Registers */ -struct qoriq_tmu_site_regs { - u32 tritsr; /* Immediate Temperature Site Register */ - u32 tratsr; /* Average Temperature Site Register */ - u8 res0[0x8]; -}; -struct qoriq_tmu_regs { - u32 tmr; /* Mode Register */ +#define REGS_TMR 0x000 /* Mode Register */ #define TMR_DISABLE 0x0 #define TMR_ME 0x80000000 #define TMR_ALPF 0x0c000000 - u32 tsr; /* Status Register */ - u32 tmtmir; /* Temperature measurement interval Register */ + +#define REGS_TMTMIR 0x008 /* Temperature measurement interval Register */ #define TMTMIR_DEFAULT 0x0000000f - u8 res0[0x14]; - u32 tier; /* Interrupt Enable Register */ + +#define REGS_TIER 0x020 /* Interrupt Enable Register */ #define TIER_DISABLE 0x0 - u32 tidr; /* Interrupt Detect Register */ - u32 tiscr; /* Interrupt Site Capture Register */ - u32 ticscr; /* Interrupt Critical Site Capture Register */ - u8 res1[0x10]; - u32 tmhtcrh; /* High Temperature Capture Register */ - u32 tmhtcrl; /* Low Temperature Capture Register */ - u8 res2[0x8]; - u32 tmhtitr; /* High Temperature Immediate Threshold */ - u32 tmhtatr; /* High Temperature Average Threshold */ - u32 tmhtactr; /* High Temperature Average Crit Threshold */ - u8 res3[0x24]; - u32 ttcfgr; /* Temperature Configuration Register */ - u32 tscfgr; /* Sensor Configuration Register */ - u8 res4[0x78]; - struct qoriq_tmu_site_regs site[SITES_MAX]; - u8 res5[0x9f8]; - u32 ipbrr0; /* IP Block Revision Register 0 */ - u32 ipbrr1; /* IP Block Revision Register 1 */ - u8 res6[0x310]; - u32 ttr0cr; /* Temperature Range 0 Control Register */ - u32 ttr1cr; /* Temperature Range 1 Control Register */ - u32 ttr2cr; /* Temperature Range 2 Control Register */ - u32 ttr3cr; /* Temperature Range 3 Control Register */ -}; +#define REGS_TTCFGR 0x080 /* Temperature Configuration Register */ +#define REGS_TSCFGR 0x084 /* Sensor Configuration Register */ + +#define REGS_TRITSR(n) (0x100 + 16 * (n)) /* Immediate Temperature + * Site Register + */ +#define REGS_TTRnCR(n) (0xf10 + 4 * (n)) /* Temperature Range n + * Control Register + */ /* * Thermal zone data */ @@ -68,9 +48,8 @@ struct qoriq_sensor { }; struct qoriq_tmu_data { - struct qoriq_tmu_regs __iomem *regs; + struct regmap *regmap; struct clk *clk; - bool little_endian; struct qoriq_sensor sensor[SITES_MAX]; }; @@ -79,29 +58,13 @@ static struct qoriq_tmu_data *qoriq_sensor_to_data(struct qoriq_sensor *s) return container_of(s, struct qoriq_tmu_data, sensor[s->id]); } -static void tmu_write(struct qoriq_tmu_data *p, u32 val, void __iomem *addr) -{ - if (p->little_endian) - iowrite32(val, addr); - else - iowrite32be(val, addr); -} - -static u32 tmu_read(struct qoriq_tmu_data *p, void __iomem *addr) -{ - if (p->little_endian) - return ioread32(addr); - else - return ioread32be(addr); -} - static int tmu_get_temp(void *p, int *temp) { struct qoriq_sensor *qsensor = p; struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor); u32 val; - val = tmu_read(qdata, &qdata->regs->site[qsensor->id].tritsr); + regmap_read(qdata->regmap, REGS_TRITSR(qsensor->id), &val); *temp = (val & 0xff) * 1000; return 0; @@ -139,7 +102,8 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, /* Enable monitoring */ if (sites != 0) - tmu_write(qdata, sites | TMR_ME | TMR_ALPF, &qdata->regs->tmr); + regmap_write(qdata->regmap, REGS_TMR, + sites | TMR_ME | TMR_ALPF); return 0; } @@ -158,10 +122,8 @@ static int qoriq_tmu_calibration(struct device *dev, } /* Init temperature range registers */ - tmu_write(data, range[0], &data->regs->ttr0cr); - tmu_write(data, range[1], &data->regs->ttr1cr); - tmu_write(data, range[2], &data->regs->ttr2cr); - tmu_write(data, range[3], &data->regs->ttr3cr); + for (i = 0; i < ARRAY_SIZE(range); i++) + regmap_write(data->regmap, REGS_TTRnCR(i), range[i]); calibration = of_get_property(np, "fsl,tmu-calibration", &len); if (calibration == NULL || len % 8) { @@ -171,9 +133,9 @@ static int qoriq_tmu_calibration(struct device *dev, for (i = 0; i < len; i += 8, calibration += 2) { val = of_read_number(calibration, 1); - tmu_write(data, val, &data->regs->ttcfgr); + regmap_write(data->regmap, REGS_TTCFGR, val); val = of_read_number(calibration + 1, 1); - tmu_write(data, val, &data->regs->tscfgr); + regmap_write(data->regmap, REGS_TSCFGR, val); } return 0; @@ -182,33 +144,68 @@ static int qoriq_tmu_calibration(struct device *dev, static void qoriq_tmu_init_device(struct qoriq_tmu_data *data) { /* Disable interrupt, using polling instead */ - tmu_write(data, TIER_DISABLE, &data->regs->tier); + regmap_write(data->regmap, REGS_TIER, TIER_DISABLE); /* Set update_interval */ - tmu_write(data, TMTMIR_DEFAULT, &data->regs->tmtmir); + regmap_write(data->regmap, REGS_TMTMIR, TMTMIR_DEFAULT); /* Disable monitoring */ - tmu_write(data, TMR_DISABLE, &data->regs->tmr); + regmap_write(data->regmap, REGS_TMR, TMR_DISABLE); } +static const struct regmap_range qoriq_yes_ranges[] = { + regmap_reg_range(REGS_TMR, REGS_TSCFGR), + regmap_reg_range(REGS_TTRnCR(0), REGS_TTRnCR(3)), + /* Read only registers below */ + regmap_reg_range(REGS_TRITSR(0), REGS_TRITSR(15)), +}; + +static const struct regmap_access_table qoriq_wr_table = { + .yes_ranges = qoriq_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(qoriq_yes_ranges) - 1, +}; + +static const struct regmap_access_table qoriq_rd_table = { + .yes_ranges = qoriq_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(qoriq_yes_ranges), +}; + static int qoriq_tmu_probe(struct platform_device *pdev) { int ret; struct qoriq_tmu_data *data; struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; + const bool little_endian = of_property_read_bool(np, "little-endian"); + const enum regmap_endian format_endian = + little_endian ? REGMAP_ENDIAN_LITTLE : REGMAP_ENDIAN_BIG; + const struct regmap_config regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .rd_table = &qoriq_rd_table, + .wr_table = &qoriq_wr_table, + .val_format_endian = format_endian, + .max_register = SZ_4K, + }; + void __iomem *base; data = devm_kzalloc(dev, sizeof(struct qoriq_tmu_data), GFP_KERNEL); if (!data) return -ENOMEM; - data->little_endian = of_property_read_bool(np, "little-endian"); - - data->regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(data->regs)) { + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) { dev_err(dev, "Failed to get memory region\n"); - return PTR_ERR(data->regs); + return PTR_ERR(base); + } + + data->regmap = devm_regmap_init_mmio(dev, base, ®map_config); + ret = PTR_ERR_OR_ZERO(data->regmap); + if (ret) { + dev_err(dev, "Failed to init regmap (%d)\n", ret); + return ret; } data->clk = devm_clk_get_optional(dev, NULL); @@ -249,7 +246,7 @@ static int qoriq_tmu_remove(struct platform_device *pdev) struct qoriq_tmu_data *data = platform_get_drvdata(pdev); /* Disable monitoring */ - tmu_write(data, TMR_DISABLE, &data->regs->tmr); + regmap_write(data->regmap, REGS_TMR, TMR_DISABLE); clk_disable_unprepare(data->clk); @@ -258,13 +255,12 @@ static int qoriq_tmu_remove(struct platform_device *pdev) static int __maybe_unused qoriq_tmu_suspend(struct device *dev) { - u32 tmr; struct qoriq_tmu_data *data = dev_get_drvdata(dev); + int ret; - /* Disable monitoring */ - tmr = tmu_read(data, &data->regs->tmr); - tmr &= ~TMR_ME; - tmu_write(data, tmr, &data->regs->tmr); + ret = regmap_update_bits(data->regmap, REGS_TMR, TMR_ME, 0); + if (ret) + return ret; clk_disable_unprepare(data->clk); @@ -273,7 +269,6 @@ static int __maybe_unused qoriq_tmu_suspend(struct device *dev) static int __maybe_unused qoriq_tmu_resume(struct device *dev) { - u32 tmr; int ret; struct qoriq_tmu_data *data = dev_get_drvdata(dev); @@ -282,11 +277,7 @@ static int __maybe_unused qoriq_tmu_resume(struct device *dev) return ret; /* Enable monitoring */ - tmr = tmu_read(data, &data->regs->tmr); - tmr |= TMR_ME; - tmu_write(data, tmr, &data->regs->tmr); - - return 0; + return regmap_update_bits(data->regmap, REGS_TMR, TMR_ME, TMR_ME); } static SIMPLE_DEV_PM_OPS(qoriq_tmu_pm_ops, From patchwork Thu Sep 12 01:34:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142017 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3C12924 for ; Thu, 12 Sep 2019 01:35:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D274621479 for ; Thu, 12 Sep 2019 01:35:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EcAihO1q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728628AbfILBfB (ORCPT ); Wed, 11 Sep 2019 21:35:01 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43005 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728545AbfILBfB (ORCPT ); Wed, 11 Sep 2019 21:35:01 -0400 Received: by mail-pl1-f193.google.com with SMTP id g6so366670plj.9; Wed, 11 Sep 2019 18:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oFSJfi3ZJCYXJKXtfe/e03Q38MolntauiwlSEHO3ZX0=; b=EcAihO1qWRSofOzVvvWF296PjLO9/ngsnRkOVeTv1AuMifMeI+8d6w5zADnBnPZLvQ cY4/c+MMb24yGJTRq6Zlq9Kw0OzyxpF6gHx1mrvV/vrh0SUUTIFeVhUaujHpXAQ4sr8h v+gJlpK4HyIj/JwSi2jPXWldVDKKOkc1KxcnXijyNov7V7Mt7/xaKnhlbECx2Rkj88x5 Zre1iXYZw+VMpE7a8oQEBhmHU+w1LrCH3BGyYJvmINRixof8ujV9jkUUgZWbimM0R6bk d98Ck4hKq0Gme3NMqf+L3e/AKT7Vy1/dPa4M2eBR8LPuo4461qKZY5U5tBUnijNk7/Dd Wx6w== 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:mime-version:content-transfer-encoding; bh=oFSJfi3ZJCYXJKXtfe/e03Q38MolntauiwlSEHO3ZX0=; b=G2Im7PJA051lfp29PNmsgMWEZ/qRd+5UioLQ1VlSJF4D2i/uU12Z0HN4DNhR/gCoQq Y2bbDChPjfRCgz77VmnPf66UVJYsgpF4GxUhnXIUwbvOHiTmR8pSV54I04CfMdfuXPWm Fmp0YvVGqyiLjmkmbRPGvTuxooBFXJRHa2RoTsK9PNx7BxTO7nVs2RgO5PmnVQ18DUt2 wYijSkuN0KjdNyneY7XRyCMxKWs5O56Q8V1kbIxKSx740NMC3ZLvWbHzl4XchFmzWA5O al+dAXV7DSNcAKLwj0RQB9mDO1hirIgvWtL/7CQidC0iVf0t8LbjrfMXYll20ToDXt0n abQQ== X-Gm-Message-State: APjAAAWscxLkfcoy2wbVDzbLCCWBq20xfKKsOKOzQVdfagkroe0ReFpC lZ5spq8zzI4QqBBFoyJ40j4g8qza19w= X-Google-Smtp-Source: APXvYqw9/YRrLAhRhYRXGSmkXfw5lt9ho74SUnC71ljTA6ZDuKvZeZ2DurYfoZGyn+B36TAzzkvM/g== X-Received: by 2002:a17:902:9684:: with SMTP id n4mr9751094plp.266.1568252100474; Wed, 11 Sep 2019 18:35:00 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id b126sm35248236pfa.177.2019.09.11.18.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:34:59 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Lucas Stach , Chris Healy , Eduardo Valentin , Daniel Lezcano , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 09/12] thermal: qoriq: Enable all sensors before registering them Date: Wed, 11 Sep 2019 18:34:44 -0700 Message-Id: <20190912013447.2977-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912013447.2977-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> <20190912013447.2977-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Tmu_get_temp will get called as a part of sensor registration via devm_thermal_zone_of_sensor_register(). To prevent it from retruning bogus data we need to enable sensor monitoring before that. Looking at the datasheet (i.MX8MQ RM) there doesn't seem to be any harm in enabling them all, so, for the sake of simplicity, change the code to do just that. Signed-off-by: Andrey Smirnov Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 32bf5ed57f5c..1cc53a4a5c47 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -24,6 +24,7 @@ #define TMR_DISABLE 0x0 #define TMR_ME 0x80000000 #define TMR_ALPF 0x0c000000 +#define TMR_MSITE_ALL GENMASK(15, 0) #define REGS_TMTMIR 0x008 /* Temperature measurement interval Register */ #define TMTMIR_DEFAULT 0x0000000f @@ -77,7 +78,10 @@ static const struct thermal_zone_of_device_ops tmu_tz_ops = { static int qoriq_tmu_register_tmu_zone(struct device *dev, struct qoriq_tmu_data *qdata) { - int id, sites = 0; + int id; + + regmap_write(qdata->regmap, REGS_TMR, + TMR_MSITE_ALL | TMR_ME | TMR_ALPF); for (id = 0; id < SITES_MAX; id++) { struct thermal_zone_device *tzd; @@ -93,18 +97,12 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, if (ret) { if (ret == -ENODEV) continue; - else - return ret; - } - sites |= 0x1 << (15 - id); + regmap_write(qdata->regmap, REGS_TMR, TMR_DISABLE); + return ret; + } } - /* Enable monitoring */ - if (sites != 0) - regmap_write(qdata->regmap, REGS_TMR, - sites | TMR_ME | TMR_ALPF); - return 0; } From patchwork Thu Sep 12 01:34:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142011 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 846EC924 for ; Thu, 12 Sep 2019 01:35:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62C0E20CC7 for ; Thu, 12 Sep 2019 01:35:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CKtn8l2g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728770AbfILBfD (ORCPT ); Wed, 11 Sep 2019 21:35:03 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34680 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728673AbfILBfC (ORCPT ); Wed, 11 Sep 2019 21:35:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id r12so14884673pfh.1; Wed, 11 Sep 2019 18:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1rLahVlu4CEDCKDroxNVW1usHiwtWZlfedC9bz+64Ew=; b=CKtn8l2gXqX9kwIsebIl6Ni9V4udChMHZFLuPa5zg4I7rSoYfqloVb67SyvrEnrUtw UvHk7UzXhIeaEzXf9D1JlKclBB4lucNE4sNrBG4Pb0rXI03FN+3X5/OdKAzvo+c9vlx2 w+108UhgleWi2Mmggmr/GLCMT0+USaVgyiH3m9614iYcoRKmj0qClbt9XeJYHqHVl+VN ZTkoy31FkCUPjQCwLbpgenrV7Hy4rGbPzWaYnzgXkBCOihUpQ1SJkmD9tTl/+XvhVwE5 YWBm8qZ721/I/ZMunGD6PYAoH1KtcVimrlFXCcqPBbZZ8m6SUDakKY4GSY/AbSH/9hXO YALA== 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:mime-version:content-transfer-encoding; bh=1rLahVlu4CEDCKDroxNVW1usHiwtWZlfedC9bz+64Ew=; b=NNCXt6q0E2T1NdLKJiXjxhLgFGxbSc0mL/U+i+D4K0fGKje5bvJ8rghkAMa0wBnbZ9 OUdhcYweLZAsdtqswX9GWZrzVuhuuy+UK7kcXSVgzSX+2JiOGGV3KcdG4+C+PaAdR0ha 7oVrC1JSm09ZtFW1JQKMx9LkyRC/aGDXF5/ouxAMVJcGDGiO61sfzbwMDNsHY3b2l/6X AhYp+TtJgN64u/MEdLCnF+544mGhgMyUKd+zYVHLsQPX1HSl23DoS5rcxAyavzj7iq03 jAuM4+VL+G0cxmtYE44IKdOCNpMZd5/Ua7HwBsMc2YY547FCJswhsyoEAYikcCoanl8X wp2A== X-Gm-Message-State: APjAAAX7tlfkcjKsboUSGrO0h1dWaLV/l7HI3OrYBaxpukTlduxLhgan njAPMbtLJpIFwiHJvO6LfQs= X-Google-Smtp-Source: APXvYqwyz/a46GFwnyW6glvee++myUmL2Gcl5uJEXSbxPvRVF03nq0lRbyLMoiXJRnOiuxmeEzFh7g== X-Received: by 2002:a63:d64f:: with SMTP id d15mr36546251pgj.345.1568252101635; Wed, 11 Sep 2019 18:35:01 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id b126sm35248236pfa.177.2019.09.11.18.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:35:00 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 10/12] thermal: qoriq: Do not report invalid temperature reading Date: Wed, 11 Sep 2019 18:34:45 -0700 Message-Id: <20190912013447.2977-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912013447.2977-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> <20190912013447.2977-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Before returning measured temperature data to upper layer we need to make sure that the reading was marked as "valid" to avoid reporting bogus data. Signed-off-by: Andrey Smirnov Reviewed-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 1cc53a4a5c47..48853192514a 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -38,6 +38,7 @@ #define REGS_TRITSR(n) (0x100 + 16 * (n)) /* Immediate Temperature * Site Register */ +#define TRITSR_V BIT(31) #define REGS_TTRnCR(n) (0xf10 + 4 * (n)) /* Temperature Range n * Control Register */ @@ -64,8 +65,24 @@ static int tmu_get_temp(void *p, int *temp) struct qoriq_sensor *qsensor = p; struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor); u32 val; + /* + * REGS_TRITSR(id) has the following layout: + * + * 31 ... 7 6 5 4 3 2 1 0 + * V TEMP + * + * Where V bit signifies if the measurement is ready and is + * within sensor range. TEMP is an 8 bit value representing + * temperature in C. + */ + if (regmap_read_poll_timeout(qdata->regmap, + REGS_TRITSR(qsensor->id), + val, + val & TRITSR_V, + USEC_PER_MSEC, + 10 * USEC_PER_MSEC)) + return -ENODATA; - regmap_read(qdata->regmap, REGS_TRITSR(qsensor->id), &val); *temp = (val & 0xff) * 1000; return 0; From patchwork Thu Sep 12 01:34:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142013 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A67D817E6 for ; Thu, 12 Sep 2019 01:35:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8390220872 for ; Thu, 12 Sep 2019 01:35:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AdGmVzVx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbfILBfG (ORCPT ); Wed, 11 Sep 2019 21:35:06 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40035 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728815AbfILBfE (ORCPT ); Wed, 11 Sep 2019 21:35:04 -0400 Received: by mail-pg1-f194.google.com with SMTP id w10so12498133pgj.7; Wed, 11 Sep 2019 18:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e0lwGN+LUXDKi5KuFbcc2RGuv/5GribWzP248c589m4=; b=AdGmVzVx2MPHq3lSjRZ8BQGsla6vEamT3K1D6aGbaqHu1NqjC+TD4TwE2LSYbVBi9l teC8nzxpgN3ANQbrIFnyhTpzkxHIm1Kzq2Ga9x9kshjaotxnyE/l6j9xeJ9fgkNHM+Qp tmyLowjmVf+4WmefmJysKNrLRX+CFieoKvAaVGiW20ZGsRJjLjDj1k2wEJ+dzrhLunsi 4f6a9tfhGEJNA9aXSUec87WePxq9wfY9yPIW8p3I4O/2ouRhz3JcELoJYZJGQeR+MzRG QROt7vnzm/QXm5mwVIssiaeEQfKNYP0T8vNID2UE+WeDz7mhytBNX5AQj1RhLtOGhtz2 cnkw== 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:mime-version:content-transfer-encoding; bh=e0lwGN+LUXDKi5KuFbcc2RGuv/5GribWzP248c589m4=; b=U9MFmMS8jdwIEhHJMSeefN1rkoD01ZtyWzhszDnbBgxVpyCqeRckEL8ZztV76bU7HW SgrRC0LihbRySkcgDUdRjoGx96Lob5Ij0FW5L+vKr6Vu5RNyuSwF30Q/TJrL3SAubqI2 53324CKto9K2e74Xq+MdTxcBHb0cixs+Y2iTtwhQMVgV/TQ4SvE1yCKqh1NGZ2hUP6VQ Q+QS0qVFy3Ws5Zs8QHudb1R+NBH0odZw+DnQK9+lcbGFalEZSXKyB5X60Betm4ApDEfx Pm/nHsfUl0A7JIECyOiehPrP9EtcCIsYVw7ueD1bfXXtWk7q6ztvz4t4NmxQa4Su9sJW 7/rQ== X-Gm-Message-State: APjAAAUEqwPcIScUTMc8v84h5+uwgGOApkts9CLGyzTm5hv5DOHjYZN9 KHkBpziPpimDKbNGCbPT72w= X-Google-Smtp-Source: APXvYqyZKE1SxukxD5sUaq9u3PxLRoLLHIBTVxWdGAOomEDoAlp0u00YX7nGTruOcfYtoef/yMjUTQ== X-Received: by 2002:aa7:869a:: with SMTP id d26mr46996259pfo.2.1568252103285; Wed, 11 Sep 2019 18:35:03 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id b126sm35248236pfa.177.2019.09.11.18.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:35:02 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 11/12] thermal_hwmon: Add devres wrapper for thermal_add_hwmon_sysfs() Date: Wed, 11 Sep 2019 18:34:46 -0700 Message-Id: <20190912013447.2977-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912013447.2977-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> <20190912013447.2977-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add devres wrapper for thermal_add_hwmon_sysfs() to simplify driver code. Signed-off-by: Andrey Smirnov Reviewed-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/thermal_hwmon.c | 28 ++++++++++++++++++++++++++++ drivers/thermal/thermal_hwmon.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index dd5d8ee37928..c8d2620f2e42 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -248,3 +248,31 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) kfree(hwmon); } EXPORT_SYMBOL_GPL(thermal_remove_hwmon_sysfs); + +static void devm_thermal_hwmon_release(struct device *dev, void *res) +{ + thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res); +} + +int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) +{ + struct thermal_zone_device **ptr; + int ret; + + ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return -ENOMEM; + + ret = thermal_add_hwmon_sysfs(tz); + if (ret) { + devres_free(ptr); + return ret; + } + + *ptr = tz; + devres_add(&tz->device, ptr); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_thermal_add_hwmon_sysfs); diff --git a/drivers/thermal/thermal_hwmon.h b/drivers/thermal/thermal_hwmon.h index a160b9d62dd0..1a9d65f6a6a8 100644 --- a/drivers/thermal/thermal_hwmon.h +++ b/drivers/thermal/thermal_hwmon.h @@ -17,6 +17,7 @@ #ifdef CONFIG_THERMAL_HWMON int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz); +int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz); void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz); #else static inline int @@ -25,6 +26,12 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) return 0; } +static inline int +devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) +{ + return 0; +} + static inline void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) { From patchwork Thu Sep 12 01:34:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11142015 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1CDD184E for ; Thu, 12 Sep 2019 01:35:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF97B20872 for ; Thu, 12 Sep 2019 01:35:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MyBrC6i6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728854AbfILBfG (ORCPT ); Wed, 11 Sep 2019 21:35:06 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44348 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728673AbfILBfF (ORCPT ); Wed, 11 Sep 2019 21:35:05 -0400 Received: by mail-pl1-f194.google.com with SMTP id k1so10975769pls.11; Wed, 11 Sep 2019 18:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cWsYbqUsjfWBFB132P+70l3TxUklV7bh1JoltYP6jwg=; b=MyBrC6i6+1kxrLbsnlfDDL0aEm1Fz6LZLVW02g8qpEjAZEbXFhu+a4lUt5nEfn3fSJ C022VdB7gVPIsWueyYSZ2cJ67LaHIrWe/M9mI0isacZYZ3hSYQ385tvAh6IILbIS6h/G YHrxvf+UMUovoXwvmgC4b6q3f6EE144Y4fkdMozx07UFo2fEvcJkGmnt3aMg1HendhGN 9fCju6kGaOFWbGslerMN9XUP5ql9RV9cEr6Q5k1PAX8edmdzpigLHPoOnYoIFjxHzLKz QpbH9o74zrX0Dik9n3VyNG7QUjXZQppgJc0rUbnW91i153mK9ekm2ioEgSdFmJYb1MfC 2k1g== 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:mime-version:content-transfer-encoding; bh=cWsYbqUsjfWBFB132P+70l3TxUklV7bh1JoltYP6jwg=; b=Fxzw1AbywGZ/Ij6hDkR/+5d/nvHe35XQMfydjVixZFafk93zGhyuK14dVDdNbUxQJx gXM6BN81Fw5y8R+PuSoyYOTIpKh2/0ths6hEMx5WC1U/g/Xbc98egIlL+lx5Eg3RJ0LA xcfFPVIKoQDyywMxWq4/hae1NgI+OvUNAzq46w/aACdz8cPCsQRdMw6fcrnJ2c2fDr+3 jt33+TUoaWCYp1Zd8RyHITkXGHAjJYUIVWqpdiY6JgPOeW/hRpCHRzu3bOx3YGc4u3td zgbcFo2/gXPHVjEqeH6mJaVUKceMp6+ZJ15QxrewGFrG2fmtgGbFc6FWzkwS/0VjELng WtsQ== X-Gm-Message-State: APjAAAWDZ+9mlYwJnZ+9QU4ARvMWic/S1QjtHFLIQCkHsSP0gGi5njuO 4EbsaaXzP0IqR35gwwcE+Wg= X-Google-Smtp-Source: APXvYqxP8kYJiqLOH5C7TMGvcDrnUub31FEEbsJFEjj+MFaxYXeE07zi+1Gc4Vv0muSp00W8t23JLQ== X-Received: by 2002:a17:902:b70f:: with SMTP id d15mr40679643pls.285.1568252104542; Wed, 11 Sep 2019 18:35:04 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id b126sm35248236pfa.177.2019.09.11.18.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 18:35:03 -0700 (PDT) From: Andrey Smirnov To: Zhang Rui Cc: Andrey Smirnov , Daniel Lezcano , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 12/12] thermal: qoriq: Add hwmon support Date: Wed, 11 Sep 2019 18:34:47 -0700 Message-Id: <20190912013447.2977-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912013447.2977-1-andrew.smirnov@gmail.com> References: <20190912012920.29601-1-andrew.smirnov@gmail.com> <20190912013447.2977-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Expose thermal readings as a HWMON device, so that it could be accessed using lm-sensors. Signed-off-by: Andrey Smirnov Reviewed-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 48853192514a..e907f0d2103f 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -13,6 +13,7 @@ #include #include "thermal_core.h" +#include "thermal_hwmon.h" #define SITES_MAX 16 @@ -118,6 +119,11 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, regmap_write(qdata->regmap, REGS_TMR, TMR_DISABLE); return ret; } + + if (devm_thermal_add_hwmon_sysfs(tzd)) + dev_warn(dev, + "Failed to add hwmon sysfs attributes\n"); + } return 0;