Re: [RFC] [PATCH] Device removal callback

From: Patrick Mochel (mochel@osdl.org)
Date: Mon Mar 10 2003 - 10:59:42 EST


> Instead I now do this, with the patch.
>
> void ieee1394_remove_node(struct device *dev)
> {
> list_for_each(..., &ne->device.children) {
> device_unregister(list_to_dev(lh));
> }
> }
>
> ...
> /* Where the dev is created */
> ...
> ne->device.remove = ieee1394_remove_node;
> device_register(&ne->device);
>
> Now, no matter where it's called from, doing...
>
> device_unregister(&ne->device);
>
> ...will make sure my remove callback is executed, so the children
> devices get unregistered aswell. I extend this to the host device
> and I have a recursive remocal scheme that is safe no matter where my
> devices get unregistered. Whole lot simpler that adding in a lot of
> failsafe's and checks.

But, you can do exactly the same with just a few added lines in the
ieee1394 core - just have a wrapper that calls ->remove() (in the 1394
device structure), then calls device_unregister() for the device.

Your ->remove() can do anything you like, including removing all the
children, much as I assume it does now. So, behavior is exactly as you
want, and it keeps it out of the core for now.

I much prefer this, as I would like to see it eventually, but I'd rather
see the implications worked out before it's generalized.

Thanks,

        -pat

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Mar 15 2003 - 22:00:22 EST