Re: PATCH: tty ldisc locking/ordering

From: Alan Cox
Date: Fri Sep 10 2004 - 11:15:23 EST


On Fri, Sep 10, 2004 at 04:55:20PM +0100, Christoph Hellwig wrote:
> > +return -EBUSY if the ldisc is currently in use. Since the ldisc referencing
> > +code manages the module counts this should not usually be a concern.
>
> So what is a module supposed to do if this fails? It's usually called from
> module_exit so there's no way to recover.

Thats an interesting question. For the modular case we manage owner counts
so I think it cannot fail for modules using it at that point. If you want to
rescind a line discipline at some other time however then that isnt true.

> > +Three calls are now provided
> > +
> > + ldisc = tty_ldisc_ref(tty);
> > +
> > +takes a handle to the line discipline in the tty and returns it. If no ldisc
> > +is currently attached or the ldisc is being closed and re-opened at this
> > +point then NULL is returned. While this handle is held the ldisc will not
> > +change or go away.
> > +
> > + tty_ldisc_deref(ldisc)
>
> We tend to call these _get/_put just about everywhere else in the kernel,
> maybe some consisteny is a good idea?

ldisc_get and ldisc_put are used for taking references to each ldisc class
ldisc_ref/deref to each instance of the ldisc class. The two are not the
same thing in the tty layer. The count on the class tells you when you can
unload the module, the count on the driver is users of that instance.

When I named them it seemed that the get/put methods belonged with the case
that behaves most like the other _get/_put cases

Thoughts - I've not found a simple answer for this one ?

Alan

-
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/