[RFC,2/3] input: gpio-keys - add device links of children

Message ID 20230427221625.116050-3-opendmb@gmail.com
State New
Headers
Series input: gpio-keys - fix pm ordering |

Commit Message

Doug Berger April 27, 2023, 10:16 p.m. UTC
  Since the child nodes of gpio-keys are implemented by the
gpio-keys device driver, that driver should explicitly create
the appropriate device links to support proper device power
management and shutdown sequencing.

Fixes: f9aa460672c9 ("driver core: Refactor fw_devlink feature")
Signed-off-by: Doug Berger <opendmb@gmail.com>
---
 drivers/input/keyboard/gpio_keys.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Patch

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 0516c6279d8a..7a0dcfeb02dc 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -865,6 +865,7 @@  static int gpio_keys_probe(struct platform_device *pdev)
 
 	for (i = 0; i < pdata->nbuttons; i++) {
 		const struct gpio_keys_button *button = &pdata->buttons[i];
+		struct fwnode_link *link;
 
 		if (!dev_get_platdata(dev)) {
 			child = device_get_next_child_node(dev, child);
@@ -882,6 +883,12 @@  static int gpio_keys_probe(struct platform_device *pdev)
 			fwnode_handle_put(child);
 			return error;
 		}
+		if (child) {
+			list_for_each_entry(link, &child->suppliers, c_hook) {
+				device_link_add(dev, link->supplier->dev,
+						DL_FLAG_AUTOREMOVE_CONSUMER);
+			}
+		}
 
 		if (button->wakeup)
 			wakeup = 1;