static struct class *dgap_class;
-static struct board_t *dgap_boards_by_major[256];
static uint dgap_count = 500;
/*
spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
}
+static struct board_t *find_board_by_major(unsigned int major)
+{
+ unsigned int i;
+
+ for (i = 0; i < MAXBOARDS; i++) {
+ struct board_t *brd = dgap_board[i];
+ if (!brd)
+ return NULL;
+ if (major == brd->serial_driver->major ||
+ major == brd->print_driver->major)
+ return brd;
+ }
+
+ return NULL;
+}
+
/************************************************************************
*
* TTY Entry points and helper functions
major = MAJOR(tty_devnum(tty));
minor = MINOR(tty_devnum(tty));
- if (major > 255)
- return -EIO;
-
- /* Get board pointer from our array of majors we have allocated */
- brd = dgap_boards_by_major[major];
+ brd = find_board_by_major(major);
if (!brd)
return -EIO;
if (rc < 0)
goto unregister_serial_drv;
- dgap_boards_by_major[brd->serial_driver->major] = brd;
- dgap_boards_by_major[brd->print_driver->major] = brd;
-
return 0;
unregister_serial_drv:
struct device *dev;
unsigned int i;
- dgap_boards_by_major[brd->serial_driver->major] = NULL;
for (i = 0; i < brd->nasync; i++) {
tty_port_destroy(&brd->serial_ports[i]);
dev = brd->channels[i]->ch_tun.un_sysfs;
put_tty_driver(brd->serial_driver);
kfree(brd->serial_ports);
- dgap_boards_by_major[brd->print_driver->major] = NULL;
for (i = 0; i < brd->nasync; i++) {
tty_port_destroy(&brd->printer_ports[i]);
dev = brd->channels[i]->ch_pun.un_sysfs;