[Linux-parport] Re: [PATCH] register sysfs device for lp devices

Bernhard R. Link brlink at debian.org
Sat Feb 18 08:00:47 EST 2006

> > + * can display it in their sysfs nodes */
> > +#define parport_set_dev(port,devptr) ((port)->dev = (devptr))
> If you are going to save off a pointer to a structure, you need to
> increment it's reference count.  You aren't doing that here, and bad
> things might happen if it gets removed from under you :(

Guess I should think a bit more and copy other code a bit less.
The two examples I looked at were sound and network devices.
While they differ by calling class_device_create more directly,
this does not call a get_device either. (Or where have I missed

I thought that parport would only exist while the device exists and
is bound to the driver, when that stops it is removed anyway.
But lp.c does not implement lp_detach, so it still keeps this data
and it is really exposed even when the device vanished.

Some unrelated strage behaviour from this: When I manualy unbind
and bind an parport supplier, via 
echo -n "id" > /sys/bus/.../drivers/.../unbind
and then echo -n "id" > /sys/bus/.../drivers/.../bind
I get a new lp device every time without the old one vanishing.

	Bernhard R. Link

More information about the Linux-parport mailing list