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: 137598 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2426057lji; Sat, 2 Jun 2018 12:32:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLl6Ck84EEO0tYRLBpVPkRZquYkua6x0sG1PU6KJEifDaQqhzGk6891Vgf+xOmkC0e/sTxA X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr15352291pfc.179.1527967938528; Sat, 02 Jun 2018 12:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527967938; cv=none; d=google.com; s=arc-20160816; b=Y5cRWxF1U3yNtFqek5t1glFpgn/ysewswumykdmCdBFQOcp60cGWu1fyMhpI2aqGII OhBHqt3LMWp6xP5N6au/pNJZpfB2gwuNzOTHT6RX4FiwuSd1QBwnxmI82AU+j8DZmiWr mNZj/YeIn9RqdllIgrLbTPvAapPTZH6329AAm217zLiBHoegp5iNOmx4X/GCuDjdQiPv Jf1KbEczLw0sZq0t313AhkznHGRN9kmSCjExTiv8YiIislX7ivkWQ816xNU4YPWgm05l L+9k8fPhW2d+etDOFgGzXGQDFxXwyNyBhK26239GKIz4ShR3qghrmjaSXwo+pgeRnYQB SScA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=goLGogK4rKM3xgGtufIzwIFEBi8F2fdpcgfcYxbo5/Y=; b=UTIPY/EQ2I9PuNXtmdZPJJdlwvcolWMOgmKwyJqL1NoRaVx/6XzfzP6X0jEJpNMuhP kzYAQSsshSSr50IOhoy3slQRpymDXEKTrcpKHpbH8gUfufr6t2O4D7WIEogAuXU7Fdu4 DMcvf8wpdPJTNC32NrAPr1stWSUsw0d5gx55rqVuyJTSpsgobUyT8QXO02kJTspPmymo Acy7oOod/h3tepilvhvsWhKoSauJFeU0BVe2XV5PANbHPN5HhPzabTjcRpKPkeUXkysy 9ZUrwVK2mPgTdrmKShG+4oKoF2AMYR5nbPpOaAMI6fNe+9TRXIK78u4u7bD4maWsPzSp NAkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dzWyPz9l; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si41602241pld.218.2018.06.02.12.32.17; Sat, 02 Jun 2018 12:32:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dzWyPz9l; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751818AbeFBTcQ (ORCPT + 5 others); 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-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(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)