* [PATCH] n_hdlc.c 2.5.68 (try 2)
@ 2003-04-21 19:20 Paul Fulghum
2003-04-21 19:42 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Paul Fulghum @ 2003-04-21 19:20 UTC (permalink / raw)
To: linux-kernel; +Cc: alan, torvalds
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
Please apply
--
Paul Fulghum, paulkf@microgate.com
Microgate Corporation, http://www.microgate.com
--- linux-2.5.68/drivers/char/n_hdlc.c 2003-04-07 12:30:59.000000000 -0500
+++ linux-2.5.68-mg/drivers/char/n_hdlc.c 2003-04-21 14:15:07.733582832 -0500
@@ -9,7 +9,7 @@
* Al Longyear <longyear@netcom.com>, Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
*
* Original release 01/11/99
- * $Id: n_hdlc.c,v 4.2 2002/10/10 14:52:41 paulkf Exp $
+ * $Id: n_hdlc.c,v 4.6 2003/04/21 19:14:07 paulkf Exp $
*
* This code is released under the GNU General Public License (GPL)
*
@@ -78,7 +78,7 @@
*/
#define HDLC_MAGIC 0x239e
-#define HDLC_VERSION "$Revision: 4.2 $"
+#define HDLC_VERSION "$Revision: 4.6 $"
#include <linux/version.h>
#include <linux/config.h>
@@ -171,9 +171,9 @@
/*
* HDLC buffer list manipulation functions
*/
-void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list);
-void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf);
-N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list);
+static void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list);
+static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf);
+static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list);
/* Local functions */
@@ -299,7 +299,6 @@
n_hdlc->tty = n_hdlc->backup_tty;
} else {
n_hdlc_release (n_hdlc);
- MOD_DEC_USE_COUNT;
}
}
@@ -339,8 +338,6 @@
tty->disc_data = n_hdlc;
n_hdlc->tty = tty;
- MOD_INC_USE_COUNT;
-
#if defined(TTY_NO_WRITE_SPLIT)
/* change tty_io write() to not split large writes into 8K chunks */
set_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
@@ -903,7 +900,7 @@
* Arguments: list pointer to buffer list
* Return Value: None
*/
-void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list)
+static void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list)
{
memset(list,0,sizeof(N_HDLC_BUF_LIST));
spin_lock_init(&list->spinlock);
@@ -920,7 +917,7 @@
*
* Return Value: None
*/
-void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
+static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
{
unsigned long flags;
spin_lock_irqsave(&list->spinlock,flags);
@@ -950,7 +947,7 @@
*
* pointer to HDLC buffer if available, otherwise NULL
*/
-N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
+static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
{
unsigned long flags;
N_HDLC_BUF *buf;
@@ -971,7 +968,25 @@
static int __init n_hdlc_init(void)
{
- static struct tty_ldisc n_hdlc_ldisc;
+ static struct tty_ldisc n_hdlc_ldisc = {
+ TTY_LDISC_MAGIC, /* magic */
+ "hdlc", /* name */
+ 0, /* num */
+ 0, /* flags */
+ n_hdlc_tty_open, /* open */
+ n_hdlc_tty_close, /* close */
+ 0, /* flush_buffer */
+ 0, /* chars_in_buffer */
+ n_hdlc_tty_read, /* read */
+ n_hdlc_tty_write, /* write */
+ n_hdlc_tty_ioctl, /* ioctl */
+ 0, /* set_termios */
+ n_hdlc_tty_poll, /* poll */
+ n_hdlc_tty_receive, /* receive_buf */
+ n_hdlc_tty_room, /* receive_room */
+ n_hdlc_tty_wakeup, /* write_wakeup */
+ THIS_MODULE /* owner */
+ };
int status;
/* range check maxframe arg */
@@ -983,21 +998,6 @@
printk("HDLC line discipline: version %s, maxframe=%u\n",
szVersion, maxframe);
- /* Register the tty discipline */
-
- memset(&n_hdlc_ldisc, 0, sizeof (n_hdlc_ldisc));
- n_hdlc_ldisc.magic = TTY_LDISC_MAGIC;
- n_hdlc_ldisc.name = "hdlc";
- n_hdlc_ldisc.open = n_hdlc_tty_open;
- n_hdlc_ldisc.close = n_hdlc_tty_close;
- n_hdlc_ldisc.read = n_hdlc_tty_read;
- n_hdlc_ldisc.write = n_hdlc_tty_write;
- n_hdlc_ldisc.ioctl = n_hdlc_tty_ioctl;
- n_hdlc_ldisc.poll = n_hdlc_tty_poll;
- n_hdlc_ldisc.receive_room = n_hdlc_tty_room;
- n_hdlc_ldisc.receive_buf = n_hdlc_tty_receive;
- n_hdlc_ldisc.write_wakeup = n_hdlc_tty_wakeup;
-
status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc);
if (!status)
printk (KERN_INFO"N_HDLC line discipline registered.\n");
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] n_hdlc.c 2.5.68 (try 2)
2003-04-21 19:20 [PATCH] n_hdlc.c 2.5.68 (try 2) Paul Fulghum
@ 2003-04-21 19:42 ` Christoph Hellwig
2003-04-21 21:12 ` [PATCH] n_hdlc.c 2.5.68 (try 3) Paul Fulghum
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2003-04-21 19:42 UTC (permalink / raw)
To: Paul Fulghum; +Cc: linux-kernel, alan, torvalds
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,
};
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH] n_hdlc.c 2.5.68 (try 3)
2003-04-21 19:42 ` Christoph Hellwig
@ 2003-04-21 21:12 ` Paul Fulghum
0 siblings, 0 replies; 3+ messages in thread
From: Paul Fulghum @ 2003-04-21 21:12 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, alan, torvalds
On Mon, 2003-04-21 at 14:42, Christoph Hellwig wrote:
> .oO(I guess you'll have me for moaning again, but..)
You dirty bastard :-)
* Remove MODULE_USE_COUNT macros
* add owner member to struct tty_ldisc
* init tty_ldisc using C99 initializers
* make some functions static
--
Paul Fulghum, paulkf@microgate.com
Microgate Corporation, http://www.microgate.com
--- linux-2.5.68/drivers/char/n_hdlc.c 2003-04-07 12:30:59.000000000 -0500
+++ linux-2.5.68-mg/drivers/char/n_hdlc.c 2003-04-21 16:05:04.768636536 -0500
@@ -9,7 +9,7 @@
* Al Longyear <longyear@netcom.com>, Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
*
* Original release 01/11/99
- * $Id: n_hdlc.c,v 4.2 2002/10/10 14:52:41 paulkf Exp $
+ * $Id: n_hdlc.c,v 4.7 2003/04/21 21:03:41 paulkf Exp $
*
* This code is released under the GNU General Public License (GPL)
*
@@ -78,7 +78,7 @@
*/
#define HDLC_MAGIC 0x239e
-#define HDLC_VERSION "$Revision: 4.2 $"
+#define HDLC_VERSION "$Revision: 4.7 $"
#include <linux/version.h>
#include <linux/config.h>
@@ -171,9 +171,9 @@
/*
* HDLC buffer list manipulation functions
*/
-void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list);
-void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf);
-N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list);
+static void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list);
+static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf);
+static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list);
/* Local functions */
@@ -215,6 +215,21 @@
/* Define this string only once for all macro invocations */
static char szVersion[] = HDLC_VERSION;
+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,
+};
+
/* n_hdlc_release()
*
* release an n_hdlc per device line discipline info structure
@@ -299,7 +314,6 @@
n_hdlc->tty = n_hdlc->backup_tty;
} else {
n_hdlc_release (n_hdlc);
- MOD_DEC_USE_COUNT;
}
}
@@ -339,8 +353,6 @@
tty->disc_data = n_hdlc;
n_hdlc->tty = tty;
- MOD_INC_USE_COUNT;
-
#if defined(TTY_NO_WRITE_SPLIT)
/* change tty_io write() to not split large writes into 8K chunks */
set_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
@@ -903,7 +915,7 @@
* Arguments: list pointer to buffer list
* Return Value: None
*/
-void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list)
+static void n_hdlc_buf_list_init(N_HDLC_BUF_LIST *list)
{
memset(list,0,sizeof(N_HDLC_BUF_LIST));
spin_lock_init(&list->spinlock);
@@ -920,7 +932,7 @@
*
* Return Value: None
*/
-void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
+static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
{
unsigned long flags;
spin_lock_irqsave(&list->spinlock,flags);
@@ -950,7 +962,7 @@
*
* pointer to HDLC buffer if available, otherwise NULL
*/
-N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
+static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
{
unsigned long flags;
N_HDLC_BUF *buf;
@@ -971,7 +983,6 @@
static int __init n_hdlc_init(void)
{
- static struct tty_ldisc n_hdlc_ldisc;
int status;
/* range check maxframe arg */
@@ -983,21 +994,6 @@
printk("HDLC line discipline: version %s, maxframe=%u\n",
szVersion, maxframe);
- /* Register the tty discipline */
-
- memset(&n_hdlc_ldisc, 0, sizeof (n_hdlc_ldisc));
- n_hdlc_ldisc.magic = TTY_LDISC_MAGIC;
- n_hdlc_ldisc.name = "hdlc";
- n_hdlc_ldisc.open = n_hdlc_tty_open;
- n_hdlc_ldisc.close = n_hdlc_tty_close;
- n_hdlc_ldisc.read = n_hdlc_tty_read;
- n_hdlc_ldisc.write = n_hdlc_tty_write;
- n_hdlc_ldisc.ioctl = n_hdlc_tty_ioctl;
- n_hdlc_ldisc.poll = n_hdlc_tty_poll;
- n_hdlc_ldisc.receive_room = n_hdlc_tty_room;
- n_hdlc_ldisc.receive_buf = n_hdlc_tty_receive;
- n_hdlc_ldisc.write_wakeup = n_hdlc_tty_wakeup;
-
status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc);
if (!status)
printk (KERN_INFO"N_HDLC line discipline registered.\n");
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-21 21:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-21 19:20 [PATCH] n_hdlc.c 2.5.68 (try 2) Paul Fulghum
2003-04-21 19:42 ` Christoph Hellwig
2003-04-21 21:12 ` [PATCH] n_hdlc.c 2.5.68 (try 3) Paul Fulghum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®