Skip to content

Commit

Permalink
thermal: qcom: tsens: Allow number of sensors to come from DT
Browse files Browse the repository at this point in the history
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 <bjorn.andersson@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Bjorn Andersson authored and Eduardo Valentin committed Jun 1, 2018
1 parent cc50ba5 commit 6d7c70d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/thermal/qcom-tsens.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions drivers/thermal/qcom/tsens.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 6d7c70d

Please sign in to comment.