On Tue, Jun 30, 2009 at 5:03 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote: > > long story short, i was perusing the kernel source tree, looking for > a random loadable module file to demonstrate the concept of a module > init() routine undoing whatever work it had done in case it runs into > an error, and i chanced across drivers/usb/gadget/dummy_hcd.c, where i > saw at the bottom of the file: > > ... snip ... > > return retval; > > err_add_udc: > platform_device_del(the_hcd_pdev); > err_add_hcd: > platform_driver_unregister(&dummy_udc_driver); > err_register_udc_driver: > platform_driver_unregister(&dummy_hcd_driver); > err_register_hcd_driver: > platform_device_put(the_udc_pdev); > err_alloc_udc: > platform_device_put(the_hcd_pdev); > return retval; > } > module_init (init); > > static void __exit cleanup (void) > { > platform_device_unregister(the_udc_pdev); > platform_device_unregister(the_hcd_pdev); > platform_driver_unregister(&dummy_udc_driver); > platform_driver_unregister(&dummy_hcd_driver); > } > > note how the init() routine backs off on "the_udc_pdev" and > "the_hcd_pdev" objects by calling platform_device_put(), while the > exit() routine uses platform_device_unregister() instead. maybe i > just don't understand enough about what's going on underneath. is > there a reason that those two invocations don't match? platform_device_unregister is just a wrapper for put and del so the functionality remains the same! In case of init() it is error handling so free whatever allocated. > > rday > -- > > ======================================================================== > Robert P. J. Day Waterloo, Ontario, CANADA > > Linux Consulting, Training and Annoying Kernel Pedantry. > > Web page: http://crashcourse.ca > Linked In: http://www.linkedin.com/in/rpjday > Twitter: http://twitter.com/rpjday > ======================================================================== > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html