Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: simatic-ipc-leds-gpio: Move two extra gpio pins into another table

There are two special pins needed to init the LEDs. We used to have them
at the end of the gpiod_lookup table to give to "leds-gpio". A cleaner
way is to have a dedicated table for the special pins.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230524124628.32295-3-henning.schild@siemens.com

authored by

Henning Schild and committed by
Lee Jones
799c0197 8aee49eb

+25 -3
+25 -3
drivers/leds/simple/simatic-ipc-leds-gpio.c
··· 16 16 #include <linux/platform_data/x86/simatic-ipc-base.h> 17 17 18 18 static struct gpiod_lookup_table *simatic_ipc_led_gpio_table; 19 + static struct gpiod_lookup_table *simatic_ipc_led_gpio_table_extra; 19 20 20 21 static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = { 21 22 .dev_id = "leds-gpio", ··· 27 26 GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 58, NULL, 3, GPIO_ACTIVE_LOW), 28 27 GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 60, NULL, 4, GPIO_ACTIVE_LOW), 29 28 GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW), 29 + {} /* Terminating entry */ 30 + }, 31 + }; 32 + 33 + static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e_extra = { 34 + .dev_id = NULL, /* Filled during initialization */ 35 + .table = { 30 36 GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW), 31 37 GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH), 32 38 {} /* Terminating entry */ ··· 49 41 GPIO_LOOKUP_IDX("gpio-f7188x-2", 3, NULL, 3, GPIO_ACTIVE_LOW), 50 42 GPIO_LOOKUP_IDX("gpio-f7188x-2", 4, NULL, 4, GPIO_ACTIVE_LOW), 51 43 GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW), 44 + {} /* Terminating entry */ 45 + }, 46 + }; 47 + 48 + static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g_extra = { 49 + .dev_id = NULL, /* Filled during initialization */ 50 + .table = { 52 51 GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH), 53 52 GPIO_LOOKUP_IDX("gpio-f7188x-3", 7, NULL, 7, GPIO_ACTIVE_HIGH), 54 53 {} /* Terminating entry */ 55 - } 54 + }, 56 55 }; 57 56 58 57 static const struct gpio_led simatic_ipc_gpio_leds[] = { ··· 81 66 static int simatic_ipc_leds_gpio_remove(struct platform_device *pdev) 82 67 { 83 68 gpiod_remove_lookup_table(simatic_ipc_led_gpio_table); 69 + gpiod_remove_lookup_table(simatic_ipc_led_gpio_table_extra); 84 70 platform_device_unregister(simatic_leds_pdev); 85 71 86 72 return 0; ··· 90 74 static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev) 91 75 { 92 76 const struct simatic_ipc_platform *plat = pdev->dev.platform_data; 77 + struct device *dev = &pdev->dev; 93 78 struct gpio_desc *gpiod; 94 79 int err; 95 80 ··· 99 82 if (!IS_ENABLED(CONFIG_PINCTRL_BROXTON)) 100 83 return -ENODEV; 101 84 simatic_ipc_led_gpio_table = &simatic_ipc_led_gpio_table_127e; 85 + simatic_ipc_led_gpio_table_extra = &simatic_ipc_led_gpio_table_127e_extra; 102 86 break; 103 87 case SIMATIC_IPC_DEVICE_227G: 104 88 if (!IS_ENABLED(CONFIG_GPIO_F7188X)) 105 89 return -ENODEV; 106 90 request_module("gpio-f7188x"); 107 91 simatic_ipc_led_gpio_table = &simatic_ipc_led_gpio_table_227g; 92 + simatic_ipc_led_gpio_table_extra = &simatic_ipc_led_gpio_table_227g_extra; 108 93 break; 109 94 default: 110 95 return -ENODEV; ··· 122 103 goto out; 123 104 } 124 105 106 + simatic_ipc_led_gpio_table_extra->dev_id = dev_name(dev); 107 + gpiod_add_lookup_table(simatic_ipc_led_gpio_table_extra); 108 + 125 109 /* PM_BIOS_BOOT_N */ 126 - gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 6, GPIOD_OUT_LOW); 110 + gpiod = gpiod_get_index(dev, NULL, 6, GPIOD_OUT_LOW); 127 111 if (IS_ERR(gpiod)) { 128 112 err = PTR_ERR(gpiod); 129 113 goto out; ··· 134 112 gpiod_put(gpiod); 135 113 136 114 /* PM_WDT_OUT */ 137 - gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 7, GPIOD_OUT_LOW); 115 + gpiod = gpiod_get_index(dev, NULL, 7, GPIOD_OUT_LOW); 138 116 if (IS_ERR(gpiod)) { 139 117 err = PTR_ERR(gpiod); 140 118 goto out;