Commit 784d5858 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by Linus Torvalds

[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: default avatarHansjoerg Lipp <hjlipp@web.de>
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ec81b5e6
...@@ -51,7 +51,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -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, ...@@ -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 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -154,39 +154,37 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
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 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -200,9 +198,11 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
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 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -225,7 +225,8 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
} 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 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -233,7 +234,7 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
#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 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -241,8 +242,8 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
#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 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -251,7 +252,7 @@ static inline int hdlc_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)) {
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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 @@ void gigaset_m10x_input(struct inbuf_t *inbuf) ...@@ -441,7 +446,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
} }
} }
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) ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -206,9 +206,9 @@ static inline void dump_urb(enum debuglevel level, const char *tag, ...@@ -206,9 +206,9 @@ static inline void dump_urb(enum debuglevel level, const char *tag,
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
int i; int i;
IFNULLRET(tag); IFNULLRET(tag);
dbg(level, "%s urb(0x%08lx)->{", tag, (unsigned long) urb); gig_dbg(level, "%s urb(0x%08lx)->{", tag, (unsigned long) urb);
if (urb) { if (urb) {
dbg(level, gig_dbg(level,
" dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, " " dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, "
"status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,", "status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,",
(unsigned long) urb->dev, (unsigned long) urb->dev,
...@@ -217,32 +217,33 @@ static inline void dump_urb(enum debuglevel level, const char *tag, ...@@ -217,32 +217,33 @@ static inline void dump_urb(enum debuglevel level, const char *tag,
usb_pipein(urb->pipe) ? "in" : "out", usb_pipein(urb->pipe) ? "in" : "out",
urb->status, (unsigned long) urb->hcpriv, urb->status, (unsigned long) urb->hcpriv,
urb->transfer_flags); urb->transfer_flags);
dbg(level, gig_dbg(level,
" transfer_buffer=0x%08lx[%d], actual_length=%d, " " transfer_buffer=0x%08lx[%d], actual_length=%d, "
"bandwidth=%d, setup_packet=0x%08lx,", "bandwidth=%d, setup_packet=0x%08lx,",
(unsigned long) urb->transfer_buffer, (unsigned long) urb->transfer_buffer,
urb->transfer_buffer_length, urb->actual_length, urb->transfer_buffer_length, urb->actual_length,
urb->bandwidth, (unsigned long) urb->setup_packet); urb->bandwidth, (unsigned long) urb->setup_packet);
dbg(level, gig_dbg(level,
" start_frame=%d, number_of_packets=%d, interval=%d, " " start_frame=%d, number_of_packets=%d, interval=%d, "
"error_count=%d,", "error_count=%d,",
urb->start_frame, urb->number_of_packets, urb->interval, urb->start_frame, urb->number_of_packets, urb->interval,
urb->error_count); urb->error_count);
dbg(level, gig_dbg(level,
" context=0x%08lx, complete=0x%08lx, iso_frame_desc[]={", " context=0x%08lx, complete=0x%08lx, "
"iso_frame_desc[]={",
(unsigned long) urb->context, (unsigned long) urb->context,
(unsigned long) urb->complete); (unsigned long) urb->complete);
for (i = 0; i < urb->number_of_packets; i++) { for (i = 0; i < urb->number_of_packets; i++) {
struct usb_iso_packet_descriptor *pifd struct usb_iso_packet_descriptor *pifd
= &urb->iso_frame_desc[i]; = &urb->iso_frame_desc[i];
dbg(level, gig_dbg(level,
" {offset=%u, length=%u, actual_length=%u, " " {offset=%u, length=%u, actual_length=%u, "
"status=%u}", "status=%u}",
pifd->offset, pifd->length, pifd->actual_length, pifd->offset, pifd->length, pifd->actual_length,
pifd->status); pifd->status);
} }
} }
dbg(level, "}}"); gig_dbg(level, "}}");
#endif #endif
} }
...@@ -274,8 +275,8 @@ static inline void error_hangup(struct bc_state *bcs) ...@@ -274,8 +275,8 @@ static inline void error_hangup(struct bc_state *bcs)
{ {
struct cardstate *cs = bcs->cs; struct cardstate *cs = bcs->cs;
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY, "%s: scheduling HUP for channel %d",
"%s: scheduling HUP for channel %d", __func__, bcs->channel); __func__, bcs->channel);
if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) { if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) {
//FIXME what should we do? //FIXME what should we do?
...@@ -295,21 +296,20 @@ static inline void error_hangup(struct bc_state *bcs) ...@@ -295,21 +296,20 @@ static inline void error_hangup(struct bc_state *bcs)
static inline void error_reset(struct cardstate *cs) static inline void error_reset(struct cardstate *cs)
{ {
//FIXME try to recover without bothering the user //FIXME try to recover without bothering the user
err("unrecoverable error - please disconnect the Gigaset base to reset"); dev_err(cs->dev,
"unrecoverable error - please disconnect Gigaset base to reset\n");
} }
/* check_pending /* check_pending
* check for completion of pending control request * check for completion of pending control request
* parameter: * parameter:
* urb USB request block of completed request * ucs hardware specific controller state structure
* urb->context = hardware specific controller state structure
*/ */
static void check_pending(struct bas_cardstate *ucs) static void check_pending(struct bas_cardstate *ucs)
{ {
unsigned long flags; unsigned long flags;
IFNULLRET(ucs); IFNULLRET(ucs);
IFNULLRET(cardstate);
spin_lock_irqsave(&ucs->lock, flags); spin_lock_irqsave(&ucs->lock, flags);
switch (ucs->pending) { switch (ucs->pending) {
...@@ -330,8 +330,6 @@ static void check_pending(struct bas_cardstate *ucs) ...@@ -330,8 +330,6 @@ static void check_pending(struct bas_cardstate *ucs)
case HD_CLOSE_ATCHANNEL: case HD_CLOSE_ATCHANNEL:
if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) if (!(atomic_read(&ucs->basstate) & BS_ATOPEN))
ucs->pending = 0; ucs->pending = 0;
//wake_up_interruptible(cs->initwait);
//FIXME need own wait queue?
break; break;
case HD_CLOSE_B1CHANNEL: case HD_CLOSE_B1CHANNEL:
if (!(atomic_read(&ucs->basstate) & BS_B1OPEN)) if (!(atomic_read(&ucs->basstate) & BS_B1OPEN))
...@@ -348,7 +346,9 @@ static void check_pending(struct bas_cardstate *ucs) ...@@ -348,7 +346,9 @@ static void check_pending(struct bas_cardstate *ucs)
* are handled separately and should never end up here * are handled separately and should never end up here
*/ */
default: default:
warn("unknown pending request 0x%02x cleared", ucs->pending); dev_warn(&ucs->interface->dev,
"unknown pending request 0x%02x cleared\n",
ucs->pending);
ucs->pending = 0; ucs->pending = 0;
} }
...@@ -374,19 +374,19 @@ static void cmd_in_timeout(unsigned long data) ...@@ -374,19 +374,19 @@ static void cmd_in_timeout(unsigned long data)
IFNULLRET(ucs); IFNULLRET(ucs);
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
if (!atomic_read(&cs->connected)) { if (unlikely(!atomic_read(&cs->connected))) {
dbg(DEBUG_USBREQ, "%s: disconnected", __func__); gig_dbg(DEBUG_USBREQ, "%s: disconnected", __func__);
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
return; return;
} }
if (!ucs->rcvbuf_size) { if (!ucs->rcvbuf_size) {
dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__); gig_dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__);
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
return; return;
} }
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
err("timeout reading AT response"); dev_err(cs->dev, "timeout reading AT response\n");
error_reset(cs); //FIXME retry? error_reset(cs); //FIXME retry?
} }
...@@ -414,10 +414,12 @@ static int atread_submit(struct cardstate *cs, int timeout) ...@@ -414,10 +414,12 @@ static int atread_submit(struct cardstate *cs, int timeout)
IFNULLRETVAL(ucs, -EINVAL); IFNULLRETVAL(ucs, -EINVAL);
IFNULLRETVAL(ucs->urb_cmd_in, -EINVAL); IFNULLRETVAL(ucs->urb_cmd_in, -EINVAL);
dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)", ucs->rcvbuf_size); gig_dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)",
ucs->rcvbuf_size);
if (ucs->urb_cmd_in->status == -EINPROGRESS) { if (ucs->urb_cmd_in->status == -EINPROGRESS) {
err("could not submit HD_READ_ATMESSAGE: URB busy"); dev_err(cs->dev,
"could not submit HD_READ_ATMESSAGE: URB busy\n");
return -EBUSY; return -EBUSY;
} }
...@@ -433,13 +435,13 @@ static int atread_submit(struct cardstate *cs, int timeout) ...@@ -433,13 +435,13 @@ static int atread_submit(struct cardstate *cs, int timeout)
read_ctrl_callback, cs->inbuf); read_ctrl_callback, cs->inbuf);
if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) {
err("could not submit HD_READ_ATMESSAGE: %s", dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
get_usb_statmsg(ret)); get_usb_statmsg(ret));
return ret; return ret;
} }
if (timeout > 0) { if (timeout > 0) {
dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout); gig_dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
ucs->timer_cmd_in.expires = jiffies + timeout * HZ / 10; ucs->timer_cmd_in.expires = jiffies + timeout * HZ / 10;
ucs->timer_cmd_in.data = (unsigned long) cs; ucs->timer_cmd_in.data = (unsigned long) cs;
ucs->timer_cmd_in.function = cmd_in_timeout; ucs->timer_cmd_in.function = cmd_in_timeout;
...@@ -503,11 +505,12 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) ...@@ -503,11 +505,12 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
case -ECONNRESET: /* canceled (async) */ case -ECONNRESET: /* canceled (async) */
case -EINPROGRESS: /* pending */ case -EINPROGRESS: /* pending */
/* ignore silently */ /* ignore silently */
dbg(DEBUG_USBREQ, gig_dbg(DEBUG_USBREQ, "%s: %s",
"%s: %s", __func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(urb->status));
return; return;
default: /* severe trouble */ default: /* severe trouble */
warn("interrupt read: %s", get_usb_statmsg(urb->status)); dev_warn(cs->dev, "interrupt read: %s\n",
get_usb_statmsg(urb->status));
//FIXME corrective action? resubmission always ok? //FIXME corrective action? resubmission always ok?
goto resubmit; goto resubmit;
} }
...@@ -515,9 +518,8 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) ...@@ -515,9 +518,8 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
l = (unsigned) ucs->int_in_buf[1] + l = (unsigned) ucs->int_in_buf[1] +
(((unsigned) ucs->int_in_buf[2]) << 8); (((unsigned) ucs->int_in_buf[2]) << 8);
dbg(DEBUG_USBREQ, gig_dbg(DEBUG_USBREQ, "<-------%d: 0x%02x (%u [0x%02x 0x%02x])",
"<-------%d: 0x%02x (%u [0x%02x 0x%02x])", urb->actual_length, urb->actual_length, (int)ucs->int_in_buf[0], l,
(int)ucs->int_in_buf[0], l,
(int)ucs->int_in_buf[1], (int)ucs->int_in_buf[2]); (int)ucs->int_in_buf[1], (int)ucs->int_in_buf[2]);
channel = 0; channel = 0;
...@@ -565,7 +567,7 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) ...@@ -565,7 +567,7 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
bcs = cs->bcs + channel; bcs = cs->bcs + channel;
atomic_add((l - BAS_NORMFRAME) * BAS_CORRFRAMES, atomic_add((l - BAS_NORMFRAME) * BAS_CORRFRAMES,
&bcs->hw.bas->corrbytes); &bcs->hw.bas->corrbytes);
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO,
"Flow control (channel %d, sub %d): 0x%02x => %d", "Flow control (channel %d, sub %d): 0x%02x => %d",
channel, bcs->hw.bas->numsub, l, channel, bcs->hw.bas->numsub, l,
atomic_read(&bcs->hw.bas->corrbytes)); atomic_read(&bcs->hw.bas->corrbytes));
...@@ -573,19 +575,21 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) ...@@ -573,19 +575,21 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
case HD_RECEIVEATDATA_ACK: /* AT response ready to be received */ case HD_RECEIVEATDATA_ACK: /* AT response ready to be received */
if (!l) { if (!l) {
warn("HD_RECEIVEATDATA_ACK with length 0 ignored"); dev_warn(cs->dev,
"HD_RECEIVEATDATA_ACK with length 0 ignored\n");
break; break;
} }
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
if (ucs->rcvbuf_size) { if (ucs->rcvbuf_size) {
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
err("receive AT data overrun, %d bytes lost", l); dev_err(cs->dev,
"receive AT data overrun, %d bytes lost\n", l);
error_reset(cs); //FIXME reschedule error_reset(cs); //FIXME reschedule
break; break;
} }
if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) { if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) {
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
err("%s: out of memory, %d bytes lost", __func__, l); dev_err(cs->dev, "out of memory, %d bytes lost\n", l);
error_reset(cs); //FIXME reschedule error_reset(cs); //FIXME reschedule
break; break;
} }
...@@ -601,15 +605,16 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) ...@@ -601,15 +605,16 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
break; break;
case HD_RESET_INTERRUPT_PIPE_ACK: case HD_RESET_INTERRUPT_PIPE_ACK:
dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK"); gig_dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK");
break; break;
case HD_SUSPEND_END: case HD_SUSPEND_END:
dbg(DEBUG_USBREQ, "HD_SUSPEND_END"); gig_dbg(DEBUG_USBREQ, "HD_SUSPEND_END");
break; break;
default: default:
warn("unknown Gigaset signal 0x%02x (%u) ignored", dev_warn(cs->dev,
"unknown Gigaset signal 0x%02x (%u) ignored\n",
(int) ucs->int_in_buf[0], l); (int) ucs->int_in_buf[0], l);
} }
...@@ -618,7 +623,7 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) ...@@ -618,7 +623,7 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
resubmit: resubmit:
status = usb_submit_urb(urb, SLAB_ATOMIC); status = usb_submit_urb(urb, SLAB_ATOMIC);
if (unlikely(status)) { if (unlikely(status)) {
err("could not resubmit interrupt URB: %s", dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
get_usb_statmsg(status)); get_usb_statmsg(status));
error_reset(cs); error_reset(cs);
} }
...@@ -649,14 +654,14 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) ...@@ -649,14 +654,14 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
IFNULLRET(ucs); IFNULLRET(ucs);
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
if (!atomic_read(&cs->connected)) { if (unlikely(!atomic_read(&cs->connected))) {
warn("%s: disconnected", __func__); warn("%s: disconnected", __func__);
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
return; return;
} }
if (!ucs->rcvbuf_size) { if (!ucs->rcvbuf_size) {
warn("%s: no receive in progress", __func__); dev_warn(cs->dev, "%s: no receive in progress\n", __func__);
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
return; return;
} }
...@@ -667,11 +672,13 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) ...@@ -667,11 +672,13 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
case 0: /* normal completion */ case 0: /* normal completion */
numbytes = urb->actual_length; numbytes = urb->actual_length;
if (unlikely(numbytes == 0)) { if (unlikely(numbytes == 0)) {
warn("control read: empty block received"); dev_warn(cs->dev,
"control read: empty block received\n");
goto retry; goto retry;
} }
if (unlikely(numbytes != ucs->rcvbuf_size)) { if (unlikely(numbytes != ucs->rcvbuf_size)) {
warn("control read: received %d chars, expected %d", dev_warn(cs->dev,
"control read: received %d chars, expected %d\n",
numbytes, ucs->rcvbuf_size); numbytes, ucs->rcvbuf_size);
if (numbytes > ucs->rcvbuf_size) if (numbytes > ucs->rcvbuf_size)
numbytes = ucs->rcvbuf_size; numbytes = ucs->rcvbuf_size;
...@@ -692,22 +699,25 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) ...@@ -692,22 +699,25 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
case -ECONNRESET: /* canceled (async) */ case -ECONNRESET: /* canceled (async) */
case -EINPROGRESS: /* pending */ case -EINPROGRESS: /* pending */
/* no action necessary */ /* no action necessary */
dbg(DEBUG_USBREQ, gig_dbg(DEBUG_USBREQ, "%s: %s",
"%s: %s", __func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(urb->status));
break; break;
default: /* severe trouble */ default: /* severe trouble */
warn("control read: %s", get_usb_statmsg(urb->status)); dev_warn(cs->dev, "control read: %s\n",
get_usb_statmsg(urb->status));
retry: retry:
if (ucs->retry_cmd_in++ < BAS_RETRY) { if (ucs->retry_cmd_in++ < BAS_RETRY) {
notice("control read: retry %d", ucs->retry_cmd_in); dev_notice(cs->dev, "control read: retry %d\n",
ucs->retry_cmd_in);
if (atread_submit(cs, BAS_TIMEOUT) >= 0) { if (atread_submit(cs, BAS_TIMEOUT) >= 0) {
/* resubmitted - bypass regular exit block */ /* resubmitted - bypass regular exit block */
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
return; return;
} }
} else { } else {
err("control read: giving up after %d tries", dev_err(cs->dev,
"control read: giving up after %d tries\n",
ucs->retry_cmd_in); ucs->retry_cmd_in);
} }
error_reset(cs); error_reset(cs);
...@@ -718,7 +728,7 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) ...@@ -718,7 +728,7 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
ucs->rcvbuf_size = 0; ucs->rcvbuf_size = 0;
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
if (have_data) { if (have_data) {
dbg(DEBUG_INTR, "%s-->BH", __func__); gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
gigaset_schedule_event(cs); gigaset_schedule_event(cs);
} }
} }
...@@ -744,8 +754,8 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs) ...@@ -744,8 +754,8 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs)
/* status codes not worth bothering the tasklet with */ /* status codes not worth bothering the tasklet with */
if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET || if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
urb->status == -EINPROGRESS)) { urb->status == -EINPROGRESS)) {
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO, "%s: %s",
"%s: %s", __func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(urb->status));
return; return;
} }
...@@ -771,15 +781,17 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs) ...@@ -771,15 +781,17 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs)
urb->iso_frame_desc[i].actual_length = 0; urb->iso_frame_desc[i].actual_length = 0;
} }
if (likely(atomic_read(&ubc->running))) { if (likely(atomic_read(&ubc->running))) {
urb->dev = bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */ /* urb->dev is clobbered by USB subsystem */
urb->dev = bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP; urb->transfer_flags = URB_ISO_ASAP;
urb->number_of_packets = BAS_NUMFRAMES; urb->number_of_packets = BAS_NUMFRAMES;
dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
__func__); __func__);
rc = usb_submit_urb(urb, SLAB_ATOMIC); rc = usb_submit_urb(urb, SLAB_ATOMIC);
if (unlikely(rc != 0)) { if (unlikely(rc != 0)) {
err("could not resubmit isochronous read URB: %s", dev_err(bcs->cs->dev,
get_usb_statmsg(rc)); "could not resubmit isochronous read "
"URB: %s\n", get_usb_statmsg(rc));
dump_urb(DEBUG_ISO, "isoc read", urb); dump_urb(DEBUG_ISO, "isoc read", urb);
error_hangup(bcs); error_hangup(bcs);
} }
...@@ -808,8 +820,8 @@ static void write_iso_callback(struct urb *urb, struct pt_regs *regs) ...@@ -808,8 +820,8 @@ static void write_iso_callback(struct urb *urb, struct pt_regs *regs)
/* status codes not worth bothering the tasklet with */ /* status codes not worth bothering the tasklet with */
if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET || if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
urb->status == -EINPROGRESS)) { urb->status == -EINPROGRESS)) {
dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO, "%s: %s",
"%s: %s", __func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(urb->status));
return; return;
} }
...@@ -854,7 +866,7 @@ static int starturbs(struct bc_state *bcs) ...@@ -854,7 +866,7 @@ static int starturbs(struct bc_state *bcs)
for (k = 0; k < BAS_INURBS; k++) { for (k = 0; k < BAS_INURBS; k++) {
urb = ubc->isoinurbs[k]; urb = ubc->isoinurbs[k];
if (!urb) { if (!urb) {
err("isoinurbs[%d]==NULL", k); dev_err(bcs->cs->dev, "isoinurbs[%d]==NULL\n", k);
rc = -EFAULT; rc = -EFAULT;
goto error; goto error;
} }
...@@ -877,7 +889,8 @@ static int starturbs(struct bc_state *bcs) ...@@ -877,7 +889,8 @@ static int starturbs(struct bc_state *bcs)
dump_urb(DEBUG_ISO, "Initial isoc read", urb); dump_urb(DEBUG_ISO, "Initial isoc read", urb);
if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
err("could not submit isochronous read URB %d: %s", dev_err(bcs->cs->dev,
"could not submit isochronous read URB %d: %s\n",
k, get_usb_statmsg(rc)); k, get_usb_statmsg(rc));
goto error; goto error;
} }
...@@ -890,7 +903,7 @@ static int starturbs(struct bc_state *bcs) ...@@ -890,7 +903,7 @@ static int starturbs(struct bc_state *bcs)
for (k = 0; k < BAS_OUTURBS; ++k) { for (k = 0; k < BAS_OUTURBS; ++k) {
urb = ubc->isoouturbs[k].urb; urb = ubc->isoouturbs[k].urb;
if (!urb) { if (!urb) {
err("isoouturbs[%d].urb==NULL", k); dev_err(bcs->cs->dev, "isoouturbs[%d].urb==NULL\n", k);
rc = -EFAULT; rc = -EFAULT;
goto error; goto error;
} }
...@@ -917,7 +930,8 @@ static int starturbs(struct bc_state *bcs) ...@@ -917,7 +930,8 @@ static int starturbs(struct bc_state *bcs)
dump_urb(DEBUG_ISO, "Initial isoc write", urb); dump_urb(DEBUG_ISO, "Initial isoc write", urb);
rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC);
if (rc != 0) { if (rc != 0) {
err("could not submit isochronous write URB %d: %s", dev_err(bcs->cs->dev,
"could not submit isochronous write URB %d: %s\n",
k, get_usb_statmsg(rc)); k, get_usb_statmsg(rc));
goto error; goto error;
} }
...@@ -947,13 +961,15 @@ static void stopurbs(struct bas_bc_state *ubc) ...@@ -947,13 +961,15 @@ static void stopurbs(struct bas_bc_state *ubc)
for (k = 0; k < BAS_INURBS; ++k) { for (k = 0; k < BAS_INURBS; ++k) {
rc = usb_unlink_urb(ubc->isoinurbs[k]); rc = usb_unlink_urb(ubc->isoinurbs[k]);
dbg(DEBUG_ISO, "%s: isoc input URB %d unlinked, result = %d", gig_dbg(DEBUG_ISO,
"%s: isoc input URB %d unlinked, result = %d",
__func__, k, rc); __func__, k, rc);
} }
for (k = 0; k < BAS_OUTURBS; ++k) { for (k = 0; k < BAS_OUTURBS; ++k) {
rc = usb_unlink_urb(ubc->isoouturbs[k].urb); rc = usb_unlink_urb(ubc->isoouturbs[k].urb);
dbg(DEBUG_ISO, "%s: isoc output URB %d unlinked, result = %d", gig_dbg(DEBUG_ISO,
"%s: isoc output URB %d unlinked, result = %d",
__func__, k, rc); __func__, k, rc);
} }
} }
...@@ -984,7 +1000,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -984,7 +1000,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
ubc = ucx->bcs->hw.bas; ubc = ucx->bcs->hw.bas;
IFNULLRETVAL(ubc, -EFAULT); IFNULLRETVAL(ubc, -EFAULT);
urb->dev = ucx->bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */ /* urb->dev is clobbered by USB subsystem */
urb->dev = ucx->bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP; urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = ubc->isooutbuf->data; urb->transfer_buffer = ubc->isooutbuf->data;
urb->transfer_buffer_length = sizeof(ubc->isooutbuf->data); urb->transfer_buffer_length = sizeof(ubc->isooutbuf->data);
...@@ -995,7 +1012,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -995,7 +1012,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
/* compute frame length according to flow control */ /* compute frame length according to flow control */
ifd->length = BAS_NORMFRAME; ifd->length = BAS_NORMFRAME;
if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) { if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) {
dbg(DEBUG_ISO, "%s: corrbytes=%d", __func__, corrbytes); gig_dbg(DEBUG_ISO, "%s: corrbytes=%d",
__func__, corrbytes);
if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME) if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME)
corrbytes = BAS_HIGHFRAME - BAS_NORMFRAME; corrbytes = BAS_HIGHFRAME - BAS_NORMFRAME;
else if (corrbytes < BAS_LOWFRAME - BAS_NORMFRAME) else if (corrbytes < BAS_LOWFRAME - BAS_NORMFRAME)
...@@ -1003,18 +1021,20 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -1003,18 +1021,20 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
ifd->length += corrbytes; ifd->length += corrbytes;
atomic_add(-corrbytes, &ubc->corrbytes); atomic_add(-corrbytes, &ubc->corrbytes);
} }
//dbg(DEBUG_ISO, "%s: frame %d length=%d", __func__, nframe, ifd->length);
/* retrieve block of data to send */ /* retrieve block of data to send */
ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf, ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf,
ifd->length); ifd->length);
if (ifd->offset < 0) { if (ifd->offset < 0) {
if (ifd->offset == -EBUSY) { if (ifd->offset == -EBUSY) {
dbg(DEBUG_ISO, "%s: buffer busy at frame %d", gig_dbg(DEBUG_ISO,
"%s: buffer busy at frame %d",
__func__, nframe); __func__, nframe);
/* tasklet will be restarted from gigaset_send_skb() */ /* tasklet will be restarted from
gigaset_send_skb() */
} else { } else {
err("%s: buffer error %d at frame %d", dev_err(ucx->bcs->cs->dev,
"%s: buffer error %d at frame %d\n",
__func__, ifd->offset, nframe); __func__, ifd->offset, nframe);
return ifd->offset; return ifd->offset;
} }
...@@ -1026,7 +1046,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -1026,7 +1046,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
} }
if ((urb->number_of_packets = nframe) > 0) { if ((urb->number_of_packets = nframe) > 0) {
if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
err("could not submit isochronous write URB: %s", dev_err(ucx->bcs->cs->dev,
"could not submit isochronous write URB: %s\n",
get_usb_statmsg(rc)); get_usb_statmsg(rc));
dump_urb(DEBUG_ISO, "isoc write", urb); dump_urb(DEBUG_ISO, "isoc write", urb);
return rc; return rc;
...@@ -1071,7 +1092,7 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1071,7 +1092,7 @@ static void write_iso_tasklet(unsigned long data)
} }
if (unlikely(!(atomic_read(&ubc->running)))) { if (unlikely(!(atomic_read(&ubc->running)))) {
dbg(DEBUG_ISO, "%s: not running", __func__); gig_dbg(DEBUG_ISO, "%s: not running", __func__);
return; return;
} }
...@@ -1083,7 +1104,7 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1083,7 +1104,7 @@ static void write_iso_tasklet(unsigned long data)
ubc->isooutovfl = NULL; ubc->isooutovfl = NULL;
spin_unlock_irqrestore(&ubc->isooutlock, flags); spin_unlock_irqrestore(&ubc->isooutlock, flags);
if (ovfl) { if (ovfl) {
err("isochronous write buffer underrun - buy a faster machine :-)"); dev_err(cs->dev, "isochronous write buffer underrun\n");
error_hangup(bcs); error_hangup(bcs);
break; break;
} }
...@@ -1106,7 +1127,8 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1106,7 +1127,8 @@ static void write_iso_tasklet(unsigned long data)
spin_unlock_irqrestore(&ubc->isooutlock, flags); spin_unlock_irqrestore(&ubc->isooutlock, flags);
if (next) { if (next) {
/* couldn't put it back */ /* couldn't put it back */
err("losing isochronous write URB"); dev_err(cs->dev,
"losing isochronous write URB\n");
error_hangup(bcs); error_hangup(bcs);
} }
} }
...@@ -1123,14 +1145,16 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1123,14 +1145,16 @@ static void write_iso_tasklet(unsigned long data)
* successfully sent * successfully sent
* - all following frames are not sent at all * - all following frames are not sent at all
*/ */
dbg(DEBUG_ISO, "%s: URB partially completed", __func__); gig_dbg(DEBUG_ISO, "%s: URB partially completed",
__func__);
offset = done->limit; /* just in case */ offset = done->limit; /* just in case */
for (i = 0; i < BAS_NUMFRAMES; i++) { for (i = 0; i < BAS_NUMFRAMES; i++) {
ifd = &urb->iso_frame_desc[i]; ifd = &urb->iso_frame_desc[i];
if (ifd->status || if (ifd->status ||
ifd->actual_length != ifd->length) { ifd->actual_length != ifd->length) {
warn("isochronous write: frame %d: %s, " dev_warn(cs->dev,
"only %d of %d bytes sent", "isochronous write: frame %d: %s, "
"only %d of %d bytes sent\n",
i, get_usb_statmsg(ifd->status), i, get_usb_statmsg(ifd->status),
ifd->actual_length, ifd->length); ifd->actual_length, ifd->length);
offset = (ifd->offset + offset = (ifd->offset +
...@@ -1145,8 +1169,9 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1145,8 +1169,9 @@ static void write_iso_tasklet(unsigned long data)
ifd = &urb->iso_frame_desc[i]; ifd = &urb->iso_frame_desc[i];
if (ifd->status != -EINPROGRESS if (ifd->status != -EINPROGRESS
|| ifd->actual_length != 0) { || ifd->actual_length != 0) {
warn("isochronous write: frame %d: %s, " dev_warn(cs->dev,
"%d of %d bytes sent", "isochronous write: frame %d: %s, "
"%d of %d bytes sent\n",
i, get_usb_statmsg(ifd->status), i, get_usb_statmsg(ifd->status),
ifd->actual_length, ifd->length); ifd->actual_length, ifd->length);
offset = (ifd->offset + offset = (ifd->offset +
...@@ -1158,11 +1183,11 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1158,11 +1183,11 @@ static void write_iso_tasklet(unsigned long data)
#endif #endif
break; break;
case -EPIPE: //FIXME is this the code for "underrun"? case -EPIPE: //FIXME is this the code for "underrun"?
err("isochronous write stalled"); dev_err(cs->dev, "isochronous write stalled\n");
error_hangup(bcs); error_hangup(bcs);
break; break;
default: /* severe trouble */ default: /* severe trouble */
warn("isochronous write: %s", dev_warn(cs->dev, "isochronous write: %s\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(urb->status));
} }
...@@ -1191,7 +1216,7 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1191,7 +1216,7 @@ static void write_iso_tasklet(unsigned long data)
if (gigaset_isoc_buildframe(bcs, skb->data, len) == -EAGAIN) { if (gigaset_isoc_buildframe(bcs, skb->data, len) == -EAGAIN) {
/* insufficient buffer space, push back onto queue */ /* insufficient buffer space, push back onto queue */
skb_queue_head(&bcs->squeue, skb); skb_queue_head(&bcs->squeue, skb);
dbg(DEBUG_ISO, "%s: skb requeued, qlen=%d", gig_dbg(DEBUG_ISO, "%s: skb requeued, qlen=%d",
__func__, skb_queue_len(&bcs->squeue)); __func__, skb_queue_len(&bcs->squeue));
break; break;
} }
...@@ -1229,7 +1254,7 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1229,7 +1254,7 @@ static void read_iso_tasklet(unsigned long data)
/* loop while more completed URBs arrive in the meantime */ /* loop while more completed URBs arrive in the meantime */
for (;;) { for (;;) {
if (!atomic_read(&cs->connected)) { if (unlikely(!atomic_read(&cs->connected))) {
warn("%s: disconnected", __func__); warn("%s: disconnected", __func__);
return; return;
} }
...@@ -1242,14 +1267,19 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1242,14 +1267,19 @@ static void read_iso_tasklet(unsigned long data)
} }
ubc->isoindone = NULL; ubc->isoindone = NULL;
if (unlikely(ubc->loststatus != -EINPROGRESS)) { if (unlikely(ubc->loststatus != -EINPROGRESS)) {
warn("isochronous read overrun, dropped URB with status: %s, %d bytes lost", dev_warn(cs->dev,
get_usb_statmsg(ubc->loststatus), ubc->isoinlost); "isochronous read overrun, "
"dropped URB with status: %s, %d bytes lost\n",
get_usb_statmsg(ubc->loststatus),
ubc->isoinlost);
ubc->loststatus = -EINPROGRESS; ubc->loststatus = -EINPROGRESS;
} }
spin_unlock_irqrestore(&ubc->isoinlock, flags); spin_unlock_irqrestore(&ubc->isoinlock, flags);
if (unlikely(!(atomic_read(&ubc->running)))) { if (unlikely(!(atomic_read(&ubc->running)))) {
dbg(DEBUG_ISO, "%s: channel not running, dropped URB with status: %s", gig_dbg(DEBUG_ISO,
"%s: channel not running, "
"dropped URB with status: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(urb->status));
return; return;
} }
...@@ -1259,21 +1289,22 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1259,21 +1289,22 @@ static void read_iso_tasklet(unsigned long data)
break; break;
case -EXDEV: /* inspect individual frames case -EXDEV: /* inspect individual frames
(we do that anyway) */ (we do that anyway) */
dbg(DEBUG_ISO, "%s: URB partially completed", __func__); gig_dbg(DEBUG_ISO, "%s: URB partially completed",
__func__);
break; break;
case -ENOENT: case -ENOENT:
case -ECONNRESET: case -ECONNRESET:
dbg(DEBUG_ISO, "%s: URB canceled", __func__); gig_dbg(DEBUG_ISO, "%s: URB canceled", __func__);
continue; /* -> skip */ continue; /* -> skip */
case -EINPROGRESS: /* huh? */ case -EINPROGRESS: /* huh? */
dbg(DEBUG_ISO, "%s: URB still pending", __func__); gig_dbg(DEBUG_ISO, "%s: URB still pending", __func__);
continue; /* -> skip */ continue; /* -> skip */
case -EPIPE: case -EPIPE:
err("isochronous read stalled"); dev_err(cs->dev, "isochronous read stalled\n");
error_hangup(bcs); error_hangup(bcs);
continue; /* -> skip */ continue; /* -> skip */
default: /* severe trouble */ default: /* severe trouble */
warn("isochronous read: %s", dev_warn(cs->dev, "isochronous read: %s\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(urb->status));
goto error; goto error;
} }
...@@ -1282,24 +1313,34 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1282,24 +1313,34 @@ static void read_iso_tasklet(unsigned long data)
totleft = urb->actual_length; totleft = urb->actual_length;
for (frame = 0; totleft > 0 && frame < BAS_NUMFRAMES; frame++) { for (frame = 0; totleft > 0 && frame < BAS_NUMFRAMES; frame++) {
if (unlikely(urb->iso_frame_desc[frame].status)) { if (unlikely(urb->iso_frame_desc[frame].status)) {
warn("isochronous read: frame %d: %s", frame, dev_warn(cs->dev,
get_usb_statmsg(urb->iso_frame_desc[frame].status)); "isochronous read: frame %d: %s\n",
frame,
get_usb_statmsg(
urb->iso_frame_desc[frame].status));
break; break;
} }
numbytes = urb->iso_frame_desc[frame].actual_length; numbytes = urb->iso_frame_desc[frame].actual_length;
if (unlikely(numbytes > BAS_MAXFRAME)) { if (unlikely(numbytes > BAS_MAXFRAME)) {
warn("isochronous read: frame %d: numbytes (%d) > BAS_MAXFRAME", dev_warn(cs->dev,
"isochronous read: frame %d: "
"numbytes (%d) > BAS_MAXFRAME\n",
frame, numbytes); frame, numbytes);
break; break;
} }
if (unlikely(numbytes > totleft)) { if (unlikely(numbytes > totleft)) {
warn("isochronous read: frame %d: numbytes (%d) > totleft (%d)", dev_warn(cs->dev,
"isochronous read: frame %d: "
"numbytes (%d) > totleft (%d)\n",
frame, numbytes, totleft); frame, numbytes, totleft);
break; break;
} }
offset = urb->iso_frame_desc[frame].offset; offset = urb->iso_frame_desc[frame].offset;
if (unlikely(offset + numbytes > BAS_INBUFSIZE)) { if (unlikely(offset + numbytes > BAS_INBUFSIZE)) {
warn("isochronous read: frame %d: offset (%d) + numbytes (%d) > BAS_INBUFSIZE", dev_warn(cs->dev,
"isochronous read: frame %d: "
"offset (%d) + numbytes (%d) "
"> BAS_INBUFSIZE\n",
frame, offset, numbytes); frame, offset, numbytes);
break; break;
} }
...@@ -1307,7 +1348,8 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1307,7 +1348,8 @@ static void read_iso_tasklet(unsigned long data)
totleft -= numbytes; totleft -= numbytes;
} }
if (unlikely(totleft > 0)) if (unlikely(totleft > 0))
warn("isochronous read: %d data bytes missing", dev_warn(cs->dev,
"isochronous read: %d data bytes missing\n",
totleft); totleft);
error: error:
...@@ -1316,11 +1358,13 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1316,11 +1358,13 @@ static void read_iso_tasklet(unsigned long data)
urb->iso_frame_desc[frame].status = 0; urb->iso_frame_desc[frame].status = 0;
urb->iso_frame_desc[frame].actual_length = 0; urb->iso_frame_desc[frame].actual_length = 0;
} }
urb->dev = bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */ /* urb->dev is clobbered by USB subsystem */
urb->dev = bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP; urb->transfer_flags = URB_ISO_ASAP;
urb->number_of_packets = BAS_NUMFRAMES; urb->number_of_packets = BAS_NUMFRAMES;
if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
err("could not resubmit isochronous read URB: %s", dev_err(cs->dev,
"could not resubmit isochronous read URB: %s\n",
get_usb_statmsg(rc)); get_usb_statmsg(rc));
dump_urb(DEBUG_ISO, "resubmit iso read", urb); dump_urb(DEBUG_ISO, "resubmit iso read", urb);
error_hangup(bcs); error_hangup(bcs);
...@@ -1357,33 +1401,34 @@ static void req_timeout(unsigned long data) ...@@ -1357,33 +1401,34 @@ static void req_timeout(unsigned long data)
switch (pending) { switch (pending) {
case 0: /* no pending request */ case 0: /* no pending request */
dbg(DEBUG_USBREQ, "%s: no request pending", __func__); gig_dbg(DEBUG_USBREQ, "%s: no request pending", __func__);
break; break;
case HD_OPEN_ATCHANNEL: case HD_OPEN_ATCHANNEL:
err("timeout opening AT channel"); dev_err(bcs->cs->dev, "timeout opening AT channel\n");
error_reset(bcs->cs); error_reset(bcs->cs);
break; break;
case HD_OPEN_B2CHANNEL: case HD_OPEN_B2CHANNEL:
case HD_OPEN_B1CHANNEL: case HD_OPEN_B1CHANNEL:
err("timeout opening channel %d", bcs->channel + 1); dev_err(bcs->cs->dev, "timeout opening channel %d\n",
bcs->channel + 1);
error_hangup(bcs); error_hangup(bcs);
break; break;
case HD_CLOSE_ATCHANNEL: case HD_CLOSE_ATCHANNEL:
err("timeout closing AT channel"); dev_err(bcs->cs->dev, "timeout closing AT channel\n");
//wake_up_interruptible(cs->initwait);
//FIXME need own wait queue?
break; break;
case HD_CLOSE_B2CHANNEL: case HD_CLOSE_B2CHANNEL:
case HD_CLOSE_B1CHANNEL: case HD_CLOSE_B1CHANNEL:
err("timeout closing channel %d", bcs->channel + 1); dev_err(bcs->cs->dev, "timeout closing channel %d\n",
bcs->channel + 1);
break; break;
default: default:
warn("request 0x%02x timed out, clearing", pending); dev_warn(bcs->cs->dev, "request 0x%02x timed out, clearing\n",
pending);
} }
} }
...@@ -1406,7 +1451,8 @@ static void write_ctrl_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1406,7 +1451,8 @@ static void write_ctrl_callback(struct urb *urb, struct pt_regs *regs)
ucs = (struct bas_cardstate *) urb->context; ucs = (struct bas_cardstate *) urb->context;
spin_lock_irqsave(&ucs->lock, flags); spin_lock_irqsave(&ucs->lock, flags);
if (urb->status && ucs->pending) { if (urb->status && ucs->pending) {
err("control request 0x%02x failed: %s", dev_err(&ucs->interface->dev,
"control request 0x%02x failed: %s\n",
ucs->pending, get_usb_statmsg(urb->status)); ucs->pending, get_usb_statmsg(urb->status));
del_timer(&ucs->timer_ctrl); del_timer(&ucs->timer_ctrl);
ucs->pending = 0; ucs->pending = 0;
...@@ -1446,18 +1492,21 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout) ...@@ -1446,18 +1492,21 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
IFNULLRETVAL(ucs, -EINVAL); IFNULLRETVAL(ucs, -EINVAL);
IFNULLRETVAL(ucs->urb_ctrl, -EINVAL); IFNULLRETVAL(ucs->urb_ctrl, -EINVAL);
dbg(DEBUG_USBREQ, "-------> 0x%02x (%d)", req, val); gig_dbg(DEBUG_USBREQ, "-------> 0x%02x (%d)", req, val);
spin_lock_irqsave(&ucs->lock, flags); spin_lock_irqsave(&ucs->lock, flags);
if (ucs->pending) { if (ucs->pending) {
spin_unlock_irqrestore(&ucs->lock, flags); spin_unlock_irqrestore(&ucs->lock, flags);
err("submission of request 0x%02x failed: request 0x%02x still pending", dev_err(bcs->cs->dev,
"submission of request 0x%02x failed: "
"request 0x%02x still pending\n",
req, ucs->pending); req, ucs->pending);
return -EBUSY; return -EBUSY;
} }
if (ucs->urb_ctrl->status == -EINPROGRESS) { if (ucs->urb_ctrl->status == -EINPROGRESS) {
spin_unlock_irqrestore(&ucs->lock, flags); spin_unlock_irqrestore(&ucs->lock, flags);
err("could not submit request 0x%02x: URB busy", req); dev_err(bcs->cs->dev,
"could not submit request 0x%02x: URB busy\n", req);
return -EBUSY; return -EBUSY;
} }
...@@ -1471,7 +1520,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout) ...@@ -1471,7 +1520,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
(unsigned char*) &ucs->dr_ctrl, NULL, 0, (unsigned char*) &ucs->dr_ctrl, NULL, 0,
write_ctrl_callback, ucs); write_ctrl_callback, ucs);
if ((ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC)) != 0) { if ((ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC)) != 0) {
err("could not submit request 0x%02x: %s", dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
req, get_usb_statmsg(ret)); req, get_usb_statmsg(ret));
spin_unlock_irqrestore(&ucs->lock, flags); spin_unlock_irqrestore(&ucs->lock, flags);
return ret; return ret;
...@@ -1479,7 +1528,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout) ...@@ -1479,7 +1528,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
ucs->pending = req; ucs->pending = req;
if (timeout > 0) { if (timeout > 0) {
dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout); gig_dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
ucs->timer_ctrl.expires = jiffies + timeout * HZ / 10; ucs->timer_ctrl.expires = jiffies + timeout * HZ / 10;
ucs->timer_ctrl.data = (unsigned long) bcs; ucs->timer_ctrl.data = (unsigned long) bcs;
ucs->timer_ctrl.function = req_timeout; ucs->timer_ctrl.function = req_timeout;
...@@ -1505,7 +1554,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs) ...@@ -1505,7 +1554,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
IFNULLRETVAL(bcs, -EINVAL); IFNULLRETVAL(bcs, -EINVAL);
if ((ret = starturbs(bcs)) < 0) { if ((ret = starturbs(bcs)) < 0) {
err("could not start isochronous I/O for channel %d", dev_err(bcs->cs->dev,
"could not start isochronous I/O for channel %d\n",
bcs->channel + 1); bcs->channel + 1);
error_hangup(bcs); error_hangup(bcs);
return ret; return ret;
...@@ -1513,7 +1563,7 @@ static int gigaset_init_bchannel(struct bc_state *bcs) ...@@ -1513,7 +1563,7 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL;
if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) {
err("could not open channel %d: %s", dev_err(bcs->cs->dev, "could not open channel %d: %s\n",
bcs->channel + 1, get_usb_statmsg(ret)); bcs->channel + 1, get_usb_statmsg(ret));
stopurbs(bcs->hw.bas); stopurbs(bcs->hw.bas);
error_hangup(bcs); error_hangup(bcs);
...@@ -1546,7 +1596,8 @@ static int gigaset_close_bchannel(struct bc_state *bcs) ...@@ -1546,7 +1596,8 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL;
if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0)
err("could not submit HD_CLOSE_BxCHANNEL request: %s", dev_err(bcs->cs->dev,
"could not submit HD_CLOSE_BxCHANNEL request: %s\n",
get_usb_statmsg(ret)); get_usb_statmsg(ret));
return ret; return ret;
} }
...@@ -1570,7 +1621,7 @@ static void complete_cb(struct cardstate *cs) ...@@ -1570,7 +1621,7 @@ static void complete_cb(struct cardstate *cs)
/* unqueue completed buffer */ /* unqueue completed buffer */
cs->cmdbytes -= cs->curlen; cs->cmdbytes -= cs->curlen;
dbg(DEBUG_TRANSCMD | DEBUG_LOCKCMD, gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD,
"write_command: sent %u bytes, %u left", "write_command: sent %u bytes, %u left",
cs->curlen, cs->cmdbytes); cs->curlen, cs->cmdbytes);
if ((cs->cmdbuf = cb->next) != NULL) { if ((cs->cmdbuf = cb->next) != NULL) {
...@@ -1616,21 +1667,26 @@ static void write_command_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1616,21 +1667,26 @@ static void write_command_callback(struct urb *urb, struct pt_regs *regs)
case -ECONNRESET: /* canceled (async) */ case -ECONNRESET: /* canceled (async) */
case -EINPROGRESS: /* pending */ case -EINPROGRESS: /* pending */
/* ignore silently */ /* ignore silently */
dbg(DEBUG_USBREQ, gig_dbg(DEBUG_USBREQ, "%s: %s",
"%s: %s", __func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(urb->status));
return; return;
default: /* any failure */ default: /* any failure */
if (++ucs->retry_cmd_out > BAS_RETRY) { if (++ucs->retry_cmd_out > BAS_RETRY) {
warn("command write: %s, giving up after %d retries", dev_warn(cs->dev,
get_usb_statmsg(urb->status), ucs->retry_cmd_out); "command write: %s, "
"giving up after %d retries\n",
get_usb_statmsg(urb->status),
ucs->retry_cmd_out);
break; break;
} }
if (cs->cmdbuf == NULL) { if (cs->cmdbuf == NULL) {
warn("command write: %s, cannot retry - cmdbuf gone", dev_warn(cs->dev,
"command write: %s, "
"cannot retry - cmdbuf gone\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(urb->status));
break; break;
} }
notice("command write: %s, retry %d", dev_notice(cs->dev, "command write: %s, retry %d\n",
get_usb_statmsg(urb->status), ucs->retry_cmd_out); get_usb_statmsg(urb->status), ucs->retry_cmd_out);
if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0) if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0)
/* resubmitted - bypass regular exit block */ /* resubmitted - bypass regular exit block */
...@@ -1659,7 +1715,7 @@ static void atrdy_timeout(unsigned long data) ...@@ -1659,7 +1715,7 @@ static void atrdy_timeout(unsigned long data)
ucs = cs->hw.bas; ucs = cs->hw.bas;
IFNULLRET(ucs); IFNULLRET(ucs);
warn("timeout waiting for HD_READY_SEND_ATDATA"); dev_warn(cs->dev, "timeout waiting for HD_READY_SEND_ATDATA\n");
/* fake the missing signal - what else can I do? */ /* fake the missing signal - what else can I do? */
update_basstate(ucs, BS_ATREADY, BS_ATTIMER); update_basstate(ucs, BS_ATREADY, BS_ATTIMER);
...@@ -1688,10 +1744,11 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) ...@@ -1688,10 +1744,11 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
IFNULLRETVAL(ucs, -EFAULT); IFNULLRETVAL(ucs, -EFAULT);
IFNULLRETVAL(ucs->urb_cmd_out, -EFAULT); IFNULLRETVAL(ucs->urb_cmd_out, -EFAULT);
dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len); gig_dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len);
if (ucs->urb_cmd_out->status == -EINPROGRESS) { if (ucs->urb_cmd_out->status == -EINPROGRESS) {
err("could not submit HD_WRITE_ATMESSAGE: URB busy"); dev_err(cs->dev,
"could not submit HD_WRITE_ATMESSAGE: URB busy\n");
return -EBUSY; return -EBUSY;
} }
...@@ -1706,7 +1763,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) ...@@ -1706,7 +1763,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
write_command_callback, cs); write_command_callback, cs);
if ((ret = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC)) != 0) { if ((ret = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC)) != 0) {
err("could not submit HD_WRITE_ATMESSAGE: %s", dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
get_usb_statmsg(ret)); get_usb_statmsg(ret));
return ret; return ret;
} }
...@@ -1716,8 +1773,8 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) ...@@ -1716,8 +1773,8 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
/* start timeout if necessary */ /* start timeout if necessary */
if (!(atomic_read(&ucs->basstate) & BS_ATTIMER)) { if (!(atomic_read(&ucs->basstate) & BS_ATTIMER)) {
dbg(DEBUG_OUTPUT, gig_dbg(DEBUG_OUTPUT, "setting ATREADY timeout of %d/10 secs",
"setting ATREADY timeout of %d/10 secs", ATRDY_TIMEOUT); ATRDY_TIMEOUT);
ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10; ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10;
ucs->timer_atrdy.data = (unsigned long) cs; ucs->timer_atrdy.data = (unsigned long) cs;
ucs->timer_atrdy.function = atrdy_timeout; ucs->timer_atrdy.function = atrdy_timeout;
...@@ -1749,10 +1806,10 @@ static int start_cbsend(struct cardstate *cs) ...@@ -1749,10 +1806,10 @@ static int start_cbsend(struct cardstate *cs)
/* check if AT channel is open */ /* check if AT channel is open */
if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) { if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) {
dbg(DEBUG_TRANSCMD | DEBUG_LOCKCMD, "AT channel not open"); gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open");
rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT); rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT);
if (rc < 0) { if (rc < 0) {
err("could not open AT channel"); dev_err(cs->dev, "could not open AT channel\n");
/* flush command queue */ /* flush command queue */
spin_lock_irqsave(&cs->cmdlock, flags); spin_lock_irqsave(&cs->cmdlock, flags);
while (cs->cmdbuf != NULL) while (cs->cmdbuf != NULL)
...@@ -1808,8 +1865,8 @@ static int gigaset_write_cmd(struct cardstate *cs, ...@@ -1808,8 +1865,8 @@ static int gigaset_write_cmd(struct cardstate *cs,
DEBUG_TRANSCMD : DEBUG_LOCKCMD, DEBUG_TRANSCMD : DEBUG_LOCKCMD,
"CMD Transmit", len, buf, 0); "CMD Transmit", len, buf, 0);
if (!atomic_read(&cs->connected)) { if (unlikely(!atomic_read(&cs->connected))) {
err("%s: not connected", __func__); err("%s: disconnected", __func__);
return -ENODEV; return -ENODEV;
} }
...@@ -1819,7 +1876,7 @@ static int gigaset_write_cmd(struct cardstate *cs, ...@@ -1819,7 +1876,7 @@ static int gigaset_write_cmd(struct cardstate *cs,
if (len > IF_WRITEBUF) if (len > IF_WRITEBUF)
len = IF_WRITEBUF; len = IF_WRITEBUF;
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;
} }
...@@ -2041,7 +2098,7 @@ static void freeurbs(struct cardstate *cs) ...@@ -2041,7 +2098,7 @@ static void freeurbs(struct cardstate *cs)
for (i = 0; i < BAS_OUTURBS; ++i) for (i = 0; i < BAS_OUTURBS; ++i)
if (ubc->isoouturbs[i].urb) { if (ubc->isoouturbs[i].urb) {
usb_kill_urb(ubc->isoouturbs[i].urb); usb_kill_urb(ubc->isoouturbs[i].urb);
dbg(DEBUG_INIT, gig_dbg(DEBUG_INIT,
"%s: isoc output URB %d/%d unlinked", "%s: isoc output URB %d/%d unlinked",
__func__, j, i); __func__, j, i);
usb_free_urb(ubc->isoouturbs[i].urb); usb_free_urb(ubc->isoouturbs[i].urb);
...@@ -2050,7 +2107,7 @@ static void freeurbs(struct cardstate *cs) ...@@ -2050,7 +2107,7 @@ static void freeurbs(struct cardstate *cs)
for (i = 0; i < BAS_INURBS; ++i) for (i = 0; i < BAS_INURBS; ++i)
if (ubc->isoinurbs[i]) { if (ubc->isoinurbs[i]) {
usb_kill_urb(ubc->isoinurbs[i]); usb_kill_urb(ubc->isoinurbs[i]);
dbg(DEBUG_INIT, gig_dbg(DEBUG_INIT,
"%s: isoc input URB %d/%d unlinked", "%s: isoc input URB %d/%d unlinked",
__func__, j, i); __func__, j, i);
usb_free_urb(ubc->isoinurbs[i]); usb_free_urb(ubc->isoinurbs[i]);
...@@ -2059,25 +2116,29 @@ static void freeurbs(struct cardstate *cs) ...@@ -2059,25 +2116,29 @@ static void freeurbs(struct cardstate *cs)
} }
if (ucs->urb_int_in) { if (ucs->urb_int_in) {
usb_kill_urb(ucs->urb_int_in); usb_kill_urb(ucs->urb_int_in);
dbg(DEBUG_INIT, "%s: interrupt input URB unlinked", __func__); gig_dbg(DEBUG_INIT, "%s: interrupt input URB unlinked",
__func__);
usb_free_urb(ucs->urb_int_in); usb_free_urb(ucs->urb_int_in);
ucs->urb_int_in = NULL; ucs->urb_int_in = NULL;
} }
if (ucs->urb_cmd_out) { if (ucs->urb_cmd_out) {
usb_kill_urb(ucs->urb_cmd_out); usb_kill_urb(ucs->urb_cmd_out);
dbg(DEBUG_INIT, "%s: command output URB unlinked", __func__); gig_dbg(DEBUG_INIT, "%s: command output URB unlinked",
__func__);
usb_free_urb(ucs->urb_cmd_out); usb_free_urb(ucs->urb_cmd_out);
ucs->urb_cmd_out = NULL; ucs->urb_cmd_out = NULL;
} }
if (ucs->urb_cmd_in) { if (ucs->urb_cmd_in) {
usb_kill_urb(ucs->urb_cmd_in); usb_kill_urb(ucs->urb_cmd_in);
dbg(DEBUG_INIT, "%s: command input URB unlinked", __func__); gig_dbg(DEBUG_INIT, "%s: command input URB unlinked",
__func__);
usb_free_urb(ucs->urb_cmd_in); usb_free_urb(ucs->urb_cmd_in);
ucs->urb_cmd_in = NULL; ucs->urb_cmd_in = NULL;
} }
if (ucs->urb_ctrl) { if (ucs->urb_ctrl) {
usb_kill_urb(ucs->urb_ctrl); usb_kill_urb(ucs->urb_ctrl);
dbg(DEBUG_INIT, "%s: control output URB unlinked", __func__); gig_dbg(DEBUG_INIT, "%s: control output URB unlinked",
__func__);
usb_free_urb(ucs->urb_ctrl); usb_free_urb(ucs->urb_ctrl);
ucs->urb_ctrl = NULL; ucs->urb_ctrl = NULL;
} }
...@@ -2101,7 +2162,7 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2101,7 +2162,7 @@ static int gigaset_probe(struct usb_interface *interface,
IFNULLRETVAL(udev, -ENODEV); IFNULLRETVAL(udev, -ENODEV);
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY,
"%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", "%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));
...@@ -2112,18 +2173,19 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2112,18 +2173,19 @@ static int gigaset_probe(struct usb_interface *interface,
le16_to_cpu(udev->descriptor.idProduct) != USB_4175_PRODUCT_ID && le16_to_cpu(udev->descriptor.idProduct) != USB_4175_PRODUCT_ID &&
le16_to_cpu(udev->descriptor.idProduct) != USB_SX303_PRODUCT_ID && le16_to_cpu(udev->descriptor.idProduct) != USB_SX303_PRODUCT_ID &&
le16_to_cpu(udev->descriptor.idProduct) != USB_SX353_PRODUCT_ID)) { le16_to_cpu(udev->descriptor.idProduct) != USB_SX353_PRODUCT_ID)) {
dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__); gig_dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__);
return -ENODEV; return -ENODEV;
} }
/* set required alternate setting */ /* set required alternate setting */
hostif = interface->cur_altsetting; hostif = interface->cur_altsetting;
if (hostif->desc.bAlternateSetting != 3) { if (hostif->desc.bAlternateSetting != 3) {
dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY,
"%s: wrong alternate setting %d - trying to switch", "%s: wrong alternate setting %d - trying to switch",
__func__, hostif->desc.bAlternateSetting); __func__, hostif->desc.bAlternateSetting);
if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) { if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) {
warn("usb_set_interface failed, device %d interface %d altsetting %d", dev_warn(&udev->dev, "usb_set_interface failed, "
"device %d interface %d altsetting %d\n",
udev->devnum, hostif->desc.bInterfaceNumber, udev->devnum, hostif->desc.bInterfaceNumber,
hostif->desc.bAlternateSetting); hostif->desc.bAlternateSetting);
return -ENODEV; return -ENODEV;
...@@ -2134,23 +2196,28 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2134,23 +2196,28 @@ static int gigaset_probe(struct usb_interface *interface,
/* Reject application specific interfaces /* Reject application specific interfaces
*/ */
if (hostif->desc.bInterfaceClass != 255) { if (hostif->desc.bInterfaceClass != 255) {
warn("%s: bInterfaceClass == %d", dev_warn(&udev->dev, "%s: bInterfaceClass == %d\n",
__func__, hostif->desc.bInterfaceClass); __func__, hostif->desc.bInterfaceClass);
return -ENODEV; return -ENODEV;
} }
info("%s: Device matched (Vendor: 0x%x, Product: 0x%x)", dev_info(&udev->dev,
"%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n",
__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));
cs = gigaset_getunassignedcs(driver); cs = gigaset_getunassignedcs(driver);
if (!cs) { if (!cs) {
err("%s: no free cardstate", __func__); dev_err(&udev->dev, "no free cardstate\n");
return -ENODEV; return -ENODEV;
} }
ucs = cs->hw.bas; ucs = cs->hw.bas;
/* save off device structure ptrs for later use */
usb_get_dev(udev);
ucs->udev = udev; ucs->udev = udev;
ucs->interface = interface; ucs->interface = interface;
cs->dev = &udev->dev;
/* allocate URBs: /* allocate URBs:
* - one for the interrupt pipe * - one for the interrupt pipe
...@@ -2159,22 +2226,22 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2159,22 +2226,22 @@ static int gigaset_probe(struct usb_interface *interface,
*/ */
ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL); ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_int_in) { if (!ucs->urb_int_in) {
err("No free urbs available"); dev_err(cs->dev, "no free urbs available\n");
goto error; goto error;
} }
ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL); ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_cmd_in) { if (!ucs->urb_cmd_in) {
err("No free urbs available"); dev_err(cs->dev, "no free urbs available\n");
goto error; goto error;
} }
ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL); ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_cmd_out) { if (!ucs->urb_cmd_out) {
err("No free urbs available"); dev_err(cs->dev, "no free urbs available\n");
goto error; goto error;
} }
ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL); ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_ctrl) { if (!ucs->urb_ctrl) {
err("No free urbs available"); dev_err(cs->dev, "no free urbs available\n");
goto error; goto error;
} }
...@@ -2184,7 +2251,7 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2184,7 +2251,7 @@ static int gigaset_probe(struct usb_interface *interface,
ubc->isoouturbs[i].urb = ubc->isoouturbs[i].urb =
usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL); usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL);
if (!ubc->isoouturbs[i].urb) { if (!ubc->isoouturbs[i].urb) {
err("No free urbs available"); dev_err(cs->dev, "no free urbs available\n");
goto error; goto error;
} }
} }
...@@ -2192,7 +2259,7 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2192,7 +2259,7 @@ static int gigaset_probe(struct usb_interface *interface,
ubc->isoinurbs[i] = ubc->isoinurbs[i] =
usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL); usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL);
if (!ubc->isoinurbs[i]) { if (!ubc->isoinurbs[i]) {
err("No free urbs available"); dev_err(cs->dev, "no free urbs available\n");
goto error; goto error;
} }
} }
...@@ -2210,7 +2277,8 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2210,7 +2277,8 @@ static int gigaset_probe(struct usb_interface *interface,
endpoint->bInterval); endpoint->bInterval);
ret = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL); ret = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL);
if (ret) { if (ret) {
err("could not submit interrupt URB: %s", get_usb_statmsg(ret)); dev_err(cs->dev, "could not submit interrupt URB: %s\n",
get_usb_statmsg(ret));
goto error; goto error;
} }
...@@ -2255,7 +2323,7 @@ static void gigaset_disconnect(struct usb_interface *interface) ...@@ -2255,7 +2323,7 @@ static void gigaset_disconnect(struct usb_interface *interface)
ucs = cs->hw.bas; ucs = cs->hw.bas;
IFNULLRET(ucs); IFNULLRET(ucs);
info("disconnecting GigaSet base"); dev_info(cs->dev, "disconnecting GigaSet base");
gigaset_stop(cs); gigaset_stop(cs);
freeurbs(cs); freeurbs(cs);
kfree(ucs->rcvbuf); kfree(ucs->rcvbuf);
...@@ -2337,12 +2405,11 @@ static void __exit bas_gigaset_exit(void) ...@@ -2337,12 +2405,11 @@ static void __exit bas_gigaset_exit(void)
/* from now on, no isdn callback should be possible */ /* from now on, no isdn callback should be possible */
if (atomic_read(&cardstate->hw.bas->basstate) & BS_ATOPEN) { if (atomic_read(&cardstate->hw.bas->basstate) & BS_ATOPEN) {
dbg(DEBUG_ANY, "closing AT channel"); gig_dbg(DEBUG_ANY, "closing AT channel");
if (req_submit(cardstate->bcs, if (req_submit(cardstate->bcs,
HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) { HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) {
/* successfully submitted - wait for completion */ /* successfully submitted */
//wait_event_interruptible(cs->initwait, !cs->hw.bas->pending); //FIXME wait for completion?
//FIXME need own wait queue? wakeup?
} }
} }
......
...@@ -32,9 +32,6 @@ MODULE_PARM_DESC(debug, "debug level"); ...@@ -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, ...@@ -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, ...@@ -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++ = '^'; *out++ = '\\';
if (space) {
*out++ = '@' + *in;
--space;
} }
if (c & 0x80) {
if (space-- <= 0)
break;
*out++ = '~';
c ^= 0x80;
} }
if (c < 0x20 || c == 0x7f) {
if (space-- <= 0)
break;
*out++ = '^';
c ^= 0x40;
}
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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
} }
......
...@@ -444,7 +444,7 @@ static int isdn_getnum(char *p) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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);
} }
...@@ -1416,7 +1426,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1416,7 +1426,7 @@ static void do_action(int action, struct cardstate *cs,
atomic_set(&cs->commands_pending, 1); atomic_set(&cs->commands_pending, 1);
break; break;
case ACT_GETSTRING: /* warning: RING, ZDLE, ... case ACT_GETSTRING: /* warning: RING, ZDLE, ...
are not handled properly any more */ are not handled properly anymore */
at_state->getstring = 1; at_state->getstring = 1;
break; break;
case ACT_SETVER: case ACT_SETVER:
...@@ -1457,7 +1467,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
} }
......
...@@ -106,7 +106,7 @@ extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */ ...@@ -106,7 +106,7 @@ extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */
* DEBUG_INTR. * DEBUG_INTR.
*/ */
enum debuglevel { /* up to 24 bits (atomic_t) */ enum debuglevel { /* up to 24 bits (atomic_t) */
DEBUG_REG = 0x0002,/* serial port I/O register operations */ DEBUG_REG = 0x0002, /* serial port I/O register operations */
DEBUG_OPEN = 0x0004, /* open/close serial port */ DEBUG_OPEN = 0x0004, /* open/close serial port */
DEBUG_INTR = 0x0008, /* interrupt processing */ DEBUG_INTR = 0x0008, /* interrupt processing */
DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on
...@@ -137,45 +137,47 @@ enum debuglevel { /* up to 24 bits (atomic_t) */ ...@@ -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.
* linux/usb.h already contains these but in an obsolete form which clutters
* the log needlessly, and according to the USB maintainer those should be
* removed rather than fixed anyway.
*/
#undef err
#undef info #undef info
#define info(format, arg...) \
printk(KERN_INFO "%s: " format "\n", \
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 #undef warn
#define warn(format, arg...) \ #undef notice
printk(KERN_WARNING "%s: " format "\n", \
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
#undef err #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
#define err(format, arg...) \ format "\n" , ## arg)
printk(KERN_ERR "%s: " format "\n", \ #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) 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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -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 @@ ...@@ -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 * ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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,
"phone: %s,ownmsn: %s, si1: %d, si2: %d)", "ISDN_CMD_DIAL (driver: %d, ch: %ld, "
"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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -22,7 +22,7 @@ static int if_lock(struct cardstate *cs, int *arg) ...@@ -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) ...@@ -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]) ...@@ -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]) ...@@ -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]) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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;
......
...@@ -83,12 +83,12 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -50,7 +50,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, ...@@ -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); ...@@ -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); ...@@ -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);
...@@ -126,17 +126,17 @@ struct usb_cardstate { ...@@ -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) ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
} }
} }
...@@ -426,14 +426,15 @@ static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs) ...@@ -426,14 +426,15 @@ static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
IFNULLRET(cs); IFNULLRET(cs);
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (!atomic_read(&cs->connected)) { if (!atomic_read(&cs->connected)) {
err("%s:not connected", __func__); err("%s: not connected", __func__);
return; return;
} }
#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) ...@@ -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) ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -820,6 +829,9 @@ static int gigaset_probe(struct usb_interface *interface,
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) ...@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment