Re: [PATCH] Minor change to platform_device_register_simple prototype



On 12/7/05, Greg KH <greg@xxxxxxxxx> wrote:
> On Wed, Dec 07, 2005 at 05:18:40PM -0500, Dmitry Torokhov wrote:
> > On 12/7/05, Russell King <rmk+lkml@xxxxxxxxxxxxxxxx> wrote:
> >
> > > Unregistering is just a matter of calling platform_device_unregister().
> > > An unregister call is a del + put in exactly the same way as it is
> > > throughout the rest of the driver model.
> > >
> >
> > Yes, and it works just fine everywhere except in initialization code
> > when you need to jump in the middle of _del + _put sequence.
>
> 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..

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



Relevant Pages

  • Re: [PATCH] Try 2, Fix release function in IPMI device model
    ... instead of using the container_ofmacro. ... Arjun van de Ven pointed out that the changeover to the driver model ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
    (Linux-Kernel)
  • Re: [PATCH 18/33] x86_64: Kill temp_boot_pmds
    ... I also modify the early page table initialization code ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: MTRR driver model support broken on SMP.
    ... >> Okay. ... >> understand much about the driver model, but it seems to me that all we ... send the line "unsubscribe linux-kernel" in ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
    (Linux-Kernel)
  • ip3106_uart oddity
    ... it looks like drivers/serial/ip3106_uart.c was dropped from the mainline at some point I couldn't identify. ... So, given the above, does it make sense to try make it fir into standard 8250 driver model or restore/rework the custom driver? ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • [PATCH 2.6.20-rc2-git1] start_kernel: Test if irqs got enabled early, barf, and disable them
    ... The calls made by parse_parms to other initialization code might ... enable interrupts again way too early. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)