Commit b6b5803f authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Pass around struct isdn_slot directly

The common way in the kernel is to pass around the struct (e.g.
struct net_device), and leave the user the possibility to add
its private data using ::priv, so do it the same way when accessing
an ISDN channel.
parent 59c28988
......@@ -26,7 +26,6 @@
#include "isdn_audio.h"
#endif
#include <linux/isdn_divertif.h>
#include "isdn_v110.h"
#include <linux/devfs_fs_kernel.h>
MODULE_DESCRIPTION("ISDN4Linux: link layer");
......@@ -57,22 +56,6 @@ static char *slot_st_str[] = {
"ST_SLOT_WAIT_DHUP",
};
struct isdn_slot {
int di; /* driver index */
struct isdn_driver *drv; /* driver */
int ch; /* channel index (per driver) */
int usage; /* how is it used */
char num[ISDN_MSNLEN]; /* the current phone number */
unsigned long ibytes; /* Statistics incoming bytes */
unsigned long obytes; /* Statistics outgoing bytes */
struct isdn_v110 iv110; /* For V.110 */
int m_idx; /* Index for mdm.... */
void *priv; /* pointer to isdn_net_dev */
int (*event_cb)(int sl, int pr, void *arg);
struct fsm_inst fi;
};
static char *ev_str[] = {
"EV_DRV_REGISTER",
"EV_STAT_RUN",
......@@ -117,10 +100,8 @@ static int isdn_v110_data_req(struct isdn_slot *slot, struct sk_buff *skb);
static inline int
do_event_cb(struct isdn_slot *slot, int pr, void *arg)
{
int sl = slot - slots;
if (slot->event_cb)
return slot->event_cb(sl, pr, arg);
return slot->event_cb(slot, pr, arg);
return -ENXIO;
}
......@@ -304,7 +285,6 @@ slot_icall(struct fsm_inst *fi, int pr, void *arg)
{
struct isdn_slot *slot = fi->userdata;
isdn_ctrl *ctrl = arg;
int sl = slot - slots;
int retval;
fsm_change_state(fi, ST_SLOT_IN);
......@@ -314,15 +294,13 @@ slot_icall(struct fsm_inst *fi, int pr, void *arg)
strcpy(slot->num, ctrl->parm.setup.phone);
/* Try to find a network-interface which will accept incoming call */
retval = isdn_net_find_icall(ctrl->driver, ctrl->arg, sl,
&ctrl->parm.setup);
retval = isdn_net_find_icall(slot, &ctrl->parm.setup);
/* already taken by net now? */
if (fi->state != ST_SLOT_IN)
goto out;
retval = isdn_tty_find_icall(ctrl->driver, ctrl->arg, sl,
&ctrl->parm.setup);
retval = isdn_tty_find_icall(slot, &ctrl->parm.setup);
out:
return 0;
}
......@@ -342,12 +320,11 @@ static int
slot_unbind(struct fsm_inst *fi, int pr, void *arg)
{
struct isdn_slot *slot = fi->userdata;
int sl = slot - slots;
isdn_ctrl cmd;
strcpy(slot->num, "???");
cmd.parm.num[0] = '\0';
isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd);
isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd);
slot->ibytes = 0;
slot->obytes = 0;
slot->usage = ISDN_USAGE_NONE;
......@@ -1990,7 +1967,7 @@ isdn_map_eaz2msn(char *msn, int di)
* Find an unused ISDN-channel, whose feature-flags match the
* given L2- and L3-protocols.
*/
int
struct isdn_slot *
isdn_get_free_slot(int usage, int l2_proto, int l3_proto,
int pre_dev, int pre_chan, char *msn)
{
......@@ -2029,32 +2006,28 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto,
slot->usage = usage;
isdn_info_update();
fsm_event(&slot->fi, EV_SLOT_BIND, NULL);
return i;
return slot;
}
}
restore_flags(flags);
return -1;
return NULL;
}
/*
* Set state of ISDN-channel to 'unused'
*/
void
isdn_slot_free(int sl)
isdn_slot_free(struct isdn_slot *slot)
{
fsm_event(&slots[sl].fi, EV_SLOT_UNBIND, NULL);
fsm_event(&slot->fi, EV_SLOT_UNBIND, NULL);
}
/*
* Return: length of data on success, -ERRcode on failure.
*/
int
isdn_slot_write(int sl, struct sk_buff *skb)
isdn_slot_write(struct isdn_slot *slot, struct sk_buff *skb)
{
struct isdn_slot *slot = &slots[sl];
BUG_ON(sl < 0);
return fsm_event(&slot->fi, EV_DATA_REQ, skb);
}
......@@ -2157,38 +2130,26 @@ EXPORT_SYMBOL(isdn_ppp_unregister_compressor);
#endif
int
isdn_slot_maxbufsize(int sl)
isdn_slot_maxbufsize(struct isdn_slot *slot)
{
BUG_ON(sl < 0);
return slots[sl].drv->maxbufsize;
return slot->drv->maxbufsize;
}
int
isdn_slot_hdrlen(int sl)
isdn_slot_hdrlen(struct isdn_slot *slot)
{
struct isdn_slot *slot = &slots[sl];
BUG_ON(sl < 0);
return slot->drv->interface->hl_hdrlen;
}
char *
isdn_slot_map_eaz2msn(int sl, char *msn)
isdn_slot_map_eaz2msn(struct isdn_slot *slot, char *msn)
{
struct isdn_slot *slot = &slots[sl];
BUG_ON(sl < 0);
return isdn_map_eaz2msn(msn, slot->di);
}
int
isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl)
isdn_slot_command(struct isdn_slot *slot, int cmd, isdn_ctrl *ctrl)
{
struct isdn_slot *slot = &slots[sl];
ctrl->command = cmd;
ctrl->driver = slot->di;
......@@ -2230,14 +2191,11 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl)
}
int
isdn_slot_dial(int sl, struct dial_info *dial)
isdn_slot_dial(struct isdn_slot *slot, struct dial_info *dial)
{
struct isdn_slot *slot = &slots[sl];
isdn_ctrl cmd;
int retval;
char *msn = isdn_slot_map_eaz2msn(sl, dial->msn);
BUG_ON(sl < 0);
char *msn = isdn_slot_map_eaz2msn(slot, dial->msn);
/* check for DOV */
if (dial->si1 == 7 && tolower(dial->phone[0]) == 'v') { /* DOV call */
......@@ -2249,21 +2207,21 @@ isdn_slot_dial(int sl, struct dial_info *dial)
slot->usage |= ISDN_USAGE_OUTGOING;
isdn_info_update();
retval = isdn_slot_command(sl, ISDN_CMD_CLREAZ, &cmd);
retval = isdn_slot_command(slot, ISDN_CMD_CLREAZ, &cmd);
if (retval)
return retval;
strcpy(cmd.parm.num, msn);
retval = isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd);
retval = isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd);
cmd.arg = dial->l2_proto << 8;
cmd.parm.fax = dial->fax;
retval = isdn_slot_command(sl, ISDN_CMD_SETL2, &cmd);
retval = isdn_slot_command(slot, ISDN_CMD_SETL2, &cmd);
if (retval)
return retval;
cmd.arg = dial->l3_proto << 8;
retval = isdn_slot_command(sl, ISDN_CMD_SETL3, &cmd);
retval = isdn_slot_command(slot, ISDN_CMD_SETL3, &cmd);
if (retval)
return retval;
......@@ -2272,12 +2230,12 @@ isdn_slot_dial(int sl, struct dial_info *dial)
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,
printk(KERN_INFO "ISDN: Dialing %s -> %s (SI %d/%d) (B %d/%d)\n",
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);
return isdn_slot_command(slot, ISDN_CMD_DIAL, &cmd);
}
int
......@@ -2297,39 +2255,15 @@ isdn_slot_m_idx(int sl)
}
void
isdn_slot_set_m_idx(int sl, int midx)
isdn_slot_set_m_idx(struct isdn_slot *slot, int midx)
{
BUG_ON(sl < 0);
slots[sl].m_idx = midx;
slot->m_idx = midx;
}
char *
isdn_slot_num(int sl)
{
BUG_ON(sl < 0);
return slots[sl].num;
}
void
isdn_slot_set_priv(int sl, int usage, void *priv,
int (*event_cb)(int sl, int pr, void *arg))
{
BUG_ON(sl < 0);
slots[sl].usage &= ISDN_USAGE_EXCLUSIVE;
slots[sl].usage |= usage;
slots[sl].priv = priv;
slots[sl].event_cb = event_cb;
}
void *
isdn_slot_priv(int sl)
isdn_slot_num(struct isdn_slot *slot)
{
BUG_ON(sl < 0);
return slots[sl].priv;
return slot->num;
}
int
......@@ -2548,35 +2482,29 @@ isdn_v110_add_features(struct isdn_driver *drv)
static void
__isdn_v110_open(struct isdn_slot *slot)
{
int sl = slot - slots;
if (!slot->iv110.v110emu)
return;
isdn_v110_open(sl, &slot->iv110);
isdn_v110_open(slot, &slot->iv110);
}
static void
__isdn_v110_close(struct isdn_slot *slot)
{
int sl = slot - slots;
if (!slot->iv110.v110emu)
return;
isdn_v110_close(sl, &slot->iv110);
isdn_v110_close(slot, &slot->iv110);
}
static void
__isdn_v110_bsent(struct isdn_slot *slot, int pr, isdn_ctrl *c)
{
int sl = slot - slots;
if (!slot->iv110.v110emu) {
do_event_cb(slot, pr, c);
return;
}
isdn_v110_bsent(sl, &slot->iv110);
isdn_v110_bsent(slot, &slot->iv110);
}
/*
......@@ -2615,8 +2543,6 @@ isdn_v110_setl2(struct isdn_slot *slot, isdn_ctrl *cmd)
static int
isdn_v110_data_ind(struct isdn_slot *slot, struct sk_buff *skb)
{
int sl = slot - slots;
if (!slot->iv110.v110emu)
goto recv;
......@@ -2626,7 +2552,7 @@ isdn_v110_data_ind(struct isdn_slot *slot, struct sk_buff *skb)
recv:
if (slot->event_cb)
slot->event_cb(sl, EV_DATA_IND, skb);
slot->event_cb(slot, EV_DATA_IND, skb);
return 0;
}
......
......@@ -10,6 +10,7 @@
*/
#include <linux/isdn.h>
#include "isdn_v110.h"
#undef ISDN_DEBUG_MODEM_OPEN
#undef ISDN_DEBUG_MODEM_IOCTL
......@@ -68,6 +69,21 @@ extern void isdn_dumppkt(char *, u_char *, int, int);
static inline void isdn_dumppkt(char *s, u_char *d, int l, int m) { }
#endif
struct isdn_slot {
int di; /* driver index */
struct isdn_driver *drv; /* driver */
int ch; /* channel index (per driver) */
int usage; /* how is it used */
char num[ISDN_MSNLEN]; /* the current phone number */
unsigned long ibytes; /* Statistics incoming bytes */
unsigned long obytes; /* Statistics outgoing bytes */
struct isdn_v110 iv110; /* For V.110 */
int m_idx; /* Index for mdm.... */
void *priv; /* pointer to isdn_net_dev */
int (*event_cb)(struct isdn_slot *, int pr, void *arg);
struct fsm_inst fi;
};
struct dial_info {
int l2_proto;
int l3_proto;
......@@ -78,22 +94,19 @@ struct dial_info {
unsigned char *phone;
};
extern int isdn_get_free_slot(int, int, int, int, int, char *);
extern void isdn_slot_free(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_hdrlen(int slot);
extern int isdn_slot_maxbufsize(int slot);
extern int isdn_slot_usage(int slot);
extern char *isdn_slot_num(int slot);
extern int isdn_slot_m_idx(int slot);
extern void isdn_slot_set_m_idx(int slot, int midx);
extern void isdn_slot_set_priv(int sl, int usage, void *priv,
int (*event_cb)(int sl, int pr, void *arg));
extern void *isdn_slot_priv(int sl);
extern int isdn_hard_header_len(void);
struct isdn_slot *isdn_get_free_slot(int, int, int, int, int, char *);
void isdn_slot_free(struct isdn_slot *);
int isdn_slot_command(struct isdn_slot *, int cmd, isdn_ctrl *);
int isdn_slot_dial(struct isdn_slot *, struct dial_info *dial);
char *isdn_slot_map_eaz2msn(struct isdn_slot *, char *msn);
int isdn_slot_write(struct isdn_slot *, struct sk_buff *);
int isdn_slot_hdrlen(struct isdn_slot *);
int isdn_slot_maxbufsize(struct isdn_slot *);
char *isdn_slot_num(struct isdn_slot *);
void isdn_slot_set_m_idx(struct isdn_slot *, int midx);
int isdn_hard_header_len(void);
int isdn_slot_m_idx(int sl);
int isdn_slot_usage(int sl);
int isdn_drv_lookup(char *drvid);
char *isdn_drv_drvid(int di);
......
......@@ -294,21 +294,21 @@ isdn_net_bind(isdn_net_dev *idev, isdn_net_ioctl_cfg *cfg)
goto out;
}
}
if (cfg->exclusive == (idev->exclusive >= 0) &&
if (cfg->exclusive == !!idev->exclusive &&
drvidx == idev->pre_device && chidx == idev->pre_channel) {
/* no change */
retval = 0;
goto out;
}
if (idev->exclusive >= 0) {
if (idev->exclusive) {
isdn_slot_free(idev->exclusive);
idev->exclusive = -1;
idev->exclusive = NULL;
}
if (cfg->exclusive) {
/* If binding is exclusive, try to grab the channel */
idev->exclusive = isdn_get_free_slot(ISDN_USAGE_NET | ISDN_USAGE_EXCLUSIVE,
mlp->l2_proto, mlp->l3_proto, drvidx, chidx, cfg->eaz);
if (idev->exclusive < 0) {
if (!idev->exclusive) {
/* Grab failed, because desired channel is in use */
retval = -EBUSY;
goto out;
......@@ -368,10 +368,10 @@ isdn_net_addif(char *name, isdn_net_local *mlp)
tasklet_init(&idev->tlet, isdn_net_tasklet, (unsigned long) idev);
skb_queue_head_init(&idev->super_tx_queue);
idev->isdn_slot = -1;
idev->isdn_slot = NULL;
idev->pre_device = -1;
idev->pre_channel = -1;
idev->exclusive = -1;
idev->exclusive = NULL;
idev->pppbind = -1;
......@@ -643,7 +643,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg *cfg)
mlp = idev->mlp;
strcpy(cfg->eaz, mlp->msn);
cfg->exclusive = idev->exclusive >= 0;
cfg->exclusive = !!idev->exclusive;
if (idev->pre_device >= 0) {
sprintf(cfg->drvid, "%s,%d", isdn_drv_drvid(idev->pre_device),
idev->pre_channel);
......@@ -853,7 +853,7 @@ static int
isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer)
{
isdn_net_dev *idev = isdn_net_findif(phone->name);
int idx;
struct isdn_slot *slot;
if (!idev)
return -ENODEV;
......@@ -863,15 +863,15 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer)
* in (partially) wrong number copied to user. This race
* currently ignored.
*/
idx = idev->isdn_slot;
if (idx < 0)
slot = idev->isdn_slot;
if (slot < 0)
return -ENOTCONN;
/* for pre-bound channels, we need this extra check */
if (strncmp(isdn_slot_num(idx), "???", 3) == 0 )
if (strncmp(isdn_slot_num(slot), "???", 3) == 0 )
return -ENOTCONN;
strncpy(phone->phone, isdn_slot_num(idx), ISDN_MSNLEN);
phone->outgoing = USG_OUTGOING(isdn_slot_usage(idx));
strncpy(phone->phone, isdn_slot_num(slot), ISDN_MSNLEN);
phone->outgoing = USG_OUTGOING(slot->usage);
if (copy_to_user(peer, phone, sizeof(*peer)))
return -EFAULT;
......@@ -1202,14 +1202,15 @@ isdn_net_unbind_channel(isdn_net_dev *idev)
if (mlp->ops->unbind)
mlp->ops->unbind(idev);
isdn_slot_set_priv(idev->isdn_slot, 0, NULL, NULL);
idev->isdn_slot->priv = NULL;
idev->isdn_slot->event_cb = NULL;
skb_queue_purge(&idev->super_tx_queue);
if (idev->isdn_slot != idev->exclusive)
isdn_slot_free(idev->isdn_slot);
idev->isdn_slot = -1;
idev->isdn_slot = NULL;
if (idev->fi.state != ST_NULL) {
lp_put(mlp);
......@@ -1217,27 +1218,29 @@ isdn_net_unbind_channel(isdn_net_dev *idev)
}
}
static int isdn_net_event_callback(int sl, int pr, void *arg);
static int isdn_net_event_callback(struct isdn_slot *slot, int pr, void *arg);
/*
* Assign an ISDN-channel to a net-interface
*/
static int
isdn_net_bind_channel(isdn_net_dev *idev, int slot)
isdn_net_bind_channel(isdn_net_dev *idev, struct isdn_slot *slot)
{
isdn_net_local *mlp = idev->mlp;
int retval = 0;
idev->isdn_slot = slot;
isdn_slot_set_priv(idev->isdn_slot, ISDN_USAGE_NET, idev,
isdn_net_event_callback);
if (mlp->ops->bind)
retval = mlp->ops->bind(idev);
if (retval < 0)
isdn_net_unbind_channel(idev);
goto out;
idev->isdn_slot = slot;
slot->priv = idev;
slot->event_cb = isdn_net_event_callback;
slot->usage |= ISDN_USAGE_NET;
out:
return retval;
}
......@@ -1368,7 +1371,7 @@ accept_icall(struct fsm_inst *fi, int pr, void *arg)
isdn_net_dev *idev = fi->userdata;
isdn_net_local *mlp = idev->mlp;
isdn_ctrl cmd;
int slot = (int) arg;
struct isdn_slot *slot = arg;
isdn_net_bind_channel(idev, slot);
......@@ -1407,8 +1410,8 @@ do_callback(struct fsm_inst *fi, int pr, void *arg)
}
static int
isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1,
char *eaz, char *nr)
isdn_net_dev_icall(isdn_net_dev *idev, struct isdn_slot *slot,
int si1, char *eaz, char *nr)
{
isdn_net_local *mlp = idev->mlp;
struct isdn_net_phone *ph;
......@@ -1438,11 +1441,11 @@ isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1,
}
dbg_net_icall("%s: pdev=%d di=%d pch=%d ch = %d\n", idev->name,
idev->pre_device, di, idev->pre_channel, ch);
idev->pre_device, slot->di, idev->pre_channel, slot->ch);
/* check if exclusive */
if ((isdn_slot_usage(slot) & ISDN_USAGE_EXCLUSIVE) &&
(idev->pre_channel != ch || idev->pre_device != di)) {
if ((slot->usage & ISDN_USAGE_EXCLUSIVE) &&
(idev->pre_channel != slot->ch || idev->pre_device != slot->di)) {
dbg_net_icall("%s: excl check failed\n", idev->name);
return 0;
}
......@@ -1476,7 +1479,7 @@ isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1,
printk(KERN_INFO "%s: call from %s -> %s accepted\n",
idev->name, nr, eaz);
if (fsm_event(&idev->fi, EV_NET_DO_ACCEPT, (void *) slot)) {
if (fsm_event(&idev->fi, EV_NET_DO_ACCEPT, slot)) {
lp_put(mlp);
return 0;
}
......@@ -1500,7 +1503,7 @@ isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1,
* would eventually match if CID was longer.
*/
int
isdn_net_find_icall(int di, int ch, int sl, setup_parm *setup)
isdn_net_find_icall(struct isdn_slot *slot, setup_parm *setup)
{
isdn_net_local *lp;
isdn_net_dev *idev;
......@@ -1540,8 +1543,8 @@ isdn_net_find_icall(int di, int ch, int sl, setup_parm *setup)
return 0;
}
dbg_net_icall("n_fi: di=%d ch=%d sl=%d usg=%d\n", di, ch, sl,
isdn_slot_usage(sl));
dbg_net_icall("n_fi: di=%d ch=%d usg=%#x\n", slot->di, slot->ch,
slot->usage);
retval = 0;
spin_lock_irqsave(&running_devs_lock, flags);
......@@ -1550,7 +1553,7 @@ isdn_net_find_icall(int di, int ch, int sl, setup_parm *setup)
spin_unlock_irqrestore(&running_devs_lock, flags);
list_for_each_entry(idev, &lp->slaves, slaves) {
retval = isdn_net_dev_icall(idev, sl, di, ch, si1, eaz, nr);
retval = isdn_net_dev_icall(idev, slot, si1, eaz, nr);
if (retval > 0)
break;
}
......@@ -1599,7 +1602,7 @@ do_dial(struct fsm_inst *fi, int pr, void *arg)
{
isdn_net_dev *idev = fi->userdata;
isdn_net_local *mlp = idev->mlp;
int slot;
struct isdn_slot *slot;
if (ISDN_NET_DIALMODE(*mlp) == ISDN_NET_DM_OFF)
return -EPERM;
......@@ -1607,13 +1610,13 @@ do_dial(struct fsm_inst *fi, int pr, void *arg)
if (list_empty(&mlp->phone[1])) /* no number to dial ? */
return -EINVAL;
if (idev->exclusive >= 0)
if (idev->exclusive)
slot = idev->exclusive;
else
slot = isdn_get_free_slot(ISDN_USAGE_NET, mlp->l2_proto,
mlp->l3_proto, idev->pre_device,
idev->pre_channel, mlp->msn);
if (slot < 0)
if (!slot)
return -EAGAIN;
if (isdn_net_bind_channel(idev, slot) < 0) {
......@@ -1856,12 +1859,12 @@ isdn_net_hangup(isdn_net_dev *idev)
printk(KERN_INFO "%s: local hangup\n", idev->name);
// FIXME via state machine
if (idev->isdn_slot >= 0)
if (idev->isdn_slot)
isdn_slot_command(idev->isdn_slot, ISDN_CMD_HANGUP, &cmd);
return 1;
}
static int isdn_net_rcv_skb(int idx, struct sk_buff *skb);
static int isdn_net_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb);
/*
* Handle status-messages from ISDN-interfacecard.
......@@ -1869,16 +1872,17 @@ static int isdn_net_rcv_skb(int idx, struct sk_buff *skb);
* isdn_status_callback, which itself is called from the low-level driver.
*/
static int
isdn_net_event_callback(int sl, int pr, void *arg)
isdn_net_event_callback(struct isdn_slot *slot, int pr, void *arg)
{
isdn_net_dev *idev = isdn_slot_priv(sl);
isdn_net_dev *idev = slot->priv;
if (!idev)
if (!idev) {
isdn_BUG();
return 0;
}
switch (pr) {
case EV_DATA_IND:
return isdn_net_rcv_skb(sl, arg);
return isdn_net_rcv_skb(slot, arg);
case EV_STAT_DCONN:
return fsm_event(&idev->fi, EV_NET_STAT_DCONN, arg);
case EV_STAT_BCONN:
......@@ -2267,9 +2271,9 @@ isdn_net_write_super(isdn_net_dev *idev, struct sk_buff *skb)
* else return 0.
*/
static int
isdn_net_rcv_skb(int idx, struct sk_buff *skb)
isdn_net_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb)
{
isdn_net_dev *idev = isdn_slot_priv(idx);
isdn_net_dev *idev = slot->priv;
isdn_net_local *mlp;
if (!idev) {
......
......@@ -50,7 +50,7 @@ void isdn_net_lib_init(void);
void isdn_net_lib_exit(void);
void isdn_net_hangup_all(void);
int isdn_net_ioctl(struct inode *, struct file *, uint, ulong);
int isdn_net_find_icall(int, int, int, setup_parm *);
int isdn_net_find_icall(struct isdn_slot *slot, setup_parm *setup);
/* provided for interface types to use */
void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb);
......@@ -133,10 +133,10 @@ struct isdn_net_local_s {
/* per ISDN channel (ISDN interface) data */
struct isdn_net_dev_s {
int isdn_slot; /* Index to isdn device/channel */
struct isdn_slot *isdn_slot; /* Index to isdn device/channel */
struct isdn_slot *exclusive; /* NULL if non excl */
int pre_device; /* Preselected isdn-device */
int pre_channel; /* Preselected isdn-channel */
int exclusive; /* -1 if non excl./idx to excl chan */
struct timer_list dial_timer; /* dial events timer */
struct fsm_inst fi; /* call control state machine */
......
......@@ -31,20 +31,20 @@ static void isdn_tty_modem_reset_regs(modem_info *, int);
static void isdn_tty_cmd_ATA(modem_info *);
static void isdn_tty_flush_buffer(struct tty_struct *);
static void isdn_tty_modem_result(int, modem_info *);
static int isdn_tty_stat_callback(int i, isdn_ctrl *c);
static int isdn_tty_rcv_skb(int i, struct sk_buff *skb);
static int isdn_tty_stat_callback(struct isdn_slot *slot, isdn_ctrl *c);
static int isdn_tty_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb);
#ifdef CONFIG_ISDN_AUDIO
static int isdn_tty_countDLE(unsigned char *, int);
#endif
static int
isdn_tty_event_callback(int sl, int pr, void *arg)
isdn_tty_event_callback(struct isdn_slot *slot, int pr, void *arg)
{
switch (pr) {
case EV_DATA_IND:
return isdn_tty_rcv_skb(sl, arg);
return isdn_tty_rcv_skb(slot, arg);
default:
return isdn_tty_stat_callback(sl, arg);
return isdn_tty_stat_callback(slot, arg);
}
}
......@@ -281,7 +281,7 @@ isdn_tty_readmodem(void)
}
static int
isdn_tty_rcv_skb(int i, struct sk_buff *skb)
isdn_tty_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb)
{
ulong flags;
#ifdef CONFIG_ISDN_AUDIO
......@@ -289,7 +289,7 @@ isdn_tty_rcv_skb(int i, struct sk_buff *skb)
#endif
modem_info *info;
info = isdn_slot_priv(i);
info = slot->priv;
#ifdef CONFIG_ISDN_AUDIO
ifmt = 1;
......@@ -728,7 +728,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
int si = 7;
int l2 = m->mdmreg[REG_L2PROT];
ulong flags;
int i;
struct isdn_slot *slot;
int j;
for (j = 7; j >= 0; j--)
......@@ -751,8 +751,8 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
m->mdmreg[REG_SI1I] = si2bit[si];
save_flags(flags);
cli();
i = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn);
if (i < 0) {
slot = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn);
if (!slot) {
restore_flags(flags);
isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else {
......@@ -765,9 +765,11 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
.phone = n,
};
info->isdn_slot = i;
isdn_slot_set_m_idx(i, info->line);
isdn_slot_set_priv(i, ISDN_USAGE_MODEM, info, isdn_tty_event_callback);
info->isdn_slot = slot;
isdn_slot_set_m_idx(slot, info->line);
slot->usage |= ISDN_USAGE_MODEM;
slot->priv = info;
slot->event_cb = isdn_tty_event_callback;
info->last_dir = 1;
info->last_l2 = l2;
strcpy(info->last_num, n);
......@@ -793,13 +795,13 @@ void
isdn_tty_modem_hup(modem_info * info, int local)
{
isdn_ctrl cmd;
int slot;
struct isdn_slot *slot;
if (!info)
return;
slot = info->isdn_slot;
if (slot < 0)
if (!slot)
return;
#ifdef ISDN_DEBUG_MODEM_HUP
......@@ -848,9 +850,10 @@ isdn_tty_modem_hup(modem_info * info, int local)
info->emu.mdmreg[REG_RINGCNT] = 0;
skb_queue_purge(&info->rpqueue);
slot->priv = NULL;
slot->event_cb = NULL;
isdn_slot_free(slot);
isdn_slot_set_priv(slot, 0, NULL, NULL);
info->isdn_slot = -1;
info->isdn_slot = NULL;
}
/*
......@@ -910,7 +913,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m)
int l2 = m->mdmreg[REG_L2PROT];
isdn_ctrl cmd;
ulong flags;
int i;
struct isdn_slot *slot;
int j;
int l;
......@@ -935,14 +938,16 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m)
m->mdmreg[REG_SI1I] = si2bit[si];
save_flags(flags);
cli();
i = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn);
if (i < 0) {
slot = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn);
if (!slot) {
restore_flags(flags);
isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else {
info->isdn_slot = i;
isdn_slot_set_m_idx(i, info->line);
isdn_slot_set_priv(i, ISDN_USAGE_MODEM, info, isdn_tty_event_callback);
info->isdn_slot = slot;
isdn_slot_set_m_idx(slot, info->line);
slot->usage |= ISDN_USAGE_MODEM;
slot->priv = info;
slot->event_cb = isdn_tty_event_callback;
info->last_dir = 1;
// strcpy(info->last_num, n);
restore_flags(flags);
......@@ -981,7 +986,7 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
int l2 = m->mdmreg[REG_L2PROT];
isdn_ctrl cmd;
ulong flags;
int i;
struct isdn_slot *slot;
int j;
int l;
......@@ -1010,14 +1015,16 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
m->mdmreg[REG_SI1I] = si2bit[si];
save_flags(flags);
cli();
i = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn);
if (i < 0) {
slot = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn);
if (!slot) {
restore_flags(flags);
isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else {
info->isdn_slot = i;
isdn_slot_set_m_idx(i, info->line);
isdn_slot_set_priv(i, ISDN_USAGE_MODEM, info, isdn_tty_event_callback);
info->isdn_slot = slot;
isdn_slot_set_m_idx(slot, info->line);
slot->usage |= ISDN_USAGE_MODEM;
slot->priv = info;
slot->event_cb = isdn_tty_event_callback;
info->last_dir = 1;
restore_flags(flags);
info->last_l2 = l2;
......@@ -1212,7 +1219,7 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
c = count;
if (c > info->xmit_size - info->xmit_count)
c = info->xmit_size - info->xmit_count;
if (info->isdn_slot >= 0 && c > isdn_slot_maxbufsize(info->isdn_slot))
if (info->isdn_slot && c > isdn_slot_maxbufsize(info->isdn_slot))
c = isdn_slot_maxbufsize(info->isdn_slot);
if (c <= 0)
break;
......@@ -2123,7 +2130,7 @@ isdn_tty_init(void)
info->normal_termios = m->tty_modem.init_termios;
init_waitqueue_head(&info->open_wait);
init_waitqueue_head(&info->close_wait);
info->isdn_slot = -1;
info->isdn_slot = NULL;
skb_queue_head_init(&info->rpqueue);
info->xmit_size = ISDN_SERIAL_XMIT_SIZE;
skb_queue_head_init(&info->xmit_queue);
......@@ -2240,7 +2247,7 @@ isdn_tty_match_icall(char *cid, atemu *emu, int di)
* CID is longer.
*/
int
isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup)
isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup)
{
char *eaz;
int i;
......@@ -2285,17 +2292,18 @@ isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup)
#ifndef FIX_FILE_TRANSFER
(info->flags & ISDN_ASYNC_NORMAL_ACTIVE) &&
#endif
(info->isdn_slot == -1) &&
(USG_NONE(isdn_slot_usage(sl)))) {
(!info->isdn_slot)) {
int matchret;
if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret)
if ((matchret = isdn_tty_match_icall(eaz, &info->emu, slot->di)) > wret)
wret = matchret;
if (!matchret) { /* EAZ is matching */
info->isdn_slot = sl;
isdn_slot_set_m_idx(sl, info->line);
isdn_slot_set_priv(sl, isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]), info, isdn_tty_event_callback);
strcpy(isdn_slot_num(sl), nr);
info->isdn_slot = slot;
isdn_slot_set_m_idx(slot, info->line);
slot->usage |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]);
slot->priv = info;
slot->event_cb = isdn_tty_event_callback;
strcpy(slot->num, nr);
strcpy(info->emu.cpn, eaz);
info->emu.mdmreg[REG_SI1I] = si2bit[si1];
info->emu.mdmreg[REG_PLAN] = setup->plan;
......@@ -2321,13 +2329,13 @@ isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup)
(info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE))
static int
isdn_tty_stat_callback(int i, isdn_ctrl *c)
isdn_tty_stat_callback(struct isdn_slot *slot, isdn_ctrl *c)
{
isdn_ctrl cmd;
modem_info *info;
char *e;
info = isdn_slot_priv(i);
info = slot->priv;
if (1) {
switch (c->command) {
case ISDN_STAT_CINF:
......@@ -2423,14 +2431,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c)
info->last_dir = 0;
info->dialing = 0;
info->rcvsched = 1;
if (USG_MODEM(isdn_slot_usage(i))) {
if (USG_MODEM(slot->usage)) {
if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) {
strcpy(info->emu.connmsg, c->parm.num);
isdn_tty_modem_result(RESULT_CONNECT, info);
} else
isdn_tty_modem_result(RESULT_CONNECT64000, info);
}
if (USG_VOICE(isdn_slot_usage(i)))
if (USG_VOICE(slot->usage))
isdn_tty_modem_result(RESULT_VCON, info);
return 1;
}
......@@ -2570,7 +2578,7 @@ isdn_tty_at_cout(char *msg, modem_info * info)
static void
isdn_tty_on_hook(modem_info * info)
{
if (info->isdn_slot >= 0) {
if (info->isdn_slot) {
#ifdef ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG "Mhup in isdn_tty_on_hook\n");
#endif
......
......@@ -104,7 +104,7 @@ extern void isdn_tty_carrier_timeout(void);
extern void isdn_tty_modem_xmit(void);
extern int isdn_tty_init(void);
extern void isdn_tty_readmodem(void);
extern int isdn_tty_find_icall(int, int, int, setup_parm *);
extern int isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup);
extern void isdn_tty_cleanup_xmit(modem_info *);
extern int isdn_tty_capi_facility(capi_msg *cm);
extern void isdn_tty_at_cout(char *, modem_info *);
......
......@@ -53,7 +53,7 @@ isdn_tty_fax_modem_result(int code, modem_info * info)
case 2: /* +FCON */
/* Append CPN, if enabled */
if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) &&
(!(isdn_slot_usage(info->isdn_slot) & ISDN_USAGE_OUTGOING))) {
(!(info->isdn_slot->usage & ISDN_USAGE_OUTGOING))) {
sprintf(rs, "/%s", m->cpn);
isdn_tty_at_cout(rs, info);
}
......@@ -301,7 +301,8 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
static char *cmd[] =
{"AE", "TS", "RS", "TM", "RM", "TH", "RH"};
isdn_ctrl c;
int par, i;
int par;
struct isdn_slot *slot;
long flags;
for (c.parm.aux.cmd = 0; c.parm.aux.cmd < 7; c.parm.aux.cmd++)
......@@ -343,7 +344,7 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
printk(KERN_DEBUG "isdn_tty_cmd_FCLASS1 %d/%d/%d)\n",
c.parm.aux.cmd, c.parm.aux.subcmd, c.parm.aux.para[0]);
#endif
if (info->isdn_slot < 0) {
if (!info->isdn_slot) {
save_flags(flags);
cli();
if ((c.parm.aux.subcmd == AT_EQ_VALUE) ||
......@@ -352,18 +353,18 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
PARSE_ERROR1;
}
/* get a temporary connection to the first free fax driver */
i = isdn_get_free_slot(ISDN_USAGE_FAX, ISDN_PROTO_L2_FAX,
slot = isdn_get_free_slot(ISDN_USAGE_FAX, ISDN_PROTO_L2_FAX,
ISDN_PROTO_L3_FCLASS1, -1, -1, "00");
if (i < 0) {
if (!slot) {
restore_flags(flags);
PARSE_ERROR1;
}
info->isdn_slot = i;
isdn_slot_set_m_idx(i, info->line);
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c);
isdn_slot_free(info->isdn_slot);
isdn_slot_set_m_idx(i, -1);
info->isdn_slot = -1;
info->isdn_slot = slot;
isdn_slot_set_m_idx(slot, info->line);
isdn_slot_command(slot, ISDN_CMD_FAXCMD, &c);
isdn_slot_free(slot);
isdn_slot_set_m_idx(slot, -1);
info->isdn_slot = NULL;
restore_flags(flags);
} else {
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c);
......
......@@ -512,11 +512,11 @@ isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb)
void
isdn_v110_open(int sl, struct isdn_v110 *iv110)
isdn_v110_open(struct isdn_slot *slot, struct isdn_v110 *iv110)
{
isdn_v110_stream *v;
int hdrlen = isdn_slot_hdrlen(sl);
int maxsize = isdn_slot_maxbufsize(sl);
int hdrlen = isdn_slot_hdrlen(slot);
int maxsize = isdn_slot_maxbufsize(slot);
atomic_inc(&iv110->v110use);
switch (iv110->v110emu) {
......@@ -533,7 +533,7 @@ isdn_v110_open(int sl, struct isdn_v110 *iv110)
if ((v = iv110->v110)) {
while (v->SyncInit) {
struct sk_buff *skb = isdn_v110_sync(v);
if (isdn_slot_write(sl, skb) <= 0) {
if (isdn_slot_write(slot, skb) <= 0) {
dev_kfree_skb(skb);
/* Unable to send, try later */
break;
......@@ -547,7 +547,7 @@ isdn_v110_open(int sl, struct isdn_v110 *iv110)
}
void
isdn_v110_close(int sl, struct isdn_v110 *iv110)
isdn_v110_close(struct isdn_slot *slot, struct isdn_v110 *iv110)
{
while (1) {
atomic_inc(&iv110->v110use);
......@@ -560,7 +560,7 @@ isdn_v110_close(int sl, struct isdn_v110 *iv110)
}
int
isdn_v110_bsent(int sl, struct isdn_v110 *iv110)
isdn_v110_bsent(struct isdn_slot *slot, struct isdn_v110 *iv110)
{
isdn_v110_stream *v = iv110->v110;
int i, ret;
......@@ -587,7 +587,7 @@ isdn_v110_bsent(int sl, struct isdn_v110 *iv110)
else
skb = isdn_v110_idle(v);
if (skb) {
if (isdn_slot_write(sl, skb) <= 0) {
if (isdn_slot_write(slot, skb) <= 0) {
dev_kfree_skb(skb);
break;
} else {
......
......@@ -26,10 +26,10 @@ extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *);
*/
extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *);
extern void isdn_v110_open(int sl, struct isdn_v110 *iv110);
extern void isdn_v110_open(struct isdn_slot *slot, struct isdn_v110 *iv110);
extern void isdn_v110_close(int sl, struct isdn_v110 *iv110);
extern void isdn_v110_close(struct isdn_slot *slot, struct isdn_v110 *iv110);
extern int isdn_v110_bsent(int sl, struct isdn_v110 *iv110);
extern int isdn_v110_bsent(struct isdn_slot *slot, struct isdn_v110 *iv110);
#endif
......@@ -327,7 +327,7 @@ typedef struct modem_info {
/* 2 = B-Channel is up, deliver d.*/
int dialing; /* Dial in progress or ATA */
int rcvsched; /* Receive needs schedule */
int isdn_slot; /* Index to isdn-driver/channel */
struct isdn_slot *isdn_slot; /* Ptr to isdn-driver/channel */
struct sk_buff_head rpqueue; /* Queue of recv'd packets */
int rcvcount; /* Byte-counters for B rx */
int ncarrier; /* Flag: schedule NO CARRIER */
......
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