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
...@@ -41,7 +41,7 @@ static inline int muststuff(unsigned char c) ...@@ -41,7 +41,7 @@ static inline int muststuff(unsigned char c)
* number of processed bytes * number of processed bytes
*/ */
static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes, static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
struct inbuf_t *inbuf) struct inbuf_t *inbuf)
{ {
struct cardstate *cs = inbuf->cs; struct cardstate *cs = inbuf->cs;
unsigned cbytes = cs->cbytes; unsigned cbytes = cs->cbytes;
...@@ -51,8 +51,8 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -51,8 +51,8 @@ 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
cs->dle */ cs->dle */
...@@ -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)
...@@ -93,7 +93,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -93,7 +93,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
* number of processed bytes * number of processed bytes
*/ */
static inline int lock_loop(unsigned char *src, int numbytes, static inline int lock_loop(unsigned char *src, int numbytes,
struct inbuf_t *inbuf) struct inbuf_t *inbuf)
{ {
struct cardstate *cs = inbuf->cs; struct cardstate *cs = inbuf->cs;
...@@ -113,7 +113,7 @@ static inline int lock_loop(unsigned char *src, int numbytes, ...@@ -113,7 +113,7 @@ static inline int lock_loop(unsigned char *src, int numbytes,
* numbytes (all bytes processed) on error --FIXME * numbytes (all bytes processed) on error --FIXME
*/ */
static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
struct inbuf_t *inbuf) struct inbuf_t *inbuf)
{ {
struct cardstate *cs = inbuf->cs; struct cardstate *cs = inbuf->cs;
struct bc_state *bcs = inbuf->bcs; struct bc_state *bcs = inbuf->bcs;
...@@ -154,39 +154,37 @@ byte_stuff: ...@@ -154,39 +154,37 @@ byte_stuff:
c ^= PPP_TRANS; c ^= PPP_TRANS;
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (unlikely(!muststuff(c))) if (unlikely(!muststuff(c)))
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC, "byte stuffed: 0x%02x", c);
"byte stuffed: 0x%02x", c);
#endif #endif
} else if (unlikely(c == PPP_FLAG)) { } else if (unlikely(c == PPP_FLAG)) {
if (unlikely(inputstate & INS_skip_frame)) { if (unlikely(inputstate & INS_skip_frame)) {
if (!(inputstate & INS_have_data)) { /* 7E 7E */ if (!(inputstate & INS_have_data)) { /* 7E 7E */
//dbg(DEBUG_HDLC, "(7e)7e------------------------");
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount; ++bcs->emptycount;
#endif #endif
} else } else
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC,
"7e----------------------------"); "7e----------------------------");
/* end of frame */ /* end of frame */
error = 1; error = 1;
gigaset_rcv_error(NULL, cs, bcs); gigaset_rcv_error(NULL, cs, bcs);
} else if (!(inputstate & INS_have_data)) { /* 7E 7E */ } else if (!(inputstate & INS_have_data)) { /* 7E 7E */
//dbg(DEBUG_HDLC, "(7e)7e------------------------");
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount; ++bcs->emptycount;
#endif #endif
break; break;
} else { } else {
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC,
"7e----------------------------"); "7e----------------------------");
/* end of frame */ /* end of frame */
error = 0; error = 0;
if (unlikely(fcs != PPP_GOODFCS)) { if (unlikely(fcs != PPP_GOODFCS)) {
err("Packet checksum at %lu failed, " dev_err(cs->dev,
"packet is corrupted (%u bytes)!", "Packet checksum at %lu failed, "
"packet is corrupted (%u bytes)!\n",
bcs->rcvbytes, skb->len); bcs->rcvbytes, skb->len);
compskb = NULL; compskb = NULL;
gigaset_rcv_error(compskb, cs, bcs); gigaset_rcv_error(compskb, cs, bcs);
...@@ -200,9 +198,11 @@ byte_stuff: ...@@ -200,9 +198,11 @@ byte_stuff:
skb = NULL; skb = NULL;
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
if (l == 1) { if (l == 1) {
err("invalid packet size (1)!"); dev_err(cs->dev,
"invalid packet size (1)!\n");
error = 1; error = 1;
gigaset_rcv_error(NULL, cs, bcs); gigaset_rcv_error(NULL,
cs, bcs);
} }
} }
if (likely(!(error || if (likely(!(error ||
...@@ -225,7 +225,8 @@ byte_stuff: ...@@ -225,7 +225,8 @@ byte_stuff:
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) { } else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
skb_reserve(skb, HW_HDR_LEN); skb_reserve(skb, HW_HDR_LEN);
} else { } else {
warn("could not allocate new skb"); dev_warn(cs->dev,
"could not allocate new skb\n");
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
} }
...@@ -233,7 +234,7 @@ byte_stuff: ...@@ -233,7 +234,7 @@ byte_stuff:
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
} else if (unlikely(muststuff(c))) { } else if (unlikely(muststuff(c))) {
/* Should not happen. Possible after ZDLE=1<CR><LF>. */ /* Should not happen. Possible after ZDLE=1<CR><LF>. */
dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c); gig_dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c);
#endif #endif
} }
...@@ -241,8 +242,8 @@ byte_stuff: ...@@ -241,8 +242,8 @@ byte_stuff:
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
if (unlikely(!(inputstate & INS_have_data))) { if (unlikely(!(inputstate & INS_have_data))) {
dbg(DEBUG_HDLC, gig_dbg(DEBUG_HDLC, "7e (%d x) ================",
"7e (%d x) ================", bcs->emptycount); bcs->emptycount);
bcs->emptycount = 0; bcs->emptycount = 0;
} }
#endif #endif
...@@ -251,7 +252,7 @@ byte_stuff: ...@@ -251,7 +252,7 @@ byte_stuff:
if (likely(!(inputstate & INS_skip_frame))) { if (likely(!(inputstate & INS_skip_frame))) {
if (unlikely(skb->len == SBUFSIZE)) { if (unlikely(skb->len == SBUFSIZE)) {
warn("received packet too long"); dev_warn(cs->dev, "received packet too long\n");
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = NULL; skb = NULL;
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
...@@ -287,7 +288,7 @@ byte_stuff: ...@@ -287,7 +288,7 @@ byte_stuff:
* numbytes (all bytes processed) on error --FIXME * numbytes (all bytes processed) on error --FIXME
*/ */
static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes, static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
struct inbuf_t *inbuf) struct inbuf_t *inbuf)
{ {
struct cardstate *cs = inbuf->cs; struct cardstate *cs = inbuf->cs;
struct bc_state *bcs = inbuf->bcs; struct bc_state *bcs = inbuf->bcs;
...@@ -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 @@ nextbyte: ...@@ -441,7 +446,7 @@ nextbyte:
} }
} }
dbg(DEBUG_INTR, "setting head to %u", head); gig_dbg(DEBUG_INTR, "setting head to %u", head);
atomic_set(&inbuf->head, head); atomic_set(&inbuf->head, head);
} }
} }
...@@ -476,14 +481,13 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) ...@@ -476,14 +481,13 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
stuf_cnt++; stuf_cnt++;
fcs = crc_ccitt_byte(fcs, *cp++); fcs = crc_ccitt_byte(fcs, *cp++);
} }
fcs ^= 0xffff; /* complement */ fcs ^= 0xffff; /* complement */
/* size of new buffer: original size + number of stuffing bytes /* size of new buffer: original size + number of stuffing bytes
* + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
*/ */
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;
} }
...@@ -505,7 +509,7 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) ...@@ -505,7 +509,7 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
} }
/* Finally add FCS (byte stuffed) and flag sequence */ /* Finally add FCS (byte stuffed) and flag sequence */
c = (fcs & 0x00ff); /* least significant byte first */ c = (fcs & 0x00ff); /* least significant byte first */
if (muststuff(c)) { if (muststuff(c)) {
*(skb_put(hdlc_skb, 1)) = PPP_ESCAPE; *(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
c ^= PPP_TRANS; c ^= PPP_TRANS;
...@@ -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);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -44,13 +44,13 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, ...@@ -44,13 +44,13 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
cs->waiting = 1; cs->waiting = 1;
if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
NULL, value, NULL)) { NULL, value, NULL)) {
cs->waiting = 0; cs->waiting = 0;
up(&cs->sem); up(&cs->sem);
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);
This diff is collapsed.
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