From patchwork Sat Jun 2 19:32:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10444973 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.web.codeaurora.org (Postfix) with ESMTP id 1781060234 for ; Sat, 2 Jun 2018 19:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E562C28AC8 for ; Sat, 2 Jun 2018 19:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D996E28ACE; Sat, 2 Jun 2018 19:32:19 +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 B867528AC8 for ; Sat, 2 Jun 2018 19:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751963AbeFBTcR (ORCPT ); Sat, 2 Jun 2018 15:32:17 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46629 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbeFBTcP (ORCPT ); Sat, 2 Jun 2018 15:32:15 -0400 Received: by mail-pg0-f68.google.com with SMTP id d2-v6so2066638pga.13 for ; Sat, 02 Jun 2018 12:32:15 -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; bh=wMhO/7N67y4ca5eOStmMoTht94PDirKP9MBQnOXYxJE=; b=dzWyPz9lmnhuc34lkApjiIH9bulW0mYyyI/PQfytNKwM09F6Gtv8kfAaLWidqleUx6 +5ftVzcKuTITRNRYWyDwsU8pwM/z9rq8sT9z3Fztd0SD4VPs31TVnalYUCVmuqAcjZ6c h4Z3tWQn6H1y9yjszYKGokKd2hNUarKTCcBSs= 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; bh=wMhO/7N67y4ca5eOStmMoTht94PDirKP9MBQnOXYxJE=; b=nmZGS062I28x3FYCksLtrqkx6CX+HsFLE46YGbIQK04koJv9e9aCb42f2zB7dAH2qw r5rgh1CuBjxVueXl/Vbo27P+suqKoZkRlfc6QNrZRUA4wNQUBGO6JZQXhpVYd/rf+BqJ CVKlJ1D9UXGaAAzEZuPcQxJCdgO/V7vz3EkEUyIPZ/6p6ZDHO9nMd1pLJqPRWR1zzfjN mYwa1ZhvQHIoXGM4zXhiOYBmVsXVxmmNCfOcPMe097Evvn41aGNynwuPGPOUvAB/4c4g /n1UYrXAodsf+lcZx8/wQM+M+5a4Zdj60/ejyXvRn7dF2CVzv9lMaB40b7TKnO1U7f1b gE8w== X-Gm-Message-State: ALKqPwdeJccZlZEi687DDZybAKhBcQwNKITFpBSKM1G7jdVHh5DuTUqq 4vhkNsWMxacPL+IW1Woo11jOhm72oVY= X-Google-Smtp-Source: ADUXVKKKY6Pp4mjV8bpVQG3EaIDa04M3u7vSWmknjkeqRr8UdI/sAZ1yzmiyjKoXfRWN/CPdBsV1bA== X-Received: by 2002:a63:8848:: with SMTP id l69-v6mr12865860pgd.149.1527967935166; Sat, 02 Jun 2018 12:32:15 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t10-v6sm12539018pgn.20.2018.06.02.12.32.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 12:32:14 -0700 (PDT) From: Bjorn Andersson To: Zhang Rui , Eduardo Valentin Cc: Rob Herring , Mark Rutland , Amit Kucheria , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2] thermal: qcom: tsens: Allow number of sensors to come from DT Date: Sat, 2 Jun 2018 12:32:11 -0700 Message-Id: <20180602193211.25731-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 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 For platforms that has multiple copies of the TSENS hardware block it's convenient to specify the number of sensors per block in DeviceTree. Reviewed-by: Amit Kucheria Reviewed-by: Rob Herring [binding] Signed-off-by: Bjorn Andersson --- Changes since v1: - Added comment as suggested by Amit - Picked up Amit and Rob's R-b .../devicetree/bindings/thermal/qcom-tsens.txt | 1 + drivers/thermal/qcom/tsens.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt index 292ed89d900b..06195e8f35e2 100644 --- a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt +++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt @@ -8,6 +8,7 @@ Required properties: - reg: Address range of the thermal registers - #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description. +- #qcom,sensors: Number of sensors in tsens block - Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to specify nvmem cells diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 3f9fe6aa51cc..b212bebcfc36 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -116,6 +116,7 @@ static int tsens_probe(struct platform_device *pdev) struct tsens_device *tmdev; const struct tsens_data *data; const struct of_device_id *id; + u32 num_sensors; if (pdev->dev.of_node) dev = &pdev->dev; @@ -130,18 +131,24 @@ static int tsens_probe(struct platform_device *pdev) else data = &data_8960; - if (data->num_sensors <= 0) { + num_sensors = data->num_sensors; + + /* Override driver provided num_sensors, if specified in DT */ + if (np) + of_property_read_u32(np, "#qcom,sensors", &num_sensors); + + if (num_sensors <= 0) { dev_err(dev, "invalid number of sensors\n"); return -EINVAL; } tmdev = devm_kzalloc(dev, sizeof(*tmdev) + - data->num_sensors * sizeof(*s), GFP_KERNEL); + num_sensors * sizeof(*s), GFP_KERNEL); if (!tmdev) return -ENOMEM; tmdev->dev = dev; - tmdev->num_sensors = data->num_sensors; + tmdev->num_sensors = num_sensors; tmdev->ops = data->ops; for (i = 0; i < tmdev->num_sensors; i++) { if (data->hw_ids)