package/kernel/leds-apu2: add apu3 board detection
[openwrt/staging/mkresin.git] / package / kernel / leds-apu2 / src / leds-apu2.c
index 00f80a3fa8bb4573d3369165de6e0a9700a21a2a..4ea552cf5f7266bc41b92dda685431f6819e50e8 100644 (file)
@@ -194,7 +194,11 @@ static int gpio_apu2_probe (struct platform_device *dev)
                }
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
        gpio_apu2_chip.dev = &dev->dev;
+#else
+       gpio_apu2_chip.parent = &dev->dev;
+#endif
        ret = gpiochip_add (&gpio_apu2_chip);
        if (ret) {
                pr_err ("%s: adding gpiochip failed\n", DEVNAME);
@@ -224,21 +228,21 @@ static struct platform_driver gpio_apu2_driver = {
 };
 
 static struct gpio_led apu2_leds_gpio[] = {
-        {
-                .name           = "apu2:green:power",
-                .gpio           = 509,
-                .active_low     = 1,
-        },
-        {
-                .name           = "apu2:green:led2",
-                .gpio           = 510,
-                .active_low     = 1,
-        },
-        {
-                .name           = "apu2:green:led3",
-                .gpio           = 511,
-                .active_low     = 1,
-        },
+       {
+               .name           = "apu2:green:power",
+               .gpio           = 509,
+               .active_low     = 1,
+       },
+       {
+               .name           = "apu2:green:led2",
+               .gpio           = 510,
+               .active_low     = 1,
+       },
+       {
+               .name           = "apu2:green:led3",
+               .gpio           = 511,
+               .active_low     = 1,
+       },
 };
 
 static struct gpio_keys_button apu2_gpio_keys[] = {
@@ -328,7 +332,10 @@ static int __init gpio_apu2_init (void)
        const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
 
        /* Match the device name/model */
-       if (!board_name || !board_vendor || strcasecmp(board_vendor, "PC Engines") || strcasecmp(board_name, "apu2")) {
+       if (!board_name \
+                       || !board_vendor \
+                       || strcasecmp(board_vendor, "PC Engines") \
+                       || (strcasecmp(board_name, "apu2") && strcasecmp(board_name, "apu3"))) {
                err = -ENODEV;
                goto exit;
        }