From patchwork Mon May 7 23:53:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 135121 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp3744597lji; Mon, 7 May 2018 16:53:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqM7UsyTqFhlm98k8iUNoGX9tHSOF7NIGd35cV6SuuU5ojrydV4Ky13FjsZZz5QxBWrTJl9 X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr40248110plb.24.1525737229895; Mon, 07 May 2018 16:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525737229; cv=none; d=google.com; s=arc-20160816; b=nAbJuvdYveEBm6UuqHub8Pd5X2mm5UbWjTgMWcF2a0OiPaFQUxeyu2FMiCN2+qSUcU 8VF7Zt2y310SInspdDhvdpd9BdY1AsnkZC/xy2A2OIzWfYCq/3UO5XA1xFEfJYdDoEFM sI7rfwmLjCLgf1JmuzaJ4jXMU5SVtLxVdJM8qq01WTuU3adc629ntTiQqbhL8HKILMwI ebEtR8Ieri4QQC76OJUPQQpIYwmaQqPH11uUqusT2oARoqgzJLZlMFTVG0tAbMZAj8Jw fzho7aU0lC+gaM0KYDbvI+hs8xy4RgsK48lpoUdMJhN0S77PPf2MejOIFYpdVNGFQBLI Sq6g== 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=d9s9cX7XSOKN39MTMeApNHuYuXbuVzrEnAI4gm1jPig=; b=hNL2fNg+4aR4PvN0u6pz6/ZyuBNj76PaZYnK1+skch6rLaTDnyMY21vN5wv3KO1CW7 KoUdUtGTV5N7TzcMihIbgdEuEEL92sE9JEnsp2xOoTEpwKyEL1+0S6hThkO29CeZZMCU vEATz9TOUum867WABlL7xl9WRnxVWSiohQesezTAuCXkwYnBGaJspOB2AGL9pC0f1pEL WPUlmYpKMguRblo5zXxGDfO49QI6/zdMi8vjbnQhcbV1bu8CEOtSI6yzEeREi3hCMsip b13is5fYArEFD5+48eg9Z/Woo+rkhGtFuVQ1yewtYKf9ZP+xN55+7XI5unWnTo/eERbT Wrtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Mdq5BlrE; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 h123-v6si12394898pgc.299.2018.05.07.16.53.49; Mon, 07 May 2018 16:53:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=Mdq5BlrE; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1753541AbeEGXxq (ORCPT + 12 others); Mon, 7 May 2018 19:53:46 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36437 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753549AbeEGXxm (ORCPT ); Mon, 7 May 2018 19:53:42 -0400 Received: by mail-pl0-f66.google.com with SMTP id v24-v6so1076135plo.3 for ; Mon, 07 May 2018 16:53: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; bh=snwJmaUHYckrcQq2GSiPTJUbAsv9VzZH9Cn0DvCECZ0=; b=Mdq5BlrEShn3c/WYlyk98dUOXM2SCkCmoG/4BRkrmdz3cPlLKrMXwTZAPLKaqolHtj aw4xpbGJPxeK5jX+w0+4XMwreBqblnP+SfV1J2uAglPbMe35rB/2TKG4k9X+CYa7P+uK YhjJZFstozNDerfiUZeAE8DRfXx7pmJPn6tmY= 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=snwJmaUHYckrcQq2GSiPTJUbAsv9VzZH9Cn0DvCECZ0=; b=C2+PT5zPG+YfFwLKg9L4DvqU8mJVmszZuYfF633GMs19gVMK/CB3RDr+fTaNuBuVM+ lsBcePNiFOjZeeRoE+CXm4PabnCdUFkaCyrlO5r+vp1l8HdyGAWrPyoYdyQVpr9El8lT l38tN5PgtlwWM7eoZdgPSAVi45GHLKpe4ALCNJ8eoZ/HlqWUG6NSgJktbsf/ViXY3czp eB6C5YVKB1StohpHFsvJs5wIpSAO/MiQL7GTQVf/OPu5NoH2lUpzD4YRbxBiqfNDlIvA tMRlg94HPlg8NAnlaEmbIhC96jiIoEG2TseJJJCS069qCo8WLLtQNv4kdp7l+5MPHR3A TU1A== X-Gm-Message-State: ALQs6tAXRwl3v2TXxUUNUXd79lr8pzaycKqROZEC1juN2Yg+tcfZdG3O fOFUIaF2D7EamK381VrdO078yw== X-Received: by 2002:a17:902:6b09:: with SMTP id o9-v6mr40120364plk.256.1525737222173; Mon, 07 May 2018 16:53:42 -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 i127sm43891680pfc.154.2018.05.07.16.53.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 16:53:41 -0700 (PDT) From: Bjorn Andersson To: Zhang Rui , Eduardo Valentin , Rob Herring , Mark Rutland , Rajendra Nayak Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT Date: Mon, 7 May 2018 16:53:39 -0700 Message-Id: <20180507235339.8836-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org For platforms that has multiple copies of the TSENS hardware block it's necessary to be able to specify the number of sensors per block in DeviceTree. Signed-off-by: Bjorn Andersson --- .../devicetree/bindings/thermal/qcom-tsens.txt | 1 + drivers/thermal/qcom/tsens.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Rob Herring 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..20f3b87d7667 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,23 @@ static int tsens_probe(struct platform_device *pdev) else data = &data_8960; - if (data->num_sensors <= 0) { + num_sensors = data->num_sensors; + + 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)