Understanding the LDM: Removing a device's parent

Rick Ramstetter rick.ramstetter at gmail.com
Fri Jan 10 04:11:19 EST 2014


I need a strategy for handling unregistered parent devices.

struct device *parent =  get_ptr_to_parent();
struct device *child = kzalloc ( a device )
child->parent = get_device(parent);
...
device_register(child)

Later on:
struct device *parent =  get_ptr_to_parent();
device_unregister(parent);
/* device_unregister(child) not invoked */

The parent device is not released because my child device is still holding
a reference. In my case, the child device is not useful without the parent
being registered. How can the child receive notification that the parent
has been unregistered? The parent device and child device are being created
by different drivers.

I've been referencing:
http://lxr.free-electrons.com/source/drivers/base/core.c#L1259

Thanks,
--Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140110/67bf5849/attachment.html 


More information about the Kernelnewbies mailing list