Commit 08cf89b4 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Move the now shared fields

Since we now use former HSCX specific fields in common code, they
get moved out of bcs->hw.hscx and into bcs directly.
parent 4e52ad01
......@@ -367,7 +367,7 @@ HDLC_irq(struct BCState *bcs, u_int stat)
write_ctrl(bcs, 1);
bcs->hw.hdlc.ctrl.sr.cmd &= ~HDLC_CMD_RRS;
write_ctrl(bcs, 1);
bcs->hw.hdlc.rcvidx = 0;
bcs->rcvidx = 0;
} else {
if (!(len = (stat & HDLC_STAT_RML_MASK)>>8))
len = 32;
......@@ -381,7 +381,7 @@ HDLC_irq(struct BCState *bcs, u_int stat)
debugl1(bcs->cs, "invalid frame");
else
debugl1(bcs->cs, "ch%d invalid frame %#x", bcs->channel, stat);
bcs->hw.hdlc.rcvidx = 0;
bcs->rcvidx = 0;
}
}
}
......@@ -468,9 +468,9 @@ close_hdlcstate(struct BCState *bcs)
{
modehdlc(bcs, 0, 0);
if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
if (bcs->hw.hdlc.rcvbuf) {
kfree(bcs->hw.hdlc.rcvbuf);
bcs->hw.hdlc.rcvbuf = NULL;
if (bcs->rcvbuf) {
kfree(bcs->rcvbuf);
bcs->rcvbuf = NULL;
}
if (bcs->blog) {
kfree(bcs->blog);
......@@ -490,7 +490,7 @@ int
open_hdlcstate(struct IsdnCardState *cs, struct BCState *bcs)
{
if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
if (!(bcs->hw.hdlc.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
if (!(bcs->rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for hdlc.rcvbuf\n");
return (1);
......@@ -499,8 +499,8 @@ open_hdlcstate(struct IsdnCardState *cs, struct BCState *bcs)
printk(KERN_WARNING
"HiSax: No memory for bcs->blog\n");
test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
kfree(bcs->hw.hdlc.rcvbuf);
bcs->hw.hdlc.rcvbuf = NULL;
kfree(bcs->rcvbuf);
bcs->rcvbuf = NULL;
return (2);
}
skb_queue_head_init(&bcs->rqueue);
......@@ -509,7 +509,7 @@ open_hdlcstate(struct IsdnCardState *cs, struct BCState *bcs)
bcs->tx_skb = NULL;
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
bcs->event = 0;
bcs->hw.hdlc.rcvidx = 0;
bcs->rcvidx = 0;
bcs->tx_cnt = 0;
return (0);
}
......@@ -518,7 +518,7 @@ int
setstack_hdlc(struct PStack *st, struct BCState *bcs)
{
bcs->channel = st->l1.bc;
bcs->hw.hscx.hscx = bcs->channel;
bcs->unit = bcs->channel;
if (open_hdlcstate(st->l1.hardware, bcs))
return (-1);
st->l1.bcs = bcs;
......
......@@ -455,7 +455,7 @@ MemwaitforXFW(struct IsdnCardState *cs, int hscx)
static inline void
MemWriteHSCXCMDR(struct BCState *bcs, u8 data)
{
int hscx = bcs->hw.hscx.hscx;
int hscx = bcs->unit;
MemwaitforCEC(bcs->cs, hscx);
mem_hscx_write(bcs->cs, hscx, HSCX_CMDR, data);
......@@ -480,9 +480,9 @@ Memhscx_fill_fifo(struct BCState *bcs)
if (!p)
return;
MemwaitforXFW(cs, bcs->hw.hscx.hscx);
MemwaitforXFW(cs, bcs->unit);
while (count--)
memwritereg(cs->hw.diva.cfg_reg, bcs->hw.hscx.hscx ? 0x40 : 0,
memwritereg(cs->hw.diva.cfg_reg, bcs->unit ? 0x40 : 0,
*p++);
MemWriteHSCXCMDR(bcs, more ? 0x8 : 0xa);
}
......
......@@ -349,15 +349,12 @@ struct l3_process {
};
struct hscx_hw {
int hscx;
u8 tsaxr0;
u8 tsaxr1;
};
struct w6692B_hw {
int bchan;
int rcvidx;
u8 *rcvbuf; /* B-Channel receive Buffer */
};
struct isar_reg {
......@@ -405,8 +402,6 @@ struct hdlc_hw {
struct hdlc_stat_reg sr;
} ctrl;
u_int stat;
int rcvidx;
u8 *rcvbuf; /* B-Channel receive Buffer */
};
struct hfcB_hw {
......@@ -479,6 +474,7 @@ struct BCState {
int mode;
long Flag;
struct IsdnCardState *cs;
int unit; /* first or second unit (e.g. HSCX) */
int rcvidx;
u8 *rcvbuf; /* B-Channel receive Buffer */
int tx_cnt; /* B-Channel transmit counter */
......
......@@ -25,27 +25,24 @@ static inline u8
hscx_read(struct BCState *bcs, u8 addr)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
return cs->bc_hw_ops->read_reg(cs, hscx, addr);
return cs->bc_hw_ops->read_reg(cs, bcs->unit, addr);
}
static inline void
hscx_write(struct BCState *bcs, u8 addr, u8 val)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
cs->bc_hw_ops->write_reg(cs, hscx, addr, val);
cs->bc_hw_ops->write_reg(cs, bcs->unit, addr, val);
}
static inline void
hscx_write_fifo(struct BCState *bcs, u8 *p, int len)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
cs->bc_hw_ops->write_fifo(cs, hscx, p, len);
cs->bc_hw_ops->write_fifo(cs, bcs->unit, p, len);
}
int __init
......@@ -58,16 +55,16 @@ HscxVersion(struct IsdnCardState *cs, char *s)
printk(KERN_INFO "%s HSCX version A: %s B: %s\n", s,
HSCXVer[verA], HSCXVer[verB]);
if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf))
return (1);
return 1;
else
return (0);
return 0;
}
void
modehscx(struct BCState *bcs, int mode, int bc)
{
struct IsdnCardState *cs = bcs->cs;
int hscx = bcs->hw.hscx.hscx;
int hscx = bcs->unit;
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hscx %c mode %d ichan %d",
......@@ -235,8 +232,8 @@ inithscx(struct IsdnCardState *cs)
cs->bcs[1].BC_SetStack = setstack_hscx;
cs->bcs[0].BC_Close = close_hscxstate;
cs->bcs[1].BC_Close = close_hscxstate;
cs->bcs[0].hw.hscx.hscx = 0;
cs->bcs[1].hw.hscx.hscx = 1;
cs->bcs[0].unit = 0;
cs->bcs[1].unit = 1;
cs->bcs[0].hw.hscx.tsaxr0 = 0x2f;
cs->bcs[0].hw.hscx.tsaxr1 = 3;
cs->bcs[1].hw.hscx.tsaxr0 = 0x2f;
......
......@@ -57,18 +57,16 @@ static inline u8
ipacx_bc_read_reg(struct BCState *bcs, u8 addr)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
return cs->bc_hw_ops->read_reg(cs, hscx, addr);
return cs->bc_hw_ops->read_reg(cs, bcs->unit, addr);
}
static inline void
ipacx_bc_write_reg(struct BCState *bcs, u8 addr, u8 val)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
cs->bc_hw_ops->write_reg(cs, hscx, addr, val);
cs->bc_hw_ops->write_reg(cs, bcs->unit, addr, val);
}
static inline u8
......@@ -598,7 +596,7 @@ static void
bch_mode(struct BCState *bcs, int mode, int bc)
{
struct IsdnCardState *cs = bcs->cs;
int hscx = bcs->hw.hscx.hscx;
int hscx = bcs->unit;
bc = bc ? 1 : 0; // in case bc is greater than 1
if (cs->debug & L1_DEB_HSCX)
......@@ -718,7 +716,7 @@ bch_init(struct IsdnCardState *cs, int hscx)
{
cs->bcs[hscx].BC_SetStack = bch_setstack;
cs->bcs[hscx].BC_Close = bch_close_state;
cs->bcs[hscx].hw.hscx.hscx = hscx;
cs->bcs[hscx].unit = hscx;
cs->bcs[hscx].cs = cs;
bch_mode(cs->bcs + hscx, 0, hscx);
}
......
......@@ -372,7 +372,7 @@ xmit_fill_fifo_b(struct BCState *bcs, int fifo_size, int *count, int *more)
char *t = bcs->blog;
t += sprintf(t, "%s %c cnt %d", __FUNCTION__,
bcs->hw.hscx.hscx ? 'B' : 'A', *count);
bcs->unit ? 'B' : 'A', *count);
QuickHex(t, p, *count);
debugl1(cs, bcs->blog);
}
......@@ -430,13 +430,13 @@ recv_empty_fifo_b(struct BCState *bcs, int count)
}
p = bcs->rcvbuf + bcs->rcvidx;
bcs->rcvidx += count;
cs->bc_hw_ops->read_fifo(cs, bcs->hw.hscx.hscx, p, count);
cs->bc_hw_ops->read_fifo(cs, bcs->unit, p, count);
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
t += sprintf(t, "%s %c cnt %d", __FUNCTION__,
bcs->hw.hscx.hscx ? 'B' : 'A', count);
bcs->unit ? 'B' : 'A', count);
QuickHex(t, p, count);
debugl1(cs, bcs->blog);
}
......
......@@ -36,9 +36,8 @@ static inline void
jade_write_fifo(struct BCState *bcs, u8 *p, int len)
{
struct IsdnCardState *cs = bcs->cs;
u8 hscx = bcs->hw.hscx.hscx;
cs->bc_hw_ops->write_fifo(cs, hscx, p, len);
cs->bc_hw_ops->write_fifo(cs, bcs->unit, p, len);
}
int __init
......@@ -103,7 +102,7 @@ void
modejade(struct BCState *bcs, int mode, int bc)
{
struct IsdnCardState *cs = bcs->cs;
int jade = bcs->hw.hscx.hscx;
int jade = bcs->unit;
if (cs->debug & L1_DEB_HSCX) {
char tmp[40];
......@@ -270,8 +269,8 @@ initjade(struct IsdnCardState *cs)
cs->bcs[1].BC_SetStack = setstack_jade;
cs->bcs[0].BC_Close = close_jadestate;
cs->bcs[1].BC_Close = close_jadestate;
cs->bcs[0].hw.hscx.hscx = 0;
cs->bcs[1].hw.hscx.hscx = 1;
cs->bcs[0].unit = 0;
cs->bcs[1].unit = 1;
jade_write_reg(cs, 0, jade_HDLC_IMR, 0x00);
jade_write_reg(cs, 1, jade_HDLC_IMR, 0x00);
......
......@@ -32,7 +32,7 @@ waitforXFW(struct BCState *bcs)
static inline void
WriteJADECMDR(struct BCState *bcs, int reg, u8 data)
{
int jade = bcs->hw.hscx.hscx;
int jade = bcs->unit;
waitforCEC(bcs->cs, jade, reg);
jade_write_reg(bcs->cs, jade, reg, data);
......
......@@ -284,7 +284,7 @@ W6692B_interrupt(struct IsdnCardState *cs, u8 bchan)
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "W6692 B CRC error");
w6692_bc_write_reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT);
bcs->hw.w6692.rcvidx = 0;
bcs->rcvidx = 0;
} else {
count = w6692_bc_read_reg(cs, bchan, W_B_RBCL) & (W_B_FIFO_THRESH - 1);
if (count == 0)
......@@ -599,9 +599,9 @@ close_w6692state(struct BCState *bcs)
{
W6692Bmode(bcs, 0, bcs->channel);
if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
if (bcs->hw.w6692.rcvbuf) {
kfree(bcs->hw.w6692.rcvbuf);
bcs->hw.w6692.rcvbuf = NULL;
if (bcs->rcvbuf) {
kfree(bcs->rcvbuf);
bcs->rcvbuf = NULL;
}
if (bcs->blog) {
kfree(bcs->blog);
......@@ -621,7 +621,7 @@ static int
open_w6692state(struct IsdnCardState *cs, struct BCState *bcs)
{
if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
if (!(bcs->hw.w6692.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
if (!(bcs->rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for w6692.rcvbuf\n");
test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
......@@ -631,8 +631,8 @@ open_w6692state(struct IsdnCardState *cs, struct BCState *bcs)
printk(KERN_WARNING
"HiSax: No memory for bcs->blog\n");
test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
kfree(bcs->hw.w6692.rcvbuf);
bcs->hw.w6692.rcvbuf = NULL;
kfree(bcs->rcvbuf);
bcs->rcvbuf = NULL;
return (2);
}
skb_queue_head_init(&bcs->rqueue);
......@@ -641,7 +641,7 @@ open_w6692state(struct IsdnCardState *cs, struct BCState *bcs)
bcs->tx_skb = NULL;
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
bcs->event = 0;
bcs->hw.w6692.rcvidx = 0;
bcs->rcvidx = 0;
bcs->tx_cnt = 0;
return (0);
}
......
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