Hi Uwe, Sorry for the late reply, got distracted with other stuff. On Mon, 2020-10-19 at 08:52 +0200, Uwe Kleine-König wrote: > On Fri, Oct 16, 2020 at 05:26:56PM +0200, Nicolas Saenz Julienne wrote: > > On Fri, 2020-10-16 at 09:38 -0500, Rob Herring wrote: > > > On Thu, Oct 15, 2020 at 6:43 AM Nicolas Saenz Julienne > > > wrote: > > > > 'simple-mfd' usage implies there might be some kind of resource sharing > > > > between the parent device and its children. > > > > > > It does? No! The reason behind simple-mfd was specifically because > > > there was no parent driver or dependency on the parent. No doubt > > > simple-mfd has been abused. > > > > Fair enough, so we're doing things wrong. Just for the record, I'm looking at > > RPi´s firmware interface: > > > > firmware: firmware { > > compatible = "raspberrypi,bcm2835-firmware", "simple-mfd"; > > #address-cells = <1>; > > #size-cells = <1>; > > mboxes = <&mailbox>; > > > > firmware_clocks: clocks { > > compatible = "raspberrypi,firmware-clocks"; > > #clock-cells = <1>; > > }; > > > > reset: reset { > > compatible = "raspberrypi,firmware-reset"; > > #reset-cells = <1>; > > }; > > [...] > > }; > > > > Note that "raspberrypi,bcm2835-firmware" has a driver, it's not just a > > placeholder. Consumer drivers get a handle to RPi's firmware interface through > > the supplier's API, rpi_firmware_get(). The handle to firmware becomes > > meaningless if it is unbinded, which I want to protect myself against. > > > > A simpler solution would be to manually create a device link between both > > devices ("raspberrypi,bcm2835-firmware" and "raspberrypi,firmware-clocks" for > > example) upon calling rpi_firmware_get(). But I wanted to try addressing the > > problem in a generic way first. > > IMHO rpi_firmware_get() should get a reference on the firmware device > (and call try_module_get()) which prevents unbinding it. Yes, it seems the way to go. Just one last question WRT this, since 'drv->remove(dev)' can't fail should I just block until the reference count hits zero? Regards, Nicolas