[PATCH] isdn4linux: Siemens Gigaset drivers: logging usage
With Hansjoerg Lipp <hjlipp@web.de> Improve error reporting of the Gigaset drivers, by using the dev_err/dev_warn/dev_info macros from device.h instead of err/warn/info from usb.h whereever possible. Also rename the private dbg macro to gig_dbg in order to avoid confusion with the macro of the same name in usb.h. Signed-off-by: Hansjoerg Lipp <hjlipp@web.de> Signed-off-by: Tilman Schmidt <tilman@imap.cc> Cc: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Родитель
ec81b5e629
Коммит
784d5858aa
|
@ -51,7 +51,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
|
|||
for (;;) {
|
||||
cs->respdata[cbytes] = c;
|
||||
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);
|
||||
cs->cbytes = cbytes;
|
||||
gigaset_handle_modem_response(cs); /* can change
|
||||
|
@ -68,7 +68,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
|
|||
if (cbytes < MAX_RESP_SIZE - 1)
|
||||
cbytes++;
|
||||
else
|
||||
warn("response too large");
|
||||
dev_warn(cs->dev, "response too large\n");
|
||||
}
|
||||
|
||||
if (!numbytes)
|
||||
|
@ -154,39 +154,37 @@ byte_stuff:
|
|||
c ^= PPP_TRANS;
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
if (unlikely(!muststuff(c)))
|
||||
dbg(DEBUG_HDLC,
|
||||
"byte stuffed: 0x%02x", c);
|
||||
gig_dbg(DEBUG_HDLC, "byte stuffed: 0x%02x", c);
|
||||
#endif
|
||||
} else if (unlikely(c == PPP_FLAG)) {
|
||||
if (unlikely(inputstate & INS_skip_frame)) {
|
||||
if (!(inputstate & INS_have_data)) { /* 7E 7E */
|
||||
//dbg(DEBUG_HDLC, "(7e)7e------------------------");
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
++bcs->emptycount;
|
||||
#endif
|
||||
} else
|
||||
dbg(DEBUG_HDLC,
|
||||
gig_dbg(DEBUG_HDLC,
|
||||
"7e----------------------------");
|
||||
|
||||
/* end of frame */
|
||||
error = 1;
|
||||
gigaset_rcv_error(NULL, cs, bcs);
|
||||
} else if (!(inputstate & INS_have_data)) { /* 7E 7E */
|
||||
//dbg(DEBUG_HDLC, "(7e)7e------------------------");
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
++bcs->emptycount;
|
||||
#endif
|
||||
break;
|
||||
} else {
|
||||
dbg(DEBUG_HDLC,
|
||||
gig_dbg(DEBUG_HDLC,
|
||||
"7e----------------------------");
|
||||
|
||||
/* end of frame */
|
||||
error = 0;
|
||||
|
||||
if (unlikely(fcs != PPP_GOODFCS)) {
|
||||
err("Packet checksum at %lu failed, "
|
||||
"packet is corrupted (%u bytes)!",
|
||||
dev_err(cs->dev,
|
||||
"Packet checksum at %lu failed, "
|
||||
"packet is corrupted (%u bytes)!\n",
|
||||
bcs->rcvbytes, skb->len);
|
||||
compskb = NULL;
|
||||
gigaset_rcv_error(compskb, cs, bcs);
|
||||
|
@ -200,9 +198,11 @@ byte_stuff:
|
|||
skb = NULL;
|
||||
inputstate |= INS_skip_frame;
|
||||
if (l == 1) {
|
||||
err("invalid packet size (1)!");
|
||||
dev_err(cs->dev,
|
||||
"invalid packet size (1)!\n");
|
||||
error = 1;
|
||||
gigaset_rcv_error(NULL, cs, bcs);
|
||||
gigaset_rcv_error(NULL,
|
||||
cs, bcs);
|
||||
}
|
||||
}
|
||||
if (likely(!(error ||
|
||||
|
@ -225,7 +225,8 @@ byte_stuff:
|
|||
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
|
||||
skb_reserve(skb, HW_HDR_LEN);
|
||||
} else {
|
||||
warn("could not allocate new skb");
|
||||
dev_warn(cs->dev,
|
||||
"could not allocate new skb\n");
|
||||
inputstate |= INS_skip_frame;
|
||||
}
|
||||
|
||||
|
@ -233,7 +234,7 @@ byte_stuff:
|
|||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
} else if (unlikely(muststuff(c))) {
|
||||
/* 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
|
||||
}
|
||||
|
||||
|
@ -241,8 +242,8 @@ byte_stuff:
|
|||
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
if (unlikely(!(inputstate & INS_have_data))) {
|
||||
dbg(DEBUG_HDLC,
|
||||
"7e (%d x) ================", bcs->emptycount);
|
||||
gig_dbg(DEBUG_HDLC, "7e (%d x) ================",
|
||||
bcs->emptycount);
|
||||
bcs->emptycount = 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -251,7 +252,7 @@ byte_stuff:
|
|||
|
||||
if (likely(!(inputstate & INS_skip_frame))) {
|
||||
if (unlikely(skb->len == SBUFSIZE)) {
|
||||
warn("received packet too long");
|
||||
dev_warn(cs->dev, "received packet too long\n");
|
||||
dev_kfree_skb_any(skb);
|
||||
skb = NULL;
|
||||
inputstate |= INS_skip_frame;
|
||||
|
@ -307,7 +308,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
|
|||
if (likely(!(inputstate & INS_skip_frame))) {
|
||||
if (unlikely(skb->len == SBUFSIZE)) {
|
||||
//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);
|
||||
skb = NULL;
|
||||
inputstate |= INS_skip_frame;
|
||||
|
@ -341,7 +342,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
|
|||
!= NULL)) {
|
||||
skb_reserve(skb, HW_HDR_LEN);
|
||||
} else {
|
||||
warn("could not allocate new skb");
|
||||
dev_warn(cs->dev, "could not allocate new skb\n");
|
||||
inputstate |= INS_skip_frame;
|
||||
}
|
||||
}
|
||||
|
@ -362,13 +363,13 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
|
|||
|
||||
head = atomic_read(&inbuf->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) {
|
||||
cs = inbuf->cs;
|
||||
src = inbuf->data + head;
|
||||
numbytes = (head > tail ? RBUFSIZE : tail) - head;
|
||||
dbg(DEBUG_INTR, "processing %u bytes", numbytes);
|
||||
gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
|
||||
|
||||
while (numbytes) {
|
||||
if (atomic_read(&cs->mstate) == MS_LOCKED) {
|
||||
|
@ -400,13 +401,14 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
|
|||
|
||||
src += procbytes;
|
||||
numbytes -= procbytes;
|
||||
} else { /* DLE-char */
|
||||
} else { /* DLE char */
|
||||
inbuf->inputstate &= ~INS_DLE_char;
|
||||
switch (c) {
|
||||
case 'X': /*begin of command*/
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
if (inbuf->inputstate & INS_command)
|
||||
err("received <DLE> 'X' in command mode");
|
||||
dev_err(cs->dev,
|
||||
"received <DLE> 'X' in command mode\n");
|
||||
#endif
|
||||
inbuf->inputstate |=
|
||||
INS_command | INS_DLE_command;
|
||||
|
@ -414,7 +416,8 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
|
|||
case '.': /*end of command*/
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
if (!(inbuf->inputstate & INS_command))
|
||||
err("received <DLE> '.' in hdlc mode");
|
||||
dev_err(cs->dev,
|
||||
"received <DLE> '.' in hdlc mode\n");
|
||||
#endif
|
||||
inbuf->inputstate &= cs->dle ?
|
||||
~(INS_DLE_command|INS_command)
|
||||
|
@ -422,7 +425,9 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
|
|||
break;
|
||||
//case DLE_FLAG: /*DLE_FLAG in data stream*/ /* schon oben behandelt! */
|
||||
default:
|
||||
err("received 0x10 0x%02x!", (int) c);
|
||||
dev_err(cs->dev,
|
||||
"received 0x10 0x%02x!\n",
|
||||
(int) c);
|
||||
/* FIXME: reset driver?? */
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +446,7 @@ nextbyte:
|
|||
}
|
||||
}
|
||||
|
||||
dbg(DEBUG_INTR, "setting head to %u", head);
|
||||
gig_dbg(DEBUG_INTR, "setting head to %u", head);
|
||||
atomic_set(&inbuf->head, head);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
if (!hdlc_skb) {
|
||||
err("unable to allocate memory for HDLC encoding!");
|
||||
dev_kfree_skb(skb);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -543,7 +547,6 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
|
|||
/* worst case: every byte must be stuffed */
|
||||
iraw_skb = dev_alloc_skb(2*skb->len + tail + head);
|
||||
if (!iraw_skb) {
|
||||
err("unable to allocate memory for HDLC encoding!");
|
||||
dev_kfree_skb(skb);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -584,8 +587,11 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
|
|||
skb = HDLC_Encode(skb, HW_HDR_LEN, 0);
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
||||
skb_queue_tail(&bcs->squeue, skb);
|
||||
tasklet_schedule(&bcs->cs->write_tasklet);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -32,9 +32,6 @@ MODULE_PARM_DESC(debug, "debug level");
|
|||
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 void free_cs(struct cardstate *cs);
|
||||
static void make_valid(struct cardstate *cs, unsigned mask);
|
||||
|
@ -86,6 +83,7 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
|
|||
{
|
||||
unsigned char outbuf[80];
|
||||
unsigned char inbuf[80 - 1];
|
||||
unsigned char c;
|
||||
size_t numin;
|
||||
const unsigned char *in;
|
||||
size_t space = sizeof outbuf - 1;
|
||||
|
@ -99,26 +97,38 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
|
|||
in = inbuf;
|
||||
if (copy_from_user(inbuf, (const unsigned char __user *) buf,
|
||||
numin)) {
|
||||
strncpy(inbuf, "<FAULT>", sizeof inbuf);
|
||||
numin = sizeof "<FAULT>" - 1;
|
||||
gig_dbg(level, "%s (%u bytes) - copy_from_user failed",
|
||||
msg, (unsigned) len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (; numin && space; --numin, ++in) {
|
||||
--space;
|
||||
if (*in >= 32)
|
||||
*out++ = *in;
|
||||
else {
|
||||
while (numin-- > 0) {
|
||||
c = *buf++;
|
||||
if (c == '~' || c == '^' || c == '\\') {
|
||||
if (space-- <= 0)
|
||||
break;
|
||||
*out++ = '\\';
|
||||
}
|
||||
if (c & 0x80) {
|
||||
if (space-- <= 0)
|
||||
break;
|
||||
*out++ = '~';
|
||||
c ^= 0x80;
|
||||
}
|
||||
if (c < 0x20 || c == 0x7f) {
|
||||
if (space-- <= 0)
|
||||
break;
|
||||
*out++ = '^';
|
||||
if (space) {
|
||||
*out++ = '@' + *in;
|
||||
--space;
|
||||
}
|
||||
c ^= 0x40;
|
||||
}
|
||||
if (space-- <= 0)
|
||||
break;
|
||||
*out++ = c;
|
||||
}
|
||||
*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);
|
||||
|
||||
|
@ -171,7 +181,7 @@ int gigaset_enterconfigmode(struct cardstate *cs)
|
|||
return 0;
|
||||
|
||||
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->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR);
|
||||
|
||||
|
@ -184,7 +194,7 @@ static int test_timeout(struct at_state_t *at_state)
|
|||
return 0;
|
||||
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -221,7 +231,7 @@ static void timer_tick(unsigned long data)
|
|||
if (atomic_read(&cs->running)) {
|
||||
mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK));
|
||||
if (timeout) {
|
||||
dbg(DEBUG_CMD, "scheduling timeout");
|
||||
gig_dbg(DEBUG_CMD, "scheduling timeout");
|
||||
tasklet_schedule(&cs->event_tasklet);
|
||||
}
|
||||
}
|
||||
|
@ -235,13 +245,14 @@ int gigaset_get_channel(struct bc_state *bcs)
|
|||
|
||||
spin_lock_irqsave(&bcs->cs->lock, flags);
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
++bcs->use_count;
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
@ -252,13 +263,13 @@ void gigaset_free_channel(struct bc_state *bcs)
|
|||
|
||||
spin_lock_irqsave(&bcs->cs->lock, flags);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
--bcs->use_count;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -271,14 +282,14 @@ int gigaset_get_channels(struct cardstate *cs)
|
|||
for (i = 0; i < cs->channels; ++i)
|
||||
if (cs->bcs[i].use_count) {
|
||||
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;
|
||||
}
|
||||
for (i = 0; i < cs->channels; ++i)
|
||||
++cs->bcs[i].use_count;
|
||||
spin_unlock_irqrestore(&cs->lock, flags);
|
||||
|
||||
dbg(DEBUG_ANY, "allocated all channels");
|
||||
gig_dbg(DEBUG_ANY, "allocated all channels");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -288,7 +299,7 @@ void gigaset_free_channels(struct cardstate *cs)
|
|||
unsigned long flags;
|
||||
int i;
|
||||
|
||||
dbg(DEBUG_ANY, "unblocking all channels");
|
||||
gig_dbg(DEBUG_ANY, "unblocking all channels");
|
||||
spin_lock_irqsave(&cs->lock, flags);
|
||||
for (i = 0; i < cs->channels; ++i)
|
||||
--cs->bcs[i].use_count;
|
||||
|
@ -300,7 +311,7 @@ void gigaset_block_channels(struct cardstate *cs)
|
|||
unsigned long flags;
|
||||
int i;
|
||||
|
||||
dbg(DEBUG_ANY, "blocking all channels");
|
||||
gig_dbg(DEBUG_ANY, "blocking all channels");
|
||||
spin_lock_irqsave(&cs->lock, flags);
|
||||
for (i = 0; i < cs->channels; ++i)
|
||||
++cs->bcs[i].use_count;
|
||||
|
@ -388,14 +399,14 @@ static void gigaset_freebcs(struct bc_state *bcs)
|
|||
{
|
||||
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)) {
|
||||
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);
|
||||
dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
|
||||
gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
|
||||
|
||||
if (bcs->skb)
|
||||
dev_kfree_skb(bcs->skb);
|
||||
|
@ -432,7 +443,7 @@ void gigaset_freecs(struct cardstate *cs)
|
|||
default:
|
||||
gigaset_if_free(cs);
|
||||
|
||||
dbg(DEBUG_INIT, "clearing hw");
|
||||
gig_dbg(DEBUG_INIT, "clearing hw");
|
||||
cs->ops->freecshw(cs);
|
||||
|
||||
//FIXME cmdbuf
|
||||
|
@ -441,29 +452,29 @@ void gigaset_freecs(struct cardstate *cs)
|
|||
case 2: /* error in initcshw */
|
||||
/* Deregister from LL */
|
||||
make_invalid(cs, VALID_ID);
|
||||
dbg(DEBUG_INIT, "clearing iif");
|
||||
gig_dbg(DEBUG_INIT, "clearing iif");
|
||||
gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD);
|
||||
|
||||
/* fall through */
|
||||
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);
|
||||
dealloc_at_states(cs);
|
||||
|
||||
/* fall through */
|
||||
case 0: /* error in one call to initbcs */
|
||||
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);
|
||||
}
|
||||
|
||||
clear_events(cs);
|
||||
dbg(DEBUG_INIT, "freeing inbuf");
|
||||
gig_dbg(DEBUG_INIT, "freeing inbuf");
|
||||
kfree(cs->inbuf);
|
||||
}
|
||||
f_bcs: dbg(DEBUG_INIT, "freeing bcs[]");
|
||||
f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
|
||||
kfree(cs->bcs);
|
||||
f_cs: dbg(DEBUG_INIT, "freeing cs");
|
||||
f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
|
||||
up(&cs->sem);
|
||||
free_cs(cs);
|
||||
}
|
||||
|
@ -524,7 +535,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
|
|||
bcs->trans_down = 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);
|
||||
|
||||
bcs->rcvbytes = 0;
|
||||
|
@ -533,7 +544,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
|
|||
bcs->emptycount = 0;
|
||||
#endif
|
||||
|
||||
dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel);
|
||||
gig_dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel);
|
||||
bcs->fcs = PPP_INITFCS;
|
||||
bcs->inputstate = 0;
|
||||
if (cs->ignoreframes) {
|
||||
|
@ -542,7 +553,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
|
|||
} else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
|
||||
skb_reserve(bcs->skb, HW_HDR_LEN);
|
||||
else {
|
||||
warn("could not allocate skb");
|
||||
dev_warn(cs->dev, "could not allocate skb\n");
|
||||
bcs->inputstate |= INS_skip_frame;
|
||||
}
|
||||
|
||||
|
@ -557,13 +568,13 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
|
|||
for (i = 0; i < AT_NUM; ++i)
|
||||
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))
|
||||
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)
|
||||
dev_kfree_skb(bcs->skb);
|
||||
|
||||
|
@ -593,15 +604,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
|
|||
struct cardstate *cs = NULL;
|
||||
int i;
|
||||
|
||||
dbg(DEBUG_INIT, "allocating cs");
|
||||
gig_dbg(DEBUG_INIT, "allocating cs");
|
||||
cs = alloc_cs(drv);
|
||||
if (!cs)
|
||||
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);
|
||||
if (!cs->bcs)
|
||||
goto error;
|
||||
dbg(DEBUG_INIT, "allocating inbuf");
|
||||
gig_dbg(DEBUG_INIT, "allocating inbuf");
|
||||
cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
|
||||
if (!cs->inbuf)
|
||||
goto error;
|
||||
|
@ -623,6 +634,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
|
|||
cs->cur_at_seq = 0;
|
||||
cs->gotfwver = -1;
|
||||
cs->open_count = 0;
|
||||
cs->dev = NULL;
|
||||
cs->tty = NULL;
|
||||
atomic_set(&cs->cidmode, cidmode != 0);
|
||||
|
||||
|
@ -641,20 +653,20 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
|
|||
atomic_set(&cs->mstate, MS_UNINITIALIZED);
|
||||
|
||||
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))
|
||||
goto error;
|
||||
}
|
||||
|
||||
++cs->cs_init;
|
||||
|
||||
dbg(DEBUG_INIT, "setting up at_state");
|
||||
gig_dbg(DEBUG_INIT, "setting up at_state");
|
||||
spin_lock_init(&cs->lock);
|
||||
gigaset_at_init(&cs->at_state, NULL, cs, 0);
|
||||
cs->dle = 0;
|
||||
cs->cbytes = 0;
|
||||
|
||||
dbg(DEBUG_INIT, "setting up inbuf");
|
||||
gig_dbg(DEBUG_INIT, "setting up inbuf");
|
||||
if (onechannel) { //FIXME distinction necessary?
|
||||
gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command);
|
||||
} else
|
||||
|
@ -662,21 +674,21 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
|
|||
|
||||
atomic_set(&cs->connected, 0);
|
||||
|
||||
dbg(DEBUG_INIT, "setting up cmdbuf");
|
||||
gig_dbg(DEBUG_INIT, "setting up cmdbuf");
|
||||
cs->cmdbuf = cs->lastcmdbuf = NULL;
|
||||
spin_lock_init(&cs->cmdlock);
|
||||
cs->curlen = 0;
|
||||
cs->cmdbytes = 0;
|
||||
|
||||
dbg(DEBUG_INIT, "setting up iif");
|
||||
gig_dbg(DEBUG_INIT, "setting up iif");
|
||||
if (!gigaset_register_to_LL(cs, modulename)) {
|
||||
err("register_isdn=>error");
|
||||
err("register_isdn failed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
make_valid(cs, VALID_ID);
|
||||
++cs->cs_init;
|
||||
dbg(DEBUG_INIT, "setting up hw");
|
||||
gig_dbg(DEBUG_INIT, "setting up hw");
|
||||
if (!cs->ops->initcshw(cs))
|
||||
goto error;
|
||||
|
||||
|
@ -691,13 +703,13 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
|
|||
* Same problem(?) with mod_timer() in timer_tick(). */
|
||||
add_timer(&cs->timer);
|
||||
|
||||
dbg(DEBUG_INIT, "cs initialized!");
|
||||
gig_dbg(DEBUG_INIT, "cs initialized");
|
||||
up(&cs->sem);
|
||||
return cs;
|
||||
|
||||
error: if (cs)
|
||||
up(&cs->sem);
|
||||
dbg(DEBUG_INIT, "failed");
|
||||
gig_dbg(DEBUG_INIT, "failed");
|
||||
gigaset_freecs(cs);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -816,7 +828,7 @@ int gigaset_start(struct cardstate *cs)
|
|||
goto error;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling START");
|
||||
gig_dbg(DEBUG_CMD, "scheduling START");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
wait_event(cs->waitqueue, !cs->waiting);
|
||||
|
@ -841,11 +853,11 @@ void gigaset_shutdown(struct cardstate *cs)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling SHUTDOWN");
|
||||
gig_dbg(DEBUG_CMD, "scheduling SHUTDOWN");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
|
||||
warn("aborted");
|
||||
warn("%s: aborted", __func__);
|
||||
//FIXME
|
||||
}
|
||||
|
||||
|
@ -879,11 +891,11 @@ void gigaset_stop(struct cardstate *cs)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling STOP");
|
||||
gig_dbg(DEBUG_CMD, "scheduling STOP");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
|
||||
warn("aborted");
|
||||
warn("%s: aborted", __func__);
|
||||
//FIXME
|
||||
}
|
||||
|
||||
|
@ -937,17 +949,18 @@ void gigaset_debugdrivers(void)
|
|||
|
||||
spin_lock_irqsave(&driver_lock, flags);
|
||||
list_for_each_entry(drv, &drivers, list) {
|
||||
dbg(DEBUG_DRIVER, "driver %p", drv);
|
||||
gig_dbg(DEBUG_DRIVER, "driver %p", drv);
|
||||
spin_lock(&drv->lock);
|
||||
for (i = 0; i < drv->minors; ++i) {
|
||||
dbg(DEBUG_DRIVER, " index %u", i);
|
||||
dbg(DEBUG_DRIVER, " flags 0x%02x", drv->flags[i]);
|
||||
gig_dbg(DEBUG_DRIVER, " index %u", i);
|
||||
gig_dbg(DEBUG_DRIVER, " flags 0x%02x",
|
||||
drv->flags[i]);
|
||||
cs = drv->cs + i;
|
||||
dbg(DEBUG_DRIVER, " cardstate %p", cs);
|
||||
dbg(DEBUG_DRIVER, " minor_index %u",
|
||||
gig_dbg(DEBUG_DRIVER, " cardstate %p", cs);
|
||||
gig_dbg(DEBUG_DRIVER, " minor_index %u",
|
||||
cs->minor_index);
|
||||
dbg(DEBUG_DRIVER, " driver %p", cs->driver);
|
||||
dbg(DEBUG_DRIVER, " i4l id %d", cs->myid);
|
||||
gig_dbg(DEBUG_DRIVER, " driver %p", cs->driver);
|
||||
gig_dbg(DEBUG_DRIVER, " i4l id %d", cs->myid);
|
||||
}
|
||||
spin_unlock(&drv->lock);
|
||||
}
|
||||
|
|
|
@ -444,7 +444,7 @@ static int isdn_getnum(char *p)
|
|||
|
||||
IFNULLRETVAL(p, -1);
|
||||
|
||||
dbg(DEBUG_TRANSCMD, "string: %s", p);
|
||||
gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
|
||||
|
||||
while (*p >= '0' && *p <= '9')
|
||||
v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
|
||||
|
@ -463,7 +463,7 @@ static int isdn_gethex(char *p)
|
|||
|
||||
IFNULLRETVAL(p, -1);
|
||||
|
||||
dbg(DEBUG_TRANSCMD, "string: %s", p);
|
||||
gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
|
||||
|
||||
if (!*p)
|
||||
return -1;
|
||||
|
@ -537,11 +537,11 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
len = cs->cbytes;
|
||||
if (!len) {
|
||||
/* 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;
|
||||
}
|
||||
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;
|
||||
params = 1;
|
||||
if (cs->at_state.getstring) {
|
||||
|
@ -557,7 +557,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
case ',':
|
||||
case '=':
|
||||
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) */
|
||||
params--;
|
||||
}
|
||||
|
@ -575,14 +576,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
for (j = 1; j < params; ++j)
|
||||
argv[j][-1] = 0;
|
||||
|
||||
dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
|
||||
gig_dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
|
||||
if (cid) {
|
||||
--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++)
|
||||
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);
|
||||
|
@ -594,7 +595,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
while (curarg < params) {
|
||||
next = (tail + 1) % MAX_EVENTS;
|
||||
if (unlikely(next == head)) {
|
||||
err("event queue full");
|
||||
dev_err(cs->dev, "event queue full\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -615,7 +616,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
|
||||
if (!rt->response) {
|
||||
event->type = RSP_UNKNOWN;
|
||||
warn("unknown modem response: %s",
|
||||
dev_warn(cs->dev,
|
||||
"unknown modem response: %s\n",
|
||||
argv[curarg]);
|
||||
break;
|
||||
}
|
||||
|
@ -632,7 +634,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
break;
|
||||
case RT_RING:
|
||||
if (!cid) {
|
||||
err("received RING without CID!");
|
||||
dev_err(cs->dev,
|
||||
"received RING without CID!\n");
|
||||
event->type = RSP_INVAL;
|
||||
abort = 1;
|
||||
} else {
|
||||
|
@ -660,27 +663,25 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
event->parameter = ZSAU_DISCONNECT_REQ;
|
||||
else {
|
||||
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]);
|
||||
}
|
||||
++curarg;
|
||||
break;
|
||||
case RT_STRING:
|
||||
if (curarg < params) {
|
||||
len = strlen(argv[curarg]) + 1;
|
||||
event->ptr = kmalloc(len, GFP_ATOMIC);
|
||||
if (event->ptr)
|
||||
memcpy(event->ptr, argv[curarg], len);
|
||||
else
|
||||
err("no memory for string!");
|
||||
event->ptr = kstrdup(argv[curarg], GFP_ATOMIC);
|
||||
if (!event->ptr)
|
||||
dev_err(cs->dev, "out of memory\n");
|
||||
++curarg;
|
||||
}
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
if (!event->ptr)
|
||||
dbg(DEBUG_CMD, "string==NULL");
|
||||
gig_dbg(DEBUG_CMD, "string==NULL");
|
||||
else
|
||||
dbg(DEBUG_CMD,
|
||||
"string==%s", (char *) event->ptr);
|
||||
gig_dbg(DEBUG_CMD, "string==%s",
|
||||
(char *) event->ptr);
|
||||
#endif
|
||||
break;
|
||||
case RT_ZCAU:
|
||||
|
@ -708,7 +709,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
} else
|
||||
event->parameter = -1;
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
dbg(DEBUG_CMD, "parameter==%d", event->parameter);
|
||||
gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -724,7 +725,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
|
|||
spin_unlock_irqrestore(&cs->ev_lock, flags);
|
||||
|
||||
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);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gigaset_handle_modem_response);
|
||||
|
@ -750,7 +752,7 @@ static void disconnect(struct at_state_t **at_state_p)
|
|||
if (!atomic_read(&cs->cidmode)) {
|
||||
cs->at_state.pending_commands |= PC_UMMODE;
|
||||
atomic_set(&cs->commands_pending, 1); //FIXME
|
||||
dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
|
||||
gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
|
||||
}
|
||||
|
||||
if (bcs) {
|
||||
|
@ -822,7 +824,7 @@ static void init_failed(struct cardstate *cs, int mode)
|
|||
static void schedule_init(struct cardstate *cs, int state)
|
||||
{
|
||||
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;
|
||||
}
|
||||
atomic_set(&cs->mstate, state);
|
||||
|
@ -830,7 +832,7 @@ static void schedule_init(struct cardstate *cs, int state)
|
|||
gigaset_block_channels(cs);
|
||||
cs->at_state.pending_commands |= PC_INIT;
|
||||
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
|
||||
|
@ -843,10 +845,17 @@ static void send_command(struct cardstate *cs, const char *cmd, int cid,
|
|||
|
||||
cmdlen = strlen(cmd);
|
||||
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);
|
||||
if (likely(cmdbuf != NULL)) {
|
||||
if (unlikely(!cmdbuf)) {
|
||||
dev_err(cs->dev, "out of memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cmdpos = cmdbuf + 9;
|
||||
cmdtail = cmdpos + cmdlen;
|
||||
memcpy(cmdpos, cmd, cmdlen);
|
||||
|
@ -873,10 +882,6 @@ static void send_command(struct cardstate *cs, const char *cmd, int cid,
|
|||
|
||||
cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL);
|
||||
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)
|
||||
|
@ -930,13 +935,14 @@ static void bchannel_up(struct bc_state *bcs)
|
|||
IFNULLRET(bcs);
|
||||
|
||||
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;
|
||||
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
dbg(DEBUG_CMD, "Scheduling PC_CID");
|
||||
gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
|
||||
atomic_set(&cs->commands_pending, 1);
|
||||
return;
|
||||
|
||||
error:
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -982,12 +988,12 @@ static void start_accept(struct at_state_t *at_state)
|
|||
|
||||
if (retval == 0) {
|
||||
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);
|
||||
} else {
|
||||
//FIXME
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1029,7 +1035,7 @@ static void do_shutdown(struct cardstate *cs)
|
|||
atomic_set(&cs->mstate, MS_SHUTDOWN);
|
||||
cs->at_state.pending_commands |= PC_SHUTDOWN;
|
||||
atomic_set(&cs->commands_pending, 1);
|
||||
dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
|
||||
gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
|
||||
} else
|
||||
finish_shutdown(cs);
|
||||
}
|
||||
|
@ -1059,9 +1065,11 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
|
|||
return 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 {
|
||||
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;
|
||||
}
|
||||
schedule_init(cs, MS_INIT);
|
||||
|
@ -1106,7 +1114,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
|
|||
case ICALL_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
err("internal error: disposition=%d", retval);
|
||||
dev_err(cs->dev, "internal error: disposition=%d\n", retval);
|
||||
/* --v-- fall through --v-- */
|
||||
case ICALL_IGNORE:
|
||||
case ICALL_REJECT:
|
||||
|
@ -1201,10 +1209,10 @@ static void do_action(int action, struct cardstate *cs,
|
|||
}
|
||||
cs->at_state.pending_commands |= PC_CIDMODE;
|
||||
atomic_set(&cs->commands_pending, 1);
|
||||
dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
|
||||
gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
|
||||
break;
|
||||
case ACT_FAILINIT:
|
||||
warn("Could not initialize the device.");
|
||||
dev_warn(cs->dev, "Could not initialize the device.\n");
|
||||
cs->dle = 0;
|
||||
init_failed(cs, M_UNKNOWN);
|
||||
cs->cur_at_seq = SEQ_NONE;
|
||||
|
@ -1260,8 +1268,8 @@ static void do_action(int action, struct cardstate *cs,
|
|||
/* get fresh AT state structure for new CID */
|
||||
at_state2 = get_free_channel(cs, ev->parameter);
|
||||
if (!at_state2) {
|
||||
warn("RING ignored: "
|
||||
"could not allocate channel structure");
|
||||
dev_warn(cs->dev,
|
||||
"RING ignored: could not allocate channel structure\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1289,7 +1297,7 @@ static void do_action(int action, struct cardstate *cs,
|
|||
at_state = *p_at_state;
|
||||
break;
|
||||
case ACT_FAILSDOWN:
|
||||
warn("Could not shut down the device.");
|
||||
dev_warn(cs->dev, "Could not shut down the device.\n");
|
||||
/* fall through */
|
||||
case ACT_FAKESDOWN:
|
||||
case ACT_SDOWN:
|
||||
|
@ -1342,7 +1350,7 @@ static void do_action(int action, struct cardstate *cs,
|
|||
break;
|
||||
case ACT_ABORTHUP:
|
||||
cs->cur_at_seq = SEQ_NONE;
|
||||
warn("Could not hang up.");
|
||||
dev_warn(cs->dev, "Could not hang up.\n");
|
||||
at_state->cid = -1;
|
||||
if (bcs && cs->onechannel)
|
||||
at_state->pending_commands |= PC_DLE0;
|
||||
|
@ -1354,14 +1362,15 @@ static void do_action(int action, struct cardstate *cs,
|
|||
break;
|
||||
case ACT_FAILDLE0:
|
||||
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;
|
||||
disconnect(&at_state2);
|
||||
schedule_init(cs, MS_RECOVER);
|
||||
break;
|
||||
case ACT_FAILDLE1:
|
||||
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;
|
||||
cs->bcs[channel].at_state.pending_commands |= PC_HUP;
|
||||
atomic_set(&cs->commands_pending, 1);
|
||||
|
@ -1382,7 +1391,8 @@ static void do_action(int action, struct cardstate *cs,
|
|||
cs->cur_at_seq = SEQ_NONE;
|
||||
channel = cs->curchannel;
|
||||
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;
|
||||
disconnect(&at_state2);
|
||||
}
|
||||
|
@ -1457,7 +1467,7 @@ static void do_action(int action, struct cardstate *cs,
|
|||
case ACT_GOTVER:
|
||||
if (cs->gotfwver == 0) {
|
||||
cs->gotfwver = 1;
|
||||
dbg(DEBUG_ANY,
|
||||
gig_dbg(DEBUG_ANY,
|
||||
"firmware version %02d.%03d.%02d.%02d",
|
||||
cs->fwver[0], cs->fwver[1],
|
||||
cs->fwver[2], cs->fwver[3]);
|
||||
|
@ -1466,7 +1476,7 @@ static void do_action(int action, struct cardstate *cs,
|
|||
/* fall through */
|
||||
case ACT_FAILVER:
|
||||
cs->gotfwver = -1;
|
||||
err("could not read firmware version.");
|
||||
dev_err(cs->dev, "could not read firmware version.\n");
|
||||
break;
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
case ACT_ERROR:
|
||||
|
@ -1484,15 +1494,15 @@ static void do_action(int action, struct cardstate *cs,
|
|||
break;
|
||||
#endif
|
||||
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);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
|
||||
|
@ -1504,14 +1514,14 @@ static void do_action(int action, struct cardstate *cs,
|
|||
start_accept(at_state);
|
||||
break;
|
||||
case ACT_PROTO_L2:
|
||||
dbg(DEBUG_CMD,
|
||||
"set protocol to %u", (unsigned) ev->parameter);
|
||||
gig_dbg(DEBUG_CMD, "set protocol to %u",
|
||||
(unsigned) ev->parameter);
|
||||
at_state->bcs->proto2 = ev->parameter;
|
||||
break;
|
||||
case ACT_HUP:
|
||||
at_state->pending_commands |= PC_HUP;
|
||||
atomic_set(&cs->commands_pending, 1);
|
||||
dbg(DEBUG_CMD, "Scheduling PC_HUP");
|
||||
gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
|
||||
break;
|
||||
|
||||
/* hotplug events */
|
||||
|
@ -1547,10 +1557,10 @@ static void do_action(int action, struct cardstate *cs,
|
|||
atomic_set(&cs->cidmode, ev->parameter);
|
||||
if (ev->parameter) {
|
||||
cs->at_state.pending_commands |= PC_CIDMODE;
|
||||
dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
|
||||
gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
@ -1578,7 +1588,7 @@ static void do_action(int action, struct cardstate *cs,
|
|||
*p_resp_code = RSP_NULL;
|
||||
}
|
||||
} else
|
||||
err("%s: action==%d!", __func__, action);
|
||||
dev_err(cs->dev, "%s: action==%d!\n", __func__, action);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1610,14 +1620,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
|
|||
} else {
|
||||
at_state = ev->at_state;
|
||||
if (at_state_invalid(cs, at_state)) {
|
||||
dbg(DEBUG_ANY,
|
||||
"event for invalid at_state %p", at_state);
|
||||
gig_dbg(DEBUG_ANY, "event for invalid at_state %p",
|
||||
at_state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD,
|
||||
"connection state %d, event %d", at_state->ConState, ev->type);
|
||||
gig_dbg(DEBUG_CMD, "connection state %d, event %d",
|
||||
at_state->ConState, ev->type);
|
||||
|
||||
bcs = at_state->bcs;
|
||||
sendcid = at_state->cid;
|
||||
|
@ -1630,11 +1640,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
|
|||
if (ev->parameter != atomic_read(&at_state->timer_index)
|
||||
|| !at_state->timer_active) {
|
||||
ev->type = RSP_NONE; /* old timeout */
|
||||
dbg(DEBUG_ANY, "old timeout");
|
||||
gig_dbg(DEBUG_ANY, "old timeout");
|
||||
} else if (!at_state->waiting)
|
||||
dbg(DEBUG_ANY, "timeout occured");
|
||||
gig_dbg(DEBUG_ANY, "timeout occurred");
|
||||
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]
|
||||
|
@ -1657,10 +1667,10 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
|
|||
constate */
|
||||
for (;; rep++) {
|
||||
rcode = rep->resp_code;
|
||||
/* dbg (DEBUG_ANY, "rcode %d", rcode); */
|
||||
if (rcode == RSP_LAST) {
|
||||
/* 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);
|
||||
return;
|
||||
}
|
||||
|
@ -1741,11 +1751,11 @@ static void process_command_flags(struct cardstate *cs)
|
|||
atomic_set(&cs->commands_pending, 0);
|
||||
|
||||
if (cs->cur_at_seq) {
|
||||
dbg(DEBUG_CMD, "not searching scheduled commands: busy");
|
||||
gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
|
||||
return;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "searching scheduled commands");
|
||||
gig_dbg(DEBUG_CMD, "searching scheduled commands");
|
||||
|
||||
sequence = SEQ_NONE;
|
||||
|
||||
|
@ -1884,7 +1894,7 @@ static void process_command_flags(struct cardstate *cs)
|
|||
switch (atomic_read(&cs->mode)) {
|
||||
case M_UNIMODEM:
|
||||
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);
|
||||
return;
|
||||
#ifdef GIG_MAYINITONDIAL
|
||||
|
@ -1945,7 +1955,8 @@ static void process_events(struct cardstate *cs)
|
|||
}
|
||||
|
||||
if (i == 2 * MAX_EVENTS) {
|
||||
err("infinite loop in process_events; aborting.");
|
||||
dev_err(cs->dev,
|
||||
"infinite loop in process_events; aborting.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1962,7 +1973,7 @@ void gigaset_handle_event(unsigned long data)
|
|||
|
||||
/* handle incoming data on control/common channel */
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,45 +137,47 @@ enum debuglevel { /* up to 24 bits (atomic_t) */
|
|||
activated */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
|
||||
#else
|
||||
#define DEBUG_DEFAULT 0
|
||||
/* missing from linux/device.h ... */
|
||||
#ifndef dev_notice
|
||||
#define dev_notice(dev, format, arg...) \
|
||||
dev_printk(KERN_NOTICE , dev , format , ## arg)
|
||||
#endif
|
||||
|
||||
/* redefine syslog macros to prepend module name instead of entire
|
||||
* source path */
|
||||
#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
|
||||
#define warn(format, arg...) \
|
||||
printk(KERN_WARNING "%s: " format "\n", \
|
||||
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
|
||||
|
||||
/* Kernel message macros for situations where dev_printk and friends cannot be
|
||||
* 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
|
||||
#define err(format, arg...) \
|
||||
printk(KERN_ERR "%s: " format "\n", \
|
||||
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
|
||||
#undef info
|
||||
#undef warn
|
||||
#undef notice
|
||||
|
||||
#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
|
||||
format "\n" , ## arg)
|
||||
#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
|
||||
format "\n" , ## arg)
|
||||
#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
|
||||
format "\n" , ## arg)
|
||||
#define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \
|
||||
format "\n" , ## arg)
|
||||
|
||||
#undef dbg
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
#define dbg(level, format, arg...) \
|
||||
|
||||
#define gig_dbg(level, format, arg...) \
|
||||
do { \
|
||||
if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
|
||||
printk(KERN_DEBUG "%s: " format "\n", \
|
||||
THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" \
|
||||
, ## arg); \
|
||||
printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \
|
||||
## arg); \
|
||||
} while (0)
|
||||
#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
|
||||
|
||||
#else
|
||||
#define dbg(level, format, arg...) do {} while (0)
|
||||
|
||||
#define gig_dbg(level, format, arg...) do {} while (0)
|
||||
#define DEBUG_DEFAULT 0
|
||||
|
||||
#endif
|
||||
|
||||
void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
|
||||
|
@ -368,16 +370,6 @@ struct inbuf_t {
|
|||
* BAS_OUTBUFPAD bytes immediately before data[write] (if
|
||||
* write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD)
|
||||
* 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 {
|
||||
atomic_t read;
|
||||
|
@ -471,7 +463,7 @@ struct bc_state {
|
|||
int busy;
|
||||
int use_count;
|
||||
|
||||
/* hardware drivers */
|
||||
/* private data of hardware drivers */
|
||||
union {
|
||||
struct ser_bc_state *ser; /* serial hardware driver */
|
||||
struct usb_bc_state *usb; /* usb hardware driver (m105) */
|
||||
|
@ -482,6 +474,7 @@ struct bc_state {
|
|||
struct cardstate {
|
||||
struct gigaset_driver *driver;
|
||||
unsigned minor_index;
|
||||
struct device *dev;
|
||||
|
||||
const struct gigaset_ops *ops;
|
||||
|
||||
|
@ -531,11 +524,11 @@ struct cardstate {
|
|||
int cs_init;
|
||||
int ignoreframes; /* frames to ignore after setting up the
|
||||
B channel */
|
||||
struct semaphore sem; /* locks this structure: */
|
||||
/* connected is not changed, */
|
||||
/* hardware_up is not changed, */
|
||||
/* MState is not changed to or from
|
||||
MS_LOCKED */
|
||||
struct semaphore sem; /* locks this structure:
|
||||
* connected is not changed,
|
||||
* hardware_up is not changed,
|
||||
* MState is not changed to or from
|
||||
* MS_LOCKED */
|
||||
|
||||
struct timer_list timer;
|
||||
int retry_count;
|
||||
|
@ -543,7 +536,7 @@ struct cardstate {
|
|||
dle encoded */
|
||||
int cur_at_seq; /* sequence of AT commands being
|
||||
processed */
|
||||
int curchannel; /* channel, those commands are meant
|
||||
int curchannel; /* channel those commands are meant
|
||||
for */
|
||||
atomic_t commands_pending; /* flag(s) in xxx.commands_pending have
|
||||
been set */
|
||||
|
@ -551,7 +544,7 @@ struct cardstate {
|
|||
/* tasklet for serializing AT commands.
|
||||
* Scheduled
|
||||
* -> for modem reponses (and
|
||||
* incomming data for M10x)
|
||||
* incoming data for M10x)
|
||||
* -> on timeout
|
||||
* -> after setting bits in
|
||||
* xxx.at_state.pending_command
|
||||
|
@ -569,7 +562,7 @@ struct cardstate {
|
|||
unsigned char respdata[MAX_RESP_SIZE];
|
||||
unsigned cbytes;
|
||||
|
||||
/* hardware drivers */
|
||||
/* private data of hardware drivers */
|
||||
union {
|
||||
struct usb_cardstate *usb; /* USB hardware driver (m105) */
|
||||
struct ser_cardstate *ser; /* serial hardware driver */
|
||||
|
@ -607,8 +600,8 @@ struct bas_bc_state {
|
|||
struct isow_urbctx_t isoouturbs[BAS_OUTURBS];
|
||||
struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl;
|
||||
struct isowbuf_t *isooutbuf;
|
||||
unsigned numsub; /* submitted URB counter (for
|
||||
diagnostic messages only) */
|
||||
unsigned numsub; /* submitted URB counter
|
||||
(for diagnostic messages only) */
|
||||
struct tasklet_struct sent_tasklet;
|
||||
|
||||
/* isochronous input state */
|
||||
|
@ -618,25 +611,22 @@ struct bas_bc_state {
|
|||
struct urb *isoindone; /* completed isoc read URB */
|
||||
int loststatus; /* status of dropped URB */
|
||||
unsigned isoinlost; /* number of bytes lost */
|
||||
/* state of bit unstuffing algorithm (in addition to
|
||||
BC_state.inputstate) */
|
||||
/* state of bit unstuffing algorithm
|
||||
(in addition to BC_state.inputstate) */
|
||||
unsigned seqlen; /* number of '1' bits not yet
|
||||
unstuffed */
|
||||
unsigned inbyte, inbits; /* collected bits for next byte
|
||||
*/
|
||||
unsigned inbyte, inbits; /* collected bits for next byte */
|
||||
/* statistics */
|
||||
unsigned goodbytes; /* bytes correctly received */
|
||||
unsigned alignerrs; /* frames with incomplete byte
|
||||
at end */
|
||||
unsigned alignerrs; /* frames with incomplete byte at end */
|
||||
unsigned fcserrs; /* FCS errors */
|
||||
unsigned frameerrs; /* framing errors */
|
||||
unsigned giants; /* long frames */
|
||||
unsigned runts; /* short frames */
|
||||
unsigned aborts; /* HDLC aborts */
|
||||
unsigned shared0s; /* '0' bits shared between flags
|
||||
*/
|
||||
unsigned stolen0s; /* '0' stuff bits also serving
|
||||
as leading flag bits */
|
||||
unsigned shared0s; /* '0' bits shared between flags */
|
||||
unsigned stolen0s; /* '0' stuff bits also serving as
|
||||
leading flag bits */
|
||||
struct tasklet_struct rcvd_tasklet;
|
||||
};
|
||||
|
||||
|
@ -764,7 +754,7 @@ static inline void gigaset_isdn_rcv_err(struct bc_state *bcs)
|
|||
isdn_ctrl response;
|
||||
|
||||
/* error -> LL */
|
||||
dbg(DEBUG_CMD, "sending L1ERR");
|
||||
gig_dbg(DEBUG_CMD, "sending L1ERR");
|
||||
response.driver = bcs->cs->myid;
|
||||
response.command = ISDN_STAT_L1ERR;
|
||||
response.arg = bcs->channel;
|
||||
|
@ -872,7 +862,7 @@ static inline void gigaset_bchannel_down(struct bc_state *bcs)
|
|||
{
|
||||
gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL);
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling BC_CLOSED");
|
||||
gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED");
|
||||
gigaset_schedule_event(bcs->cs);
|
||||
}
|
||||
|
||||
|
@ -882,7 +872,7 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
|
|||
{
|
||||
gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL);
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling BC_OPEN");
|
||||
gig_dbg(DEBUG_CMD, "scheduling BC_OPEN");
|
||||
gigaset_schedule_event(bcs->cs);
|
||||
}
|
||||
|
||||
|
@ -947,7 +937,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
|
|||
{
|
||||
unsigned n, head, tail, bytesleft;
|
||||
|
||||
dbg(DEBUG_INTR, "received %u bytes", numbytes);
|
||||
gig_dbg(DEBUG_INTR, "received %u bytes", numbytes);
|
||||
|
||||
if (!numbytes)
|
||||
return 0;
|
||||
|
@ -955,7 +945,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
|
|||
bytesleft = numbytes;
|
||||
tail = atomic_read(&inbuf->tail);
|
||||
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) {
|
||||
if (head > tail)
|
||||
|
@ -965,7 +955,8 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
|
|||
else
|
||||
n = RBUFSIZE - tail;
|
||||
if (!n) {
|
||||
err("buffer overflow (%u bytes lost)", bytesleft);
|
||||
dev_err(inbuf->cs->dev,
|
||||
"buffer overflow (%u bytes lost)", bytesleft);
|
||||
break;
|
||||
}
|
||||
if (n > bytesleft)
|
||||
|
@ -975,7 +966,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
|
|||
tail = (tail + n) % RBUFSIZE;
|
||||
src += n;
|
||||
}
|
||||
dbg(DEBUG_INTR, "setting tail to %u", tail);
|
||||
gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
|
||||
atomic_set(&inbuf->tail, tail);
|
||||
return numbytes != bytesleft;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "gigaset.h"
|
||||
|
||||
/* == Handling of I4L IO ============================================================================*/
|
||||
/* == Handling of I4L IO =====================================================*/
|
||||
|
||||
/* writebuf_from_LL
|
||||
* called by LL to transmit data on an open channel
|
||||
|
@ -33,7 +33,8 @@
|
|||
* 0 if temporarily unable to accept data (out of buffer space)
|
||||
* <0 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 bc_state *bcs;
|
||||
|
@ -51,28 +52,30 @@ static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *
|
|||
bcs = &cs->bcs[channel];
|
||||
len = skb->len;
|
||||
|
||||
dbg(DEBUG_LLDATA,
|
||||
"Receiving data from LL (id: %d, channel: %d, ack: %d, size: %d)",
|
||||
gig_dbg(DEBUG_LLDATA,
|
||||
"Receiving data from LL (id: %d, ch: %d, ack: %d, sz: %d)",
|
||||
driverID, channel, ack, len);
|
||||
|
||||
if (!atomic_read(&cs->connected)) {
|
||||
err("%s: disconnected", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!len) {
|
||||
if (ack)
|
||||
warn("not ACKing empty packet from LL");
|
||||
notice("%s: not ACKing empty packet", __func__);
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (!atomic_read(&cs->connected))
|
||||
return -ENODEV;
|
||||
|
||||
skblen = ack ? len : 0;
|
||||
skb->head[0] = skblen & 0xff;
|
||||
skb->head[1] = skblen >> 8;
|
||||
dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x", len, skblen,
|
||||
(unsigned) skb->head[0], (unsigned) skb->head[1]);
|
||||
gig_dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x",
|
||||
len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]);
|
||||
|
||||
/* pass to device-specific module */
|
||||
return cs->ops->send_skb(bcs, skb);
|
||||
|
@ -86,13 +89,13 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb)
|
|||
++bcs->trans_up;
|
||||
|
||||
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] |
|
||||
(unsigned) (unsigned char) skb->head[1] << 8;
|
||||
if (len) {
|
||||
dbg(DEBUG_MCMD,
|
||||
"Acknowledge sending to LL (id: %d, channel: %d size: %u)",
|
||||
gig_dbg(DEBUG_MCMD, "ACKing to LL (id: %d, ch: %d, sz: %u)",
|
||||
bcs->cs->myid, bcs->channel, len);
|
||||
|
||||
response.driver = bcs->cs->myid;
|
||||
|
@ -117,7 +120,6 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
int retval = 0;
|
||||
struct setup_parm *sp;
|
||||
|
||||
//dbg(DEBUG_ANY, "Gigaset_HW: Receiving command");
|
||||
gigaset_debugdrivers();
|
||||
|
||||
//FIXME "remove test for &connected"
|
||||
|
@ -129,29 +131,30 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
|
||||
switch (cntrl->command) {
|
||||
case ISDN_CMD_IOCTL:
|
||||
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver:%d,arg: %ld)",
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver: %d, arg: %ld)",
|
||||
cntrl->driver, cntrl->arg);
|
||||
|
||||
warn("ISDN_CMD_IOCTL is not supported.");
|
||||
return -EINVAL;
|
||||
|
||||
case ISDN_CMD_DIAL:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_DIAL (driver: %d, channel: %ld, "
|
||||
gig_dbg(DEBUG_ANY,
|
||||
"ISDN_CMD_DIAL (driver: %d, ch: %ld, "
|
||||
"phone: %s, ownmsn: %s, si1: %d, si2: %d)",
|
||||
cntrl->driver, cntrl->arg,
|
||||
cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn,
|
||||
cntrl->parm.setup.si1, cntrl->parm.setup.si2);
|
||||
|
||||
if (cntrl->arg >= cs->channels) {
|
||||
err("invalid channel (%d)", (int) cntrl->arg);
|
||||
err("ISDN_CMD_DIAL: invalid channel (%d)",
|
||||
(int) cntrl->arg);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bcs = cs->bcs + cntrl->arg;
|
||||
|
||||
if (!gigaset_get_channel(bcs)) {
|
||||
err("channel not free");
|
||||
err("ISDN_CMD_DIAL: channel not free");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@ -172,14 +175,15 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling DIAL");
|
||||
gig_dbg(DEBUG_CMD, "scheduling DIAL");
|
||||
gigaset_schedule_event(cs);
|
||||
break;
|
||||
case ISDN_CMD_ACCEPTD: //FIXME
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD");
|
||||
|
||||
if (cntrl->arg >= cs->channels) {
|
||||
err("invalid channel (%d)", (int) cntrl->arg);
|
||||
err("ISDN_CMD_ACCEPTD: invalid channel (%d)",
|
||||
(int) cntrl->arg);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -189,16 +193,16 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling ACCEPT");
|
||||
gig_dbg(DEBUG_CMD, "scheduling ACCEPT");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
break;
|
||||
case ISDN_CMD_ACCEPTB:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB");
|
||||
break;
|
||||
case ISDN_CMD_HANGUP:
|
||||
dbg(DEBUG_ANY,
|
||||
"ISDN_CMD_HANGUP (channel: %d)", (int) cntrl->arg);
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_HANGUP (ch: %d)",
|
||||
(int) cntrl->arg);
|
||||
|
||||
if (cntrl->arg >= cs->channels) {
|
||||
err("ISDN_CMD_HANGUP: invalid channel (%u)",
|
||||
|
@ -212,24 +216,24 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling HUP");
|
||||
gig_dbg(DEBUG_CMD, "scheduling HUP");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
break;
|
||||
case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ");
|
||||
break;
|
||||
case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME
|
||||
dbg(DEBUG_ANY,
|
||||
"ISDN_CMD_SETEAZ (id:%d, channel: %ld, number: %s)",
|
||||
gig_dbg(DEBUG_ANY,
|
||||
"ISDN_CMD_SETEAZ (id: %d, ch: %ld, number: %s)",
|
||||
cntrl->driver, cntrl->arg, cntrl->parm.num);
|
||||
break;
|
||||
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));
|
||||
|
||||
if ((cntrl->arg & 0xff) >= cs->channels) {
|
||||
err("invalid channel (%u)",
|
||||
err("ISDN_CMD_SETL2: invalid channel (%u)",
|
||||
(unsigned) cntrl->arg & 0xff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -241,32 +245,34 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling PROTO_L2");
|
||||
gig_dbg(DEBUG_CMD, "scheduling PROTO_L2");
|
||||
gigaset_schedule_event(cs);
|
||||
break;
|
||||
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));
|
||||
|
||||
if ((cntrl->arg & 0xff) >= cs->channels) {
|
||||
err("invalid channel (%u)",
|
||||
err("ISDN_CMD_SETL3: invalid channel (%u)",
|
||||
(unsigned) cntrl->arg & 0xff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
break;
|
||||
case ISDN_CMD_PROCEED:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME
|
||||
break;
|
||||
case ISDN_CMD_ALERT:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME
|
||||
if (cntrl->arg >= cs->channels) {
|
||||
err("invalid channel (%d)", (int) cntrl->arg);
|
||||
err("ISDN_CMD_ALERT: invalid channel (%d)",
|
||||
(int) cntrl->arg);
|
||||
return -EINVAL;
|
||||
}
|
||||
//bcs = cs->bcs + cntrl->arg;
|
||||
|
@ -274,32 +280,31 @@ static int command_from_LL(isdn_ctrl *cntrl)
|
|||
// FIXME
|
||||
break;
|
||||
case ISDN_CMD_REDIR:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME
|
||||
break;
|
||||
case ISDN_CMD_PROT_IO:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO");
|
||||
break;
|
||||
case ISDN_CMD_FAXCMD:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD");
|
||||
break;
|
||||
case ISDN_CMD_GETL2:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_GETL2");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL2");
|
||||
break;
|
||||
case ISDN_CMD_GETL3:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_GETL3");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL3");
|
||||
break;
|
||||
case ISDN_CMD_GETEAZ:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ");
|
||||
break;
|
||||
case ISDN_CMD_SETSIL:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_SETSIL");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_SETSIL");
|
||||
break;
|
||||
case ISDN_CMD_GETSIL:
|
||||
dbg(DEBUG_ANY, "ISDN_CMD_GETSIL");
|
||||
gig_dbg(DEBUG_ANY, "ISDN_CMD_GETSIL");
|
||||
break;
|
||||
default:
|
||||
err("unknown command %d from LL",
|
||||
cntrl->command);
|
||||
err("unknown command %d from LL", cntrl->command);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -344,7 +349,8 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
|
|||
proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
|
||||
break;
|
||||
default:
|
||||
err("invalid protocol: %u", bcs->proto2);
|
||||
dev_err(bcs->cs->dev, "%s: invalid L2 protocol: %u\n",
|
||||
__func__, bcs->proto2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -372,7 +378,7 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
|
|||
bcs->commands[i] = NULL;
|
||||
if (length[i] &&
|
||||
!(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
|
||||
err("out of memory");
|
||||
dev_err(bcs->cs->dev, "out of memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +423,8 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
|
|||
proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
|
||||
break;
|
||||
default:
|
||||
err("invalid protocol: %u", bcs->proto2);
|
||||
dev_err(at_state->cs->dev, "%s: invalid protocol: %u\n",
|
||||
__func__, bcs->proto2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -434,7 +441,7 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
|
|||
bcs->commands[i] = NULL;
|
||||
if (length[i] &&
|
||||
!(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
|
||||
err("out of memory");
|
||||
dev_err(at_state->cs->dev, "out of memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +480,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
|
|||
response.parm.setup.si1 = 1;
|
||||
response.parm.setup.si2 = 2;
|
||||
} else {
|
||||
warn("RING ignored - unsupported BC %s",
|
||||
dev_warn(cs->dev, "RING ignored - unsupported BC %s\n",
|
||||
at_state->str_var[STR_ZBC]);
|
||||
return ICALL_IGNORE;
|
||||
}
|
||||
|
@ -491,18 +498,17 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
|
|||
response.parm.setup.eazmsn[0] = 0;
|
||||
|
||||
if (!bcs) {
|
||||
notice("no channel for incoming call");
|
||||
dbg(DEBUG_CMD, "Sending ICALLW");
|
||||
dev_notice(cs->dev, "no channel for incoming call\n");
|
||||
response.command = ISDN_STAT_ICALLW;
|
||||
response.arg = 0; //FIXME
|
||||
} else {
|
||||
dbg(DEBUG_CMD, "Sending ICALL");
|
||||
gig_dbg(DEBUG_CMD, "Sending ICALL");
|
||||
response.command = ISDN_STAT_ICALL;
|
||||
response.arg = bcs->channel; //FIXME
|
||||
}
|
||||
response.driver = cs->myid;
|
||||
retval = cs->iif.statcallb(&response);
|
||||
dbg(DEBUG_CMD, "Response: %d", retval);
|
||||
gig_dbg(DEBUG_CMD, "Response: %d", retval);
|
||||
switch (retval) {
|
||||
case 0: /* no takers */
|
||||
return ICALL_IGNORE;
|
||||
|
@ -512,7 +518,8 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
|
|||
case 2: /* reject */
|
||||
return ICALL_REJECT;
|
||||
case 3: /* incomplete */
|
||||
warn("LL requested unsupported feature: Incomplete Number");
|
||||
dev_warn(cs->dev,
|
||||
"LL requested unsupported feature: Incomplete Number\n");
|
||||
return ICALL_IGNORE;
|
||||
case 4: /* proceeding */
|
||||
/* Gigaset will send ALERTING anyway.
|
||||
|
@ -520,10 +527,11 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
|
|||
*/
|
||||
return ICALL_ACCEPT;
|
||||
case 5: /* deflect */
|
||||
warn("LL requested unsupported feature: Call Deflection");
|
||||
dev_warn(cs->dev,
|
||||
"LL requested unsupported feature: Call Deflection\n");
|
||||
return ICALL_IGNORE;
|
||||
default:
|
||||
err("LL error %d on ICALL", retval);
|
||||
dev_err(cs->dev, "LL error %d on ICALL\n", retval);
|
||||
return ICALL_IGNORE;
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +541,7 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
|
|||
{
|
||||
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;
|
||||
//strncpy(iif->id, isdnid, sizeof(iif->id) - 1);
|
||||
|
|
|
@ -22,7 +22,7 @@ static int if_lock(struct cardstate *cs, int *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)
|
||||
return -EINVAL;
|
||||
|
@ -47,7 +47,7 @@ static int if_lock(struct cardstate *cs, int *arg)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling IF_LOCK");
|
||||
gig_dbg(DEBUG_CMD, "scheduling IF_LOCK");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
wait_event(cs->waitqueue, !cs->waiting);
|
||||
|
@ -66,7 +66,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
|
|||
static const unsigned compat[4] = GIG_COMPAT;
|
||||
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) {
|
||||
case GIGVER_DRIVER:
|
||||
|
@ -83,7 +83,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling IF_VER");
|
||||
gig_dbg(DEBUG_CMD, "scheduling IF_VER");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
wait_event(cs->waitqueue, !cs->waiting);
|
||||
|
@ -99,7 +99,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
|
|||
|
||||
static int if_config(struct cardstate *cs, int *arg)
|
||||
{
|
||||
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)
|
||||
return -EINVAL;
|
||||
|
@ -151,8 +151,8 @@ static int if_open(struct tty_struct *tty, struct file *filp)
|
|||
struct cardstate *cs;
|
||||
unsigned long flags;
|
||||
|
||||
dbg(DEBUG_IF, "%d+%d: %s()", tty->driver->minor_start, tty->index,
|
||||
__FUNCTION__);
|
||||
gig_dbg(DEBUG_IF, "%d+%d: %s()",
|
||||
tty->driver->minor_start, tty->index, __func__);
|
||||
|
||||
tty->driver_data = NULL;
|
||||
|
||||
|
@ -184,16 +184,16 @@ static void if_close(struct tty_struct *tty, struct file *filp)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
|
||||
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
|
||||
|
||||
down(&cs->sem);
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else {
|
||||
if (!--cs->open_count) {
|
||||
spin_lock_irqsave(&cs->lock, flags);
|
||||
|
@ -216,17 +216,17 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
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))
|
||||
return -ERESTARTSYS; // FIXME -EINTR?
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else {
|
||||
retval = 0;
|
||||
switch (cmd) {
|
||||
|
@ -249,7 +249,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
|
|||
gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS",
|
||||
6, (const unsigned char *) arg, 1);
|
||||
if (!atomic_read(&cs->connected)) {
|
||||
dbg(DEBUG_ANY,
|
||||
gig_dbg(DEBUG_ANY,
|
||||
"can't communicate with unplugged device");
|
||||
retval = -ENODEV;
|
||||
break;
|
||||
|
@ -262,8 +262,8 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
|
|||
break;
|
||||
case GIGASET_VERSION:
|
||||
retval = copy_from_user(version,
|
||||
(unsigned __user *) arg,
|
||||
sizeof version) ? -EFAULT : 0;
|
||||
(unsigned __user *) arg, sizeof version)
|
||||
? -EFAULT : 0;
|
||||
if (retval >= 0)
|
||||
retval = if_version(cs, version);
|
||||
if (retval >= 0)
|
||||
|
@ -272,8 +272,8 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
|
|||
? -EFAULT : 0;
|
||||
break;
|
||||
default:
|
||||
dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x",
|
||||
__FUNCTION__, cmd);
|
||||
gig_dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x",
|
||||
__func__, cmd);
|
||||
retval = -ENOIOCTLCMD;
|
||||
}
|
||||
}
|
||||
|
@ -290,11 +290,11 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
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))
|
||||
return -ERESTARTSYS; // FIXME -EINTR?
|
||||
|
@ -316,18 +316,18 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
dbg(DEBUG_IF,
|
||||
"%u: %s(0x%x, 0x%x)", cs->minor_index, __FUNCTION__, set, clear);
|
||||
gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
|
||||
cs->minor_index, __func__, set, clear);
|
||||
|
||||
if (down_interruptible(&cs->sem))
|
||||
return -ERESTARTSYS; // FIXME -EINTR?
|
||||
|
||||
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;
|
||||
} else {
|
||||
mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR);
|
||||
|
@ -347,22 +347,22 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
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))
|
||||
return -ERESTARTSYS; // FIXME -EINTR?
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else if (atomic_read(&cs->mstate) != MS_LOCKED) {
|
||||
warn("can't write to unlocked device");
|
||||
retval = -EBUSY;
|
||||
} 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
|
||||
} else {
|
||||
retval = cs->ops->write_cmd(cs, buf, count,
|
||||
|
@ -381,22 +381,22 @@ static int if_write_room(struct tty_struct *tty)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
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))
|
||||
return -ERESTARTSYS; // FIXME -EINTR?
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else if (atomic_read(&cs->mstate) != MS_LOCKED) {
|
||||
warn("can't write to unlocked device");
|
||||
retval = -EBUSY; //FIXME
|
||||
} 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
|
||||
} else
|
||||
retval = cs->ops->write_room(cs);
|
||||
|
@ -413,22 +413,22 @@ static int if_chars_in_buffer(struct tty_struct *tty)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
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))
|
||||
return -ERESTARTSYS; // FIXME -EINTR?
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else if (atomic_read(&cs->mstate) != MS_LOCKED) {
|
||||
warn("can't write to unlocked device");
|
||||
retval = -EBUSY;
|
||||
} 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
|
||||
} else
|
||||
retval = cs->ops->chars_in_buffer(cs);
|
||||
|
@ -444,16 +444,16 @@ static void if_throttle(struct tty_struct *tty)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
|
||||
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
|
||||
|
||||
down(&cs->sem);
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else {
|
||||
//FIXME
|
||||
}
|
||||
|
@ -467,16 +467,16 @@ static void if_unthrottle(struct tty_struct *tty)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
|
||||
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
|
||||
|
||||
down(&cs->sem);
|
||||
|
||||
if (!cs->open_count)
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
else {
|
||||
//FIXME
|
||||
}
|
||||
|
@ -494,21 +494,21 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
|
|||
|
||||
cs = (struct cardstate *) tty->driver_data;
|
||||
if (!cs) {
|
||||
err("cs==NULL in %s", __FUNCTION__);
|
||||
err("cs==NULL in %s", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
|
||||
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
|
||||
|
||||
down(&cs->sem);
|
||||
|
||||
if (!cs->open_count) {
|
||||
warn("%s: device not opened", __FUNCTION__);
|
||||
warn("%s: device not opened", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -516,8 +516,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
|
|||
iflag = tty->termios->c_iflag;
|
||||
cflag = tty->termios->c_cflag;
|
||||
old_cflag = old ? old->c_cflag : cflag; //FIXME?
|
||||
dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x", cs->minor_index,
|
||||
iflag, cflag, old_cflag);
|
||||
gig_dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x",
|
||||
cs->minor_index, iflag, cflag, old_cflag);
|
||||
|
||||
/* get a local copy of the current port settings */
|
||||
control_state = cs->control_state;
|
||||
|
@ -535,7 +535,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
|
|||
/* don't set RTS if using hardware flow control */
|
||||
if (!(old_cflag & CRTSCTS))
|
||||
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");
|
||||
cs->ops->set_modem_ctrl(cs, control_state, new_state);
|
||||
control_state = new_state;
|
||||
|
@ -545,7 +546,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
|
|||
|
||||
if ((cflag & CBAUD) == B0) {
|
||||
/* 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);
|
||||
cs->ops->set_modem_ctrl(cs, control_state, new_state);
|
||||
control_state = new_state;
|
||||
|
@ -565,14 +566,16 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
|
|||
* Just do what we have seen with SniffUSB on Win98.
|
||||
*/
|
||||
/* 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;
|
||||
if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
|
||||
new_state |= TIOCM_DTR | TIOCM_RTS;
|
||||
else
|
||||
new_state &= ~(TIOCM_DTR | TIOCM_RTS);
|
||||
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);
|
||||
control_state = new_state;
|
||||
}
|
||||
|
@ -598,7 +601,7 @@ static void if_wake(unsigned long data)
|
|||
|
||||
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
||||
tty->ldisc.write_wakeup) {
|
||||
dbg(DEBUG_IF, "write wakeup call");
|
||||
gig_dbg(DEBUG_IF, "write wakeup call");
|
||||
tty->ldisc.write_wakeup(tty);
|
||||
}
|
||||
|
||||
|
@ -640,7 +643,7 @@ void gigaset_if_receive(struct cardstate *cs,
|
|||
|
||||
spin_lock_irqsave(&cs->lock, flags);
|
||||
if ((tty = cs->tty) == NULL)
|
||||
dbg(DEBUG_ANY, "receive on closed device");
|
||||
gig_dbg(DEBUG_ANY, "receive on closed device");
|
||||
else {
|
||||
tty_buffer_request_room(tty, len);
|
||||
tty_insert_flip_string(tty, buffer, len);
|
||||
|
@ -694,7 +697,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
|
|||
warn("failed to register tty driver (error %d)", ret);
|
||||
goto error;
|
||||
}
|
||||
dbg(DEBUG_IF, "tty driver initialized");
|
||||
gig_dbg(DEBUG_IF, "tty driver initialized");
|
||||
drv->have_tty = 1;
|
||||
return;
|
||||
|
||||
|
|
|
@ -83,12 +83,12 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
|
|||
{
|
||||
if (!atomic_dec_and_test(&iwb->writesem)) {
|
||||
atomic_inc(&iwb->writesem);
|
||||
dbg(DEBUG_ISO,
|
||||
"%s: couldn't acquire iso write semaphore", __func__);
|
||||
gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
|
||||
__func__);
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
dbg(DEBUG_ISO,
|
||||
gig_dbg(DEBUG_ISO,
|
||||
"%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
|
||||
__func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits);
|
||||
#endif
|
||||
|
@ -143,7 +143,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb)
|
|||
/* recover the idle flag byte */
|
||||
write = atomic_read(&iwb->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 */
|
||||
iwb->data[write] &= (1 << iwb->wbits) - 1;
|
||||
}
|
||||
|
@ -162,15 +162,14 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
|
|||
read = atomic_read(&iwb->nextread);
|
||||
write = atomic_read(&iwb->write);
|
||||
if (likely(read == write)) {
|
||||
//dbg(DEBUG_STREAM, "%s: send buffer empty", __func__);
|
||||
/* return idle frame */
|
||||
return read < BAS_OUTBUFPAD ?
|
||||
BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD;
|
||||
}
|
||||
|
||||
limit = read + size;
|
||||
dbg(DEBUG_STREAM,
|
||||
"%s: read=%d write=%d limit=%d", __func__, read, write, limit);
|
||||
gig_dbg(DEBUG_STREAM, "%s: read=%d write=%d limit=%d",
|
||||
__func__, read, write, limit);
|
||||
#ifdef CONFIG_GIGASET_DEBUG
|
||||
if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) {
|
||||
err("invalid size %d", size);
|
||||
|
@ -195,7 +194,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
|
|||
pbyte = iwb->data[write]; /* save
|
||||
partial byte */
|
||||
limit = write + BAS_OUTBUFPAD;
|
||||
dbg(DEBUG_STREAM,
|
||||
gig_dbg(DEBUG_STREAM,
|
||||
"%s: filling %d->%d with %02x",
|
||||
__func__, write, limit, iwb->idle);
|
||||
if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE)
|
||||
|
@ -208,7 +207,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
|
|||
- write);
|
||||
limit = 0;
|
||||
}
|
||||
dbg(DEBUG_STREAM, "%s: restoring %02x at %d",
|
||||
gig_dbg(DEBUG_STREAM,
|
||||
"%s: restoring %02x at %d",
|
||||
__func__, pbyte, limit);
|
||||
iwb->data[limit] = pbyte; /* restore
|
||||
partial byte */
|
||||
|
@ -252,7 +252,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
|
|||
while (count-- > 0) {
|
||||
if (i > sizeof(dbgline) - 4) {
|
||||
dbgline[i] = '\0';
|
||||
dbg(level, "%s:%s", tag, dbgline);
|
||||
gig_dbg(level, "%s:%s", tag, dbgline);
|
||||
i = 0;
|
||||
}
|
||||
c = *bytes++;
|
||||
|
@ -262,7 +262,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
|
|||
dbgline[i++] = hexdigit[c & 0x0f];
|
||||
}
|
||||
dbgline[i] = '\0';
|
||||
dbg(level, "%s:%s", tag, dbgline);
|
||||
gig_dbg(level, "%s:%s", tag, dbgline);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
|
|||
|
||||
if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
|
||||
!isowbuf_startwrite(iwb)) {
|
||||
dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
|
||||
gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
|
||||
__func__, isowbuf_freebytes(iwb));
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
@ -482,11 +482,11 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
|
|||
|
||||
if (isowbuf_freebytes(iwb) < count ||
|
||||
!isowbuf_startwrite(iwb)) {
|
||||
dbg(DEBUG_ISO, "can't put %d bytes", count);
|
||||
gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
dbg(DEBUG_STREAM, "put %d bytes", count);
|
||||
gig_dbg(DEBUG_STREAM, "put %d bytes", count);
|
||||
write = atomic_read(&iwb->write);
|
||||
do {
|
||||
c = gigaset_invtab[*in++];
|
||||
|
@ -506,12 +506,12 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
|
|||
switch (bcs->proto2) {
|
||||
case ISDN_PROTO_L2_HDLC:
|
||||
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);
|
||||
break;
|
||||
default: /* assume transparent */
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
|
@ -528,7 +528,7 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
|
|||
return;
|
||||
}
|
||||
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++;
|
||||
dev_kfree_skb_any(bcs->skb);
|
||||
bcs->skb = NULL;
|
||||
|
@ -549,7 +549,7 @@ static inline void hdlc_flush(struct bc_state *bcs)
|
|||
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
|
||||
skb_reserve(bcs->skb, HW_HDR_LEN);
|
||||
else
|
||||
err("could not allocate skb");
|
||||
dev_err(bcs->cs->dev, "could not allocate skb\n");
|
||||
}
|
||||
|
||||
/* reset packet state */
|
||||
|
@ -571,21 +571,23 @@ static inline void hdlc_done(struct bc_state *bcs)
|
|||
|
||||
if ((procskb = bcs->skb) == NULL) {
|
||||
/* previous error */
|
||||
dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
|
||||
gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
|
||||
gigaset_rcv_error(NULL, bcs->cs, bcs);
|
||||
} 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++;
|
||||
gigaset_rcv_error(procskb, bcs->cs, bcs);
|
||||
} 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++;
|
||||
gigaset_rcv_error(procskb, bcs->cs, bcs);
|
||||
} else {
|
||||
procskb->len -= 2; /* subtract FCS */
|
||||
procskb->tail -= 2;
|
||||
dbg(DEBUG_ISO,
|
||||
"%s: good frame (%d octets)", __func__, procskb->len);
|
||||
gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)",
|
||||
__func__, procskb->len);
|
||||
dump_bytes(DEBUG_STREAM,
|
||||
"rcv data", procskb->data, procskb->len);
|
||||
bcs->hw.bas->goodbytes += procskb->len;
|
||||
|
@ -595,7 +597,7 @@ static inline void hdlc_done(struct bc_state *bcs)
|
|||
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
|
||||
skb_reserve(bcs->skb, HW_HDR_LEN);
|
||||
else
|
||||
err("could not allocate skb");
|
||||
dev_err(bcs->cs->dev, "could not allocate skb\n");
|
||||
bcs->fcs = PPP_INITFCS;
|
||||
}
|
||||
|
||||
|
@ -610,14 +612,14 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
|
|||
return;
|
||||
}
|
||||
|
||||
notice("received partial byte (%d bits)", inbits);
|
||||
dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
|
||||
bcs->hw.bas->alignerrs++;
|
||||
gigaset_rcv_error(bcs->skb, bcs->cs, bcs);
|
||||
|
||||
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
|
||||
skb_reserve(bcs->skb, HW_HDR_LEN);
|
||||
else
|
||||
err("could not allocate skb");
|
||||
dev_err(bcs->cs->dev, "could not allocate skb\n");
|
||||
bcs->fcs = PPP_INITFCS;
|
||||
}
|
||||
|
||||
|
@ -870,7 +872,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
|
|||
if (unlikely((skb = bcs->skb) == NULL)) {
|
||||
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
|
||||
if (!skb) {
|
||||
err("could not allocate skb");
|
||||
dev_err(bcs->cs->dev, "could not allocate skb\n");
|
||||
return;
|
||||
}
|
||||
skb_reserve(skb, HW_HDR_LEN);
|
||||
|
@ -888,7 +890,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
|
|||
gigaset_rcv_skb(skb, bcs->cs, bcs);
|
||||
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
|
||||
if (!skb) {
|
||||
err("could not allocate skb");
|
||||
dev_err(bcs->cs->dev,
|
||||
"could not allocate skb\n");
|
||||
return;
|
||||
}
|
||||
skb_reserve(bcs->skb, HW_HDR_LEN);
|
||||
|
@ -921,7 +924,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
|
|||
case '\r':
|
||||
case '\n':
|
||||
/* end of line */
|
||||
dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
|
||||
gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
|
||||
__func__, cbytes);
|
||||
cs->cbytes = cbytes;
|
||||
gigaset_handle_modem_response(cs);
|
||||
|
@ -932,7 +935,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
|
|||
if (cbytes < MAX_RESP_SIZE - 1)
|
||||
cbytes++;
|
||||
else
|
||||
warn("response too large");
|
||||
dev_warn(cs->dev, "response too large\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -951,12 +954,12 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
|
|||
|
||||
head = atomic_read(&inbuf->head);
|
||||
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)
|
||||
tail = RBUFSIZE;
|
||||
src = inbuf->data + 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) {
|
||||
gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
|
||||
|
@ -971,7 +974,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
|
|||
head += numbytes;
|
||||
if (head == RBUFSIZE)
|
||||
head = 0;
|
||||
dbg(DEBUG_INTR, "setting head to %u", head);
|
||||
gig_dbg(DEBUG_INTR, "setting head to %u", head);
|
||||
atomic_set(&inbuf->head, head);
|
||||
}
|
||||
}
|
||||
|
@ -999,8 +1002,8 @@ int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
|
|||
len = skb->len;
|
||||
|
||||
skb_queue_tail(&bcs->squeue, skb);
|
||||
dbg(DEBUG_ISO,
|
||||
"%s: skb queued, qlen=%d", __func__, skb_queue_len(&bcs->squeue));
|
||||
gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d",
|
||||
__func__, skb_queue_len(&bcs->squeue));
|
||||
|
||||
/* tasklet submits URB if necessary */
|
||||
tasklet_schedule(&bcs->hw.bas->sent_tasklet);
|
||||
|
|
|
@ -50,7 +50,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
|
||||
gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
|
||||
gigaset_schedule_event(cs);
|
||||
|
||||
wait_event(cs->waitqueue, !cs->waiting);
|
||||
|
@ -65,7 +65,7 @@ static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
|
|||
/* free sysfs for device */
|
||||
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);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
|
||||
|
@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
|
|||
/* initialize sysfs for device */
|
||||
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);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs);
|
||||
|
|
|
@ -126,17 +126,17 @@ struct usb_cardstate {
|
|||
atomic_t busy; /* bulk output in progress */
|
||||
|
||||
/* Output buffer */
|
||||
unsigned char *bulk_out_buffer; /* send buffer */
|
||||
int bulk_out_size; /* send buffer size */
|
||||
__u8 bulk_out_endpointAddr; /* bulk out endpoint */
|
||||
struct urb *bulk_out_urb; /* bulk out urb */
|
||||
unsigned char *bulk_out_buffer;
|
||||
int bulk_out_size;
|
||||
__u8 bulk_out_endpointAddr;
|
||||
struct urb *bulk_out_urb;
|
||||
|
||||
/* Input buffer */
|
||||
int rcvbuf_size; /* rcv buffer */
|
||||
struct urb *read_urb; /* rcv buffer size */
|
||||
__u8 int_in_endpointAddr; /* int in endpoint */
|
||||
int rcvbuf_size;
|
||||
struct urb *read_urb;
|
||||
__u8 int_in_endpointAddr;
|
||||
|
||||
char bchars[6]; /* request 0x19 */
|
||||
char bchars[6]; /* for request 0x19 */
|
||||
};
|
||||
|
||||
struct usb_bc_state {};
|
||||
|
@ -151,16 +151,16 @@ static inline unsigned tiocm_to_gigaset(unsigned state)
|
|||
static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
|
||||
unsigned new_state)
|
||||
{
|
||||
struct usb_device *udev = cs->hw.usb->udev;
|
||||
unsigned mask, val;
|
||||
int r;
|
||||
|
||||
mask = tiocm_to_gigaset(old_state ^ 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
|
||||
r = usb_control_msg(cs->hw.usb->udev,
|
||||
usb_sndctrlpipe(cs->hw.usb->udev, 0), 7, 0x41,
|
||||
r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 7, 0x41,
|
||||
(val & 0xff) | ((mask & 0xff) << 8), 0,
|
||||
NULL, 0, 2000 /* timeout? */);
|
||||
if (r < 0)
|
||||
|
@ -171,30 +171,29 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
|
|||
|
||||
static int set_value(struct cardstate *cs, u8 req, u16 val)
|
||||
{
|
||||
struct usb_device *udev = cs->hw.usb->udev;
|
||||
int r, r2;
|
||||
|
||||
dbg(DEBUG_USBREQ, "request %02x (%04x)", (unsigned)req, (unsigned)val);
|
||||
r = usb_control_msg(cs->hw.usb->udev,
|
||||
usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x12, 0x41,
|
||||
0xf /*?*/, 0,
|
||||
NULL, 0, 2000 /*?*/); /* no idea, what this does */
|
||||
gig_dbg(DEBUG_USBREQ, "request %02x (%04x)",
|
||||
(unsigned)req, (unsigned)val);
|
||||
r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x12, 0x41,
|
||||
0xf /*?*/, 0, NULL, 0, 2000 /*?*/);
|
||||
/* no idea what this does */
|
||||
if (r < 0) {
|
||||
err("error %d on request 0x12", -r);
|
||||
dev_err(&udev->dev, "error %d on request 0x12\n", -r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = usb_control_msg(cs->hw.usb->udev,
|
||||
usb_sndctrlpipe(cs->hw.usb->udev, 0), req, 0x41,
|
||||
val, 0,
|
||||
NULL, 0, 2000 /*?*/);
|
||||
r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), req, 0x41,
|
||||
val, 0, NULL, 0, 2000 /*?*/);
|
||||
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,
|
||||
usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41,
|
||||
r2 = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
|
||||
0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/);
|
||||
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);
|
||||
}
|
||||
|
@ -222,8 +221,8 @@ static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
|
|||
case B115200: rate = 115200; break;
|
||||
default:
|
||||
rate = 9600;
|
||||
err("unsupported baudrate request 0x%x,"
|
||||
" using default of B9600", cflag);
|
||||
dev_err(cs->dev, "unsupported baudrate request 0x%x,"
|
||||
" using default of B9600\n", cflag);
|
||||
}
|
||||
|
||||
val = 0x383fff / rate + 1;
|
||||
|
@ -252,7 +251,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
|
|||
case CS8:
|
||||
val |= 8 << 8; break;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -317,10 +316,10 @@ static void gigaset_modem_fill(unsigned long data)
|
|||
unsigned long flags;
|
||||
int again;
|
||||
|
||||
dbg(DEBUG_OUTPUT, "modem_fill");
|
||||
gig_dbg(DEBUG_OUTPUT, "modem_fill");
|
||||
|
||||
if (atomic_read(&cs->hw.usb->busy)) {
|
||||
dbg(DEBUG_OUTPUT, "modem_fill: busy");
|
||||
gig_dbg(DEBUG_OUTPUT, "modem_fill: busy");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -331,9 +330,9 @@ static void gigaset_modem_fill(unsigned long data)
|
|||
cb = cs->cmdbuf;
|
||||
spin_unlock_irqrestore(&cs->cmdlock, flags);
|
||||
if (cb) { /* commands to send? */
|
||||
dbg(DEBUG_OUTPUT, "modem_fill: cb");
|
||||
gig_dbg(DEBUG_OUTPUT, "modem_fill: cb");
|
||||
if (send_cb(cs, cb) < 0) {
|
||||
dbg(DEBUG_OUTPUT,
|
||||
gig_dbg(DEBUG_OUTPUT,
|
||||
"modem_fill: send_cb failed");
|
||||
again = 1; /* no callback will be
|
||||
called! */
|
||||
|
@ -341,16 +340,16 @@ static void gigaset_modem_fill(unsigned long data)
|
|||
} else { /* skbs to send? */
|
||||
bcs->tx_skb = skb_dequeue(&bcs->squeue);
|
||||
if (bcs->tx_skb)
|
||||
dbg(DEBUG_INTR,
|
||||
gig_dbg(DEBUG_INTR,
|
||||
"Dequeued skb (Adr: %lx)!",
|
||||
(unsigned long) 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) {
|
||||
dbg(DEBUG_OUTPUT,
|
||||
gig_dbg(DEBUG_OUTPUT,
|
||||
"modem_fill: write_modem failed");
|
||||
// FIXME should we tell the LL?
|
||||
again = 1; /* no callback will be called! */
|
||||
|
@ -377,12 +376,11 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
|
|||
inbuf = (struct inbuf_t *) urb->context;
|
||||
IFNULLRET(inbuf);
|
||||
cs = inbuf->cs;
|
||||
IFNULLGOTO(cs, exit);
|
||||
IFNULLGOTO(cardstate, exit);
|
||||
IFNULLRET(cs);
|
||||
|
||||
if (!atomic_read(&cs->connected)) {
|
||||
err("%s: disconnected", __func__);
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!urb->status) {
|
||||
|
@ -391,29 +389,31 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
|
|||
if (numbytes) {
|
||||
src = inbuf->rcvbuf;
|
||||
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);
|
||||
++src; /* skip leading 0x00 */
|
||||
--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);
|
||||
}
|
||||
} else
|
||||
dbg(DEBUG_INTR, "Received zero block length");
|
||||
gig_dbg(DEBUG_INTR, "Received zero block length");
|
||||
resubmit = 1;
|
||||
} else {
|
||||
/* 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);
|
||||
if (urb->status != -ENOENT) /* not killed */
|
||||
resubmit = 1;
|
||||
}
|
||||
exit:
|
||||
|
||||
if (resubmit) {
|
||||
r = usb_submit_urb(urb, SLAB_ATOMIC);
|
||||
if (r)
|
||||
err("error %d when resubmitting urb.", -r);
|
||||
dev_err(cs->dev, "error %d when resubmitting urb.\n",
|
||||
-r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,9 +431,10 @@ static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
|
|||
}
|
||||
#endif
|
||||
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
|
||||
are handeled by timeouts or network protocols */
|
||||
are handled by timeouts or network protocols. */
|
||||
|
||||
atomic_set(&cs->hw.usb->busy, 0);
|
||||
tasklet_schedule(&cs->write_tasklet);
|
||||
|
@ -453,7 +454,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
|
|||
|
||||
spin_lock_irqsave(&cs->cmdlock, flags);
|
||||
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->cmdbuf = cb = cb->next;
|
||||
if (cb) {
|
||||
|
@ -480,12 +481,13 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
|
|||
cb->offset += count;
|
||||
cb->len -= count;
|
||||
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);
|
||||
if (status) {
|
||||
atomic_set(&ucs->busy, 0);
|
||||
err("could not submit urb (error %d).",
|
||||
dev_err(cs->dev,
|
||||
"could not submit urb (error %d)\n",
|
||||
-status);
|
||||
cb->len = 0; /* skip urb => remove cb+wakeup
|
||||
in next loop cycle */
|
||||
|
@ -516,7 +518,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
|
|||
return 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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])
|
||||
{
|
||||
#ifdef CONFIG_GIGASET_UNDOCREQ
|
||||
struct usb_device *udev = cs->hw.usb->udev;
|
||||
|
||||
gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf, 0);
|
||||
memcpy(cs->hw.usb->bchars, buf, 6);
|
||||
return usb_control_msg(cs->hw.usb->udev,
|
||||
usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41,
|
||||
return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
|
||||
0, 0, &buf, 6, 2000);
|
||||
#else
|
||||
return -EINVAL;
|
||||
|
@ -636,7 +639,7 @@ static int write_modem(struct cardstate *cs)
|
|||
|
||||
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;
|
||||
IFNULLGOTO(ucs->bulk_out_buffer, error);
|
||||
|
@ -662,19 +665,19 @@ static int write_modem(struct cardstate *cs)
|
|||
ucs->bulk_out_buffer, count,
|
||||
gigaset_write_bulk_callback, cs);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
if (!bcs->tx_skb->len) {
|
||||
/* skb sent completely */
|
||||
gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0?
|
||||
|
||||
dbg(DEBUG_INTR,
|
||||
"kfree skb (Adr: %lx)!", (unsigned long) bcs->tx_skb);
|
||||
gig_dbg(DEBUG_INTR, "kfree skb (Adr: %lx)!",
|
||||
(unsigned long) bcs->tx_skb);
|
||||
dev_kfree_skb_any(bcs->tx_skb);
|
||||
bcs->tx_skb = NULL;
|
||||
}
|
||||
|
@ -700,7 +703,8 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
int buffer_size;
|
||||
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),
|
||||
le16_to_cpu(udev->descriptor.idProduct));
|
||||
|
||||
|
@ -717,7 +721,7 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
ifnum = hostif->desc.bInterfaceNumber; // FIXME ?
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -725,20 +729,27 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
*
|
||||
*/
|
||||
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);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
info("%s: Device matched ... !", __func__);
|
||||
dev_info(&udev->dev, "%s: Device matched ... !\n", __func__);
|
||||
|
||||
cs = gigaset_getunassignedcs(driver);
|
||||
if (!cs) {
|
||||
warn("No free cardstate!");
|
||||
dev_warn(&udev->dev, "no free cardstate\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
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;
|
||||
|
||||
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
|
||||
|
@ -746,14 +757,14 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
ucs->bulk_out_endpointAddr = endpoint->bEndpointAddress;
|
||||
ucs->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
|
||||
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;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL);
|
||||
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;
|
||||
goto error;
|
||||
}
|
||||
|
@ -761,12 +772,10 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
endpoint = &hostif->endpoint[1].desc;
|
||||
|
||||
atomic_set(&ucs->busy, 0);
|
||||
ucs->udev = udev;
|
||||
ucs->interface = interface;
|
||||
|
||||
ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL);
|
||||
if (!ucs->read_urb) {
|
||||
err("No free urbs available");
|
||||
dev_err(cs->dev, "No free urbs available\n");
|
||||
retval = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
@ -775,7 +784,7 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
ucs->int_in_endpointAddr = endpoint->bEndpointAddress;
|
||||
cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL);
|
||||
if (!cs->inbuf[0].rcvbuf) {
|
||||
err("Couldn't allocate rcvbuf");
|
||||
dev_err(cs->dev, "Couldn't allocate rcvbuf\n");
|
||||
retval = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
@ -789,7 +798,7 @@ static int gigaset_probe(struct usb_interface *interface,
|
|||
|
||||
retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL);
|
||||
if (retval) {
|
||||
err("Could not submit URB!");
|
||||
dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -820,6 +829,9 @@ error:
|
|||
usb_free_urb(ucs->read_urb);
|
||||
ucs->read_urb = ucs->bulk_out_urb = NULL;
|
||||
cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
|
||||
usb_put_dev(ucs->udev);
|
||||
ucs->udev = NULL;
|
||||
ucs->interface = NULL;
|
||||
gigaset_unassign(cs);
|
||||
return retval;
|
||||
}
|
||||
|
@ -840,7 +852,6 @@ static void gigaset_disconnect(struct usb_interface *interface)
|
|||
usb_set_intfdata(interface, NULL);
|
||||
ucs = cs->hw.usb;
|
||||
usb_kill_urb(ucs->read_urb);
|
||||
//info("GigaSet USB device #%d will be disconnected", minor);
|
||||
|
||||
gigaset_stop(cs);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче