projects
/
linux
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux]
/
drivers
/
thermal
/
qcom
/
tsens.c
diff --git
a/drivers/thermal/qcom/tsens.c
b/drivers/thermal/qcom/tsens.c
index
3f9fe6a
..
3440166
100644
(file)
--- a/
drivers/thermal/qcom/tsens.c
+++ b/
drivers/thermal/qcom/tsens.c
@@
-112,10
+112,10
@@
static int tsens_probe(struct platform_device *pdev)
int ret, i;
struct device *dev;
struct device_node *np;
int ret, i;
struct device *dev;
struct device_node *np;
- struct tsens_sensor *s;
struct tsens_device *tmdev;
const struct tsens_data *data;
const struct of_device_id *id;
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;
if (pdev->dev.of_node)
dev = &pdev->dev;
@@
-130,18
+130,24
@@
static int tsens_probe(struct platform_device *pdev)
else
data = &data_8960;
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;
}
dev_err(dev, "invalid number of sensors\n");
return -EINVAL;
}
- tmdev = devm_kzalloc(dev, sizeof(*tmdev) +
- data->num_sensors * sizeof(*s), GFP_KERNEL);
+ tmdev = devm_kzalloc(dev,
+ struct_size(tmdev, sensor, num_sensors),
+ GFP_KERNEL);
if (!tmdev)
return -ENOMEM;
tmdev->dev = dev;
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)
tmdev->ops = data->ops;
for (i = 0; i < tmdev->num_sensors; i++) {
if (data->hw_ids)