mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3]hwmon: Modify to support Phytium FT2000/4 CPU for acpi
@ 2022-11-24  3:05 Wang Honghui
  2022-11-24 14:35 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Honghui @ 2022-11-24  3:05 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel

Modify to support Phytium FT2000/4 CPU for acpi

Signed-off-by: Wang Honghui <honghui.wang@ucas.com.cn>
---
 drivers/hwmon/scpi-hwmon.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
index 4d75385f7d5e..6021ae00b334 100644
--- a/drivers/hwmon/scpi-hwmon.c
+++ b/drivers/hwmon/scpi-hwmon.c
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/thermal.h>
+#include <linux/acpi.h>
 
 struct sensor_data {
 	unsigned int scale;
@@ -132,6 +133,13 @@ static const struct of_device_id scpi_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, scpi_of_match);
 
+/* Wang Honghui add to support Phytium FT2000/4 CPU for acpi */
+static const struct acpi_device_id scpi_sensors_acpi_match[] = {
+        { .id = "PHYT000D" },
+        { }
+};
+MODULE_DEVICE_TABLE(acpi, scpi_sensors_acpi_match);
+
 static int scpi_hwmon_probe(struct platform_device *pdev)
 {
 	u16 nr_sensors, i;
@@ -141,6 +149,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
 	struct scpi_ops *scpi_ops;
 	struct device *hwdev, *dev = &pdev->dev;
 	struct scpi_sensors *scpi_sensors;
+	const struct acpi_device_id *match;
 	int idx, ret;
 
 	scpi_ops = get_scpi_ops();
@@ -170,11 +179,22 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
 
 	scpi_sensors->scpi_ops = scpi_ops;
 
-	scale = of_device_get_match_data(&pdev->dev);
-	if (!scale) {
-		dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
-		return -ENODEV;
-	}
+	/* Wang Honghui modified to support Phytium FT2000/4 CPU for acpi */
+	if (dev->of_node) {
+		scale = of_device_get_match_data(&pdev->dev);
+		if (!scale) {
+			dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
+			return -ENODEV;
+		}
+	} else {
+                match = acpi_match_device(dev->driver->acpi_match_table, dev);
+                if (!match) {
+                        dev_err(dev, "scpi-hwmon: Error ACPI match data is missing\n");
+                        return -ENODEV;
+                }   
+    
+                scale = scpi_scale;
+        }
 
 	for (i = 0, idx = 0; i < nr_sensors; i++) {
 		struct sensor_data *sensor = &scpi_sensors->data[idx];
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/3]hwmon: Modify to support Phytium FT2000/4 CPU for acpi
  2022-11-24  3:05 [PATCH 1/3]hwmon: Modify to support Phytium FT2000/4 CPU for acpi Wang Honghui
@ 2022-11-24 14:35 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-11-24 14:35 UTC (permalink / raw)
  To: Wang Honghui, Jean Delvare, linux-hwmon, linux-kernel

On 11/23/22 19:05, Wang Honghui wrote:
> Modify to support Phytium FT2000/4 CPU for acpi
> 
> Signed-off-by: Wang Honghui <honghui.wang@ucas.com.cn>
> ---
>   drivers/hwmon/scpi-hwmon.c | 30 +++++++++++++++++++++++++-----
>   1 file changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
> index 4d75385f7d5e..6021ae00b334 100644
> --- a/drivers/hwmon/scpi-hwmon.c
> +++ b/drivers/hwmon/scpi-hwmon.c
> @@ -14,6 +14,7 @@
>   #include <linux/slab.h>
>   #include <linux/sysfs.h>
>   #include <linux/thermal.h>
> +#include <linux/acpi.h>
>   
Alphabetic include file order, please.

>   struct sensor_data {
>   	unsigned int scale;
> @@ -132,6 +133,13 @@ static const struct of_device_id scpi_of_match[] = {
>   };
>   MODULE_DEVICE_TABLE(of, scpi_of_match);
>   
> +/* Wang Honghui add to support Phytium FT2000/4 CPU for acpi */

Irrelevant comment.

> +static const struct acpi_device_id scpi_sensors_acpi_match[] = {
> +        { .id = "PHYT000D" },
> +        { }
> +};
> +MODULE_DEVICE_TABLE(acpi, scpi_sensors_acpi_match);
> +
>   static int scpi_hwmon_probe(struct platform_device *pdev)
>   {
>   	u16 nr_sensors, i;
> @@ -141,6 +149,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
>   	struct scpi_ops *scpi_ops;
>   	struct device *hwdev, *dev = &pdev->dev;
>   	struct scpi_sensors *scpi_sensors;
> +	const struct acpi_device_id *match;
>   	int idx, ret;
>   
>   	scpi_ops = get_scpi_ops();
> @@ -170,11 +179,22 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
>   
>   	scpi_sensors->scpi_ops = scpi_ops;
>   
> -	scale = of_device_get_match_data(&pdev->dev);
> -	if (!scale) {
> -		dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
> -		return -ENODEV;
> -	}
> +	/* Wang Honghui modified to support Phytium FT2000/4 CPU for acpi */

Irrelevant comment.

> +	if (dev->of_node) {
> +		scale = of_device_get_match_data(&pdev->dev);
> +		if (!scale) {
> +			dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
> +			return -ENODEV;
> +		}
> +	} else {
> +                match = acpi_match_device(dev->driver->acpi_match_table, dev);
> +                if (!match) {
> +                        dev_err(dev, "scpi-hwmon: Error ACPI match data is missing\n");
> +                        return -ENODEV;
> +                }
> +
> +                scale = scpi_scale;
> +        }

	scale = device_get_match_data(&pdev->dev);

should do after setting it in the acpi_device_id array.

Guenter

>   
>   	for (i = 0, idx = 0; i < nr_sensors; i++) {
>   		struct sensor_data *sensor = &scpi_sensors->data[idx];


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-24 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24  3:05 [PATCH 1/3]hwmon: Modify to support Phytium FT2000/4 CPU for acpi Wang Honghui
2022-11-24 14:35 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®