Messages in this thread | | | Date | Thu, 8 Dec 2005 21:52:57 +0100 | From | Jean Delvare <> | Subject | Re: [PATCH] Minor change to platform_device_register_simple prototype |
| |
Hi Dmirty, Russell, Greg,
> On 12/7/05, Greg KH <greg@kroah.com> wrote: > > So, if you had _del, would it work easier for you? I just objected to > > it if it wasn't necessary. I didn't want to add functions that aren't > > used by anyone, but if is needed, I don't see a problem with it. > > Yes, the I can just write: > > ... > err = platform_driver_register(&i8042_driver); > if (err) > goto err_controller_cleanup; > > i8042_platform_device = platform_device_alloc("i8042", -1); > if (!i8042_platform_device) { > err = -ENOMEM; > goto err_unregister_driver; > } > > err = platform_device_add(i8042_platform_device); > if (err) > goto err_free_device; > ... > > if (!have_ports) { > err = -ENODEV; > goto err_delete_device; > } > > mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); > return 0; > > err_delete_device: > platform_device_del(i8042_platform_device); > err_free_device: > platform_device_put(i8042_platform_device); > err_unregister_driver: > platform_driver_unregister(&i8042_driver); > .... > > As you can see - single cleanup path..
I second Dmitry's request here. I can't seem to possibly build a valid error path during device registration with the current API. Having platform_device_del() would make it possible.
BTW, doesn't this suggest that the error path in platform_device_register_simple() is currently broken as well? If platform_device_add() fails therein, I take it that the resources previously allocated by platform_device_add_resources() will never be freed.
-- Jean Delvare - 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/
| |