Re: two patches - request for comments

From: Greg KH
Date: Wed Jun 02 2004 - 12:39:24 EST


On Wed, Jun 02, 2004 at 01:57:40AM +0400, Andrew Zabolotny wrote:
> On Tue, 01 Jun 2004 17:23:11 -0400
> Jeff Garzik <jgarzik@xxxxxxxxx> wrote:
>
> > Typical Linux usage to an item being registered is
> > ptr = alloc_foo()
> > register_foo(ptr)
> > unregister_foo(ptr)
> > free_foo()
> In this case it is:
>
> register_lcd_device("foo", ...);
> ...
> unregister_lcd_device("foo");
>
> The name is guaranteed to be unique by sysfs design during the whole
> device lifetime, and calling unregister_xxx() outside the lifetime brackets
> is clearly an error.
>
> > It is quite unusual to unregister based on name. Pointers are far more
> > likely to be unique, and the programmer is far less likely to screw up
> > the unregister operation.
> I understand this, I see why it looks unusual. I'll fix this if it matters.

It matters, please fix it.

> It'll be something like:
>
> lcd_device = register_lcd_device ("foo", ...);
> ...
> unregister_lcd_device (lcd_device);

What about:
lcd_device = alloc_lcd_device("foo", ...);
error = register_lcd_device(lcd_device);
...
unregister_lcd_device(lcd_device);

thanks,

greg k-h
-
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/