[PATCH] isdn4linux: Siemens Gigaset drivers: logging usage

With Hansjoerg Lipp <hjlipp@web.de>

Improve error reporting of the Gigaset drivers, by using the
dev_err/dev_warn/dev_info macros from device.h instead of err/warn/info from
usb.h whereever possible.

Also rename the private dbg macro to gig_dbg in order to avoid confusion with
the macro of the same name in usb.h.

Signed-off-by: Hansjoerg Lipp <hjlipp@web.de>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Tilman Schmidt 2006-04-10 22:55:04 -07:00 committed by Linus Torvalds
parent ec81b5e629
commit 784d5858aa
10 changed files with 1080 additions and 967 deletions

View file

@ -51,7 +51,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
for (;;) { for (;;) {
cs->respdata[cbytes] = c; cs->respdata[cbytes] = c;
if (c == 10 || c == 13) { if (c == 10 || c == 13) {
dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)", gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
__func__, cbytes); __func__, cbytes);
cs->cbytes = cbytes; cs->cbytes = cbytes;
gigaset_handle_modem_response(cs); /* can change gigaset_handle_modem_response(cs); /* can change
@ -68,7 +68,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
if (cbytes < MAX_RESP_SIZE - 1) if (cbytes < MAX_RESP_SIZE - 1)
cbytes++; cbytes++;
else else
warn("response too large"); dev_warn(cs->dev, "response too large\n");
} }
if (!numbytes) if (!numbytes)
@ -154,39 +154,37 @@ byte_stuff:
c ^= PPP_TRANS; c ^= PPP_TRANS;
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (unlikely(!muststuff(c))) if (unlikely(!muststuff(c)))
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC, "byte stuffed: 0x%02x", c);
"byte stuffed: 0x%02x", c);
#endif #endif
} else if (unlikely(c == PPP_FLAG)) { } else if (unlikely(c == PPP_FLAG)) {
if (unlikely(inputstate & INS_skip_frame)) { if (unlikely(inputstate & INS_skip_frame)) {
if (!(inputstate & INS_have_data)) { /* 7E 7E */ if (!(inputstate & INS_have_data)) { /* 7E 7E */
//dbg(DEBUG_HDLC, "(7e)7e------------------------");
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount; ++bcs->emptycount;
#endif #endif
} else } else
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC,
"7e----------------------------"); "7e----------------------------");
/* end of frame */ /* end of frame */
error = 1; error = 1;
gigaset_rcv_error(NULL, cs, bcs); gigaset_rcv_error(NULL, cs, bcs);
} else if (!(inputstate & INS_have_data)) { /* 7E 7E */ } else if (!(inputstate & INS_have_data)) { /* 7E 7E */
//dbg(DEBUG_HDLC, "(7e)7e------------------------");
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount; ++bcs->emptycount;
#endif #endif
break; break;
} else { } else {
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC,
"7e----------------------------"); "7e----------------------------");
/* end of frame */ /* end of frame */
error = 0; error = 0;
if (unlikely(fcs != PPP_GOODFCS)) { if (unlikely(fcs != PPP_GOODFCS)) {
err("Packet checksum at %lu failed, " dev_err(cs->dev,
"packet is corrupted (%u bytes)!", "Packet checksum at %lu failed, "
"packet is corrupted (%u bytes)!\n",
bcs->rcvbytes, skb->len); bcs->rcvbytes, skb->len);
compskb = NULL; compskb = NULL;
gigaset_rcv_error(compskb, cs, bcs); gigaset_rcv_error(compskb, cs, bcs);
@ -200,9 +198,11 @@ byte_stuff:
skb = NULL; skb = NULL;
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
if (l == 1) { if (l == 1) {
err("invalid packet size (1)!"); dev_err(cs->dev,
"invalid packet size (1)!\n");
error = 1; error = 1;
gigaset_rcv_error(NULL, cs, bcs); gigaset_rcv_error(NULL,
cs, bcs);
} }
} }
if (likely(!(error || if (likely(!(error ||
@ -225,7 +225,8 @@ byte_stuff:
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) { } else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
skb_reserve(skb, HW_HDR_LEN); skb_reserve(skb, HW_HDR_LEN);
} else { } else {
warn("could not allocate new skb"); dev_warn(cs->dev,
"could not allocate new skb\n");
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
} }
@ -233,7 +234,7 @@ byte_stuff:
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
} else if (unlikely(muststuff(c))) { } else if (unlikely(muststuff(c))) {
/* Should not happen. Possible after ZDLE=1<CR><LF>. */ /* Should not happen. Possible after ZDLE=1<CR><LF>. */
dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c); gig_dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c);
#endif #endif
} }
@ -241,8 +242,8 @@ byte_stuff:
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (unlikely(!(inputstate & INS_have_data))) { if (unlikely(!(inputstate & INS_have_data))) {
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC, "7e (%d x) ================",
"7e (%d x) ================", bcs->emptycount); bcs->emptycount);
bcs->emptycount = 0; bcs->emptycount = 0;
} }
#endif #endif
@ -251,7 +252,7 @@ byte_stuff:
if (likely(!(inputstate & INS_skip_frame))) { if (likely(!(inputstate & INS_skip_frame))) {
if (unlikely(skb->len == SBUFSIZE)) { if (unlikely(skb->len == SBUFSIZE)) {
warn("received packet too long"); dev_warn(cs->dev, "received packet too long\n");
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = NULL; skb = NULL;
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
@ -307,7 +308,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
if (likely(!(inputstate & INS_skip_frame))) { if (likely(!(inputstate & INS_skip_frame))) {
if (unlikely(skb->len == SBUFSIZE)) { if (unlikely(skb->len == SBUFSIZE)) {
//FIXME just pass skb up and allocate a new one //FIXME just pass skb up and allocate a new one
warn("received packet too long"); dev_warn(cs->dev, "received packet too long\n");
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = NULL; skb = NULL;
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
@ -341,7 +342,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
!= NULL)) { != NULL)) {
skb_reserve(skb, HW_HDR_LEN); skb_reserve(skb, HW_HDR_LEN);
} else { } else {
warn("could not allocate new skb"); dev_warn(cs->dev, "could not allocate new skb\n");
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
} }
} }
@ -362,13 +363,13 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
head = atomic_read(&inbuf->head); head = atomic_read(&inbuf->head);
tail = atomic_read(&inbuf->tail); tail = atomic_read(&inbuf->tail);
dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
if (head != tail) { if (head != tail) {
cs = inbuf->cs; cs = inbuf->cs;
src = inbuf->data + head; src = inbuf->data + head;
numbytes = (head > tail ? RBUFSIZE : tail) - head; numbytes = (head > tail ? RBUFSIZE : tail) - head;
dbg(DEBUG_INTR, "processing %u bytes", numbytes); gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
while (numbytes) { while (numbytes) {
if (atomic_read(&cs->mstate) == MS_LOCKED) { if (atomic_read(&cs->mstate) == MS_LOCKED) {
@ -400,13 +401,14 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
src += procbytes; src += procbytes;
numbytes -= procbytes; numbytes -= procbytes;
} else { /* DLE-char */ } else { /* DLE char */
inbuf->inputstate &= ~INS_DLE_char; inbuf->inputstate &= ~INS_DLE_char;
switch (c) { switch (c) {
case 'X': /*begin of command*/ case 'X': /*begin of command*/
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (inbuf->inputstate & INS_command) if (inbuf->inputstate & INS_command)
err("received <DLE> 'X' in command mode"); dev_err(cs->dev,
"received <DLE> 'X' in command mode\n");
#endif #endif
inbuf->inputstate |= inbuf->inputstate |=
INS_command | INS_DLE_command; INS_command | INS_DLE_command;
@ -414,7 +416,8 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
case '.': /*end of command*/ case '.': /*end of command*/
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (!(inbuf->inputstate & INS_command)) if (!(inbuf->inputstate & INS_command))
err("received <DLE> '.' in hdlc mode"); dev_err(cs->dev,
"received <DLE> '.' in hdlc mode\n");
#endif #endif
inbuf->inputstate &= cs->dle ? inbuf->inputstate &= cs->dle ?
~(INS_DLE_command|INS_command) ~(INS_DLE_command|INS_command)
@ -422,7 +425,9 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
break; break;
//case DLE_FLAG: /*DLE_FLAG in data stream*/ /* schon oben behandelt! */ //case DLE_FLAG: /*DLE_FLAG in data stream*/ /* schon oben behandelt! */
default: default:
err("received 0x10 0x%02x!", (int) c); dev_err(cs->dev,
"received 0x10 0x%02x!\n",
(int) c);
/* FIXME: reset driver?? */ /* FIXME: reset driver?? */
} }
} }
@ -441,7 +446,7 @@ nextbyte:
} }
} }
dbg(DEBUG_INTR, "setting head to %u", head); gig_dbg(DEBUG_INTR, "setting head to %u", head);
atomic_set(&inbuf->head, head); atomic_set(&inbuf->head, head);
} }
} }
@ -483,7 +488,6 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
*/ */
hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head); hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head);
if (!hdlc_skb) { if (!hdlc_skb) {
err("unable to allocate memory for HDLC encoding!");
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NULL; return NULL;
} }
@ -543,7 +547,6 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
/* worst case: every byte must be stuffed */ /* worst case: every byte must be stuffed */
iraw_skb = dev_alloc_skb(2*skb->len + tail + head); iraw_skb = dev_alloc_skb(2*skb->len + tail + head);
if (!iraw_skb) { if (!iraw_skb) {
err("unable to allocate memory for HDLC encoding!");
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NULL; return NULL;
} }
@ -584,8 +587,11 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
skb = HDLC_Encode(skb, HW_HDR_LEN, 0); skb = HDLC_Encode(skb, HW_HDR_LEN, 0);
else else
skb = iraw_encode(skb, HW_HDR_LEN, 0); skb = iraw_encode(skb, HW_HDR_LEN, 0);
if (!skb) if (!skb) {
dev_err(bcs->cs->dev,
"unable to allocate memory for encoding!\n");
return -ENOMEM; return -ENOMEM;
}
skb_queue_tail(&bcs->squeue, skb); skb_queue_tail(&bcs->squeue, skb);
tasklet_schedule(&bcs->cs->write_tasklet); tasklet_schedule(&bcs->cs->write_tasklet);

File diff suppressed because it is too large Load diff

View file

@ -32,9 +32,6 @@ MODULE_PARM_DESC(debug, "debug level");
Prototypes of internal functions Prototypes of internal functions
*/ */
//static void gigaset_process_response(int resp_code, int parameter,
// struct at_state_t *at_state,
// unsigned char ** pstring);
static struct cardstate *alloc_cs(struct gigaset_driver *drv); static struct cardstate *alloc_cs(struct gigaset_driver *drv);
static void free_cs(struct cardstate *cs); static void free_cs(struct cardstate *cs);
static void make_valid(struct cardstate *cs, unsigned mask); static void make_valid(struct cardstate *cs, unsigned mask);
@ -86,6 +83,7 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
{ {
unsigned char outbuf[80]; unsigned char outbuf[80];
unsigned char inbuf[80 - 1]; unsigned char inbuf[80 - 1];
unsigned char c;
size_t numin; size_t numin;
const unsigned char *in; const unsigned char *in;
size_t space = sizeof outbuf - 1; size_t space = sizeof outbuf - 1;
@ -99,26 +97,38 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
in = inbuf; in = inbuf;
if (copy_from_user(inbuf, (const unsigned char __user *) buf, if (copy_from_user(inbuf, (const unsigned char __user *) buf,
numin)) { numin)) {
strncpy(inbuf, "<FAULT>", sizeof inbuf); gig_dbg(level, "%s (%u bytes) - copy_from_user failed",
numin = sizeof "<FAULT>" - 1; msg, (unsigned) len);
return;
} }
} }
for (; numin && space; --numin, ++in) { while (numin-- > 0) {
--space; c = *buf++;
if (*in >= 32) if (c == '~' || c == '^' || c == '\\') {
*out++ = *in; if (space-- <= 0)
else { break;
*out++ = '\\';
}
if (c & 0x80) {
if (space-- <= 0)
break;
*out++ = '~';
c ^= 0x80;
}
if (c < 0x20 || c == 0x7f) {
if (space-- <= 0)
break;
*out++ = '^'; *out++ = '^';
if (space) { c ^= 0x40;
*out++ = '@' + *in;
--space;
}
} }
if (space-- <= 0)
break;
*out++ = c;
} }
*out = 0; *out = 0;
dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf); gig_dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf);
} }
EXPORT_SYMBOL_GPL(gigaset_dbg_buffer); EXPORT_SYMBOL_GPL(gigaset_dbg_buffer);
@ -171,7 +181,7 @@ int gigaset_enterconfigmode(struct cardstate *cs)
return 0; return 0;
error: error:
err("error %d on setuartbits!\n", -r); dev_err(cs->dev, "error %d on setuartbits\n", -r);
cs->control_state = TIOCM_RTS|TIOCM_DTR; // FIXME is this a good value? cs->control_state = TIOCM_RTS|TIOCM_DTR; // FIXME is this a good value?
cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR); cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR);
@ -184,7 +194,7 @@ static int test_timeout(struct at_state_t *at_state)
return 0; return 0;
if (--at_state->timer_expires) { if (--at_state->timer_expires) {
dbg(DEBUG_MCMD, "decreased timer of %p to %lu", gig_dbg(DEBUG_MCMD, "decreased timer of %p to %lu",
at_state, at_state->timer_expires); at_state, at_state->timer_expires);
return 0; return 0;
} }
@ -221,7 +231,7 @@ static void timer_tick(unsigned long data)
if (atomic_read(&cs->running)) { if (atomic_read(&cs->running)) {
mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK)); mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK));
if (timeout) { if (timeout) {
dbg(DEBUG_CMD, "scheduling timeout"); gig_dbg(DEBUG_CMD, "scheduling timeout");
tasklet_schedule(&cs->event_tasklet); tasklet_schedule(&cs->event_tasklet);
} }
} }
@ -235,13 +245,14 @@ int gigaset_get_channel(struct bc_state *bcs)
spin_lock_irqsave(&bcs->cs->lock, flags); spin_lock_irqsave(&bcs->cs->lock, flags);
if (bcs->use_count) { if (bcs->use_count) {
dbg(DEBUG_ANY, "could not allocate channel %d", bcs->channel); gig_dbg(DEBUG_ANY, "could not allocate channel %d",
bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags); spin_unlock_irqrestore(&bcs->cs->lock, flags);
return 0; return 0;
} }
++bcs->use_count; ++bcs->use_count;
bcs->busy = 1; bcs->busy = 1;
dbg(DEBUG_ANY, "allocated channel %d", bcs->channel); gig_dbg(DEBUG_ANY, "allocated channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags); spin_unlock_irqrestore(&bcs->cs->lock, flags);
return 1; return 1;
} }
@ -252,13 +263,13 @@ void gigaset_free_channel(struct bc_state *bcs)
spin_lock_irqsave(&bcs->cs->lock, flags); spin_lock_irqsave(&bcs->cs->lock, flags);
if (!bcs->busy) { if (!bcs->busy) {
dbg(DEBUG_ANY, "could not free channel %d", bcs->channel); gig_dbg(DEBUG_ANY, "could not free channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags); spin_unlock_irqrestore(&bcs->cs->lock, flags);
return; return;
} }
--bcs->use_count; --bcs->use_count;
bcs->busy = 0; bcs->busy = 0;
dbg(DEBUG_ANY, "freed channel %d", bcs->channel); gig_dbg(DEBUG_ANY, "freed channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags); spin_unlock_irqrestore(&bcs->cs->lock, flags);
} }
@ -271,14 +282,14 @@ int gigaset_get_channels(struct cardstate *cs)
for (i = 0; i < cs->channels; ++i) for (i = 0; i < cs->channels; ++i)
if (cs->bcs[i].use_count) { if (cs->bcs[i].use_count) {
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
dbg(DEBUG_ANY, "could not allocated all channels"); gig_dbg(DEBUG_ANY, "could not allocate all channels");
return 0; return 0;
} }
for (i = 0; i < cs->channels; ++i) for (i = 0; i < cs->channels; ++i)
++cs->bcs[i].use_count; ++cs->bcs[i].use_count;
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
dbg(DEBUG_ANY, "allocated all channels"); gig_dbg(DEBUG_ANY, "allocated all channels");
return 1; return 1;
} }
@ -288,7 +299,7 @@ void gigaset_free_channels(struct cardstate *cs)
unsigned long flags; unsigned long flags;
int i; int i;
dbg(DEBUG_ANY, "unblocking all channels"); gig_dbg(DEBUG_ANY, "unblocking all channels");
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
for (i = 0; i < cs->channels; ++i) for (i = 0; i < cs->channels; ++i)
--cs->bcs[i].use_count; --cs->bcs[i].use_count;
@ -300,7 +311,7 @@ void gigaset_block_channels(struct cardstate *cs)
unsigned long flags; unsigned long flags;
int i; int i;
dbg(DEBUG_ANY, "blocking all channels"); gig_dbg(DEBUG_ANY, "blocking all channels");
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
for (i = 0; i < cs->channels; ++i) for (i = 0; i < cs->channels; ++i)
++cs->bcs[i].use_count; ++cs->bcs[i].use_count;
@ -388,14 +399,14 @@ static void gigaset_freebcs(struct bc_state *bcs)
{ {
int i; int i;
dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel); gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
if (!bcs->cs->ops->freebcshw(bcs)) { if (!bcs->cs->ops->freebcshw(bcs)) {
dbg(DEBUG_INIT, "failed"); gig_dbg(DEBUG_INIT, "failed");
} }
dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
clear_at_state(&bcs->at_state); clear_at_state(&bcs->at_state);
dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel); gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
if (bcs->skb) if (bcs->skb)
dev_kfree_skb(bcs->skb); dev_kfree_skb(bcs->skb);
@ -432,7 +443,7 @@ void gigaset_freecs(struct cardstate *cs)
default: default:
gigaset_if_free(cs); gigaset_if_free(cs);
dbg(DEBUG_INIT, "clearing hw"); gig_dbg(DEBUG_INIT, "clearing hw");
cs->ops->freecshw(cs); cs->ops->freecshw(cs);
//FIXME cmdbuf //FIXME cmdbuf
@ -441,29 +452,29 @@ void gigaset_freecs(struct cardstate *cs)
case 2: /* error in initcshw */ case 2: /* error in initcshw */
/* Deregister from LL */ /* Deregister from LL */
make_invalid(cs, VALID_ID); make_invalid(cs, VALID_ID);
dbg(DEBUG_INIT, "clearing iif"); gig_dbg(DEBUG_INIT, "clearing iif");
gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD); gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD);
/* fall through */ /* fall through */
case 1: /* error when regestering to LL */ case 1: /* error when regestering to LL */
dbg(DEBUG_INIT, "clearing at_state"); gig_dbg(DEBUG_INIT, "clearing at_state");
clear_at_state(&cs->at_state); clear_at_state(&cs->at_state);
dealloc_at_states(cs); dealloc_at_states(cs);
/* fall through */ /* fall through */
case 0: /* error in one call to initbcs */ case 0: /* error in one call to initbcs */
for (i = 0; i < cs->channels; ++i) { for (i = 0; i < cs->channels; ++i) {
dbg(DEBUG_INIT, "clearing bcs[%d]", i); gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
gigaset_freebcs(cs->bcs + i); gigaset_freebcs(cs->bcs + i);
} }
clear_events(cs); clear_events(cs);
dbg(DEBUG_INIT, "freeing inbuf"); gig_dbg(DEBUG_INIT, "freeing inbuf");
kfree(cs->inbuf); kfree(cs->inbuf);
} }
f_bcs: dbg(DEBUG_INIT, "freeing bcs[]"); f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
kfree(cs->bcs); kfree(cs->bcs);
f_cs: dbg(DEBUG_INIT, "freeing cs"); f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
up(&cs->sem); up(&cs->sem);
free_cs(cs); free_cs(cs);
} }
@ -524,7 +535,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
bcs->trans_down = 0; bcs->trans_down = 0;
bcs->trans_up = 0; bcs->trans_up = 0;
dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel); gig_dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel);
gigaset_at_init(&bcs->at_state, bcs, cs, -1); gigaset_at_init(&bcs->at_state, bcs, cs, -1);
bcs->rcvbytes = 0; bcs->rcvbytes = 0;
@ -533,7 +544,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
bcs->emptycount = 0; bcs->emptycount = 0;
#endif #endif
dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel); gig_dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel);
bcs->fcs = PPP_INITFCS; bcs->fcs = PPP_INITFCS;
bcs->inputstate = 0; bcs->inputstate = 0;
if (cs->ignoreframes) { if (cs->ignoreframes) {
@ -542,7 +553,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
} else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN); skb_reserve(bcs->skb, HW_HDR_LEN);
else { else {
warn("could not allocate skb"); dev_warn(cs->dev, "could not allocate skb\n");
bcs->inputstate |= INS_skip_frame; bcs->inputstate |= INS_skip_frame;
} }
@ -557,13 +568,13 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
for (i = 0; i < AT_NUM; ++i) for (i = 0; i < AT_NUM; ++i)
bcs->commands[i] = NULL; bcs->commands[i] = NULL;
dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel); gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
if (cs->ops->initbcshw(bcs)) if (cs->ops->initbcshw(bcs))
return bcs; return bcs;
dbg(DEBUG_INIT, " failed"); gig_dbg(DEBUG_INIT, " failed");
dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel); gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel);
if (bcs->skb) if (bcs->skb)
dev_kfree_skb(bcs->skb); dev_kfree_skb(bcs->skb);
@ -593,15 +604,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
struct cardstate *cs = NULL; struct cardstate *cs = NULL;
int i; int i;
dbg(DEBUG_INIT, "allocating cs"); gig_dbg(DEBUG_INIT, "allocating cs");
cs = alloc_cs(drv); cs = alloc_cs(drv);
if (!cs) if (!cs)
goto error; goto error;
dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
if (!cs->bcs) if (!cs->bcs)
goto error; goto error;
dbg(DEBUG_INIT, "allocating inbuf"); gig_dbg(DEBUG_INIT, "allocating inbuf");
cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
if (!cs->inbuf) if (!cs->inbuf)
goto error; goto error;
@ -623,6 +634,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->cur_at_seq = 0; cs->cur_at_seq = 0;
cs->gotfwver = -1; cs->gotfwver = -1;
cs->open_count = 0; cs->open_count = 0;
cs->dev = NULL;
cs->tty = NULL; cs->tty = NULL;
atomic_set(&cs->cidmode, cidmode != 0); atomic_set(&cs->cidmode, cidmode != 0);
@ -641,20 +653,20 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
atomic_set(&cs->mstate, MS_UNINITIALIZED); atomic_set(&cs->mstate, MS_UNINITIALIZED);
for (i = 0; i < channels; ++i) { for (i = 0; i < channels; ++i) {
dbg(DEBUG_INIT, "setting up bcs[%d].read", i); gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) if (!gigaset_initbcs(cs->bcs + i, cs, i))
goto error; goto error;
} }
++cs->cs_init; ++cs->cs_init;
dbg(DEBUG_INIT, "setting up at_state"); gig_dbg(DEBUG_INIT, "setting up at_state");
spin_lock_init(&cs->lock); spin_lock_init(&cs->lock);
gigaset_at_init(&cs->at_state, NULL, cs, 0); gigaset_at_init(&cs->at_state, NULL, cs, 0);
cs->dle = 0; cs->dle = 0;
cs->cbytes = 0; cs->cbytes = 0;
dbg(DEBUG_INIT, "setting up inbuf"); gig_dbg(DEBUG_INIT, "setting up inbuf");
if (onechannel) { //FIXME distinction necessary? if (onechannel) { //FIXME distinction necessary?
gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command); gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command);
} else } else
@ -662,21 +674,21 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
atomic_set(&cs->connected, 0); atomic_set(&cs->connected, 0);
dbg(DEBUG_INIT, "setting up cmdbuf"); gig_dbg(DEBUG_INIT, "setting up cmdbuf");
cs->cmdbuf = cs->lastcmdbuf = NULL; cs->cmdbuf = cs->lastcmdbuf = NULL;
spin_lock_init(&cs->cmdlock); spin_lock_init(&cs->cmdlock);
cs->curlen = 0; cs->curlen = 0;
cs->cmdbytes = 0; cs->cmdbytes = 0;
dbg(DEBUG_INIT, "setting up iif"); gig_dbg(DEBUG_INIT, "setting up iif");
if (!gigaset_register_to_LL(cs, modulename)) { if (!gigaset_register_to_LL(cs, modulename)) {
err("register_isdn=>error"); err("register_isdn failed");
goto error; goto error;
} }
make_valid(cs, VALID_ID); make_valid(cs, VALID_ID);
++cs->cs_init; ++cs->cs_init;
dbg(DEBUG_INIT, "setting up hw"); gig_dbg(DEBUG_INIT, "setting up hw");
if (!cs->ops->initcshw(cs)) if (!cs->ops->initcshw(cs))
goto error; goto error;
@ -691,13 +703,13 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
* Same problem(?) with mod_timer() in timer_tick(). */ * Same problem(?) with mod_timer() in timer_tick(). */
add_timer(&cs->timer); add_timer(&cs->timer);
dbg(DEBUG_INIT, "cs initialized!"); gig_dbg(DEBUG_INIT, "cs initialized");
up(&cs->sem); up(&cs->sem);
return cs; return cs;
error: if (cs) error: if (cs)
up(&cs->sem); up(&cs->sem);
dbg(DEBUG_INIT, "failed"); gig_dbg(DEBUG_INIT, "failed");
gigaset_freecs(cs); gigaset_freecs(cs);
return NULL; return NULL;
} }
@ -816,7 +828,7 @@ int gigaset_start(struct cardstate *cs)
goto error; goto error;
} }
dbg(DEBUG_CMD, "scheduling START"); gig_dbg(DEBUG_CMD, "scheduling START");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting); wait_event(cs->waitqueue, !cs->waiting);
@ -841,11 +853,11 @@ void gigaset_shutdown(struct cardstate *cs)
goto exit; goto exit;
} }
dbg(DEBUG_CMD, "scheduling SHUTDOWN"); gig_dbg(DEBUG_CMD, "scheduling SHUTDOWN");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) { if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
warn("aborted"); warn("%s: aborted", __func__);
//FIXME //FIXME
} }
@ -879,11 +891,11 @@ void gigaset_stop(struct cardstate *cs)
goto exit; goto exit;
} }
dbg(DEBUG_CMD, "scheduling STOP"); gig_dbg(DEBUG_CMD, "scheduling STOP");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) { if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
warn("aborted"); warn("%s: aborted", __func__);
//FIXME //FIXME
} }
@ -937,17 +949,18 @@ void gigaset_debugdrivers(void)
spin_lock_irqsave(&driver_lock, flags); spin_lock_irqsave(&driver_lock, flags);
list_for_each_entry(drv, &drivers, list) { list_for_each_entry(drv, &drivers, list) {
dbg(DEBUG_DRIVER, "driver %p", drv); gig_dbg(DEBUG_DRIVER, "driver %p", drv);
spin_lock(&drv->lock); spin_lock(&drv->lock);
for (i = 0; i < drv->minors; ++i) { for (i = 0; i < drv->minors; ++i) {
dbg(DEBUG_DRIVER, " index %u", i); gig_dbg(DEBUG_DRIVER, " index %u", i);
dbg(DEBUG_DRIVER, " flags 0x%02x", drv->flags[i]); gig_dbg(DEBUG_DRIVER, " flags 0x%02x",
drv->flags[i]);
cs = drv->cs + i; cs = drv->cs + i;
dbg(DEBUG_DRIVER, " cardstate %p", cs); gig_dbg(DEBUG_DRIVER, " cardstate %p", cs);
dbg(DEBUG_DRIVER, " minor_index %u", gig_dbg(DEBUG_DRIVER, " minor_index %u",
cs->minor_index); cs->minor_index);
dbg(DEBUG_DRIVER, " driver %p", cs->driver); gig_dbg(DEBUG_DRIVER, " driver %p", cs->driver);
dbg(DEBUG_DRIVER, " i4l id %d", cs->myid); gig_dbg(DEBUG_DRIVER, " i4l id %d", cs->myid);
} }
spin_unlock(&drv->lock); spin_unlock(&drv->lock);
} }

View file

@ -444,7 +444,7 @@ static int isdn_getnum(char *p)
IFNULLRETVAL(p, -1); IFNULLRETVAL(p, -1);
dbg(DEBUG_TRANSCMD, "string: %s", p); gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
while (*p >= '0' && *p <= '9') while (*p >= '0' && *p <= '9')
v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0'); v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
@ -463,7 +463,7 @@ static int isdn_gethex(char *p)
IFNULLRETVAL(p, -1); IFNULLRETVAL(p, -1);
dbg(DEBUG_TRANSCMD, "string: %s", p); gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
if (!*p) if (!*p)
return -1; return -1;
@ -537,11 +537,11 @@ void gigaset_handle_modem_response(struct cardstate *cs)
len = cs->cbytes; len = cs->cbytes;
if (!len) { if (!len) {
/* ignore additional LFs/CRs (M10x config mode or cx100) */ /* ignore additional LFs/CRs (M10x config mode or cx100) */
dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]); gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]);
return; return;
} }
cs->respdata[len] = 0; cs->respdata[len] = 0;
dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata); gig_dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata);
argv[0] = cs->respdata; argv[0] = cs->respdata;
params = 1; params = 1;
if (cs->at_state.getstring) { if (cs->at_state.getstring) {
@ -557,7 +557,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
case ',': case ',':
case '=': case '=':
if (params > MAX_REC_PARAMS) { if (params > MAX_REC_PARAMS) {
warn("too many parameters in response"); dev_warn(cs->dev,
"too many parameters in response\n");
/* need last parameter (might be CID) */ /* need last parameter (might be CID) */
params--; params--;
} }
@ -575,14 +576,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
for (j = 1; j < params; ++j) for (j = 1; j < params; ++j)
argv[j][-1] = 0; argv[j][-1] = 0;
dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]); gig_dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
if (cid) { if (cid) {
--params; --params;
dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]); gig_dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]);
} }
dbg(DEBUG_TRANSCMD, "available params: %d", params - 1); gig_dbg(DEBUG_TRANSCMD, "available params: %d", params - 1);
for (j = 1; j < params; j++) for (j = 1; j < params; j++)
dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]); gig_dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]);
} }
spin_lock_irqsave(&cs->ev_lock, flags); spin_lock_irqsave(&cs->ev_lock, flags);
@ -594,7 +595,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
while (curarg < params) { while (curarg < params) {
next = (tail + 1) % MAX_EVENTS; next = (tail + 1) % MAX_EVENTS;
if (unlikely(next == head)) { if (unlikely(next == head)) {
err("event queue full"); dev_err(cs->dev, "event queue full\n");
break; break;
} }
@ -615,7 +616,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
if (!rt->response) { if (!rt->response) {
event->type = RSP_UNKNOWN; event->type = RSP_UNKNOWN;
warn("unknown modem response: %s", dev_warn(cs->dev,
"unknown modem response: %s\n",
argv[curarg]); argv[curarg]);
break; break;
} }
@ -632,7 +634,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
break; break;
case RT_RING: case RT_RING:
if (!cid) { if (!cid) {
err("received RING without CID!"); dev_err(cs->dev,
"received RING without CID!\n");
event->type = RSP_INVAL; event->type = RSP_INVAL;
abort = 1; abort = 1;
} else { } else {
@ -660,27 +663,25 @@ void gigaset_handle_modem_response(struct cardstate *cs)
event->parameter = ZSAU_DISCONNECT_REQ; event->parameter = ZSAU_DISCONNECT_REQ;
else { else {
event->parameter = ZSAU_UNKNOWN; event->parameter = ZSAU_UNKNOWN;
warn("%s: unknown parameter %s after ZSAU", dev_warn(cs->dev,
"%s: unknown parameter %s after ZSAU\n",
__func__, argv[curarg]); __func__, argv[curarg]);
} }
++curarg; ++curarg;
break; break;
case RT_STRING: case RT_STRING:
if (curarg < params) { if (curarg < params) {
len = strlen(argv[curarg]) + 1; event->ptr = kstrdup(argv[curarg], GFP_ATOMIC);
event->ptr = kmalloc(len, GFP_ATOMIC); if (!event->ptr)
if (event->ptr) dev_err(cs->dev, "out of memory\n");
memcpy(event->ptr, argv[curarg], len);
else
err("no memory for string!");
++curarg; ++curarg;
} }
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (!event->ptr) if (!event->ptr)
dbg(DEBUG_CMD, "string==NULL"); gig_dbg(DEBUG_CMD, "string==NULL");
else else
dbg(DEBUG_CMD, gig_dbg(DEBUG_CMD, "string==%s",
"string==%s", (char *) event->ptr); (char *) event->ptr);
#endif #endif
break; break;
case RT_ZCAU: case RT_ZCAU:
@ -708,7 +709,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
} else } else
event->parameter = -1; event->parameter = -1;
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
dbg(DEBUG_CMD, "parameter==%d", event->parameter); gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter);
#endif #endif
break; break;
} }
@ -724,7 +725,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
spin_unlock_irqrestore(&cs->ev_lock, flags); spin_unlock_irqrestore(&cs->ev_lock, flags);
if (curarg != params) if (curarg != params)
dbg(DEBUG_ANY, "invalid number of processed parameters: %d/%d", gig_dbg(DEBUG_ANY,
"invalid number of processed parameters: %d/%d",
curarg, params); curarg, params);
} }
EXPORT_SYMBOL_GPL(gigaset_handle_modem_response); EXPORT_SYMBOL_GPL(gigaset_handle_modem_response);
@ -750,7 +752,7 @@ static void disconnect(struct at_state_t **at_state_p)
if (!atomic_read(&cs->cidmode)) { if (!atomic_read(&cs->cidmode)) {
cs->at_state.pending_commands |= PC_UMMODE; cs->at_state.pending_commands |= PC_UMMODE;
atomic_set(&cs->commands_pending, 1); //FIXME atomic_set(&cs->commands_pending, 1); //FIXME
dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
} }
if (bcs) { if (bcs) {
@ -822,7 +824,7 @@ static void init_failed(struct cardstate *cs, int mode)
static void schedule_init(struct cardstate *cs, int state) static void schedule_init(struct cardstate *cs, int state)
{ {
if (cs->at_state.pending_commands & PC_INIT) { if (cs->at_state.pending_commands & PC_INIT) {
dbg(DEBUG_CMD, "not scheduling PC_INIT again"); gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again");
return; return;
} }
atomic_set(&cs->mstate, state); atomic_set(&cs->mstate, state);
@ -830,7 +832,7 @@ static void schedule_init(struct cardstate *cs, int state)
gigaset_block_channels(cs); gigaset_block_channels(cs);
cs->at_state.pending_commands |= PC_INIT; cs->at_state.pending_commands |= PC_INIT;
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
dbg(DEBUG_CMD, "Scheduling PC_INIT"); gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
} }
/* Add "AT" to a command, add the cid, dle encode it, send the result to the /* Add "AT" to a command, add the cid, dle encode it, send the result to the
@ -843,10 +845,17 @@ static void send_command(struct cardstate *cs, const char *cmd, int cid,
cmdlen = strlen(cmd); cmdlen = strlen(cmd);
buflen = 11 + cmdlen; buflen = 11 + cmdlen;
if (unlikely(buflen <= cmdlen)) {
dev_err(cs->dev, "integer overflow in buflen\n");
return;
}
if (likely(buflen > cmdlen)) {
cmdbuf = kmalloc(buflen, kmallocflags); cmdbuf = kmalloc(buflen, kmallocflags);
if (likely(cmdbuf != NULL)) { if (unlikely(!cmdbuf)) {
dev_err(cs->dev, "out of memory\n");
return;
}
cmdpos = cmdbuf + 9; cmdpos = cmdbuf + 9;
cmdtail = cmdpos + cmdlen; cmdtail = cmdpos + cmdlen;
memcpy(cmdpos, cmd, cmdlen); memcpy(cmdpos, cmd, cmdlen);
@ -873,10 +882,6 @@ static void send_command(struct cardstate *cs, const char *cmd, int cid,
cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL); cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL);
kfree(cmdbuf); kfree(cmdbuf);
} else
err("no memory for command buffer");
} else
err("overflow in buflen");
} }
static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid) static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid)
@ -930,13 +935,14 @@ static void bchannel_up(struct bc_state *bcs)
IFNULLRET(bcs); IFNULLRET(bcs);
if (!(bcs->chstate & CHS_D_UP)) { if (!(bcs->chstate & CHS_D_UP)) {
notice("%s: D channel not up", __func__); dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
bcs->chstate |= CHS_D_UP; bcs->chstate |= CHS_D_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
} }
if (bcs->chstate & CHS_B_UP) { if (bcs->chstate & CHS_B_UP) {
notice("%s: B channel already up", __func__); dev_notice(bcs->cs->dev, "%s: B channel already up\n",
__func__);
return; return;
} }
@ -962,13 +968,13 @@ static void start_dial(struct at_state_t *at_state, void *data, int seq_index)
at_state->pending_commands |= PC_CID; at_state->pending_commands |= PC_CID;
dbg(DEBUG_CMD, "Scheduling PC_CID"); gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
return; return;
error: error:
at_state->pending_commands |= PC_NOCID; at_state->pending_commands |= PC_NOCID;
dbg(DEBUG_CMD, "Scheduling PC_NOCID"); gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
return; return;
} }
@ -982,12 +988,12 @@ static void start_accept(struct at_state_t *at_state)
if (retval == 0) { if (retval == 0) {
at_state->pending_commands |= PC_ACCEPT; at_state->pending_commands |= PC_ACCEPT;
dbg(DEBUG_CMD, "Scheduling PC_ACCEPT"); gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
} else { } else {
//FIXME //FIXME
at_state->pending_commands |= PC_HUP; at_state->pending_commands |= PC_HUP;
dbg(DEBUG_CMD, "Scheduling PC_HUP"); gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
} }
} }
@ -1029,7 +1035,7 @@ static void do_shutdown(struct cardstate *cs)
atomic_set(&cs->mstate, MS_SHUTDOWN); atomic_set(&cs->mstate, MS_SHUTDOWN);
cs->at_state.pending_commands |= PC_SHUTDOWN; cs->at_state.pending_commands |= PC_SHUTDOWN;
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN"); gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
} else } else
finish_shutdown(cs); finish_shutdown(cs);
} }
@ -1059,9 +1065,11 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
return 0; return 0;
if (channel < 0) if (channel < 0)
warn("Could not enter cid mode. Reinit device and try again."); dev_warn(cs->dev,
"Could not enter cid mode. Reinit device and try again.\n");
else { else {
warn("Could not get a call id. Reinit device and try again."); dev_warn(cs->dev,
"Could not get a call id. Reinit device and try again.\n");
cs->bcs[channel].at_state.pending_commands |= PC_CID; cs->bcs[channel].at_state.pending_commands |= PC_CID;
} }
schedule_init(cs, MS_INIT); schedule_init(cs, MS_INIT);
@ -1106,7 +1114,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
case ICALL_ACCEPT: case ICALL_ACCEPT:
break; break;
default: default:
err("internal error: disposition=%d", retval); dev_err(cs->dev, "internal error: disposition=%d\n", retval);
/* --v-- fall through --v-- */ /* --v-- fall through --v-- */
case ICALL_IGNORE: case ICALL_IGNORE:
case ICALL_REJECT: case ICALL_REJECT:
@ -1201,10 +1209,10 @@ static void do_action(int action, struct cardstate *cs,
} }
cs->at_state.pending_commands |= PC_CIDMODE; cs->at_state.pending_commands |= PC_CIDMODE;
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
break; break;
case ACT_FAILINIT: case ACT_FAILINIT:
warn("Could not initialize the device."); dev_warn(cs->dev, "Could not initialize the device.\n");
cs->dle = 0; cs->dle = 0;
init_failed(cs, M_UNKNOWN); init_failed(cs, M_UNKNOWN);
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
@ -1260,8 +1268,8 @@ static void do_action(int action, struct cardstate *cs,
/* get fresh AT state structure for new CID */ /* get fresh AT state structure for new CID */
at_state2 = get_free_channel(cs, ev->parameter); at_state2 = get_free_channel(cs, ev->parameter);
if (!at_state2) { if (!at_state2) {
warn("RING ignored: " dev_warn(cs->dev,
"could not allocate channel structure"); "RING ignored: could not allocate channel structure\n");
break; break;
} }
@ -1289,7 +1297,7 @@ static void do_action(int action, struct cardstate *cs,
at_state = *p_at_state; at_state = *p_at_state;
break; break;
case ACT_FAILSDOWN: case ACT_FAILSDOWN:
warn("Could not shut down the device."); dev_warn(cs->dev, "Could not shut down the device.\n");
/* fall through */ /* fall through */
case ACT_FAKESDOWN: case ACT_FAKESDOWN:
case ACT_SDOWN: case ACT_SDOWN:
@ -1342,7 +1350,7 @@ static void do_action(int action, struct cardstate *cs,
break; break;
case ACT_ABORTHUP: case ACT_ABORTHUP:
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
warn("Could not hang up."); dev_warn(cs->dev, "Could not hang up.\n");
at_state->cid = -1; at_state->cid = -1;
if (bcs && cs->onechannel) if (bcs && cs->onechannel)
at_state->pending_commands |= PC_DLE0; at_state->pending_commands |= PC_DLE0;
@ -1354,14 +1362,15 @@ static void do_action(int action, struct cardstate *cs,
break; break;
case ACT_FAILDLE0: case ACT_FAILDLE0:
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
warn("Could not leave DLE mode."); dev_warn(cs->dev, "Could not leave DLE mode.\n");
at_state2 = &cs->bcs[cs->curchannel].at_state; at_state2 = &cs->bcs[cs->curchannel].at_state;
disconnect(&at_state2); disconnect(&at_state2);
schedule_init(cs, MS_RECOVER); schedule_init(cs, MS_RECOVER);
break; break;
case ACT_FAILDLE1: case ACT_FAILDLE1:
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
warn("Could not enter DLE mode. Try to hang up."); dev_warn(cs->dev,
"Could not enter DLE mode. Trying to hang up.\n");
channel = cs->curchannel; channel = cs->curchannel;
cs->bcs[channel].at_state.pending_commands |= PC_HUP; cs->bcs[channel].at_state.pending_commands |= PC_HUP;
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
@ -1382,7 +1391,8 @@ static void do_action(int action, struct cardstate *cs,
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
channel = cs->curchannel; channel = cs->curchannel;
if (!reinit_and_retry(cs, channel)) { if (!reinit_and_retry(cs, channel)) {
warn("Could not get a call id. Dialing not possible"); dev_warn(cs->dev,
"Could not get a call ID. Cannot dial.\n");
at_state2 = &cs->bcs[channel].at_state; at_state2 = &cs->bcs[channel].at_state;
disconnect(&at_state2); disconnect(&at_state2);
} }
@ -1457,7 +1467,7 @@ static void do_action(int action, struct cardstate *cs,
case ACT_GOTVER: case ACT_GOTVER:
if (cs->gotfwver == 0) { if (cs->gotfwver == 0) {
cs->gotfwver = 1; cs->gotfwver = 1;
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY,
"firmware version %02d.%03d.%02d.%02d", "firmware version %02d.%03d.%02d.%02d",
cs->fwver[0], cs->fwver[1], cs->fwver[0], cs->fwver[1],
cs->fwver[2], cs->fwver[3]); cs->fwver[2], cs->fwver[3]);
@ -1466,7 +1476,7 @@ static void do_action(int action, struct cardstate *cs,
/* fall through */ /* fall through */
case ACT_FAILVER: case ACT_FAILVER:
cs->gotfwver = -1; cs->gotfwver = -1;
err("could not read firmware version."); dev_err(cs->dev, "could not read firmware version.\n");
break; break;
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
case ACT_ERROR: case ACT_ERROR:
@ -1484,15 +1494,15 @@ static void do_action(int action, struct cardstate *cs,
break; break;
#endif #endif
case ACT_DEBUG: case ACT_DEBUG:
dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d", gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
__func__, ev->type, at_state->ConState); __func__, ev->type, at_state->ConState);
break; break;
case ACT_WARN: case ACT_WARN:
warn("%s: resp_code %d in ConState %d!", dev_warn(cs->dev, "%s: resp_code %d in ConState %d!\n",
__func__, ev->type, at_state->ConState); __func__, ev->type, at_state->ConState);
break; break;
case ACT_ZCAU: case ACT_ZCAU:
warn("cause code %04x in connection state %d.", dev_warn(cs->dev, "cause code %04x in connection state %d.\n",
ev->parameter, at_state->ConState); ev->parameter, at_state->ConState);
break; break;
@ -1504,14 +1514,14 @@ static void do_action(int action, struct cardstate *cs,
start_accept(at_state); start_accept(at_state);
break; break;
case ACT_PROTO_L2: case ACT_PROTO_L2:
dbg(DEBUG_CMD, gig_dbg(DEBUG_CMD, "set protocol to %u",
"set protocol to %u", (unsigned) ev->parameter); (unsigned) ev->parameter);
at_state->bcs->proto2 = ev->parameter; at_state->bcs->proto2 = ev->parameter;
break; break;
case ACT_HUP: case ACT_HUP:
at_state->pending_commands |= PC_HUP; at_state->pending_commands |= PC_HUP;
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
dbg(DEBUG_CMD, "Scheduling PC_HUP"); gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
break; break;
/* hotplug events */ /* hotplug events */
@ -1547,10 +1557,10 @@ static void do_action(int action, struct cardstate *cs,
atomic_set(&cs->cidmode, ev->parameter); atomic_set(&cs->cidmode, ev->parameter);
if (ev->parameter) { if (ev->parameter) {
cs->at_state.pending_commands |= PC_CIDMODE; cs->at_state.pending_commands |= PC_CIDMODE;
dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
} else { } else {
cs->at_state.pending_commands |= PC_UMMODE; cs->at_state.pending_commands |= PC_UMMODE;
dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
} }
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
} }
@ -1578,7 +1588,7 @@ static void do_action(int action, struct cardstate *cs,
*p_resp_code = RSP_NULL; *p_resp_code = RSP_NULL;
} }
} else } else
err("%s: action==%d!", __func__, action); dev_err(cs->dev, "%s: action==%d!\n", __func__, action);
} }
} }
@ -1610,14 +1620,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
} else { } else {
at_state = ev->at_state; at_state = ev->at_state;
if (at_state_invalid(cs, at_state)) { if (at_state_invalid(cs, at_state)) {
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY, "event for invalid at_state %p",
"event for invalid at_state %p", at_state); at_state);
return; return;
} }
} }
dbg(DEBUG_CMD, gig_dbg(DEBUG_CMD, "connection state %d, event %d",
"connection state %d, event %d", at_state->ConState, ev->type); at_state->ConState, ev->type);
bcs = at_state->bcs; bcs = at_state->bcs;
sendcid = at_state->cid; sendcid = at_state->cid;
@ -1630,11 +1640,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
if (ev->parameter != atomic_read(&at_state->timer_index) if (ev->parameter != atomic_read(&at_state->timer_index)
|| !at_state->timer_active) { || !at_state->timer_active) {
ev->type = RSP_NONE; /* old timeout */ ev->type = RSP_NONE; /* old timeout */
dbg(DEBUG_ANY, "old timeout"); gig_dbg(DEBUG_ANY, "old timeout");
} else if (!at_state->waiting) } else if (!at_state->waiting)
dbg(DEBUG_ANY, "timeout occured"); gig_dbg(DEBUG_ANY, "timeout occurred");
else else
dbg(DEBUG_ANY, "stopped waiting"); gig_dbg(DEBUG_ANY, "stopped waiting");
} }
/* if the response belongs to a variable in at_state->int_var[VAR_XXXX] /* if the response belongs to a variable in at_state->int_var[VAR_XXXX]
@ -1657,10 +1667,10 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
constate */ constate */
for (;; rep++) { for (;; rep++) {
rcode = rep->resp_code; rcode = rep->resp_code;
/* dbg (DEBUG_ANY, "rcode %d", rcode); */
if (rcode == RSP_LAST) { if (rcode == RSP_LAST) {
/* found nothing...*/ /* found nothing...*/
warn("%s: rcode=RSP_LAST: resp_code %d in ConState %d!", dev_warn(cs->dev, "%s: rcode=RSP_LAST: "
"resp_code %d in ConState %d!\n",
__func__, ev->type, at_state->ConState); __func__, ev->type, at_state->ConState);
return; return;
} }
@ -1741,11 +1751,11 @@ static void process_command_flags(struct cardstate *cs)
atomic_set(&cs->commands_pending, 0); atomic_set(&cs->commands_pending, 0);
if (cs->cur_at_seq) { if (cs->cur_at_seq) {
dbg(DEBUG_CMD, "not searching scheduled commands: busy"); gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
return; return;
} }
dbg(DEBUG_CMD, "searching scheduled commands"); gig_dbg(DEBUG_CMD, "searching scheduled commands");
sequence = SEQ_NONE; sequence = SEQ_NONE;
@ -1884,7 +1894,7 @@ static void process_command_flags(struct cardstate *cs)
switch (atomic_read(&cs->mode)) { switch (atomic_read(&cs->mode)) {
case M_UNIMODEM: case M_UNIMODEM:
cs->at_state.pending_commands |= PC_CIDMODE; cs->at_state.pending_commands |= PC_CIDMODE;
dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
return; return;
#ifdef GIG_MAYINITONDIAL #ifdef GIG_MAYINITONDIAL
@ -1945,7 +1955,8 @@ static void process_events(struct cardstate *cs)
} }
if (i == 2 * MAX_EVENTS) { if (i == 2 * MAX_EVENTS) {
err("infinite loop in process_events; aborting."); dev_err(cs->dev,
"infinite loop in process_events; aborting.\n");
} }
} }
@ -1962,7 +1973,7 @@ void gigaset_handle_event(unsigned long data)
/* handle incoming data on control/common channel */ /* handle incoming data on control/common channel */
if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) { if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) {
dbg(DEBUG_INTR, "processing new data"); gig_dbg(DEBUG_INTR, "processing new data");
cs->ops->handle_input(cs->inbuf); cs->ops->handle_input(cs->inbuf);
} }

View file

@ -137,45 +137,47 @@ enum debuglevel { /* up to 24 bits (atomic_t) */
activated */ activated */
}; };
#ifdef CONFIG_GIGASET_DEBUG /* missing from linux/device.h ... */
#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) #ifndef dev_notice
#else #define dev_notice(dev, format, arg...) \
#define DEBUG_DEFAULT 0 dev_printk(KERN_NOTICE , dev , format , ## arg)
#endif #endif
/* redefine syslog macros to prepend module name instead of entire /* Kernel message macros for situations where dev_printk and friends cannot be
* source path */ * used for lack of reliable access to a device structure.
#undef info * linux/usb.h already contains these but in an obsolete form which clutters
#define info(format, arg...) \ * the log needlessly, and according to the USB maintainer those should be
printk(KERN_INFO "%s: " format "\n", \ * removed rather than fixed anyway.
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) */
#undef notice
#define notice(format, arg...) \
printk(KERN_NOTICE "%s: " format "\n", \
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
#undef warn
#define warn(format, arg...) \
printk(KERN_WARNING "%s: " format "\n", \
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
#undef err #undef err
#define err(format, arg...) \ #undef info
printk(KERN_ERR "%s: " format "\n", \ #undef warn
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) #undef notice
#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
format "\n" , ## arg)
#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
format "\n" , ## arg)
#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
format "\n" , ## arg)
#define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \
format "\n" , ## arg)
#undef dbg
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
#define dbg(level, format, arg...) \
#define gig_dbg(level, format, arg...) \
do { \ do { \
if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
printk(KERN_DEBUG "%s: " format "\n", \ printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" \ ## arg); \
, ## arg); \
} while (0) } while (0)
#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
#else #else
#define dbg(level, format, arg...) do {} while (0)
#define gig_dbg(level, format, arg...) do {} while (0)
#define DEBUG_DEFAULT 0
#endif #endif
void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
@ -368,16 +370,6 @@ struct inbuf_t {
* BAS_OUTBUFPAD bytes immediately before data[write] (if * BAS_OUTBUFPAD bytes immediately before data[write] (if
* write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD) * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD)
* are also filled with that value * are also filled with that value
* - optionally, the following statistics on the buffer's usage can be
* collected:
* maxfill: maximum number of bytes occupied
* idlefills: number of times a frame of idle bytes is prepared
* emptygets: number of times the buffer was empty when a data frame was
* requested
* backtoback: number of times two data packets were entered into the buffer
* without intervening idle flags
* nakedback: set if no idle flags have been inserted since the last data
* packet
*/ */
struct isowbuf_t { struct isowbuf_t {
atomic_t read; atomic_t read;
@ -471,7 +463,7 @@ struct bc_state {
int busy; int busy;
int use_count; int use_count;
/* hardware drivers */ /* private data of hardware drivers */
union { union {
struct ser_bc_state *ser; /* serial hardware driver */ struct ser_bc_state *ser; /* serial hardware driver */
struct usb_bc_state *usb; /* usb hardware driver (m105) */ struct usb_bc_state *usb; /* usb hardware driver (m105) */
@ -482,6 +474,7 @@ struct bc_state {
struct cardstate { struct cardstate {
struct gigaset_driver *driver; struct gigaset_driver *driver;
unsigned minor_index; unsigned minor_index;
struct device *dev;
const struct gigaset_ops *ops; const struct gigaset_ops *ops;
@ -531,11 +524,11 @@ struct cardstate {
int cs_init; int cs_init;
int ignoreframes; /* frames to ignore after setting up the int ignoreframes; /* frames to ignore after setting up the
B channel */ B channel */
struct semaphore sem; /* locks this structure: */ struct semaphore sem; /* locks this structure:
/* connected is not changed, */ * connected is not changed,
/* hardware_up is not changed, */ * hardware_up is not changed,
/* MState is not changed to or from * MState is not changed to or from
MS_LOCKED */ * MS_LOCKED */
struct timer_list timer; struct timer_list timer;
int retry_count; int retry_count;
@ -543,7 +536,7 @@ struct cardstate {
dle encoded */ dle encoded */
int cur_at_seq; /* sequence of AT commands being int cur_at_seq; /* sequence of AT commands being
processed */ processed */
int curchannel; /* channel, those commands are meant int curchannel; /* channel those commands are meant
for */ for */
atomic_t commands_pending; /* flag(s) in xxx.commands_pending have atomic_t commands_pending; /* flag(s) in xxx.commands_pending have
been set */ been set */
@ -551,7 +544,7 @@ struct cardstate {
/* tasklet for serializing AT commands. /* tasklet for serializing AT commands.
* Scheduled * Scheduled
* -> for modem reponses (and * -> for modem reponses (and
* incomming data for M10x) * incoming data for M10x)
* -> on timeout * -> on timeout
* -> after setting bits in * -> after setting bits in
* xxx.at_state.pending_command * xxx.at_state.pending_command
@ -569,7 +562,7 @@ struct cardstate {
unsigned char respdata[MAX_RESP_SIZE]; unsigned char respdata[MAX_RESP_SIZE];
unsigned cbytes; unsigned cbytes;
/* hardware drivers */ /* private data of hardware drivers */
union { union {
struct usb_cardstate *usb; /* USB hardware driver (m105) */ struct usb_cardstate *usb; /* USB hardware driver (m105) */
struct ser_cardstate *ser; /* serial hardware driver */ struct ser_cardstate *ser; /* serial hardware driver */
@ -607,8 +600,8 @@ struct bas_bc_state {
struct isow_urbctx_t isoouturbs[BAS_OUTURBS]; struct isow_urbctx_t isoouturbs[BAS_OUTURBS];
struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl; struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl;
struct isowbuf_t *isooutbuf; struct isowbuf_t *isooutbuf;
unsigned numsub; /* submitted URB counter (for unsigned numsub; /* submitted URB counter
diagnostic messages only) */ (for diagnostic messages only) */
struct tasklet_struct sent_tasklet; struct tasklet_struct sent_tasklet;
/* isochronous input state */ /* isochronous input state */
@ -618,25 +611,22 @@ struct bas_bc_state {
struct urb *isoindone; /* completed isoc read URB */ struct urb *isoindone; /* completed isoc read URB */
int loststatus; /* status of dropped URB */ int loststatus; /* status of dropped URB */
unsigned isoinlost; /* number of bytes lost */ unsigned isoinlost; /* number of bytes lost */
/* state of bit unstuffing algorithm (in addition to /* state of bit unstuffing algorithm
BC_state.inputstate) */ (in addition to BC_state.inputstate) */
unsigned seqlen; /* number of '1' bits not yet unsigned seqlen; /* number of '1' bits not yet
unstuffed */ unstuffed */
unsigned inbyte, inbits; /* collected bits for next byte unsigned inbyte, inbits; /* collected bits for next byte */
*/
/* statistics */ /* statistics */
unsigned goodbytes; /* bytes correctly received */ unsigned goodbytes; /* bytes correctly received */
unsigned alignerrs; /* frames with incomplete byte unsigned alignerrs; /* frames with incomplete byte at end */
at end */
unsigned fcserrs; /* FCS errors */ unsigned fcserrs; /* FCS errors */
unsigned frameerrs; /* framing errors */ unsigned frameerrs; /* framing errors */
unsigned giants; /* long frames */ unsigned giants; /* long frames */
unsigned runts; /* short frames */ unsigned runts; /* short frames */
unsigned aborts; /* HDLC aborts */ unsigned aborts; /* HDLC aborts */
unsigned shared0s; /* '0' bits shared between flags unsigned shared0s; /* '0' bits shared between flags */
*/ unsigned stolen0s; /* '0' stuff bits also serving as
unsigned stolen0s; /* '0' stuff bits also serving leading flag bits */
as leading flag bits */
struct tasklet_struct rcvd_tasklet; struct tasklet_struct rcvd_tasklet;
}; };
@ -764,7 +754,7 @@ static inline void gigaset_isdn_rcv_err(struct bc_state *bcs)
isdn_ctrl response; isdn_ctrl response;
/* error -> LL */ /* error -> LL */
dbg(DEBUG_CMD, "sending L1ERR"); gig_dbg(DEBUG_CMD, "sending L1ERR");
response.driver = bcs->cs->myid; response.driver = bcs->cs->myid;
response.command = ISDN_STAT_L1ERR; response.command = ISDN_STAT_L1ERR;
response.arg = bcs->channel; response.arg = bcs->channel;
@ -872,7 +862,7 @@ static inline void gigaset_bchannel_down(struct bc_state *bcs)
{ {
gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL); gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL);
dbg(DEBUG_CMD, "scheduling BC_CLOSED"); gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED");
gigaset_schedule_event(bcs->cs); gigaset_schedule_event(bcs->cs);
} }
@ -882,7 +872,7 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
{ {
gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL); gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL);
dbg(DEBUG_CMD, "scheduling BC_OPEN"); gig_dbg(DEBUG_CMD, "scheduling BC_OPEN");
gigaset_schedule_event(bcs->cs); gigaset_schedule_event(bcs->cs);
} }
@ -947,7 +937,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
{ {
unsigned n, head, tail, bytesleft; unsigned n, head, tail, bytesleft;
dbg(DEBUG_INTR, "received %u bytes", numbytes); gig_dbg(DEBUG_INTR, "received %u bytes", numbytes);
if (!numbytes) if (!numbytes)
return 0; return 0;
@ -955,7 +945,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
bytesleft = numbytes; bytesleft = numbytes;
tail = atomic_read(&inbuf->tail); tail = atomic_read(&inbuf->tail);
head = atomic_read(&inbuf->head); head = atomic_read(&inbuf->head);
dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
while (bytesleft) { while (bytesleft) {
if (head > tail) if (head > tail)
@ -965,7 +955,8 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
else else
n = RBUFSIZE - tail; n = RBUFSIZE - tail;
if (!n) { if (!n) {
err("buffer overflow (%u bytes lost)", bytesleft); dev_err(inbuf->cs->dev,
"buffer overflow (%u bytes lost)", bytesleft);
break; break;
} }
if (n > bytesleft) if (n > bytesleft)
@ -975,7 +966,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
tail = (tail + n) % RBUFSIZE; tail = (tail + n) % RBUFSIZE;
src += n; src += n;
} }
dbg(DEBUG_INTR, "setting tail to %u", tail); gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
atomic_set(&inbuf->tail, tail); atomic_set(&inbuf->tail, tail);
return numbytes != bytesleft; return numbytes != bytesleft;
} }

View file

@ -15,7 +15,7 @@
#include "gigaset.h" #include "gigaset.h"
/* == Handling of I4L IO ============================================================================*/ /* == Handling of I4L IO =====================================================*/
/* writebuf_from_LL /* writebuf_from_LL
* called by LL to transmit data on an open channel * called by LL to transmit data on an open channel
@ -33,7 +33,8 @@
* 0 if temporarily unable to accept data (out of buffer space) * 0 if temporarily unable to accept data (out of buffer space)
* <0 on error (eg. -EINVAL) * <0 on error (eg. -EINVAL)
*/ */
static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *skb) static int writebuf_from_LL(int driverID, int channel, int ack,
struct sk_buff *skb)
{ {
struct cardstate *cs; struct cardstate *cs;
struct bc_state *bcs; struct bc_state *bcs;
@ -51,28 +52,30 @@ static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *
bcs = &cs->bcs[channel]; bcs = &cs->bcs[channel];
len = skb->len; len = skb->len;
dbg(DEBUG_LLDATA, gig_dbg(DEBUG_LLDATA,
"Receiving data from LL (id: %d, channel: %d, ack: %d, size: %d)", "Receiving data from LL (id: %d, ch: %d, ack: %d, sz: %d)",
driverID, channel, ack, len); driverID, channel, ack, len);
if (!atomic_read(&cs->connected)) {
err("%s: disconnected", __func__);
return -ENODEV;
}
if (!len) { if (!len) {
if (ack) if (ack)
warn("not ACKing empty packet from LL"); notice("%s: not ACKing empty packet", __func__);
return 0; return 0;
} }
if (len > MAX_BUF_SIZE) { if (len > MAX_BUF_SIZE) {
err("%s: packet too large (%d bytes)", __func__, channel); err("%s: packet too large (%d bytes)", __func__, len);
return -EINVAL; return -EINVAL;
} }
if (!atomic_read(&cs->connected))
return -ENODEV;
skblen = ack ? len : 0; skblen = ack ? len : 0;
skb->head[0] = skblen & 0xff; skb->head[0] = skblen & 0xff;
skb->head[1] = skblen >> 8; skb->head[1] = skblen >> 8;
dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x", len, skblen, gig_dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x",
(unsigned) skb->head[0], (unsigned) skb->head[1]); len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]);
/* pass to device-specific module */ /* pass to device-specific module */
return cs->ops->send_skb(bcs, skb); return cs->ops->send_skb(bcs, skb);
@ -86,13 +89,13 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb)
++bcs->trans_up; ++bcs->trans_up;
if (skb->len) if (skb->len)
warn("%s: skb->len==%d", __func__, skb->len); dev_warn(bcs->cs->dev, "%s: skb->len==%d\n",
__func__, skb->len);
len = (unsigned char) skb->head[0] | len = (unsigned char) skb->head[0] |
(unsigned) (unsigned char) skb->head[1] << 8; (unsigned) (unsigned char) skb->head[1] << 8;
if (len) { if (len) {
dbg(DEBUG_MCMD, gig_dbg(DEBUG_MCMD, "ACKing to LL (id: %d, ch: %d, sz: %u)",
"Acknowledge sending to LL (id: %d, channel: %d size: %u)",
bcs->cs->myid, bcs->channel, len); bcs->cs->myid, bcs->channel, len);
response.driver = bcs->cs->myid; response.driver = bcs->cs->myid;
@ -117,7 +120,6 @@ static int command_from_LL(isdn_ctrl *cntrl)
int retval = 0; int retval = 0;
struct setup_parm *sp; struct setup_parm *sp;
//dbg(DEBUG_ANY, "Gigaset_HW: Receiving command");
gigaset_debugdrivers(); gigaset_debugdrivers();
//FIXME "remove test for &connected" //FIXME "remove test for &connected"
@ -129,29 +131,30 @@ static int command_from_LL(isdn_ctrl *cntrl)
switch (cntrl->command) { switch (cntrl->command) {
case ISDN_CMD_IOCTL: case ISDN_CMD_IOCTL:
gig_dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver: %d, arg: %ld)",
dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver:%d,arg: %ld)",
cntrl->driver, cntrl->arg); cntrl->driver, cntrl->arg);
warn("ISDN_CMD_IOCTL is not supported."); warn("ISDN_CMD_IOCTL is not supported.");
return -EINVAL; return -EINVAL;
case ISDN_CMD_DIAL: case ISDN_CMD_DIAL:
dbg(DEBUG_ANY, "ISDN_CMD_DIAL (driver: %d, channel: %ld, " gig_dbg(DEBUG_ANY,
"ISDN_CMD_DIAL (driver: %d, ch: %ld, "
"phone: %s, ownmsn: %s, si1: %d, si2: %d)", "phone: %s, ownmsn: %s, si1: %d, si2: %d)",
cntrl->driver, cntrl->arg, cntrl->driver, cntrl->arg,
cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn, cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn,
cntrl->parm.setup.si1, cntrl->parm.setup.si2); cntrl->parm.setup.si1, cntrl->parm.setup.si2);
if (cntrl->arg >= cs->channels) { if (cntrl->arg >= cs->channels) {
err("invalid channel (%d)", (int) cntrl->arg); err("ISDN_CMD_DIAL: invalid channel (%d)",
(int) cntrl->arg);
return -EINVAL; return -EINVAL;
} }
bcs = cs->bcs + cntrl->arg; bcs = cs->bcs + cntrl->arg;
if (!gigaset_get_channel(bcs)) { if (!gigaset_get_channel(bcs)) {
err("channel not free"); err("ISDN_CMD_DIAL: channel not free");
return -EBUSY; return -EBUSY;
} }
@ -172,14 +175,15 @@ static int command_from_LL(isdn_ctrl *cntrl)
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling DIAL"); gig_dbg(DEBUG_CMD, "scheduling DIAL");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
break; break;
case ISDN_CMD_ACCEPTD: //FIXME case ISDN_CMD_ACCEPTD: //FIXME
dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD"); gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD");
if (cntrl->arg >= cs->channels) { if (cntrl->arg >= cs->channels) {
err("invalid channel (%d)", (int) cntrl->arg); err("ISDN_CMD_ACCEPTD: invalid channel (%d)",
(int) cntrl->arg);
return -EINVAL; return -EINVAL;
} }
@ -189,16 +193,16 @@ static int command_from_LL(isdn_ctrl *cntrl)
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling ACCEPT"); gig_dbg(DEBUG_CMD, "scheduling ACCEPT");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
break; break;
case ISDN_CMD_ACCEPTB: case ISDN_CMD_ACCEPTB:
dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB"); gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB");
break; break;
case ISDN_CMD_HANGUP: case ISDN_CMD_HANGUP:
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY, "ISDN_CMD_HANGUP (ch: %d)",
"ISDN_CMD_HANGUP (channel: %d)", (int) cntrl->arg); (int) cntrl->arg);
if (cntrl->arg >= cs->channels) { if (cntrl->arg >= cs->channels) {
err("ISDN_CMD_HANGUP: invalid channel (%u)", err("ISDN_CMD_HANGUP: invalid channel (%u)",
@ -212,24 +216,24 @@ static int command_from_LL(isdn_ctrl *cntrl)
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling HUP"); gig_dbg(DEBUG_CMD, "scheduling HUP");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
break; break;
case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME
dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ"); gig_dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ");
break; break;
case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY,
"ISDN_CMD_SETEAZ (id:%d, channel: %ld, number: %s)", "ISDN_CMD_SETEAZ (id: %d, ch: %ld, number: %s)",
cntrl->driver, cntrl->arg, cntrl->parm.num); cntrl->driver, cntrl->arg, cntrl->parm.num);
break; break;
case ISDN_CMD_SETL2: /* Set L2 to given protocol */ case ISDN_CMD_SETL2: /* Set L2 to given protocol */
dbg(DEBUG_ANY, "ISDN_CMD_SETL2 (Channel: %ld, Proto: %lx)", gig_dbg(DEBUG_ANY, "ISDN_CMD_SETL2 (ch: %ld, proto: %lx)",
cntrl->arg & 0xff, (cntrl->arg >> 8)); cntrl->arg & 0xff, (cntrl->arg >> 8));
if ((cntrl->arg & 0xff) >= cs->channels) { if ((cntrl->arg & 0xff) >= cs->channels) {
err("invalid channel (%u)", err("ISDN_CMD_SETL2: invalid channel (%u)",
(unsigned) cntrl->arg & 0xff); (unsigned) cntrl->arg & 0xff);
return -EINVAL; return -EINVAL;
} }
@ -241,32 +245,34 @@ static int command_from_LL(isdn_ctrl *cntrl)
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling PROTO_L2"); gig_dbg(DEBUG_CMD, "scheduling PROTO_L2");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
break; break;
case ISDN_CMD_SETL3: /* Set L3 to given protocol */ case ISDN_CMD_SETL3: /* Set L3 to given protocol */
dbg(DEBUG_ANY, "ISDN_CMD_SETL3 (Channel: %ld, Proto: %lx)", gig_dbg(DEBUG_ANY, "ISDN_CMD_SETL3 (ch: %ld, proto: %lx)",
cntrl->arg & 0xff, (cntrl->arg >> 8)); cntrl->arg & 0xff, (cntrl->arg >> 8));
if ((cntrl->arg & 0xff) >= cs->channels) { if ((cntrl->arg & 0xff) >= cs->channels) {
err("invalid channel (%u)", err("ISDN_CMD_SETL3: invalid channel (%u)",
(unsigned) cntrl->arg & 0xff); (unsigned) cntrl->arg & 0xff);
return -EINVAL; return -EINVAL;
} }
if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) { if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) {
err("invalid protocol %lu", cntrl->arg >> 8); err("ISDN_CMD_SETL3: invalid protocol %lu",
cntrl->arg >> 8);
return -EINVAL; return -EINVAL;
} }
break; break;
case ISDN_CMD_PROCEED: case ISDN_CMD_PROCEED:
dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME gig_dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME
break; break;
case ISDN_CMD_ALERT: case ISDN_CMD_ALERT:
dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME gig_dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME
if (cntrl->arg >= cs->channels) { if (cntrl->arg >= cs->channels) {
err("invalid channel (%d)", (int) cntrl->arg); err("ISDN_CMD_ALERT: invalid channel (%d)",
(int) cntrl->arg);
return -EINVAL; return -EINVAL;
} }
//bcs = cs->bcs + cntrl->arg; //bcs = cs->bcs + cntrl->arg;
@ -274,32 +280,31 @@ static int command_from_LL(isdn_ctrl *cntrl)
// FIXME // FIXME
break; break;
case ISDN_CMD_REDIR: case ISDN_CMD_REDIR:
dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME gig_dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME
break; break;
case ISDN_CMD_PROT_IO: case ISDN_CMD_PROT_IO:
dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO"); gig_dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO");
break; break;
case ISDN_CMD_FAXCMD: case ISDN_CMD_FAXCMD:
dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD"); gig_dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD");
break; break;
case ISDN_CMD_GETL2: case ISDN_CMD_GETL2:
dbg(DEBUG_ANY, "ISDN_CMD_GETL2"); gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL2");
break; break;
case ISDN_CMD_GETL3: case ISDN_CMD_GETL3:
dbg(DEBUG_ANY, "ISDN_CMD_GETL3"); gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL3");
break; break;
case ISDN_CMD_GETEAZ: case ISDN_CMD_GETEAZ:
dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ"); gig_dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ");
break; break;
case ISDN_CMD_SETSIL: case ISDN_CMD_SETSIL:
dbg(DEBUG_ANY, "ISDN_CMD_SETSIL"); gig_dbg(DEBUG_ANY, "ISDN_CMD_SETSIL");
break; break;
case ISDN_CMD_GETSIL: case ISDN_CMD_GETSIL:
dbg(DEBUG_ANY, "ISDN_CMD_GETSIL"); gig_dbg(DEBUG_ANY, "ISDN_CMD_GETSIL");
break; break;
default: default:
err("unknown command %d from LL", err("unknown command %d from LL", cntrl->command);
cntrl->command);
return -EINVAL; return -EINVAL;
} }
@ -344,7 +349,8 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */ proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
break; break;
default: default:
err("invalid protocol: %u", bcs->proto2); dev_err(bcs->cs->dev, "%s: invalid L2 protocol: %u\n",
__func__, bcs->proto2);
return -EINVAL; return -EINVAL;
} }
@ -372,7 +378,7 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
bcs->commands[i] = NULL; bcs->commands[i] = NULL;
if (length[i] && if (length[i] &&
!(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) { !(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
err("out of memory"); dev_err(bcs->cs->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
} }
} }
@ -417,7 +423,8 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */ proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
break; break;
default: default:
err("invalid protocol: %u", bcs->proto2); dev_err(at_state->cs->dev, "%s: invalid protocol: %u\n",
__func__, bcs->proto2);
return -EINVAL; return -EINVAL;
} }
@ -434,7 +441,7 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
bcs->commands[i] = NULL; bcs->commands[i] = NULL;
if (length[i] && if (length[i] &&
!(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) { !(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
err("out of memory"); dev_err(at_state->cs->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
} }
} }
@ -473,7 +480,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
response.parm.setup.si1 = 1; response.parm.setup.si1 = 1;
response.parm.setup.si2 = 2; response.parm.setup.si2 = 2;
} else { } else {
warn("RING ignored - unsupported BC %s", dev_warn(cs->dev, "RING ignored - unsupported BC %s\n",
at_state->str_var[STR_ZBC]); at_state->str_var[STR_ZBC]);
return ICALL_IGNORE; return ICALL_IGNORE;
} }
@ -491,18 +498,17 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
response.parm.setup.eazmsn[0] = 0; response.parm.setup.eazmsn[0] = 0;
if (!bcs) { if (!bcs) {
notice("no channel for incoming call"); dev_notice(cs->dev, "no channel for incoming call\n");
dbg(DEBUG_CMD, "Sending ICALLW");
response.command = ISDN_STAT_ICALLW; response.command = ISDN_STAT_ICALLW;
response.arg = 0; //FIXME response.arg = 0; //FIXME
} else { } else {
dbg(DEBUG_CMD, "Sending ICALL"); gig_dbg(DEBUG_CMD, "Sending ICALL");
response.command = ISDN_STAT_ICALL; response.command = ISDN_STAT_ICALL;
response.arg = bcs->channel; //FIXME response.arg = bcs->channel; //FIXME
} }
response.driver = cs->myid; response.driver = cs->myid;
retval = cs->iif.statcallb(&response); retval = cs->iif.statcallb(&response);
dbg(DEBUG_CMD, "Response: %d", retval); gig_dbg(DEBUG_CMD, "Response: %d", retval);
switch (retval) { switch (retval) {
case 0: /* no takers */ case 0: /* no takers */
return ICALL_IGNORE; return ICALL_IGNORE;
@ -512,7 +518,8 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
case 2: /* reject */ case 2: /* reject */
return ICALL_REJECT; return ICALL_REJECT;
case 3: /* incomplete */ case 3: /* incomplete */
warn("LL requested unsupported feature: Incomplete Number"); dev_warn(cs->dev,
"LL requested unsupported feature: Incomplete Number\n");
return ICALL_IGNORE; return ICALL_IGNORE;
case 4: /* proceeding */ case 4: /* proceeding */
/* Gigaset will send ALERTING anyway. /* Gigaset will send ALERTING anyway.
@ -520,10 +527,11 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
*/ */
return ICALL_ACCEPT; return ICALL_ACCEPT;
case 5: /* deflect */ case 5: /* deflect */
warn("LL requested unsupported feature: Call Deflection"); dev_warn(cs->dev,
"LL requested unsupported feature: Call Deflection\n");
return ICALL_IGNORE; return ICALL_IGNORE;
default: default:
err("LL error %d on ICALL", retval); dev_err(cs->dev, "LL error %d on ICALL\n", retval);
return ICALL_IGNORE; return ICALL_IGNORE;
} }
} }
@ -533,7 +541,7 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
{ {
isdn_if *iif = &cs->iif; isdn_if *iif = &cs->iif;
dbg(DEBUG_ANY, "Register driver capabilities to LL"); gig_dbg(DEBUG_ANY, "Register driver capabilities to LL");
//iif->id[sizeof(iif->id) - 1]=0; //iif->id[sizeof(iif->id) - 1]=0;
//strncpy(iif->id, isdnid, sizeof(iif->id) - 1); //strncpy(iif->id, isdnid, sizeof(iif->id) - 1);

View file

@ -22,7 +22,7 @@ static int if_lock(struct cardstate *cs, int *arg)
{ {
int cmd = *arg; int cmd = *arg;
dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd); gig_dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd);
if (cmd > 1) if (cmd > 1)
return -EINVAL; return -EINVAL;
@ -47,7 +47,7 @@ static int if_lock(struct cardstate *cs, int *arg)
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling IF_LOCK"); gig_dbg(DEBUG_CMD, "scheduling IF_LOCK");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting); wait_event(cs->waitqueue, !cs->waiting);
@ -66,7 +66,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
static const unsigned compat[4] = GIG_COMPAT; static const unsigned compat[4] = GIG_COMPAT;
unsigned cmd = arg[0]; unsigned cmd = arg[0];
dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd); gig_dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd);
switch (cmd) { switch (cmd) {
case GIGVER_DRIVER: case GIGVER_DRIVER:
@ -83,7 +83,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling IF_VER"); gig_dbg(DEBUG_CMD, "scheduling IF_VER");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting); wait_event(cs->waitqueue, !cs->waiting);
@ -99,7 +99,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
static int if_config(struct cardstate *cs, int *arg) static int if_config(struct cardstate *cs, int *arg)
{ {
dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg); gig_dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg);
if (*arg != 1) if (*arg != 1)
return -EINVAL; return -EINVAL;
@ -151,8 +151,8 @@ static int if_open(struct tty_struct *tty, struct file *filp)
struct cardstate *cs; struct cardstate *cs;
unsigned long flags; unsigned long flags;
dbg(DEBUG_IF, "%d+%d: %s()", tty->driver->minor_start, tty->index, gig_dbg(DEBUG_IF, "%d+%d: %s()",
__FUNCTION__); tty->driver->minor_start, tty->index, __func__);
tty->driver_data = NULL; tty->driver_data = NULL;
@ -184,16 +184,16 @@ static void if_close(struct tty_struct *tty, struct file *filp)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return; return;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
down(&cs->sem); down(&cs->sem);
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else { else {
if (!--cs->open_count) { if (!--cs->open_count) {
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
@ -216,17 +216,17 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return -ENODEV; return -ENODEV;
} }
dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __FUNCTION__, cmd); gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd);
if (down_interruptible(&cs->sem)) if (down_interruptible(&cs->sem))
return -ERESTARTSYS; // FIXME -EINTR? return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else { else {
retval = 0; retval = 0;
switch (cmd) { switch (cmd) {
@ -249,7 +249,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS",
6, (const unsigned char *) arg, 1); 6, (const unsigned char *) arg, 1);
if (!atomic_read(&cs->connected)) { if (!atomic_read(&cs->connected)) {
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY,
"can't communicate with unplugged device"); "can't communicate with unplugged device");
retval = -ENODEV; retval = -ENODEV;
break; break;
@ -262,8 +262,8 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
break; break;
case GIGASET_VERSION: case GIGASET_VERSION:
retval = copy_from_user(version, retval = copy_from_user(version,
(unsigned __user *) arg, (unsigned __user *) arg, sizeof version)
sizeof version) ? -EFAULT : 0; ? -EFAULT : 0;
if (retval >= 0) if (retval >= 0)
retval = if_version(cs, version); retval = if_version(cs, version);
if (retval >= 0) if (retval >= 0)
@ -272,8 +272,8 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
? -EFAULT : 0; ? -EFAULT : 0;
break; break;
default: default:
dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x", gig_dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x",
__FUNCTION__, cmd); __func__, cmd);
retval = -ENOIOCTLCMD; retval = -ENOIOCTLCMD;
} }
} }
@ -290,11 +290,11 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return -ENODEV; return -ENODEV;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (down_interruptible(&cs->sem)) if (down_interruptible(&cs->sem))
return -ERESTARTSYS; // FIXME -EINTR? return -ERESTARTSYS; // FIXME -EINTR?
@ -316,18 +316,18 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return -ENODEV; return -ENODEV;
} }
dbg(DEBUG_IF, gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
"%u: %s(0x%x, 0x%x)", cs->minor_index, __FUNCTION__, set, clear); cs->minor_index, __func__, set, clear);
if (down_interruptible(&cs->sem)) if (down_interruptible(&cs->sem))
return -ERESTARTSYS; // FIXME -EINTR? return -ERESTARTSYS; // FIXME -EINTR?
if (!atomic_read(&cs->connected)) { if (!atomic_read(&cs->connected)) {
dbg(DEBUG_ANY, "can't communicate with unplugged device"); gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
retval = -ENODEV; retval = -ENODEV;
} else { } else {
mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR); mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR);
@ -347,22 +347,22 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return -ENODEV; return -ENODEV;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (down_interruptible(&cs->sem)) if (down_interruptible(&cs->sem))
return -ERESTARTSYS; // FIXME -EINTR? return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else if (atomic_read(&cs->mstate) != MS_LOCKED) { else if (atomic_read(&cs->mstate) != MS_LOCKED) {
warn("can't write to unlocked device"); warn("can't write to unlocked device");
retval = -EBUSY; retval = -EBUSY;
} else if (!atomic_read(&cs->connected)) { } else if (!atomic_read(&cs->connected)) {
dbg(DEBUG_ANY, "can't write to unplugged device"); gig_dbg(DEBUG_ANY, "can't write to unplugged device");
retval = -EBUSY; //FIXME retval = -EBUSY; //FIXME
} else { } else {
retval = cs->ops->write_cmd(cs, buf, count, retval = cs->ops->write_cmd(cs, buf, count,
@ -381,22 +381,22 @@ static int if_write_room(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return -ENODEV; return -ENODEV;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (down_interruptible(&cs->sem)) if (down_interruptible(&cs->sem))
return -ERESTARTSYS; // FIXME -EINTR? return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else if (atomic_read(&cs->mstate) != MS_LOCKED) { else if (atomic_read(&cs->mstate) != MS_LOCKED) {
warn("can't write to unlocked device"); warn("can't write to unlocked device");
retval = -EBUSY; //FIXME retval = -EBUSY; //FIXME
} else if (!atomic_read(&cs->connected)) { } else if (!atomic_read(&cs->connected)) {
dbg(DEBUG_ANY, "can't write to unplugged device"); gig_dbg(DEBUG_ANY, "can't write to unplugged device");
retval = -EBUSY; //FIXME retval = -EBUSY; //FIXME
} else } else
retval = cs->ops->write_room(cs); retval = cs->ops->write_room(cs);
@ -413,22 +413,22 @@ static int if_chars_in_buffer(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return -ENODEV; return -ENODEV;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (down_interruptible(&cs->sem)) if (down_interruptible(&cs->sem))
return -ERESTARTSYS; // FIXME -EINTR? return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else if (atomic_read(&cs->mstate) != MS_LOCKED) { else if (atomic_read(&cs->mstate) != MS_LOCKED) {
warn("can't write to unlocked device"); warn("can't write to unlocked device");
retval = -EBUSY; retval = -EBUSY;
} else if (!atomic_read(&cs->connected)) { } else if (!atomic_read(&cs->connected)) {
dbg(DEBUG_ANY, "can't write to unplugged device"); gig_dbg(DEBUG_ANY, "can't write to unplugged device");
retval = -EBUSY; //FIXME retval = -EBUSY; //FIXME
} else } else
retval = cs->ops->chars_in_buffer(cs); retval = cs->ops->chars_in_buffer(cs);
@ -444,16 +444,16 @@ static void if_throttle(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return; return;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
down(&cs->sem); down(&cs->sem);
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else { else {
//FIXME //FIXME
} }
@ -467,16 +467,16 @@ static void if_unthrottle(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return; return;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
down(&cs->sem); down(&cs->sem);
if (!cs->open_count) if (!cs->open_count)
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
else { else {
//FIXME //FIXME
} }
@ -494,21 +494,21 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
cs = (struct cardstate *) tty->driver_data; cs = (struct cardstate *) tty->driver_data;
if (!cs) { if (!cs) {
err("cs==NULL in %s", __FUNCTION__); err("cs==NULL in %s", __func__);
return; return;
} }
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
down(&cs->sem); down(&cs->sem);
if (!cs->open_count) { if (!cs->open_count) {
warn("%s: device not opened", __FUNCTION__); warn("%s: device not opened", __func__);
goto out; goto out;
} }
if (!atomic_read(&cs->connected)) { if (!atomic_read(&cs->connected)) {
dbg(DEBUG_ANY, "can't communicate with unplugged device"); gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
goto out; goto out;
} }
@ -516,8 +516,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
iflag = tty->termios->c_iflag; iflag = tty->termios->c_iflag;
cflag = tty->termios->c_cflag; cflag = tty->termios->c_cflag;
old_cflag = old ? old->c_cflag : cflag; //FIXME? old_cflag = old ? old->c_cflag : cflag; //FIXME?
dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x", cs->minor_index, gig_dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x",
iflag, cflag, old_cflag); cs->minor_index, iflag, cflag, old_cflag);
/* get a local copy of the current port settings */ /* get a local copy of the current port settings */
control_state = cs->control_state; control_state = cs->control_state;
@ -535,7 +535,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
/* don't set RTS if using hardware flow control */ /* don't set RTS if using hardware flow control */
if (!(old_cflag & CRTSCTS)) if (!(old_cflag & CRTSCTS))
new_state |= TIOCM_RTS; new_state |= TIOCM_RTS;
dbg(DEBUG_IF, "%u: from B0 - set DTR%s", cs->minor_index, gig_dbg(DEBUG_IF, "%u: from B0 - set DTR%s",
cs->minor_index,
(new_state & TIOCM_RTS) ? " only" : "/RTS"); (new_state & TIOCM_RTS) ? " only" : "/RTS");
cs->ops->set_modem_ctrl(cs, control_state, new_state); cs->ops->set_modem_ctrl(cs, control_state, new_state);
control_state = new_state; control_state = new_state;
@ -545,7 +546,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
if ((cflag & CBAUD) == B0) { if ((cflag & CBAUD) == B0) {
/* Drop RTS and DTR */ /* Drop RTS and DTR */
dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index); gig_dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index);
new_state = control_state & ~(TIOCM_DTR | TIOCM_RTS); new_state = control_state & ~(TIOCM_DTR | TIOCM_RTS);
cs->ops->set_modem_ctrl(cs, control_state, new_state); cs->ops->set_modem_ctrl(cs, control_state, new_state);
control_state = new_state; control_state = new_state;
@ -565,14 +566,16 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
* Just do what we have seen with SniffUSB on Win98. * Just do what we have seen with SniffUSB on Win98.
*/ */
/* Drop DTR/RTS if no flow control otherwise assert */ /* Drop DTR/RTS if no flow control otherwise assert */
dbg(DEBUG_IF, "%u: control_state %x", cs->minor_index, control_state); gig_dbg(DEBUG_IF, "%u: control_state %x",
cs->minor_index, control_state);
new_state = control_state; new_state = control_state;
if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
new_state |= TIOCM_DTR | TIOCM_RTS; new_state |= TIOCM_DTR | TIOCM_RTS;
else else
new_state &= ~(TIOCM_DTR | TIOCM_RTS); new_state &= ~(TIOCM_DTR | TIOCM_RTS);
if (new_state != control_state) { if (new_state != control_state) {
dbg(DEBUG_IF, "%u: new_state %x", cs->minor_index, new_state); gig_dbg(DEBUG_IF, "%u: new_state %x",
cs->minor_index, new_state);
gigaset_set_modem_ctrl(cs, control_state, new_state); gigaset_set_modem_ctrl(cs, control_state, new_state);
control_state = new_state; control_state = new_state;
} }
@ -598,7 +601,7 @@ static void if_wake(unsigned long data)
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup) { tty->ldisc.write_wakeup) {
dbg(DEBUG_IF, "write wakeup call"); gig_dbg(DEBUG_IF, "write wakeup call");
tty->ldisc.write_wakeup(tty); tty->ldisc.write_wakeup(tty);
} }
@ -640,7 +643,7 @@ void gigaset_if_receive(struct cardstate *cs,
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
if ((tty = cs->tty) == NULL) if ((tty = cs->tty) == NULL)
dbg(DEBUG_ANY, "receive on closed device"); gig_dbg(DEBUG_ANY, "receive on closed device");
else { else {
tty_buffer_request_room(tty, len); tty_buffer_request_room(tty, len);
tty_insert_flip_string(tty, buffer, len); tty_insert_flip_string(tty, buffer, len);
@ -694,7 +697,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
warn("failed to register tty driver (error %d)", ret); warn("failed to register tty driver (error %d)", ret);
goto error; goto error;
} }
dbg(DEBUG_IF, "tty driver initialized"); gig_dbg(DEBUG_IF, "tty driver initialized");
drv->have_tty = 1; drv->have_tty = 1;
return; return;

View file

@ -83,12 +83,12 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
{ {
if (!atomic_dec_and_test(&iwb->writesem)) { if (!atomic_dec_and_test(&iwb->writesem)) {
atomic_inc(&iwb->writesem); atomic_inc(&iwb->writesem);
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
"%s: couldn't acquire iso write semaphore", __func__); __func__);
return 0; return 0;
} }
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO,
"%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
__func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits); __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits);
#endif #endif
@ -143,7 +143,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb)
/* recover the idle flag byte */ /* recover the idle flag byte */
write = atomic_read(&iwb->write); write = atomic_read(&iwb->write);
iwb->idle = iwb->data[write]; iwb->idle = iwb->data[write];
dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle); gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle);
/* mask extraneous bits in buffer */ /* mask extraneous bits in buffer */
iwb->data[write] &= (1 << iwb->wbits) - 1; iwb->data[write] &= (1 << iwb->wbits) - 1;
} }
@ -162,15 +162,14 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
read = atomic_read(&iwb->nextread); read = atomic_read(&iwb->nextread);
write = atomic_read(&iwb->write); write = atomic_read(&iwb->write);
if (likely(read == write)) { if (likely(read == write)) {
//dbg(DEBUG_STREAM, "%s: send buffer empty", __func__);
/* return idle frame */ /* return idle frame */
return read < BAS_OUTBUFPAD ? return read < BAS_OUTBUFPAD ?
BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD; BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD;
} }
limit = read + size; limit = read + size;
dbg(DEBUG_STREAM, gig_dbg(DEBUG_STREAM, "%s: read=%d write=%d limit=%d",
"%s: read=%d write=%d limit=%d", __func__, read, write, limit); __func__, read, write, limit);
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) { if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) {
err("invalid size %d", size); err("invalid size %d", size);
@ -195,7 +194,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
pbyte = iwb->data[write]; /* save pbyte = iwb->data[write]; /* save
partial byte */ partial byte */
limit = write + BAS_OUTBUFPAD; limit = write + BAS_OUTBUFPAD;
dbg(DEBUG_STREAM, gig_dbg(DEBUG_STREAM,
"%s: filling %d->%d with %02x", "%s: filling %d->%d with %02x",
__func__, write, limit, iwb->idle); __func__, write, limit, iwb->idle);
if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE) if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE)
@ -208,7 +207,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
- write); - write);
limit = 0; limit = 0;
} }
dbg(DEBUG_STREAM, "%s: restoring %02x at %d", gig_dbg(DEBUG_STREAM,
"%s: restoring %02x at %d",
__func__, pbyte, limit); __func__, pbyte, limit);
iwb->data[limit] = pbyte; /* restore iwb->data[limit] = pbyte; /* restore
partial byte */ partial byte */
@ -252,7 +252,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
while (count-- > 0) { while (count-- > 0) {
if (i > sizeof(dbgline) - 4) { if (i > sizeof(dbgline) - 4) {
dbgline[i] = '\0'; dbgline[i] = '\0';
dbg(level, "%s:%s", tag, dbgline); gig_dbg(level, "%s:%s", tag, dbgline);
i = 0; i = 0;
} }
c = *bytes++; c = *bytes++;
@ -262,7 +262,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
dbgline[i++] = hexdigit[c & 0x0f]; dbgline[i++] = hexdigit[c & 0x0f];
} }
dbgline[i] = '\0'; dbgline[i] = '\0';
dbg(level, "%s:%s", tag, dbgline); gig_dbg(level, "%s:%s", tag, dbgline);
#endif #endif
} }
@ -429,7 +429,7 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
if (isowbuf_freebytes(iwb) < count + count / 5 + 6 || if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
!isowbuf_startwrite(iwb)) { !isowbuf_startwrite(iwb)) {
dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN", gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
__func__, isowbuf_freebytes(iwb)); __func__, isowbuf_freebytes(iwb));
return -EAGAIN; return -EAGAIN;
} }
@ -482,11 +482,11 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
if (isowbuf_freebytes(iwb) < count || if (isowbuf_freebytes(iwb) < count ||
!isowbuf_startwrite(iwb)) { !isowbuf_startwrite(iwb)) {
dbg(DEBUG_ISO, "can't put %d bytes", count); gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
return -EAGAIN; return -EAGAIN;
} }
dbg(DEBUG_STREAM, "put %d bytes", count); gig_dbg(DEBUG_STREAM, "put %d bytes", count);
write = atomic_read(&iwb->write); write = atomic_read(&iwb->write);
do { do {
c = gigaset_invtab[*in++]; c = gigaset_invtab[*in++];
@ -506,12 +506,12 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
switch (bcs->proto2) { switch (bcs->proto2) {
case ISDN_PROTO_L2_HDLC: case ISDN_PROTO_L2_HDLC:
result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len); result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len);
dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d", gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d",
__func__, len, result); __func__, len, result);
break; break;
default: /* assume transparent */ default: /* assume transparent */
result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len); result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len);
dbg(DEBUG_ISO, "%s: %d bytes trans -> %d", gig_dbg(DEBUG_ISO, "%s: %d bytes trans -> %d",
__func__, len, result); __func__, len, result);
} }
return result; return result;
@ -528,7 +528,7 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
return; return;
} }
if (unlikely(bcs->skb->len == SBUFSIZE)) { if (unlikely(bcs->skb->len == SBUFSIZE)) {
warn("received oversized packet discarded"); dev_warn(bcs->cs->dev, "received oversized packet discarded\n");
bcs->hw.bas->giants++; bcs->hw.bas->giants++;
dev_kfree_skb_any(bcs->skb); dev_kfree_skb_any(bcs->skb);
bcs->skb = NULL; bcs->skb = NULL;
@ -549,7 +549,7 @@ static inline void hdlc_flush(struct bc_state *bcs)
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN); skb_reserve(bcs->skb, HW_HDR_LEN);
else else
err("could not allocate skb"); dev_err(bcs->cs->dev, "could not allocate skb\n");
} }
/* reset packet state */ /* reset packet state */
@ -571,21 +571,23 @@ static inline void hdlc_done(struct bc_state *bcs)
if ((procskb = bcs->skb) == NULL) { if ((procskb = bcs->skb) == NULL) {
/* previous error */ /* previous error */
dbg(DEBUG_ISO, "%s: skb=NULL", __func__); gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
gigaset_rcv_error(NULL, bcs->cs, bcs); gigaset_rcv_error(NULL, bcs->cs, bcs);
} else if (procskb->len < 2) { } else if (procskb->len < 2) {
notice("received short frame (%d octets)", procskb->len); dev_notice(bcs->cs->dev, "received short frame (%d octets)\n",
procskb->len);
bcs->hw.bas->runts++; bcs->hw.bas->runts++;
gigaset_rcv_error(procskb, bcs->cs, bcs); gigaset_rcv_error(procskb, bcs->cs, bcs);
} else if (bcs->fcs != PPP_GOODFCS) { } else if (bcs->fcs != PPP_GOODFCS) {
notice("frame check error (0x%04x)", bcs->fcs); dev_notice(bcs->cs->dev, "frame check error (0x%04x)\n",
bcs->fcs);
bcs->hw.bas->fcserrs++; bcs->hw.bas->fcserrs++;
gigaset_rcv_error(procskb, bcs->cs, bcs); gigaset_rcv_error(procskb, bcs->cs, bcs);
} else { } else {
procskb->len -= 2; /* subtract FCS */ procskb->len -= 2; /* subtract FCS */
procskb->tail -= 2; procskb->tail -= 2;
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)",
"%s: good frame (%d octets)", __func__, procskb->len); __func__, procskb->len);
dump_bytes(DEBUG_STREAM, dump_bytes(DEBUG_STREAM,
"rcv data", procskb->data, procskb->len); "rcv data", procskb->data, procskb->len);
bcs->hw.bas->goodbytes += procskb->len; bcs->hw.bas->goodbytes += procskb->len;
@ -595,7 +597,7 @@ static inline void hdlc_done(struct bc_state *bcs)
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN); skb_reserve(bcs->skb, HW_HDR_LEN);
else else
err("could not allocate skb"); dev_err(bcs->cs->dev, "could not allocate skb\n");
bcs->fcs = PPP_INITFCS; bcs->fcs = PPP_INITFCS;
} }
@ -610,14 +612,14 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
return; return;
} }
notice("received partial byte (%d bits)", inbits); dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
bcs->hw.bas->alignerrs++; bcs->hw.bas->alignerrs++;
gigaset_rcv_error(bcs->skb, bcs->cs, bcs); gigaset_rcv_error(bcs->skb, bcs->cs, bcs);
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN); skb_reserve(bcs->skb, HW_HDR_LEN);
else else
err("could not allocate skb"); dev_err(bcs->cs->dev, "could not allocate skb\n");
bcs->fcs = PPP_INITFCS; bcs->fcs = PPP_INITFCS;
} }
@ -870,7 +872,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
if (unlikely((skb = bcs->skb) == NULL)) { if (unlikely((skb = bcs->skb) == NULL)) {
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
if (!skb) { if (!skb) {
err("could not allocate skb"); dev_err(bcs->cs->dev, "could not allocate skb\n");
return; return;
} }
skb_reserve(skb, HW_HDR_LEN); skb_reserve(skb, HW_HDR_LEN);
@ -888,7 +890,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
gigaset_rcv_skb(skb, bcs->cs, bcs); gigaset_rcv_skb(skb, bcs->cs, bcs);
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
if (!skb) { if (!skb) {
err("could not allocate skb"); dev_err(bcs->cs->dev,
"could not allocate skb\n");
return; return;
} }
skb_reserve(bcs->skb, HW_HDR_LEN); skb_reserve(bcs->skb, HW_HDR_LEN);
@ -921,7 +924,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
case '\r': case '\r':
case '\n': case '\n':
/* end of line */ /* end of line */
dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)", gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
__func__, cbytes); __func__, cbytes);
cs->cbytes = cbytes; cs->cbytes = cbytes;
gigaset_handle_modem_response(cs); gigaset_handle_modem_response(cs);
@ -932,7 +935,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
if (cbytes < MAX_RESP_SIZE - 1) if (cbytes < MAX_RESP_SIZE - 1)
cbytes++; cbytes++;
else else
warn("response too large"); dev_warn(cs->dev, "response too large\n");
} }
} }
@ -951,12 +954,12 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
head = atomic_read(&inbuf->head); head = atomic_read(&inbuf->head);
while (head != (tail = atomic_read(&inbuf->tail))) { while (head != (tail = atomic_read(&inbuf->tail))) {
dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
if (head > tail) if (head > tail)
tail = RBUFSIZE; tail = RBUFSIZE;
src = inbuf->data + head; src = inbuf->data + head;
numbytes = tail - head; numbytes = tail - head;
dbg(DEBUG_INTR, "processing %u bytes", numbytes); gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
if (atomic_read(&cs->mstate) == MS_LOCKED) { if (atomic_read(&cs->mstate) == MS_LOCKED) {
gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
@ -971,7 +974,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
head += numbytes; head += numbytes;
if (head == RBUFSIZE) if (head == RBUFSIZE)
head = 0; head = 0;
dbg(DEBUG_INTR, "setting head to %u", head); gig_dbg(DEBUG_INTR, "setting head to %u", head);
atomic_set(&inbuf->head, head); atomic_set(&inbuf->head, head);
} }
} }
@ -999,8 +1002,8 @@ int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
len = skb->len; len = skb->len;
skb_queue_tail(&bcs->squeue, skb); skb_queue_tail(&bcs->squeue, skb);
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d",
"%s: skb queued, qlen=%d", __func__, skb_queue_len(&bcs->squeue)); __func__, skb_queue_len(&bcs->squeue));
/* tasklet submits URB if necessary */ /* tasklet submits URB if necessary */
tasklet_schedule(&bcs->hw.bas->sent_tasklet); tasklet_schedule(&bcs->hw.bas->sent_tasklet);

View file

@ -50,7 +50,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
return -ENOMEM; return -ENOMEM;
} }
dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting); wait_event(cs->waitqueue, !cs->waiting);
@ -65,7 +65,7 @@ static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
/* free sysfs for device */ /* free sysfs for device */
void gigaset_free_dev_sysfs(struct usb_interface *interface) void gigaset_free_dev_sysfs(struct usb_interface *interface)
{ {
dbg(DEBUG_INIT, "removing sysfs entries"); gig_dbg(DEBUG_INIT, "removing sysfs entries");
device_remove_file(&interface->dev, &dev_attr_cidmode); device_remove_file(&interface->dev, &dev_attr_cidmode);
} }
EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
/* initialize sysfs for device */ /* initialize sysfs for device */
void gigaset_init_dev_sysfs(struct usb_interface *interface) void gigaset_init_dev_sysfs(struct usb_interface *interface)
{ {
dbg(DEBUG_INIT, "setting up sysfs"); gig_dbg(DEBUG_INIT, "setting up sysfs");
device_create_file(&interface->dev, &dev_attr_cidmode); device_create_file(&interface->dev, &dev_attr_cidmode);
} }
EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs);

View file

@ -126,17 +126,17 @@ struct usb_cardstate {
atomic_t busy; /* bulk output in progress */ atomic_t busy; /* bulk output in progress */
/* Output buffer */ /* Output buffer */
unsigned char *bulk_out_buffer; /* send buffer */ unsigned char *bulk_out_buffer;
int bulk_out_size; /* send buffer size */ int bulk_out_size;
__u8 bulk_out_endpointAddr; /* bulk out endpoint */ __u8 bulk_out_endpointAddr;
struct urb *bulk_out_urb; /* bulk out urb */ struct urb *bulk_out_urb;
/* Input buffer */ /* Input buffer */
int rcvbuf_size; /* rcv buffer */ int rcvbuf_size;
struct urb *read_urb; /* rcv buffer size */ struct urb *read_urb;
__u8 int_in_endpointAddr; /* int in endpoint */ __u8 int_in_endpointAddr;
char bchars[6]; /* request 0x19 */ char bchars[6]; /* for request 0x19 */
}; };
struct usb_bc_state {}; struct usb_bc_state {};
@ -151,16 +151,16 @@ static inline unsigned tiocm_to_gigaset(unsigned state)
static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
unsigned new_state) unsigned new_state)
{ {
struct usb_device *udev = cs->hw.usb->udev;
unsigned mask, val; unsigned mask, val;
int r; int r;
mask = tiocm_to_gigaset(old_state ^ new_state); mask = tiocm_to_gigaset(old_state ^ new_state);
val = tiocm_to_gigaset(new_state); val = tiocm_to_gigaset(new_state);
dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask); gig_dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask);
// don't use this in an interrupt/BH // don't use this in an interrupt/BH
r = usb_control_msg(cs->hw.usb->udev, r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 7, 0x41,
usb_sndctrlpipe(cs->hw.usb->udev, 0), 7, 0x41,
(val & 0xff) | ((mask & 0xff) << 8), 0, (val & 0xff) | ((mask & 0xff) << 8), 0,
NULL, 0, 2000 /* timeout? */); NULL, 0, 2000 /* timeout? */);
if (r < 0) if (r < 0)
@ -171,30 +171,29 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
static int set_value(struct cardstate *cs, u8 req, u16 val) static int set_value(struct cardstate *cs, u8 req, u16 val)
{ {
struct usb_device *udev = cs->hw.usb->udev;
int r, r2; int r, r2;
dbg(DEBUG_USBREQ, "request %02x (%04x)", (unsigned)req, (unsigned)val); gig_dbg(DEBUG_USBREQ, "request %02x (%04x)",
r = usb_control_msg(cs->hw.usb->udev, (unsigned)req, (unsigned)val);
usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x12, 0x41, r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x12, 0x41,
0xf /*?*/, 0, 0xf /*?*/, 0, NULL, 0, 2000 /*?*/);
NULL, 0, 2000 /*?*/); /* no idea, what this does */ /* no idea what this does */
if (r < 0) { if (r < 0) {
err("error %d on request 0x12", -r); dev_err(&udev->dev, "error %d on request 0x12\n", -r);
return r; return r;
} }
r = usb_control_msg(cs->hw.usb->udev, r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), req, 0x41,
usb_sndctrlpipe(cs->hw.usb->udev, 0), req, 0x41, val, 0, NULL, 0, 2000 /*?*/);
val, 0,
NULL, 0, 2000 /*?*/);
if (r < 0) if (r < 0)
err("error %d on request 0x%02x", -r, (unsigned)req); dev_err(&udev->dev, "error %d on request 0x%02x\n",
-r, (unsigned)req);
r2 = usb_control_msg(cs->hw.usb->udev, r2 = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41,
0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/); 0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/);
if (r2 < 0) if (r2 < 0)
err("error %d on request 0x19", -r2); dev_err(&udev->dev, "error %d on request 0x19\n", -r2);
return r < 0 ? r : (r2 < 0 ? r2 : 0); return r < 0 ? r : (r2 < 0 ? r2 : 0);
} }
@ -222,8 +221,8 @@ static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
case B115200: rate = 115200; break; case B115200: rate = 115200; break;
default: default:
rate = 9600; rate = 9600;
err("unsupported baudrate request 0x%x," dev_err(cs->dev, "unsupported baudrate request 0x%x,"
" using default of B9600", cflag); " using default of B9600\n", cflag);
} }
val = 0x383fff / rate + 1; val = 0x383fff / rate + 1;
@ -252,7 +251,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
case CS8: case CS8:
val |= 8 << 8; break; val |= 8 << 8; break;
default: default:
err("CSIZE was not CS5-CS8, using default of 8"); dev_err(cs->dev, "CSIZE was not CS5-CS8, using default of 8\n");
val |= 8 << 8; val |= 8 << 8;
break; break;
} }
@ -317,10 +316,10 @@ static void gigaset_modem_fill(unsigned long data)
unsigned long flags; unsigned long flags;
int again; int again;
dbg(DEBUG_OUTPUT, "modem_fill"); gig_dbg(DEBUG_OUTPUT, "modem_fill");
if (atomic_read(&cs->hw.usb->busy)) { if (atomic_read(&cs->hw.usb->busy)) {
dbg(DEBUG_OUTPUT, "modem_fill: busy"); gig_dbg(DEBUG_OUTPUT, "modem_fill: busy");
return; return;
} }
@ -331,9 +330,9 @@ static void gigaset_modem_fill(unsigned long data)
cb = cs->cmdbuf; cb = cs->cmdbuf;
spin_unlock_irqrestore(&cs->cmdlock, flags); spin_unlock_irqrestore(&cs->cmdlock, flags);
if (cb) { /* commands to send? */ if (cb) { /* commands to send? */
dbg(DEBUG_OUTPUT, "modem_fill: cb"); gig_dbg(DEBUG_OUTPUT, "modem_fill: cb");
if (send_cb(cs, cb) < 0) { if (send_cb(cs, cb) < 0) {
dbg(DEBUG_OUTPUT, gig_dbg(DEBUG_OUTPUT,
"modem_fill: send_cb failed"); "modem_fill: send_cb failed");
again = 1; /* no callback will be again = 1; /* no callback will be
called! */ called! */
@ -341,16 +340,16 @@ static void gigaset_modem_fill(unsigned long data)
} else { /* skbs to send? */ } else { /* skbs to send? */
bcs->tx_skb = skb_dequeue(&bcs->squeue); bcs->tx_skb = skb_dequeue(&bcs->squeue);
if (bcs->tx_skb) if (bcs->tx_skb)
dbg(DEBUG_INTR, gig_dbg(DEBUG_INTR,
"Dequeued skb (Adr: %lx)!", "Dequeued skb (Adr: %lx)!",
(unsigned long) bcs->tx_skb); (unsigned long) bcs->tx_skb);
} }
} }
if (bcs->tx_skb) { if (bcs->tx_skb) {
dbg(DEBUG_OUTPUT, "modem_fill: tx_skb"); gig_dbg(DEBUG_OUTPUT, "modem_fill: tx_skb");
if (write_modem(cs) < 0) { if (write_modem(cs) < 0) {
dbg(DEBUG_OUTPUT, gig_dbg(DEBUG_OUTPUT,
"modem_fill: write_modem failed"); "modem_fill: write_modem failed");
// FIXME should we tell the LL? // FIXME should we tell the LL?
again = 1; /* no callback will be called! */ again = 1; /* no callback will be called! */
@ -377,12 +376,11 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
inbuf = (struct inbuf_t *) urb->context; inbuf = (struct inbuf_t *) urb->context;
IFNULLRET(inbuf); IFNULLRET(inbuf);
cs = inbuf->cs; cs = inbuf->cs;
IFNULLGOTO(cs, exit); IFNULLRET(cs);
IFNULLGOTO(cardstate, exit);
if (!atomic_read(&cs->connected)) { if (!atomic_read(&cs->connected)) {
err("%s: disconnected", __func__); err("%s: disconnected", __func__);
goto exit; return;
} }
if (!urb->status) { if (!urb->status) {
@ -391,29 +389,31 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
if (numbytes) { if (numbytes) {
src = inbuf->rcvbuf; src = inbuf->rcvbuf;
if (unlikely(*src)) if (unlikely(*src))
warn("%s: There was no leading 0, but 0x%02x!", dev_warn(cs->dev,
"%s: There was no leading 0, but 0x%02x!\n",
__func__, (unsigned) *src); __func__, (unsigned) *src);
++src; /* skip leading 0x00 */ ++src; /* skip leading 0x00 */
--numbytes; --numbytes;
if (gigaset_fill_inbuf(inbuf, src, numbytes)) { if (gigaset_fill_inbuf(inbuf, src, numbytes)) {
dbg(DEBUG_INTR, "%s-->BH", __func__); gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
gigaset_schedule_event(inbuf->cs); gigaset_schedule_event(inbuf->cs);
} }
} else } else
dbg(DEBUG_INTR, "Received zero block length"); gig_dbg(DEBUG_INTR, "Received zero block length");
resubmit = 1; resubmit = 1;
} else { } else {
/* The urb might have been killed. */ /* The urb might have been killed. */
dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d", gig_dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d",
__func__, urb->status); __func__, urb->status);
if (urb->status != -ENOENT) /* not killed */ if (urb->status != -ENOENT) /* not killed */
resubmit = 1; resubmit = 1;
} }
exit:
if (resubmit) { if (resubmit) {
r = usb_submit_urb(urb, SLAB_ATOMIC); r = usb_submit_urb(urb, SLAB_ATOMIC);
if (r) if (r)
err("error %d when resubmitting urb.", -r); dev_err(cs->dev, "error %d when resubmitting urb.\n",
-r);
} }
} }
@ -431,9 +431,10 @@ static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
} }
#endif #endif
if (urb->status) if (urb->status)
err("bulk transfer failed (status %d)", -urb->status); dev_err(cs->dev, "bulk transfer failed (status %d)\n",
-urb->status);
/* That's all we can do. Communication problems /* That's all we can do. Communication problems
are handeled by timeouts or network protocols */ are handled by timeouts or network protocols. */
atomic_set(&cs->hw.usb->busy, 0); atomic_set(&cs->hw.usb->busy, 0);
tasklet_schedule(&cs->write_tasklet); tasklet_schedule(&cs->write_tasklet);
@ -453,7 +454,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
spin_lock_irqsave(&cs->cmdlock, flags); spin_lock_irqsave(&cs->cmdlock, flags);
cs->cmdbytes -= cs->curlen; cs->cmdbytes -= cs->curlen;
dbg(DEBUG_OUTPUT, "send_cb: sent %u bytes, %u left", gig_dbg(DEBUG_OUTPUT, "send_cb: sent %u bytes, %u left",
cs->curlen, cs->cmdbytes); cs->curlen, cs->cmdbytes);
cs->cmdbuf = cb = cb->next; cs->cmdbuf = cb = cb->next;
if (cb) { if (cb) {
@ -480,12 +481,13 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
cb->offset += count; cb->offset += count;
cb->len -= count; cb->len -= count;
atomic_set(&ucs->busy, 1); atomic_set(&ucs->busy, 1);
dbg(DEBUG_OUTPUT, "send_cb: send %d bytes", count); gig_dbg(DEBUG_OUTPUT, "send_cb: send %d bytes", count);
status = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); status = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
if (status) { if (status) {
atomic_set(&ucs->busy, 0); atomic_set(&ucs->busy, 0);
err("could not submit urb (error %d).", dev_err(cs->dev,
"could not submit urb (error %d)\n",
-status); -status);
cb->len = 0; /* skip urb => remove cb+wakeup cb->len = 0; /* skip urb => remove cb+wakeup
in next loop cycle */ in next loop cycle */
@ -516,7 +518,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
return 0; return 0;
if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) {
err("%s: out of memory", __func__); dev_err(cs->dev, "%s: out of memory\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
@ -562,10 +564,11 @@ static int gigaset_chars_in_buffer(struct cardstate *cs)
static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
{ {
#ifdef CONFIG_GIGASET_UNDOCREQ #ifdef CONFIG_GIGASET_UNDOCREQ
struct usb_device *udev = cs->hw.usb->udev;
gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf, 0); gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf, 0);
memcpy(cs->hw.usb->bchars, buf, 6); memcpy(cs->hw.usb->bchars, buf, 6);
return usb_control_msg(cs->hw.usb->udev, return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41,
0, 0, &buf, 6, 2000); 0, 0, &buf, 6, 2000);
#else #else
return -EINVAL; return -EINVAL;
@ -636,7 +639,7 @@ static int write_modem(struct cardstate *cs)
IFNULLRETVAL(bcs->tx_skb, -EINVAL); IFNULLRETVAL(bcs->tx_skb, -EINVAL);
dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len); gig_dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len);
ret = -ENODEV; ret = -ENODEV;
IFNULLGOTO(ucs->bulk_out_buffer, error); IFNULLGOTO(ucs->bulk_out_buffer, error);
@ -662,19 +665,19 @@ static int write_modem(struct cardstate *cs)
ucs->bulk_out_buffer, count, ucs->bulk_out_buffer, count,
gigaset_write_bulk_callback, cs); gigaset_write_bulk_callback, cs);
atomic_set(&ucs->busy, 1); atomic_set(&ucs->busy, 1);
dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count); gig_dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count);
ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
if (ret) { if (ret) {
err("could not submit urb (error %d).", -ret); dev_err(cs->dev, "could not submit urb (error %d)\n", -ret);
atomic_set(&ucs->busy, 0); atomic_set(&ucs->busy, 0);
} }
if (!bcs->tx_skb->len) { if (!bcs->tx_skb->len) {
/* skb sent completely */ /* skb sent completely */
gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0? gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0?
dbg(DEBUG_INTR, gig_dbg(DEBUG_INTR, "kfree skb (Adr: %lx)!",
"kfree skb (Adr: %lx)!", (unsigned long) bcs->tx_skb); (unsigned long) bcs->tx_skb);
dev_kfree_skb_any(bcs->tx_skb); dev_kfree_skb_any(bcs->tx_skb);
bcs->tx_skb = NULL; bcs->tx_skb = NULL;
} }
@ -700,7 +703,8 @@ static int gigaset_probe(struct usb_interface *interface,
int buffer_size; int buffer_size;
int alt; int alt;
info("%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", gig_dbg(DEBUG_ANY,
"%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
__func__, le16_to_cpu(udev->descriptor.idVendor), __func__, le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct)); le16_to_cpu(udev->descriptor.idProduct));
@ -717,7 +721,7 @@ static int gigaset_probe(struct usb_interface *interface,
ifnum = hostif->desc.bInterfaceNumber; // FIXME ? ifnum = hostif->desc.bInterfaceNumber; // FIXME ?
if (alt != 0 || ifnum != 0) { if (alt != 0 || ifnum != 0) {
warn("ifnum %d, alt %d", ifnum, alt); dev_warn(&udev->dev, "ifnum %d, alt %d\n", ifnum, alt);
return -ENODEV; return -ENODEV;
} }
@ -725,20 +729,27 @@ static int gigaset_probe(struct usb_interface *interface,
* *
*/ */
if (hostif->desc.bInterfaceClass != 255) { if (hostif->desc.bInterfaceClass != 255) {
info("%s: Device matched, but iface_desc[%d]->bInterfaceClass==%d !", dev_info(&udev->dev,
"%s: Device matched but iface_desc[%d]->bInterfaceClass==%d!\n",
__func__, ifnum, hostif->desc.bInterfaceClass); __func__, ifnum, hostif->desc.bInterfaceClass);
return -ENODEV; return -ENODEV;
} }
info("%s: Device matched ... !", __func__); dev_info(&udev->dev, "%s: Device matched ... !\n", __func__);
cs = gigaset_getunassignedcs(driver); cs = gigaset_getunassignedcs(driver);
if (!cs) { if (!cs) {
warn("No free cardstate!"); dev_warn(&udev->dev, "no free cardstate\n");
return -ENODEV; return -ENODEV;
} }
ucs = cs->hw.usb; ucs = cs->hw.usb;
/* save off device structure ptrs for later use */
usb_get_dev(udev);
ucs->udev = udev;
ucs->interface = interface;
cs->dev = &udev->dev;
endpoint = &hostif->endpoint[0].desc; endpoint = &hostif->endpoint[0].desc;
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
@ -746,14 +757,14 @@ static int gigaset_probe(struct usb_interface *interface,
ucs->bulk_out_endpointAddr = endpoint->bEndpointAddress; ucs->bulk_out_endpointAddr = endpoint->bEndpointAddress;
ucs->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); ucs->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!ucs->bulk_out_buffer) { if (!ucs->bulk_out_buffer) {
err("Couldn't allocate bulk_out_buffer"); dev_err(cs->dev, "Couldn't allocate bulk_out_buffer\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL); ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->bulk_out_urb) { if (!ucs->bulk_out_urb) {
err("Couldn't allocate bulk_out_buffer"); dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
@ -761,12 +772,10 @@ static int gigaset_probe(struct usb_interface *interface,
endpoint = &hostif->endpoint[1].desc; endpoint = &hostif->endpoint[1].desc;
atomic_set(&ucs->busy, 0); atomic_set(&ucs->busy, 0);
ucs->udev = udev;
ucs->interface = interface;
ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL); ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->read_urb) { if (!ucs->read_urb) {
err("No free urbs available"); dev_err(cs->dev, "No free urbs available\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
@ -775,7 +784,7 @@ static int gigaset_probe(struct usb_interface *interface,
ucs->int_in_endpointAddr = endpoint->bEndpointAddress; ucs->int_in_endpointAddr = endpoint->bEndpointAddress;
cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL); cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL);
if (!cs->inbuf[0].rcvbuf) { if (!cs->inbuf[0].rcvbuf) {
err("Couldn't allocate rcvbuf"); dev_err(cs->dev, "Couldn't allocate rcvbuf\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
@ -789,7 +798,7 @@ static int gigaset_probe(struct usb_interface *interface,
retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL); retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL);
if (retval) { if (retval) {
err("Could not submit URB!"); dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
goto error; goto error;
} }
@ -820,6 +829,9 @@ error:
usb_free_urb(ucs->read_urb); usb_free_urb(ucs->read_urb);
ucs->read_urb = ucs->bulk_out_urb = NULL; ucs->read_urb = ucs->bulk_out_urb = NULL;
cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
usb_put_dev(ucs->udev);
ucs->udev = NULL;
ucs->interface = NULL;
gigaset_unassign(cs); gigaset_unassign(cs);
return retval; return retval;
} }
@ -840,7 +852,6 @@ static void gigaset_disconnect(struct usb_interface *interface)
usb_set_intfdata(interface, NULL); usb_set_intfdata(interface, NULL);
ucs = cs->hw.usb; ucs = cs->hw.usb;
usb_kill_urb(ucs->read_urb); usb_kill_urb(ucs->read_urb);
//info("GigaSet USB device #%d will be disconnected", minor);
gigaset_stop(cs); gigaset_stop(cs);