Commit 83a64b26 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Kill drvid[] array

We know the driver ids via drivers[]->interface->id already, no need
to keep them around a second time.
parent dbc67c41
...@@ -109,6 +109,42 @@ isdn_drv_hdrlen(int di) ...@@ -109,6 +109,42 @@ isdn_drv_hdrlen(int di)
return drivers[di]->interface->hl_hdrlen; return drivers[di]->interface->hl_hdrlen;
} }
int
__isdn_drv_lookup(char *drvid)
{
int drvidx;
for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) {
if (!drivers[drvidx])
continue;
if (strcmp(drivers[drvidx]->interface->id, drvid) == 0)
return drvidx;
}
return -1;
}
int
isdn_drv_lookup(char *drvid)
{
unsigned long flags;
int drvidx;
spin_lock_irqsave(&drivers_lock, flags);
drvidx = __isdn_drv_lookup(drvid);
spin_unlock_irqrestore(&drivers_lock, flags);
return drvidx;
}
char *isdn_drv_drvid(int di)
{
if (!drivers[di]) {
isdn_BUG();
return "";
}
return drivers[di]->interface->id;
}
static int isdn_add_channels(struct isdn_driver *, int, int, int); static int isdn_add_channels(struct isdn_driver *, int, int, int);
static void isdn_receive_skb_callback(int di, int ch, struct sk_buff *skb); static void isdn_receive_skb_callback(int di, int ch, struct sk_buff *skb);
static int isdn_status_callback(isdn_ctrl * c); static int isdn_status_callback(isdn_ctrl * c);
...@@ -169,10 +205,7 @@ register_isdn(isdn_if *iif) ...@@ -169,10 +205,7 @@ register_isdn(isdn_if *iif)
if (!strlen(iif->id)) if (!strlen(iif->id))
sprintf(iif->id, "line%d", drvidx); sprintf(iif->id, "line%d", drvidx);
strcpy(dev->drvid[drvidx], iif->id); if (__isdn_drv_lookup(iif->id) >= 0)
for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++)
if (strcmp(iif->id, dev->drvid[drvidx]) == 0)
goto fail_unlock; goto fail_unlock;
if (isdn_add_channels(drv, drvidx, iif->channels, 0)) if (isdn_add_channels(drv, drvidx, iif->channels, 0))
...@@ -693,7 +726,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -693,7 +726,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_CAUSE: case ISDN_STAT_CAUSE:
dbg_statcallb("CAUSE: %d %s\n", i, c->parm.num); dbg_statcallb("CAUSE: %d %s\n", i, c->parm.num);
printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n",
dev->drvid[di], c->arg, c->parm.num); isdn_drv_drvid(di), c->arg, c->parm.num);
isdn_tty_stat_callback(i, c); isdn_tty_stat_callback(i, c);
if (divert_if) if (divert_if)
divert_if->stat_callback(c); divert_if->stat_callback(c);
...@@ -819,7 +852,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -819,7 +852,6 @@ isdn_status_callback(isdn_ctrl * c)
kfree(drivers[di]->rpqueue); kfree(drivers[di]->rpqueue);
kfree(drivers[di]); kfree(drivers[di]);
drivers[di] = NULL; drivers[di] = NULL;
dev->drvid[di][0] = '\0';
isdn_info_update(); isdn_info_update();
set_global_features(); set_global_features();
restore_flags(flags); restore_flags(flags);
...@@ -987,7 +1019,7 @@ isdn_statstr(void) ...@@ -987,7 +1019,7 @@ isdn_statstr(void)
sprintf(istatbuf, "idmap:\t"); sprintf(istatbuf, "idmap:\t");
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
sprintf(p, "%s ", (slot[i].di < 0) ? "-" : dev->drvid[slot[i].di]); sprintf(p, "%s ", (slot[i].di < 0) ? "-" : isdn_drv_drvid(slot[i].di));
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
} }
sprintf(p, "\nchmap:\t"); sprintf(p, "\nchmap:\t");
...@@ -1395,7 +1427,6 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1395,7 +1427,6 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
case IIOCSETBRJ: case IIOCSETBRJ:
drvidx = -1; drvidx = -1;
if (arg) { if (arg) {
int i;
char *p; char *p;
if (copy_from_user((char *) &iocts, (char *) arg, if (copy_from_user((char *) &iocts, (char *) arg,
sizeof(isdn_ioctl_struct))) sizeof(isdn_ioctl_struct)))
...@@ -1403,12 +1434,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1403,12 +1434,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
if (strlen(iocts.drvid)) { if (strlen(iocts.drvid)) {
if ((p = strchr(iocts.drvid, ','))) if ((p = strchr(iocts.drvid, ',')))
*p = 0; *p = 0;
drvidx = -1; drvidx = isdn_drv_lookup(iocts.drvid);
for (i = 0; i < ISDN_MAX_DRIVERS; i++)
if (!(strcmp(dev->drvid[i], iocts.drvid))) {
drvidx = i;
break;
}
} }
} }
if (drvidx == -1) if (drvidx == -1)
...@@ -1485,15 +1511,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1485,15 +1511,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
(char *) arg, (char *) arg,
sizeof(isdn_ioctl_struct))) sizeof(isdn_ioctl_struct)))
return -EFAULT; return -EFAULT;
if (strlen(iocts.drvid)) { drvidx = isdn_drv_lookup(iocts.drvid);
drvidx = -1;
for (i = 0; i < ISDN_MAX_DRIVERS; i++)
if (!(strcmp(dev->drvid[i], iocts.drvid))) {
drvidx = i;
break;
}
} else
drvidx = 0;
if (drvidx == -1) if (drvidx == -1)
return -ENODEV; return -ENODEV;
if (cmd == IIOCSETMAP) { if (cmd == IIOCSETMAP) {
...@@ -1555,21 +1573,9 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1555,21 +1573,9 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
else else
return -EINVAL; return -EINVAL;
if (arg) { if (arg) {
int i;
char *p;
if (copy_from_user((char *) &iocts, (char *) arg, sizeof(isdn_ioctl_struct))) if (copy_from_user((char *) &iocts, (char *) arg, sizeof(isdn_ioctl_struct)))
return -EFAULT; return -EFAULT;
if (strlen(iocts.drvid)) { drvidx = isdn_drv_lookup(iocts.drvid);
if ((p = strchr(iocts.drvid, ',')))
*p = 0;
drvidx = -1;
for (i = 0; i < ISDN_MAX_DRIVERS; i++)
if (!(strcmp(dev->drvid[i], iocts.drvid))) {
drvidx = i;
break;
}
} else
drvidx = 0;
if (drvidx == -1) if (drvidx == -1)
return -ENODEV; return -ENODEV;
if ((ret = verify_area(VERIFY_WRITE, (void *) arg, if ((ret = verify_area(VERIFY_WRITE, (void *) arg,
......
...@@ -104,3 +104,5 @@ void isdn_drv_queue_tail(int di, int ch, struct sk_buff *skb, int len); ...@@ -104,3 +104,5 @@ void isdn_drv_queue_tail(int di, int ch, struct sk_buff *skb, int len);
int isdn_drv_maxbufsize(int di); int isdn_drv_maxbufsize(int di);
int isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb); int isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb);
int isdn_drv_hdrlen(int di); int isdn_drv_hdrlen(int di);
int isdn_drv_lookup(char *drvid);
char *isdn_drv_drvid(int di);
...@@ -426,7 +426,6 @@ typedef struct isdn_devt { ...@@ -426,7 +426,6 @@ typedef struct isdn_devt {
infostruct *infochain; /* List of open info-devs. */ infostruct *infochain; /* List of open info-devs. */
wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */
struct timer_list timer; /* Misc.-function Timer */ struct timer_list timer; /* Misc.-function Timer */
char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */
struct task_struct *profd; /* For iprofd */ struct task_struct *profd; /* For iprofd */
modem mdm; /* tty-driver-data */ modem mdm; /* tty-driver-data */
struct semaphore sem; /* serialize list access*/ struct semaphore sem; /* serialize list access*/
......
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