Commit 33c7e1fa authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Gather per-slot data

Instead of having a number of arrays containg various bits of per-slot
data, start aggregating this data in a struct, and then have one
instance of this struct per slot.
parent a44a72fb
This diff is collapsed.
...@@ -52,3 +52,5 @@ extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int); ...@@ -52,3 +52,5 @@ extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int);
extern int isdn_slot_hdrlen(int slot); extern int isdn_slot_hdrlen(int slot);
extern int isdn_slot_driver(int slot); extern int isdn_slot_driver(int slot);
extern int isdn_slot_channel(int slot); extern int isdn_slot_channel(int slot);
extern int isdn_slot_usage(int slot);
extern void isdn_slot_set_usage(int slot, int usage);
...@@ -488,10 +488,9 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) ...@@ -488,10 +488,9 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c)
case 9: case 9:
case 10: case 10:
case 12: case 12:
if (lp->dialstate <= 6) { if (lp->dialstate <= 6)
dev->usage[idx] |= ISDN_USAGE_OUTGOING; isdn_slot_set_usage(idx, isdn_slot_usage(idx) | ISDN_USAGE_OUTGOING);
isdn_info_update(); else
} else
dev->rx_netdev[idx] = p; dev->rx_netdev[idx] = p;
lp->dialstate = 0; lp->dialstate = 0;
isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1);
...@@ -698,8 +697,7 @@ isdn_net_dial(void) ...@@ -698,8 +697,7 @@ isdn_net_dial(void)
isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn)); isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn));
if (lp->isdn_slot >= 0) { if (lp->isdn_slot >= 0) {
strcpy(dev->num[lp->isdn_slot], cmd.parm.setup.phone); strcpy(dev->num[lp->isdn_slot], cmd.parm.setup.phone);
dev->usage[lp->isdn_slot] |= ISDN_USAGE_OUTGOING; isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING);
isdn_info_update();
} }
printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name,
lp->dialretry, cmd.parm.setup.phone, lp->dialretry, cmd.parm.setup.phone,
...@@ -2084,17 +2082,14 @@ isdn_net_swapbind(int drvidx) ...@@ -2084,17 +2082,14 @@ isdn_net_swapbind(int drvidx)
static void static void
isdn_net_swap_usage(int i1, int i2) isdn_net_swap_usage(int i1, int i2)
{ {
int u1 = dev->usage[i1] & ISDN_USAGE_EXCLUSIVE; int u1 = isdn_slot_usage(i1);
int u2 = dev->usage[i2] & ISDN_USAGE_EXCLUSIVE; int u2 = isdn_slot_usage(i2);
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: usage of %d and %d\n", i1, i2); printk(KERN_DEBUG "n_fi: usage of %d and %d\n", i1, i2);
#endif #endif
dev->usage[i1] &= ~ISDN_USAGE_EXCLUSIVE; isdn_slot_set_usage(i1, (u1 & ~ISDN_USAGE_EXCLUSIVE) | (u2 & ISDN_USAGE_EXCLUSIVE));
dev->usage[i1] |= u2; isdn_slot_set_usage(i2, (u2 & ~ISDN_USAGE_EXCLUSIVE) | (u1 & ISDN_USAGE_EXCLUSIVE));
dev->usage[i2] &= ~ISDN_USAGE_EXCLUSIVE;
dev->usage[i2] |= u1;
isdn_info_update();
} }
/* /*
...@@ -2206,7 +2201,7 @@ p = dev->netdev; ...@@ -2206,7 +2201,7 @@ p = dev->netdev;
#endif #endif
if ((!matchret) && /* EAZ is matching */ if ((!matchret) && /* EAZ is matching */
(((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */ (((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */
(USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ (USG_NONE(isdn_slot_usage(idx)))) || /* and ch. unused or */
((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */ ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */
(!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */
))) )))
...@@ -2215,7 +2210,7 @@ p = dev->netdev; ...@@ -2215,7 +2210,7 @@ p = dev->netdev;
printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n", printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n",
lp->pre_device, lp->pre_channel); lp->pre_device, lp->pre_channel);
#endif #endif
if (dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) { if (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) {
if ((lp->pre_channel != ch) || if ((lp->pre_channel != ch) ||
(lp->pre_device != di)) { (lp->pre_device != di)) {
/* Here we got a problem: /* Here we got a problem:
...@@ -2232,10 +2227,10 @@ p = dev->netdev; ...@@ -2232,10 +2227,10 @@ p = dev->netdev;
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: ch is 0\n"); printk(KERN_DEBUG "n_fi: ch is 0\n");
#endif #endif
if (USG_NONE(dev->usage[sidx])) { if (USG_NONE(isdn_slot_usage(sidx))) {
/* Second Channel is free, now see if it is bound /* Second Channel is free, now see if it is bound
* exclusive too. */ * exclusive too. */
if (dev->usage[sidx] & ISDN_USAGE_EXCLUSIVE) { if (isdn_slot_usage(sidx) & ISDN_USAGE_EXCLUSIVE) {
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: 2nd channel is down and bound\n"); printk(KERN_DEBUG "n_fi: 2nd channel is down and bound\n");
#endif #endif
...@@ -2263,7 +2258,7 @@ p = dev->netdev; ...@@ -2263,7 +2258,7 @@ p = dev->netdev;
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: final check\n"); printk(KERN_DEBUG "n_fi: final check\n");
#endif #endif
if ((dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) && if ((isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) &&
((lp->pre_channel != ch) || ((lp->pre_channel != ch) ||
(lp->pre_device != di))) { (lp->pre_device != di))) {
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
...@@ -2408,10 +2403,8 @@ p = dev->netdev; ...@@ -2408,10 +2403,8 @@ p = dev->netdev;
isdn_slot_free(lp->isdn_slot, isdn_slot_free(lp->isdn_slot,
ISDN_USAGE_NET); ISDN_USAGE_NET);
} }
dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE;
dev->usage[idx] |= ISDN_USAGE_NET;
strcpy(dev->num[idx], nr); strcpy(dev->num[idx], nr);
isdn_info_update(); isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | ISDN_USAGE_NET);
dev->st_netdev[idx] = lp->netdev; dev->st_netdev[idx] = lp->netdev;
lp->isdn_slot = slot; lp->isdn_slot = slot;
lp->ppp_slot = -1; lp->ppp_slot = -1;
...@@ -2806,8 +2799,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) ...@@ -2806,8 +2799,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
return -EBUSY; return -EBUSY;
} }
/* All went ok, so update isdninfo */ /* All went ok, so update isdninfo */
dev->usage[i] = ISDN_USAGE_EXCLUSIVE; isdn_slot_set_usage(i, ISDN_USAGE_EXCLUSIVE);
isdn_info_update();
restore_flags(flags); restore_flags(flags);
lp->exclusive = i; lp->exclusive = i;
} else { } else {
...@@ -3032,7 +3024,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) ...@@ -3032,7 +3024,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer)
/* for pre-bound channels, we need this extra check */ /* for pre-bound channels, we need this extra check */
if ( strncmp(dev->num[idx],"???",3) == 0 ) return -ENOTCONN; if ( strncmp(dev->num[idx],"???",3) == 0 ) return -ENOTCONN;
strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN); strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN);
phone->outgoing=USG_OUTGOING(dev->usage[idx]); phone->outgoing=USG_OUTGOING(isdn_slot_usage(idx));
if ( copy_to_user(peer,phone,sizeof(*peer)) ) return -EFAULT; if ( copy_to_user(peer,phone,sizeof(*peer)) ) return -EFAULT;
return 0; return 0;
} }
......
...@@ -658,10 +658,9 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) ...@@ -658,10 +658,9 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; dev->m_idx[i] = info->line;
dev->usage[i] |= ISDN_USAGE_OUTGOING;
info->last_dir = 1; info->last_dir = 1;
strcpy(info->last_num, n); strcpy(info->last_num, n);
isdn_info_update(); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
restore_flags(flags); restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
...@@ -849,10 +848,9 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) ...@@ -849,10 +848,9 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m)
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; dev->m_idx[i] = info->line;
dev->usage[i] |= ISDN_USAGE_OUTGOING; isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
info->last_dir = 1; info->last_dir = 1;
// strcpy(info->last_num, n); // strcpy(info->last_num, n);
isdn_info_update();
restore_flags(flags); restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
...@@ -929,9 +927,8 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) ...@@ -929,9 +927,8 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; dev->m_idx[i] = info->line;
dev->usage[i] |= ISDN_USAGE_OUTGOING; isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
info->last_dir = 1; info->last_dir = 1;
isdn_info_update();
restore_flags(flags); restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
...@@ -2206,7 +2203,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) ...@@ -2206,7 +2203,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
(info->flags & ISDN_ASYNC_NORMAL_ACTIVE) && (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) &&
#endif #endif
(info->isdn_slot == -1) && (info->isdn_slot == -1) &&
(USG_NONE(dev->usage[idx]))) { (USG_NONE(isdn_slot_usage(idx)))) {
int matchret; int matchret;
if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret) if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret)
...@@ -2214,14 +2211,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) ...@@ -2214,14 +2211,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
if (!matchret) { /* EAZ is matching */ if (!matchret) { /* EAZ is matching */
info->isdn_slot = idx; info->isdn_slot = idx;
dev->m_idx[idx] = info->line; dev->m_idx[idx] = info->line;
dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE;
dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]);
strcpy(dev->num[idx], nr); strcpy(dev->num[idx], nr);
strcpy(info->emu.cpn, eaz); strcpy(info->emu.cpn, eaz);
info->emu.mdmreg[REG_SI1I] = si2bit[si1]; info->emu.mdmreg[REG_SI1I] = si2bit[si1];
info->emu.mdmreg[REG_PLAN] = setup->plan; info->emu.mdmreg[REG_PLAN] = setup->plan;
info->emu.mdmreg[REG_SCREEN] = setup->screen; info->emu.mdmreg[REG_SCREEN] = setup->screen;
isdn_info_update(); isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]));
restore_flags(flags); restore_flags(flags);
printk(KERN_INFO "isdn_tty: call from %s, -> RING on ttyI%d\n", nr, printk(KERN_INFO "isdn_tty: call from %s, -> RING on ttyI%d\n", nr,
info->line); info->line);
...@@ -2349,14 +2344,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) ...@@ -2349,14 +2344,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c)
info->last_dir = 0; info->last_dir = 0;
info->dialing = 0; info->dialing = 0;
info->rcvsched = 1; info->rcvsched = 1;
if (USG_MODEM(dev->usage[i])) { if (USG_MODEM(isdn_slot_usage(i))) {
if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) {
strcpy(info->emu.connmsg, c->parm.num); strcpy(info->emu.connmsg, c->parm.num);
isdn_tty_modem_result(RESULT_CONNECT, info); isdn_tty_modem_result(RESULT_CONNECT, info);
} else } else
isdn_tty_modem_result(RESULT_CONNECT64000, info); isdn_tty_modem_result(RESULT_CONNECT64000, info);
} }
if (USG_VOICE(dev->usage[i])) if (USG_VOICE(isdn_slot_usage(i)))
isdn_tty_modem_result(RESULT_VCON, info); isdn_tty_modem_result(RESULT_VCON, info);
return 1; return 1;
} }
...@@ -3940,7 +3935,7 @@ isdn_tty_modem_escape(void) ...@@ -3940,7 +3935,7 @@ isdn_tty_modem_escape(void)
int midx; int midx;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (USG_MODEM(dev->usage[i])) if (USG_MODEM(isdn_slot_usage(i)))
if ((midx = dev->m_idx[i]) >= 0) { if ((midx = dev->m_idx[i]) >= 0) {
modem_info *info = &dev->mdm.info[midx]; modem_info *info = &dev->mdm.info[midx];
if (info->online) { if (info->online) {
......
...@@ -74,7 +74,7 @@ isdn_tty_fax_modem_result(int code, modem_info * info) ...@@ -74,7 +74,7 @@ isdn_tty_fax_modem_result(int code, modem_info * info)
case 2: /* +FCON */ case 2: /* +FCON */
/* Append CPN, if enabled */ /* Append CPN, if enabled */
if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) && if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) &&
(!(dev->usage[info->isdn_slot] & ISDN_USAGE_OUTGOING))) { (!(isdn_slot_usage(info->isdn_slot) & ISDN_USAGE_OUTGOING))) {
sprintf(rs, "/%s", m->cpn); sprintf(rs, "/%s", m->cpn);
isdn_tty_at_cout(rs, info); isdn_tty_at_cout(rs, info);
} }
......
...@@ -605,7 +605,6 @@ typedef struct isdn_devt { ...@@ -605,7 +605,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 */
int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */
char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN]; char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
/* Remote number of active ch.*/ /* Remote number of active ch.*/
int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */ int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */
......
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