diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2018-09-25 05:03:03 -0400 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2018-10-22 20:44:23 -0400 |
commit | 8c0ffc8f9a76b2007258f146a4ff22ef14e68590 (patch) | |
tree | b5e4c324272e31c462f29926cb38e0379bcf0d5b | |
parent | 9bb4ec8d9e93f0d1a94e8aa9100c5f42fd364078 (diff) |
thermal/drivers/hisi: Prepare to support multiple sensors
Convert the 'sensor' field to a pointer and propagate the change in
the file. Havintg a pointer, gives us the opportunity to define
multiple sensors.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r-- | drivers/thermal/hisi_thermal.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 7287818a66b6..87b82fb00b08 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c | |||
@@ -77,10 +77,11 @@ struct hisi_thermal_ops { | |||
77 | 77 | ||
78 | struct hisi_thermal_data { | 78 | struct hisi_thermal_data { |
79 | const struct hisi_thermal_ops *ops; | 79 | const struct hisi_thermal_ops *ops; |
80 | struct hisi_thermal_sensor sensor; | 80 | struct hisi_thermal_sensor *sensor; |
81 | struct platform_device *pdev; | 81 | struct platform_device *pdev; |
82 | struct clk *clk; | 82 | struct clk *clk; |
83 | void __iomem *regs; | 83 | void __iomem *regs; |
84 | int nr_sensors; | ||
84 | int irq; | 85 | int irq; |
85 | }; | 86 | }; |
86 | 87 | ||
@@ -401,14 +402,29 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) | |||
401 | return ret; | 402 | return ret; |
402 | } | 403 | } |
403 | 404 | ||
404 | data->sensor.id = HI6220_DEFAULT_SENSOR; | 405 | data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); |
406 | if (!data->sensor) | ||
407 | return -ENOMEM; | ||
408 | |||
409 | data->sensor[0].id = HI6220_DEFAULT_SENSOR; | ||
410 | data->sensor[0].data = data; | ||
411 | data->nr_sensors = 1; | ||
405 | 412 | ||
406 | return 0; | 413 | return 0; |
407 | } | 414 | } |
408 | 415 | ||
409 | static int hi3660_thermal_probe(struct hisi_thermal_data *data) | 416 | static int hi3660_thermal_probe(struct hisi_thermal_data *data) |
410 | { | 417 | { |
411 | data->sensor.id = HI3660_DEFAULT_SENSOR; | 418 | struct platform_device *pdev = data->pdev; |
419 | struct device *dev = &pdev->dev; | ||
420 | |||
421 | data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); | ||
422 | if (!data->sensor) | ||
423 | return -ENOMEM; | ||
424 | |||
425 | data->sensor[0].id = HI3660_DEFAULT_SENSOR; | ||
426 | data->sensor[0].data = data; | ||
427 | data->nr_sensors = 1; | ||
412 | 428 | ||
413 | return 0; | 429 | return 0; |
414 | } | 430 | } |
@@ -433,7 +449,7 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { | |||
433 | static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) | 449 | static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) |
434 | { | 450 | { |
435 | struct hisi_thermal_data *data = dev; | 451 | struct hisi_thermal_data *data = dev; |
436 | struct hisi_thermal_sensor *sensor = &data->sensor; | 452 | struct hisi_thermal_sensor *sensor = &data->sensor[0]; |
437 | int temp = 0; | 453 | int temp = 0; |
438 | 454 | ||
439 | data->ops->irq_handler(sensor); | 455 | data->ops->irq_handler(sensor); |
@@ -444,7 +460,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) | |||
444 | dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", | 460 | dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", |
445 | temp, sensor->thres_temp); | 461 | temp, sensor->thres_temp); |
446 | 462 | ||
447 | thermal_zone_device_update(data->sensor.tzd, | 463 | thermal_zone_device_update(data->sensor[0].tzd, |
448 | THERMAL_EVENT_UNSPECIFIED); | 464 | THERMAL_EVENT_UNSPECIFIED); |
449 | 465 | ||
450 | } else { | 466 | } else { |
@@ -535,7 +551,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) | |||
535 | 551 | ||
536 | data->pdev = pdev; | 552 | data->pdev = pdev; |
537 | platform_set_drvdata(pdev, data); | 553 | platform_set_drvdata(pdev, data); |
538 | data->sensor.data = data; | ||
539 | data->ops = of_device_get_match_data(dev); | 554 | data->ops = of_device_get_match_data(dev); |
540 | 555 | ||
541 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 556 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -553,13 +568,13 @@ static int hisi_thermal_probe(struct platform_device *pdev) | |||
553 | if (ret) | 568 | if (ret) |
554 | return ret; | 569 | return ret; |
555 | 570 | ||
556 | ret = hisi_thermal_register_sensor(pdev, &data->sensor); | 571 | ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]); |
557 | if (ret) { | 572 | if (ret) { |
558 | dev_err(dev, "failed to register thermal sensor: %d\n", ret); | 573 | dev_err(dev, "failed to register thermal sensor: %d\n", ret); |
559 | return ret; | 574 | return ret; |
560 | } | 575 | } |
561 | 576 | ||
562 | ret = data->ops->enable_sensor(&data->sensor); | 577 | ret = data->ops->enable_sensor(&data->sensor[0]); |
563 | if (ret) { | 578 | if (ret) { |
564 | dev_err(dev, "Failed to setup the sensor: %d\n", ret); | 579 | dev_err(dev, "Failed to setup the sensor: %d\n", ret); |
565 | return ret; | 580 | return ret; |
@@ -575,7 +590,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) | |||
575 | } | 590 | } |
576 | } | 591 | } |
577 | 592 | ||
578 | hisi_thermal_toggle_sensor(&data->sensor, true); | 593 | hisi_thermal_toggle_sensor(&data->sensor[0], true); |
579 | 594 | ||
580 | return 0; | 595 | return 0; |
581 | } | 596 | } |
@@ -583,11 +598,11 @@ static int hisi_thermal_probe(struct platform_device *pdev) | |||
583 | static int hisi_thermal_remove(struct platform_device *pdev) | 598 | static int hisi_thermal_remove(struct platform_device *pdev) |
584 | { | 599 | { |
585 | struct hisi_thermal_data *data = platform_get_drvdata(pdev); | 600 | struct hisi_thermal_data *data = platform_get_drvdata(pdev); |
586 | struct hisi_thermal_sensor *sensor = &data->sensor; | 601 | struct hisi_thermal_sensor *sensor = &data->sensor[0]; |
587 | 602 | ||
588 | hisi_thermal_toggle_sensor(sensor, false); | 603 | hisi_thermal_toggle_sensor(sensor, false); |
589 | 604 | ||
590 | data->ops->disable_sensor(&data->sensor); | 605 | data->ops->disable_sensor(sensor); |
591 | 606 | ||
592 | return 0; | 607 | return 0; |
593 | } | 608 | } |
@@ -597,7 +612,7 @@ static int hisi_thermal_suspend(struct device *dev) | |||
597 | { | 612 | { |
598 | struct hisi_thermal_data *data = dev_get_drvdata(dev); | 613 | struct hisi_thermal_data *data = dev_get_drvdata(dev); |
599 | 614 | ||
600 | data->ops->disable_sensor(&data->sensor); | 615 | data->ops->disable_sensor(&data->sensor[0]); |
601 | 616 | ||
602 | return 0; | 617 | return 0; |
603 | } | 618 | } |
@@ -606,7 +621,7 @@ static int hisi_thermal_resume(struct device *dev) | |||
606 | { | 621 | { |
607 | struct hisi_thermal_data *data = dev_get_drvdata(dev); | 622 | struct hisi_thermal_data *data = dev_get_drvdata(dev); |
608 | 623 | ||
609 | return data->ops->enable_sensor(&data->sensor); | 624 | return data->ops->enable_sensor(&data->sensor[0]); |
610 | } | 625 | } |
611 | #endif | 626 | #endif |
612 | 627 | ||