* [PATCH v2] thermal: qcom: tsens: Allow number of sensors to come from DT
@ 2018-06-02 19:32 Bjorn Andersson
2018-06-02 19:38 ` Bjorn Andersson
0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Andersson @ 2018-06-02 19:32 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: Rob Herring, Mark Rutland, Amit Kucheria, linux-pm, devicetree,
linux-kernel, linux-arm-msm
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 <amit.kucheria@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org> [binding]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
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)
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] thermal: qcom: tsens: Allow number of sensors to come from DT
2018-06-02 19:32 [PATCH v2] thermal: qcom: tsens: Allow number of sensors to come from DT Bjorn Andersson
@ 2018-06-02 19:38 ` Bjorn Andersson
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Andersson @ 2018-06-02 19:38 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: Rob Herring, Mark Rutland, Amit Kucheria, linux-pm, devicetree,
linux-kernel, linux-arm-msm
On Sat 02 Jun 12:32 PDT 2018, Bjorn Andersson wrote:
> 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 <amit.kucheria@linaro.org>
> Reviewed-by: Rob Herring <robh@kernel.org> [binding]
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Please ignore, after sending this I saw that Eduardo picked up v1
yesterday.
Thanks Eduardo,
Bjorn
> ---
>
> 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)
> --
> 2.17.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-02 19:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-02 19:32 [PATCH v2] thermal: qcom: tsens: Allow number of sensors to come from DT Bjorn Andersson
2018-06-02 19:38 ` Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).