Re: [PATCH] n_hdlc.c 2.5.68 (try 2)

Christoph Hellwig (hch@infradead.org)
Mon, 21 Apr 2003 20:42:00 +0100


On Mon, Apr 21, 2003 at 02:20:53PM -0500, Paul Fulghum wrote:
> Attempt 2 with suggestions from Chritoph Hellwig
>
> * Remove MODULE_USE_COUNT macros
> * Add owner member to struct tty_ldisc
> * Init tty_ldisc at compile time
> * make some functions static

.oO(I guess you'll have me for moaning again, but..)

>
> static int __init n_hdlc_init(void)
> {
> - static struct tty_ldisc n_hdlc_ldisc;
> + static struct tty_ldisc n_hdlc_ldisc = {

Usual Linux style is to have this outside of any function scope.
That'll get important once we get a saner tty_unregister_ldisc
prototype.

> + TTY_LDISC_MAGIC, /* magic */
> + "hdlc", /* name */

Please use C99 named initializers.

> + 0, /* num */
> + 0, /* flags */

And no need to initialize anything to 0/NULL.

It should look like:

static struct tty_ldisc n_hdlc_ldisc = {
.owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC,
.name = "hdlc",
.open = n_hdlc_tty_open,
.close = n_hdlc_tty_close,
.read = n_hdlc_tty_read,
.write = n_hdlc_tty_write,
.ioctl = n_hdlc_tty_ioctl,
.poll = n_hdlc_tty_poll,
.receive_buf = n_hdlc_tty_receive,
.receive_room = n_hdlc_tty_room,
.write_wakeup = n_hdlc_tty_wakeup,
};
-
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/