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: 924561 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dzWyPz9l"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40yrtp3ztbz9s0w for ; Sun, 3 Jun 2018 05:32:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751818AbeFBTcQ (ORCPT ); Sat, 2 Jun 2018 15:32:16 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33351 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbeFBTcP (ORCPT ); Sat, 2 Jun 2018 15:32:15 -0400 Received: by mail-pg0-f66.google.com with SMTP id e11-v6so3485153pgq.0 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=C3yGp64Hho6h2V83XWWp/nLqKXDb5oQw1KrEYDCR3E3fN7qBWyMb233F/xrxaUYAQ7 GXnoF37X/D7fmlQrWDAQJqBBqDvFnlQXj/5f52fql5+mcEoyYtehd179BEUHRGSSAXoM DsK3nMp1lThgK9/VjxBj/SBzzSBTrMmUMIqydIooSRpq4s2T06OlCC+1Ju/ha3EQlHvL HxqzBzobcIrpGrZXqG41bcCfZwdHchRo5/+6HyiXrDQOehNpeC4fauQfp6RhjmbpOpea lf/r1R7tY0RtrhQXvAro1Hncsa910OvE7SngSMJ5/fI2SvHiE1x+vZsbRcAw2T3FY7ug SDYg== X-Gm-Message-State: ALKqPwcwfdbt1I9vSpD3c4+exS4g6YITrTg9JOn1hTgPqq4bmA6h6c46 qq0+ZmitNgIwWtUm8hzHUeZPVQ== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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)