Commit e4adb249 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Fix the cleanups

Testing of course revealed some bugs introduced during the cleanups,
so these are fixed here with a couple of other small bits, like improved
debugging code.
parent 96d7f4d2
...@@ -71,7 +71,7 @@ extern char *isdn_v110_revision; ...@@ -71,7 +71,7 @@ extern char *isdn_v110_revision;
#if defined(CONFIG_ISDN_DIVERSION) || defined(CONFIG_ISDN_DIVERSION_MODULE) #if defined(CONFIG_ISDN_DIVERSION) || defined(CONFIG_ISDN_DIVERSION_MODULE)
static isdn_divert_if *divert_if; /* = NULL */ static isdn_divert_if *divert_if; /* = NULL */
#else #else
#define divert_if (0) #define divert_if ((isdn_divert_if *) NULL)
#endif #endif
...@@ -357,12 +357,13 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) ...@@ -357,12 +357,13 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb)
static int static int
isdn_command(isdn_ctrl *cmd) isdn_command(isdn_ctrl *cmd)
{ {
int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255);
if (cmd->driver == -1) { if (cmd->driver == -1) {
printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command); printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command);
return(1); return(1);
} }
if (cmd->command == ISDN_CMD_SETL2) { if (cmd->command == ISDN_CMD_SETL2) {
int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255);
unsigned long l2prot = (cmd->arg >> 8) & 255; unsigned long l2prot = (cmd->arg >> 8) & 255;
unsigned long features = (dev->drv[cmd->driver]->interface->features unsigned long features = (dev->drv[cmd->driver]->interface->features
>> ISDN_FEATURE_L2_SHIFT) & >> ISDN_FEATURE_L2_SHIFT) &
...@@ -385,6 +386,28 @@ isdn_command(isdn_ctrl *cmd) ...@@ -385,6 +386,28 @@ isdn_command(isdn_ctrl *cmd)
slot[idx].iv110.v110emu = 0; slot[idx].iv110.v110emu = 0;
} }
} }
#ifdef ISDN_DEBUG_COMMAND
switch (cmd->command) {
case ISDN_CMD_SETL2:
printk(KERN_DEBUG "ISDN_CMD_SETL2 %d\n", idx); break;
case ISDN_CMD_SETL3:
printk(KERN_DEBUG "ISDN_CMD_SETL3 %d\n", idx); break;
case ISDN_CMD_DIAL:
printk(KERN_DEBUG "ISDN_CMD_DIAL %d\n", idx); break;
case ISDN_CMD_ACCEPTD:
printk(KERN_DEBUG "ISDN_CMD_ACCEPTD %d\n", idx); break;
case ISDN_CMD_ACCEPTB:
printk(KERN_DEBUG "ISDN_CMD_ACCEPTB %d\n", idx); break;
case ISDN_CMD_HANGUP:
printk(KERN_DEBUG "ISDN_CMD_HANGUP %d\n", idx); break;
case ISDN_CMD_CLREAZ:
printk(KERN_DEBUG "ISDN_CMD_CLREAZ %d\n", idx); break;
case ISDN_CMD_SETEAZ:
printk(KERN_DEBUG "ISDN_CMD_SETEAZ %d\n", idx); break;
default:
printk(KERN_DEBUG "%s: cmd = %d\n", __FUNCTION__, cmd->command);
}
#endif
return dev->drv[cmd->driver]->interface->command(cmd); return dev->drv[cmd->driver]->interface->command(cmd);
} }
...@@ -458,7 +481,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -458,7 +481,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_ICALL: case ISDN_STAT_ICALL:
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("ICALL: %d %ld %s\n", di, c->arg, c->parm.num); dbg_statcallb("ICALL: %d (%d,%ld) %s\n", i, di, c->arg, c->parm.num);
if (dev->global_flags & ISDN_GLOBAL_STOPPED) { if (dev->global_flags & ISDN_GLOBAL_STOPPED) {
cmd.driver = di; cmd.driver = di;
cmd.arg = c->arg; cmd.arg = c->arg;
...@@ -490,13 +513,11 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -490,13 +513,11 @@ isdn_status_callback(isdn_ctrl * c)
} }
break; break;
case 1: case 1:
/* Schedule connection-setup */
isdn_net_dial();
list_for_each(l, &isdn_net_devs) { list_for_each(l, &isdn_net_devs) {
isdn_net_dev *p = list_entry(l, isdn_net_dev, global_list); isdn_net_dev *p = list_entry(l, isdn_net_dev, global_list);
if (p->local.isdn_slot == isdn_dc2minor(di, cmd.arg)) { if (p->local.isdn_slot == i) {
strcpy( cmd.parm.setup.eazmsn, p->local.msn ); strcpy(cmd.parm.setup.eazmsn, p->local.msn);
isdn_slot_command(p->local.isdn_slot, ISDN_CMD_ACCEPTD, &cmd); isdn_slot_command(i, ISDN_CMD_ACCEPTD, &cmd);
retval = 1; retval = 1;
break; break;
} }
...@@ -516,7 +537,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -516,7 +537,6 @@ isdn_status_callback(isdn_ctrl * c)
/* Fall through */ /* Fall through */
case 4: case 4:
/* ... then start callback. */ /* ... then start callback. */
isdn_net_dial();
break; break;
case 5: case 5:
/* Number would eventually match, if longer */ /* Number would eventually match, if longer */
...@@ -529,7 +549,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -529,7 +549,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_CINF: case ISDN_STAT_CINF:
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("CINF: %ld %s\n", c->arg, c->parm.num); dbg_statcallb("CINF: %d %s\n", i, c->parm.num);
if (dev->global_flags & ISDN_GLOBAL_STOPPED) if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0; return 0;
if (strcmp(c->parm.num, "0")) if (strcmp(c->parm.num, "0"))
...@@ -537,7 +557,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -537,7 +557,7 @@ isdn_status_callback(isdn_ctrl * c)
isdn_tty_stat_callback(i, c); isdn_tty_stat_callback(i, c);
break; break;
case ISDN_STAT_CAUSE: case ISDN_STAT_CAUSE:
dbg_statcallb("CAUSE: %ld %s\n", c->arg, 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); dev->drvid[di], c->arg, c->parm.num);
isdn_tty_stat_callback(i, c); isdn_tty_stat_callback(i, c);
...@@ -545,7 +565,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -545,7 +565,7 @@ isdn_status_callback(isdn_ctrl * c)
divert_if->stat_callback(c); divert_if->stat_callback(c);
break; break;
case ISDN_STAT_DISPLAY: case ISDN_STAT_DISPLAY:
dbg_statcallb("DISPLAY: %ld %s\n", c->arg, c->parm.display); dbg_statcallb("DISPLAY: %d %s\n", i, c->parm.display);
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);
...@@ -553,7 +573,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -553,7 +573,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_DCONN: case ISDN_STAT_DCONN:
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("DCONN: %ld\n", c->arg); dbg_statcallb("DCONN: %d\n", i);
if (dev->global_flags & ISDN_GLOBAL_STOPPED) if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0; return 0;
/* Find any net-device, waiting for D-channel setup */ /* Find any net-device, waiting for D-channel setup */
...@@ -572,7 +592,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -572,7 +592,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_DHUP: case ISDN_STAT_DHUP:
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("DHUP: %ld\n", c->arg); dbg_statcallb("DHUP: %d\n", i);
if (dev->global_flags & ISDN_GLOBAL_STOPPED) if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0; return 0;
dev->drv[di]->online &= ~(1 << (c->arg)); dev->drv[di]->online &= ~(1 << (c->arg));
...@@ -604,7 +624,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -604,7 +624,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_BHUP: case ISDN_STAT_BHUP:
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("BHUP: %ld\n", c->arg); dbg_statcallb("BHUP: %d\n", i);
if (dev->global_flags & ISDN_GLOBAL_STOPPED) if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0; return 0;
dev->drv[di]->online &= ~(1 << (c->arg)); dev->drv[di]->online &= ~(1 << (c->arg));
...@@ -2101,8 +2121,17 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) ...@@ -2101,8 +2121,17 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl)
{ {
ctrl->command = cmd; ctrl->command = cmd;
ctrl->driver = isdn_slot_driver(sl); ctrl->driver = isdn_slot_driver(sl);
ctrl->arg &= 0xff; ctrl->arg |= isdn_slot_channel(sl); switch (cmd) {
case ISDN_CMD_SETL2:
case ISDN_CMD_SETL3:
case ISDN_CMD_PROT_IO:
ctrl->arg &= ~0xff; ctrl->arg |= isdn_slot_channel(sl);
break;
default:
ctrl->arg = isdn_slot_channel(sl);
break;
}
return isdn_command(ctrl); return isdn_command(ctrl);
} }
...@@ -2179,6 +2208,30 @@ isdn_slot_set_usage(int sl, int usage) ...@@ -2179,6 +2208,30 @@ isdn_slot_set_usage(int sl, int usage)
isdn_info_update(); isdn_info_update();
} }
int
isdn_slot_m_idx(int sl)
{
BUG_ON(sl < 0);
return slot[sl].m_idx;
}
void
isdn_slot_set_m_idx(int sl, int midx)
{
BUG_ON(sl < 0);
slot[sl].m_idx = midx;
}
char *
isdn_slot_num(int sl)
{
BUG_ON(sl < 0);
return slot[sl].num;
}
void void
isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd) isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd)
{ {
...@@ -2200,7 +2253,7 @@ isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd) ...@@ -2200,7 +2253,7 @@ isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd)
{ {
BUG_ON(sl < 0); BUG_ON(sl < 0);
slot[sl].rx_netdev = nd; slot[sl].st_netdev = nd;
} }
isdn_net_dev * isdn_net_dev *
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#undef ISDN_DEBUG_NET_DIAL #undef ISDN_DEBUG_NET_DIAL
#undef ISDN_DEBUG_NET_ICALL #undef ISDN_DEBUG_NET_ICALL
#undef ISDN_DEBUG_STATCALLB #undef ISDN_DEBUG_STATCALLB
#undef ISDN_DEBUG_COMMAND
#ifdef ISDN_DEBUG_NET_DIAL #ifdef ISDN_DEBUG_NET_DIAL
#define dbg_net_dial(arg...) printk(KERN_DEBUG arg) #define dbg_net_dial(arg...) printk(KERN_DEBUG arg)
...@@ -44,9 +45,11 @@ ...@@ -44,9 +45,11 @@
#endif #endif
#define isdn_BUG() \ #define isdn_BUG() \
do { printk(KERN_WARNING "ISDN Bug at %s:%d", __FILE__, __LINE__); \ do { printk(KERN_WARNING "ISDN Bug at %s:%d\n", __FILE__, __LINE__); \
} while(0) } while(0)
#define HERE printk("%s:%d (%s)\n", __FILE__, __LINE__, __FUNCTION__)
/* Prototypes */ /* Prototypes */
extern void isdn_MOD_INC_USE_COUNT(void); extern void isdn_MOD_INC_USE_COUNT(void);
extern void isdn_MOD_DEC_USE_COUNT(void); extern void isdn_MOD_DEC_USE_COUNT(void);
...@@ -94,7 +97,7 @@ extern int isdn_slot_usage(int slot); ...@@ -94,7 +97,7 @@ extern int isdn_slot_usage(int slot);
extern void isdn_slot_set_usage(int slot, int usage); extern void isdn_slot_set_usage(int slot, int usage);
extern char *isdn_slot_num(int slot); extern char *isdn_slot_num(int slot);
extern int isdn_slot_m_idx(int slot); extern int isdn_slot_m_idx(int slot);
extern int isdn_slot_set_m_idx(int slot, int midx); extern void isdn_slot_set_m_idx(int slot, int midx);
extern void isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd); extern void isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd);
extern void isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd); extern void isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd);
extern isdn_net_dev *isdn_slot_rx_netdev(int sl); extern isdn_net_dev *isdn_slot_rx_netdev(int sl);
......
This diff is collapsed.
...@@ -44,7 +44,6 @@ extern int isdn_net_getpeer(isdn_net_ioctl_phone *, isdn_net_ioctl_phone *); ...@@ -44,7 +44,6 @@ extern int isdn_net_getpeer(isdn_net_ioctl_phone *, isdn_net_ioctl_phone *);
extern int isdn_net_delphone(isdn_net_ioctl_phone *); extern int isdn_net_delphone(isdn_net_ioctl_phone *);
extern int isdn_net_find_icall(int, int, int, setup_parm *); extern int isdn_net_find_icall(int, int, int, setup_parm *);
extern void isdn_net_hangup(struct net_device *); extern void isdn_net_hangup(struct net_device *);
extern void isdn_net_dial(void);
extern void isdn_net_autohup(void); extern void isdn_net_autohup(void);
extern int isdn_net_force_hangup(char *); extern int isdn_net_force_hangup(char *);
extern int isdn_net_force_dial(char *); extern int isdn_net_force_dial(char *);
......
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