From: Bjorn Andersson Date: Mon, 7 May 2018 23:53:39 +0000 (-0700) Subject: thermal: qcom: tsens: Allow number of sensors to come from DT X-Git-Tag: v5.15~8617^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d7c70d1cd6526dc79e3d3b3faae1c40c1681168;p=platform%2Fkernel%2Flinux-starfive.git thermal: qcom: tsens: Allow number of sensors to come from DT 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 Reviewed-by: Amit Kucheria Reviewed-by: Rob Herring Signed-off-by: Eduardo Valentin --- diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt index 292ed89..06195e8 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 3f9fe6a..20f3b87 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)