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.
#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");
"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",
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;
}
{
struct isdn_slot *slot = fi->userdata;
isdn_ctrl *ctrl = arg;
- int sl = slot - slots;
int retval;
fsm_change_state(fi, ST_SLOT_IN);
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;
}
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;
* 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)
{
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);
}
#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;
}
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 */
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;
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
}
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
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);
}
/*
static int
isdn_v110_data_ind(struct isdn_slot *slot, struct sk_buff *skb)
{
- int sl = slot - slots;
-
if (!slot->iv110.v110emu)
goto recv;
recv:
if (slot->event_cb)
- slot->event_cb(sl, EV_DATA_IND, skb);
+ slot->event_cb(slot, EV_DATA_IND, skb);
return 0;
}
*/
#include <linux/isdn.h>
+#include "isdn_v110.h"
#undef ISDN_DEBUG_MODEM_OPEN
#undef ISDN_DEBUG_MODEM_IOCTL
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;
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);
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;
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;
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);
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;
* 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;
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);
}
}
-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;
}
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);
}
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;
}
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;
}
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;
}
* 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;
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);
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;
}
{
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;
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) {
printk(KERN_INFO "%s: local hangup\n", idev->name);
// FIXME via state machine
- if (idev->isdn_slot >= 0)
- isdn_slot_command(idev->isdn_slot, ISDN_CMD_HANGUP, &cmd);
+ 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.
* 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:
* 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) {
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);
/* 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 */
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);
}
}
}
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
#endif
modem_info *info;
- info = isdn_slot_priv(i);
+ info = slot->priv;
#ifdef CONFIG_ISDN_AUDIO
ifmt = 1;
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--)
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 {
.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);
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
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;
}
/*
int l2 = m->mdmreg[REG_L2PROT];
isdn_ctrl cmd;
ulong flags;
- int i;
+ struct isdn_slot *slot;
int j;
int l;
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);
int l2 = m->mdmreg[REG_L2PROT];
isdn_ctrl cmd;
ulong flags;
- int i;
+ struct isdn_slot *slot;
int j;
int l;
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;
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;
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);
* 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;
#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;
(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:
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;
}
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
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 *);
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);
}
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++)
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) ||
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);
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) {
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;
}
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);
}
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;
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 {
*/
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
/* 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 */