Commit 93796c1f authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: More I4L linklayer cleanup

Add a helper function to prepare for and start dialing, removing duplicated
code from isdn_tty.c/isdn_net.c.

Move some parts of the big switch statement in isdn_net.c into their own 
functions.
parent cd5869cb
......@@ -19,6 +19,7 @@
#include <linux/vmalloc.h>
#include <linux/isdn.h>
#include <linux/smp_lock.h>
#include <linux/ctype.h>
#include "isdn_common.h"
#include "isdn_tty.h"
#include "isdn_net.h"
......@@ -2166,6 +2167,53 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl)
return isdn_command(ctrl);
}
int
isdn_slot_dial(int sl, struct dial_info *dial)
{
isdn_ctrl cmd;
int retval;
char *msn = isdn_slot_map_eaz2msn(sl, dial->msn);
/* check for DOV */
if (dial->si1 == 7 && tolower(dial->phone[0]) == 'v') { /* DOV call */
dial->si1 = 1;
dial->phone++; /* skip v/V */
}
strcpy(isdn_slot_num(sl), dial->phone);
isdn_slot_set_usage(sl, isdn_slot_usage(sl) | ISDN_USAGE_OUTGOING);
retval = isdn_slot_command(sl, ISDN_CMD_CLREAZ, &cmd);
if (retval)
return retval;
strcpy(cmd.parm.num, msn);
retval = isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd);
cmd.arg = dial->l2_proto << 8;
cmd.parm.fax = dial->fax;
retval = isdn_slot_command(sl, ISDN_CMD_SETL2, &cmd);
if (retval)
return retval;
cmd.arg = dial->l3_proto << 8;
retval = isdn_slot_command(sl, ISDN_CMD_SETL3, &cmd);
if (retval)
return retval;
cmd.parm.setup.si1 = dial->si1;
cmd.parm.setup.si2 = dial->si2;
strcpy(cmd.parm.setup.eazmsn, msn);
strcpy(cmd.parm.setup.phone, dial->phone);
printk(KERN_INFO "ISDN: slot %d: Dialing %s -> %s (SI %d/%d) (B %d/%d)\n",
sl, cmd.parm.setup.eazmsn, cmd.parm.setup.phone,
cmd.parm.setup.si1, cmd.parm.setup.si2,
dial->l2_proto, dial->l3_proto);
return isdn_slot_command(sl, ISDN_CMD_DIAL, &cmd);
}
void
isdn_slot_all_eaz(int sl)
{
......
......@@ -42,10 +42,21 @@ extern int isdn_add_channels(driver *, int, int, int);
extern void isdn_dumppkt(char *, u_char *, int, int);
#endif
struct dial_info {
int l2_proto;
int l3_proto;
struct T30_s *fax;
unsigned char si1;
unsigned char si2;
unsigned char *msn;
unsigned char *phone;
};
extern int isdn_get_free_slot(int, int, int, int, int, char *);
extern void isdn_slot_free(int slot, int usage);
extern void isdn_slot_all_eaz(int slot);
extern int isdn_slot_command(int slot, int cmd, isdn_ctrl *);
extern int isdn_slot_dial(int slot, struct dial_info *dial);
extern char *isdn_slot_map_eaz2msn(int slot, char *msn);
extern int isdn_slot_write(int slot, struct sk_buff *);
extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int);
......
This diff is collapsed.
......@@ -626,7 +626,6 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
int usg = ISDN_USAGE_MODEM;
int si = 7;
int l2 = m->mdmreg[REG_L2PROT];
isdn_ctrl cmd;
ulong flags;
int i;
int j;
......@@ -656,36 +655,29 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
restore_flags(flags);
isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else {
struct dial_info dial = {
.l2_proto = l2,
.l3_proto = m->mdmreg[REG_L3PROT],
.si1 = si,
.si2 = m->mdmreg[REG_SI2],
.msn = m->msn,
.phone = n,
};
info->isdn_slot = i;
isdn_slot_set_m_idx(i, info->line);
info->last_dir = 1;
info->last_l2 = l2;
strcpy(info->last_num, n);
isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETEAZ, &cmd);
info->last_l2 = l2;
cmd.arg = l2 << 8;
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL2, &cmd);
cmd.arg = m->mdmreg[REG_L3PROT] << 8;
#ifdef CONFIG_ISDN_TTY_FAX
if (l2 == ISDN_PROTO_L2_FAX) {
cmd.parm.fax = info->fax;
dial.fax = info->fax;
info->fax->direction = ISDN_TTY_FAX_CONN_OUT;
}
#endif
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL3, &cmd);
sprintf(cmd.parm.setup.phone, "%s", n);
sprintf(cmd.parm.setup.eazmsn, "%s",
isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
cmd.parm.setup.si1 = si;
cmd.parm.setup.si2 = m->mdmreg[REG_SI2];
info->dialing = 1;
info->emu.carrierwait = 0;
strcpy(isdn_slot_num(i), n);
isdn_info_update();
isdn_slot_command(info->isdn_slot, ISDN_CMD_DIAL, &cmd);
isdn_slot_dial(info->isdn_slot, &dial);
isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1);
}
}
......@@ -852,9 +844,6 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m)
info->last_dir = 1;
// strcpy(info->last_num, n);
restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETEAZ, &cmd);
info->last_l2 = l2;
cmd.arg = l2 << 8;
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL2, &cmd);
......@@ -930,9 +919,6 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
info->last_dir = 1;
restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETEAZ, &cmd);
info->last_l2 = l2;
cmd.arg = l2 << 8;
isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL2, &cmd);
......
......@@ -391,7 +391,7 @@ typedef struct isdn_net_dev_s {
channels, which are currently
online */
spinlock_t queue_lock; /* lock to protect queue */
void *next; /* Pointer to next isdn-interface */
struct isdn_net_dev_s *next; /* Pointer to next isdn-interface */
struct net_device dev; /* interface to upper levels */
#ifdef CONFIG_ISDN_PPP
ippp_bundle * pb; /* pointer to the common bundle structure
......
......@@ -418,9 +418,7 @@ typedef struct {
char display[85];/* display message data */
isdn_cmd_stat isdn_io; /* ISDN IO-parameter/result */
aux_s aux; /* for modem commands/indications */
#ifdef CONFIG_ISDN_TTY_FAX
T30_s *fax; /* Pointer to ttys fax struct */
#endif
ulong userdata; /* User Data */
} parm;
} isdn_ctrl;
......
......@@ -529,7 +529,6 @@ static void do_pre_smp_initcalls(void)
extern int migration_init(void);
extern int spawn_ksoftirqd(void);
migration_init();
spawn_ksoftirqd();
}
......
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