mfd: core: Delete corresponding OF node entries from list on MFD removal
authorMichal Oleszczyk <oleszczyk.m@gmail.com>
Tue, 9 Aug 2022 06:03:36 +0000 (08:03 +0200)
committerLee Jones <lee@kernel.org>
Wed, 28 Sep 2022 15:09:50 +0000 (16:09 +0100)
commit8e88c61d6f3432f27a2c6b8bc58ae4fe974f4b6d
tree51fc4286fd2ca7edec953dffa4f7810629268332
parent31961dc598ab8d68c4c6f2e572f9f101e1317cba
mfd: core: Delete corresponding OF node entries from list on MFD removal

When we consider MFD which implements hotplug (e.g. USB hotplug
driver based on product and vendor IDs) functionality it turns out
that its sub-devices are correctly matched with corresponding device
tree nodes only at the first time. When physical device reboots
or is replugged (and MFD driver is disconnected and probed back
again) all sub-devices fails in mfd_add_device() with error
'Failed to locate of_node'.

The reason of that behavior is that when any MFD sub-device is
created for the first time (and matched with device tree node) it
is added to the mfd_of_node_list. It looks like this list is never
cleaned even if devices added there are intentionally removed from
the system. So when MFD device is replugged and all sub-devices
are matched with their device tree nodes again they fail as matched
nodes already exist in mfd_of_node_list. In other words current
implementation does not support MFD with hotplug feature.

This commit extends MFD core for hotplugging support by removing
appropriate OF node entry from mfd_of_node_list when corresponding
device is removed from the system. Thanks to that when device is
added once again it can be matched with its device tree node
successfully.

Signed-off-by: Michal Oleszczyk <oleszczyk.m@gmail.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20220809060336.31892-1-m.oleszczyk@grinn-global.com
drivers/mfd/mfd-core.c