Commit 509e20d1 authored by Brian Gerst's avatar Brian Gerst Committed by David S. Miller

[PATCH] convert tty_drivers to list_heads

Convert the tty_drivers list to use list_heads instead of open coded
doubly-linked lists.
parent 0a359b28
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
#define CHECK_TTY_COUNT 1 #define CHECK_TTY_COUNT 1
struct termios tty_std_termios; /* for the benefit of tty drivers */ struct termios tty_std_termios; /* for the benefit of tty drivers */
struct tty_driver *tty_drivers; /* linked list of tty drivers */ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
struct tty_ldisc ldiscs[NR_LDISCS]; /* line disc dispatch table */ struct tty_ldisc ldiscs[NR_LDISCS]; /* line disc dispatch table */
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
...@@ -338,7 +338,7 @@ struct tty_driver *get_tty_driver(kdev_t device) ...@@ -338,7 +338,7 @@ struct tty_driver *get_tty_driver(kdev_t device)
minor = minor(device); minor = minor(device);
major = major(device); major = major(device);
for (p = tty_drivers; p; p = p->next) { list_for_each_entry(p, &tty_drivers, tty_drivers) {
if (p->major != major) if (p->major != major)
continue; continue;
if (minor < p->minor_start) if (minor < p->minor_start)
...@@ -2083,10 +2083,7 @@ int tty_register_driver(struct tty_driver *driver) ...@@ -2083,10 +2083,7 @@ int tty_register_driver(struct tty_driver *driver)
if (!driver->put_char) if (!driver->put_char)
driver->put_char = tty_default_put_char; driver->put_char = tty_default_put_char;
driver->prev = 0; list_add(&driver->tty_drivers, &tty_drivers);
driver->next = tty_drivers;
if (tty_drivers) tty_drivers->prev = driver;
tty_drivers = driver;
if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) { if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) {
for(i = 0; i < driver->num; i++) for(i = 0; i < driver->num; i++)
...@@ -2110,7 +2107,7 @@ int tty_unregister_driver(struct tty_driver *driver) ...@@ -2110,7 +2107,7 @@ int tty_unregister_driver(struct tty_driver *driver)
if (*driver->refcount) if (*driver->refcount)
return -EBUSY; return -EBUSY;
for (p = tty_drivers; p; p = p->next) { list_for_each_entry(p, &tty_drivers, tty_drivers) {
if (p == driver) if (p == driver)
found++; found++;
else if (p->major == driver->major) else if (p->major == driver->major)
...@@ -2127,13 +2124,7 @@ int tty_unregister_driver(struct tty_driver *driver) ...@@ -2127,13 +2124,7 @@ int tty_unregister_driver(struct tty_driver *driver)
} else } else
register_chrdev(driver->major, othername, &tty_fops); register_chrdev(driver->major, othername, &tty_fops);
if (driver->prev) list_del(&driver->tty_drivers);
driver->prev->next = driver->next;
else
tty_drivers = driver->next;
if (driver->next)
driver->next->prev = driver->prev;
/* /*
* Free the termios and termios_locked structures because * Free the termios and termios_locked structures because
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <asm/bitops.h> #include <asm/bitops.h>
extern struct tty_driver *tty_drivers; /* linked list of tty drivers */
extern struct tty_ldisc ldiscs[]; extern struct tty_ldisc ldiscs[];
...@@ -40,7 +39,7 @@ static int tty_drivers_read_proc(char *page, char **start, off_t off, ...@@ -40,7 +39,7 @@ static int tty_drivers_read_proc(char *page, char **start, off_t off,
char range[20], deftype[20]; char range[20], deftype[20];
char *type; char *type;
for (p = tty_drivers; p; p = p->next) { list_for_each_entry(p, &tty_drivers, tty_drivers) {
if (p->num > 1) if (p->num > 1)
sprintf(range, "%d-%d", p->minor_start, sprintf(range, "%d-%d", p->minor_start,
p->minor_start + p->num - 1); p->minor_start + p->num - 1);
......
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/list.h>
struct tty_driver { struct tty_driver {
int magic; /* magic number for this structure */ int magic; /* magic number for this structure */
...@@ -170,14 +171,11 @@ struct tty_driver { ...@@ -170,14 +171,11 @@ struct tty_driver {
int count, int *eof, void *data); int count, int *eof, void *data);
int (*write_proc)(struct file *file, const char *buffer, int (*write_proc)(struct file *file, const char *buffer,
unsigned long count, void *data); unsigned long count, void *data);
struct list_head tty_drivers;
/*
* linked list pointers
*/
struct tty_driver *next;
struct tty_driver *prev;
}; };
extern struct list_head tty_drivers;
/* tty driver magic number */ /* tty driver magic number */
#define TTY_DRIVER_MAGIC 0x5402 #define TTY_DRIVER_MAGIC 0x5402
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment