OSDN Git Service

platform/chrome: cros_kbd_led_backlight: support OF match
authorTzung-Bi Shih <tzungbi@kernel.org>
Mon, 23 May 2022 09:08:21 +0000 (17:08 +0800)
committerTzung-Bi Shih <tzungbi@kernel.org>
Fri, 10 Jun 2022 02:31:42 +0000 (02:31 +0000)
For letting device tree based machines to use the driver, support OF match.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Link: https://lore.kernel.org/r/20220523090822.3035189-5-tzungbi@kernel.org
drivers/platform/chrome/cros_kbd_led_backlight.c

index a86d664..4bca880 100644 (file)
@@ -10,7 +10,9 @@
 #include <linux/kernel.h>
 #include <linux/leds.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 /**
@@ -116,7 +118,7 @@ static int keyboard_led_probe(struct platform_device *pdev)
        const struct keyboard_led_drvdata *drvdata;
        int error;
 
-       drvdata = acpi_device_get_match_data(&pdev->dev);
+       drvdata = device_get_match_data(&pdev->dev);
        if (!drvdata)
                return -EINVAL;
 
@@ -152,10 +154,21 @@ static const struct acpi_device_id keyboard_led_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id keyboard_led_of_match[] = {
+       {
+               .compatible = "google,cros-kbd-led-backlight",
+       },
+       {}
+};
+MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
+#endif
+
 static struct platform_driver keyboard_led_driver = {
        .driver         = {
                .name   = "chromeos-keyboard-leds",
                .acpi_match_table = ACPI_PTR(keyboard_led_acpi_match),
+               .of_match_table = of_match_ptr(keyboard_led_of_match),
        },
        .probe          = keyboard_led_probe,
 };