Commit 088ec0cc authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

gigaset: prepare for CAPI implementation

Reorganize the code of the Gigaset driver, moving all isdn4linux
dependencies to the source file i4l.c so that it can be replaced
by a file capi.c interfacing to Kernel CAPI instead.

Impact: refactoring, no functional change
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7ecc59c1
...@@ -119,10 +119,7 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -119,10 +119,7 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
int inputstate = bcs->inputstate; int inputstate = bcs->inputstate;
__u16 fcs = bcs->fcs; __u16 fcs = bcs->fcs;
struct sk_buff *skb = bcs->skb; struct sk_buff *skb = bcs->skb;
unsigned char error;
struct sk_buff *compskb;
int startbytes = numbytes; int startbytes = numbytes;
int l;
if (unlikely(inputstate & INS_byte_stuff)) { if (unlikely(inputstate & INS_byte_stuff)) {
inputstate &= ~INS_byte_stuff; inputstate &= ~INS_byte_stuff;
...@@ -158,8 +155,8 @@ byte_stuff: ...@@ -158,8 +155,8 @@ byte_stuff:
#endif #endif
/* end of frame */ /* end of frame */
error = 1; gigaset_isdn_rcv_err(bcs);
gigaset_rcv_error(NULL, cs, bcs); dev_kfree_skb(skb);
} else if (!(inputstate & INS_have_data)) { /* 7E 7E */ } else if (!(inputstate & INS_have_data)) { /* 7E 7E */
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount; ++bcs->emptycount;
...@@ -170,54 +167,39 @@ byte_stuff: ...@@ -170,54 +167,39 @@ byte_stuff:
"7e----------------------------"); "7e----------------------------");
/* end of frame */ /* end of frame */
error = 0;
if (unlikely(fcs != PPP_GOODFCS)) { if (unlikely(fcs != PPP_GOODFCS)) {
dev_err(cs->dev, dev_err(cs->dev,
"Checksum failed, %u bytes corrupted!\n", "Checksum failed, %u bytes corrupted!\n",
skb->len); skb->len);
compskb = NULL; gigaset_isdn_rcv_err(bcs);
gigaset_rcv_error(compskb, cs, bcs); dev_kfree_skb(skb);
error = 1; } else if (likely(skb->len > 2)) {
__skb_trim(skb, skb->len - 2);
gigaset_skb_rcvd(bcs, skb);
} else { } else {
if (likely((l = skb->len) > 2)) { if (skb->len) {
skb->tail -= 2; dev_err(cs->dev,
skb->len -= 2; "invalid packet size (%d)\n", skb->len);
} else { gigaset_isdn_rcv_err(bcs);
dev_kfree_skb(skb);
skb = NULL;
inputstate |= INS_skip_frame;
if (l == 1) {
dev_err(cs->dev,
"invalid packet size (1)!\n");
error = 1;
gigaset_rcv_error(NULL,
cs, bcs);
}
}
if (likely(!(error ||
(inputstate &
INS_skip_frame)))) {
gigaset_rcv_skb(skb, cs, bcs);
} }
dev_kfree_skb(skb);
} }
} }
if (unlikely(error))
if (skb)
dev_kfree_skb(skb);
fcs = PPP_INITFCS; fcs = PPP_INITFCS;
inputstate &= ~(INS_have_data | INS_skip_frame); inputstate &= ~(INS_have_data | INS_skip_frame);
if (unlikely(bcs->ignore)) { if (unlikely(bcs->ignore)) {
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
skb = NULL; skb = NULL;
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
skb_reserve(skb, HW_HDR_LEN);
} else { } else {
dev_warn(cs->dev, skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
"could not allocate new skb\n"); if (skb != NULL) {
inputstate |= INS_skip_frame; skb_reserve(skb, cs->hw_hdr_len);
} else {
dev_warn(cs->dev,
"could not allocate new skb\n");
inputstate |= INS_skip_frame;
}
} }
break; break;
...@@ -314,18 +296,21 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -314,18 +296,21 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
/* pass data up */ /* pass data up */
if (likely(inputstate & INS_have_data)) { if (likely(inputstate & INS_have_data)) {
if (likely(!(inputstate & INS_skip_frame))) { if (likely(!(inputstate & INS_skip_frame))) {
gigaset_rcv_skb(skb, cs, bcs); gigaset_skb_rcvd(bcs, skb);
} }
inputstate &= ~(INS_have_data | INS_skip_frame); inputstate &= ~(INS_have_data | INS_skip_frame);
if (unlikely(bcs->ignore)) { if (unlikely(bcs->ignore)) {
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
skb = NULL; skb = NULL;
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN))
!= NULL)) {
skb_reserve(skb, HW_HDR_LEN);
} else { } else {
dev_warn(cs->dev, "could not allocate new skb\n"); skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
inputstate |= INS_skip_frame; if (skb != NULL) {
skb_reserve(skb, cs->hw_hdr_len);
} else {
dev_warn(cs->dev,
"could not allocate new skb\n");
inputstate |= INS_skip_frame;
}
} }
} }
...@@ -383,7 +368,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf) ...@@ -383,7 +368,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
/* FIXME use function pointers? */ /* FIXME use function pointers? */
if (inbuf->inputstate & INS_command) if (inbuf->inputstate & INS_command)
procbytes = cmd_loop(c, src, numbytes, inbuf); procbytes = cmd_loop(c, src, numbytes, inbuf);
else if (inbuf->bcs->proto2 == ISDN_PROTO_L2_HDLC) else if (inbuf->bcs->proto2 == L2_HDLC)
procbytes = hdlc_loop(c, src, numbytes, inbuf); procbytes = hdlc_loop(c, src, numbytes, inbuf);
else else
procbytes = iraw_loop(c, src, numbytes, inbuf); procbytes = iraw_loop(c, src, numbytes, inbuf);
...@@ -440,16 +425,16 @@ EXPORT_SYMBOL_GPL(gigaset_m10x_input); ...@@ -440,16 +425,16 @@ EXPORT_SYMBOL_GPL(gigaset_m10x_input);
/* == data output ========================================================== */ /* == data output ========================================================== */
/* Encoding of a PPP packet into an octet stuffed HDLC frame /*
* with FCS, opening and closing flags. * Encode a data packet into an octet stuffed HDLC frame with FCS,
* opening and closing flags, preserving headroom data.
* parameters: * parameters:
* skb skb containing original packet (freed upon return) * skb skb containing original packet (freed upon return)
* head number of headroom bytes to allocate in result skb * headroom number of headroom bytes to preserve
* tail number of tailroom bytes to allocate in result skb
* Return value: * Return value:
* pointer to newly allocated skb containing the result frame * pointer to newly allocated skb containing the result frame
*/ */
static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom)
{ {
struct sk_buff *hdlc_skb; struct sk_buff *hdlc_skb;
__u16 fcs; __u16 fcs;
...@@ -471,16 +456,17 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) ...@@ -471,16 +456,17 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
/* size of new buffer: original size + number of stuffing bytes /* size of new buffer: original size + number of stuffing bytes
* + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
* + room for acknowledgement header
*/ */
hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head); hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + headroom);
if (!hdlc_skb) { if (!hdlc_skb) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NULL; return NULL;
} }
skb_reserve(hdlc_skb, head);
/* Copy acknowledge request into new skb */ /* Copy acknowledgement header into new skb */
memcpy(hdlc_skb->head, skb->head, 2); skb_reserve(hdlc_skb, headroom);
memcpy(hdlc_skb->head, skb->head, headroom);
/* Add flag sequence in front of everything.. */ /* Add flag sequence in front of everything.. */
*(skb_put(hdlc_skb, 1)) = PPP_FLAG; *(skb_put(hdlc_skb, 1)) = PPP_FLAG;
...@@ -515,15 +501,16 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) ...@@ -515,15 +501,16 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
return hdlc_skb; return hdlc_skb;
} }
/* Encoding of a raw packet into an octet stuffed bit inverted frame /*
* Encode a data packet into an octet stuffed raw bit inverted frame,
* preserving headroom data.
* parameters: * parameters:
* skb skb containing original packet (freed upon return) * skb skb containing original packet (freed upon return)
* head number of headroom bytes to allocate in result skb * headroom number of headroom bytes to preserve
* tail number of tailroom bytes to allocate in result skb
* Return value: * Return value:
* pointer to newly allocated skb containing the result frame * pointer to newly allocated skb containing the result frame
*/ */
static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail) static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom)
{ {
struct sk_buff *iraw_skb; struct sk_buff *iraw_skb;
unsigned char c; unsigned char c;
...@@ -531,12 +518,15 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail) ...@@ -531,12 +518,15 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
int len; int len;
/* worst case: every byte must be stuffed */ /* worst case: every byte must be stuffed */
iraw_skb = dev_alloc_skb(2*skb->len + tail + head); iraw_skb = dev_alloc_skb(2*skb->len + headroom);
if (!iraw_skb) { if (!iraw_skb) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NULL; return NULL;
} }
skb_reserve(iraw_skb, head);
/* Copy acknowledgement header into new skb */
skb_reserve(iraw_skb, headroom);
memcpy(iraw_skb->head, skb->head, headroom);
cp = skb->data; cp = skb->data;
len = skb->len; len = skb->len;
...@@ -555,8 +545,10 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail) ...@@ -555,8 +545,10 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
* @bcs: B channel descriptor structure. * @bcs: B channel descriptor structure.
* @skb: data to send. * @skb: data to send.
* *
* Called by i4l.c to encode and queue an skb for sending, and start * Called by LL to encode and queue an skb for sending, and start
* transmission if necessary. * transmission if necessary.
* Once the payload data has been transmitted completely, gigaset_skb_sent()
* will be called with the first cs->hw_hdr_len bytes of skb->head preserved.
* *
* Return value: * Return value:
* number of bytes accepted for sending (skb->len) if ok, * number of bytes accepted for sending (skb->len) if ok,
...@@ -567,10 +559,10 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb) ...@@ -567,10 +559,10 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
unsigned len = skb->len; unsigned len = skb->len;
unsigned long flags; unsigned long flags;
if (bcs->proto2 == ISDN_PROTO_L2_HDLC) if (bcs->proto2 == L2_HDLC)
skb = HDLC_Encode(skb, HW_HDR_LEN, 0); skb = HDLC_Encode(skb, bcs->cs->hw_hdr_len);
else else
skb = iraw_encode(skb, HW_HDR_LEN, 0); skb = iraw_encode(skb, bcs->cs->hw_hdr_len);
if (!skb) { if (!skb) {
dev_err(bcs->cs->dev, dev_err(bcs->cs->dev,
"unable to allocate memory for encoding!\n"); "unable to allocate memory for encoding!\n");
......
...@@ -911,7 +911,7 @@ static int starturbs(struct bc_state *bcs) ...@@ -911,7 +911,7 @@ static int starturbs(struct bc_state *bcs)
int rc; int rc;
/* initialize L2 reception */ /* initialize L2 reception */
if (bcs->proto2 == ISDN_PROTO_L2_HDLC) if (bcs->proto2 == L2_HDLC)
bcs->inputstate |= INS_flag_hunt; bcs->inputstate |= INS_flag_hunt;
/* submit all isochronous input URBs */ /* submit all isochronous input URBs */
...@@ -1064,7 +1064,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -1064,7 +1064,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
"%s: buffer busy at frame %d", "%s: buffer busy at frame %d",
__func__, nframe); __func__, nframe);
/* tasklet will be restarted from /* tasklet will be restarted from
gigaset_send_skb() */ gigaset_isoc_send_skb() */
} else { } else {
dev_err(ucx->bcs->cs->dev, dev_err(ucx->bcs->cs->dev,
"%s: buffer error %d at frame %d\n", "%s: buffer error %d at frame %d\n",
......
...@@ -463,6 +463,12 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -463,6 +463,12 @@ void gigaset_freecs(struct cardstate *cs)
switch (cs->cs_init) { switch (cs->cs_init) {
default: default:
/* clear B channel structures */
for (i = 0; i < cs->channels; ++i) {
gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
gigaset_freebcs(cs->bcs + i);
}
/* clear device sysfs */ /* clear device sysfs */
gigaset_free_dev_sysfs(cs); gigaset_free_dev_sysfs(cs);
...@@ -477,22 +483,16 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -477,22 +483,16 @@ void gigaset_freecs(struct cardstate *cs)
case 2: /* error in initcshw */ case 2: /* error in initcshw */
/* Deregister from LL */ /* Deregister from LL */
make_invalid(cs, VALID_ID); make_invalid(cs, VALID_ID);
gig_dbg(DEBUG_INIT, "clearing iif"); gigaset_isdn_unregister(cs);
gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD);
/* fall through */ /* fall through */
case 1: /* error when regestering to LL */ case 1: /* error when registering to LL */
gig_dbg(DEBUG_INIT, "clearing at_state"); gig_dbg(DEBUG_INIT, "clearing at_state");
clear_at_state(&cs->at_state); clear_at_state(&cs->at_state);
dealloc_at_states(cs); dealloc_at_states(cs);
/* fall through */ /* fall through */
case 0: /* error in one call to initbcs */ case 0: /* error in basic setup */
for (i = 0; i < cs->channels; ++i) {
gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
gigaset_freebcs(cs->bcs + i);
}
clear_events(cs); clear_events(cs);
gig_dbg(DEBUG_INIT, "freeing inbuf"); gig_dbg(DEBUG_INIT, "freeing inbuf");
kfree(cs->inbuf); kfree(cs->inbuf);
...@@ -620,11 +620,14 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, ...@@ -620,11 +620,14 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
if (cs->ignoreframes) { if (cs->ignoreframes) {
bcs->inputstate |= INS_skip_frame; bcs->inputstate |= INS_skip_frame;
bcs->skb = NULL; bcs->skb = NULL;
} else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) } else {
skb_reserve(bcs->skb, HW_HDR_LEN); bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
else { if (bcs->skb != NULL)
pr_err("out of memory\n"); skb_reserve(bcs->skb, cs->hw_hdr_len);
bcs->inputstate |= INS_skip_frame; else {
pr_err("out of memory\n");
bcs->inputstate |= INS_skip_frame;
}
} }
bcs->channel = channel; bcs->channel = channel;
...@@ -726,14 +729,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -726,14 +729,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->mode = M_UNKNOWN; cs->mode = M_UNKNOWN;
cs->mstate = MS_UNINITIALIZED; cs->mstate = MS_UNINITIALIZED;
for (i = 0; i < channels; ++i) {
gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) {
pr_err("could not allocate channel %d data\n", i);
goto error;
}
}
++cs->cs_init; ++cs->cs_init;
gig_dbg(DEBUG_INIT, "setting up at_state"); gig_dbg(DEBUG_INIT, "setting up at_state");
...@@ -758,7 +753,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -758,7 +753,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->cmdbytes = 0; cs->cmdbytes = 0;
gig_dbg(DEBUG_INIT, "setting up iif"); gig_dbg(DEBUG_INIT, "setting up iif");
if (!gigaset_register_to_LL(cs, modulename)) { if (!gigaset_isdn_register(cs, modulename)) {
pr_err("error registering ISDN device\n"); pr_err("error registering ISDN device\n");
goto error; goto error;
} }
...@@ -777,6 +772,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -777,6 +772,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
/* set up device sysfs */ /* set up device sysfs */
gigaset_init_dev_sysfs(cs); gigaset_init_dev_sysfs(cs);
/* set up channel data structures */
for (i = 0; i < channels; ++i) {
gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) {
pr_err("could not allocate channel %d data\n", i);
goto error;
}
}
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
cs->running = 1; cs->running = 1;
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
......
...@@ -127,7 +127,6 @@ ...@@ -127,7 +127,6 @@
#define ACT_NOTIFY_BC_UP 39 #define ACT_NOTIFY_BC_UP 39
#define ACT_DIAL 40 #define ACT_DIAL 40
#define ACT_ACCEPT 41 #define ACT_ACCEPT 41
#define ACT_PROTO_L2 42
#define ACT_HUP 43 #define ACT_HUP 43
#define ACT_IF_LOCK 44 #define ACT_IF_LOCK 44
#define ACT_START 45 #define ACT_START 45
...@@ -365,8 +364,6 @@ struct reply_t gigaset_tab_cid[] = ...@@ -365,8 +364,6 @@ struct reply_t gigaset_tab_cid[] =
{EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME
/* misc. */ /* misc. */
{EV_PROTO_L2, -1, -1, -1, -1,-1, {ACT_PROTO_L2}}, //FIXME
{RSP_ZCON, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME {RSP_ZCON, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
{RSP_ZCCR, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME {RSP_ZCCR, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
{RSP_ZAOC, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME {RSP_ZAOC, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
...@@ -714,7 +711,7 @@ static void disconnect(struct at_state_t **at_state_p) ...@@ -714,7 +711,7 @@ static void disconnect(struct at_state_t **at_state_p)
/* notify LL */ /* notify LL */
if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP); gigaset_isdn_hupD(bcs);
} }
} else { } else {
/* no B channel assigned: just deallocate */ /* no B channel assigned: just deallocate */
...@@ -872,12 +869,12 @@ static void bchannel_down(struct bc_state *bcs) ...@@ -872,12 +869,12 @@ static void bchannel_down(struct bc_state *bcs)
{ {
if (bcs->chstate & CHS_B_UP) { if (bcs->chstate & CHS_B_UP) {
bcs->chstate &= ~CHS_B_UP; bcs->chstate &= ~CHS_B_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BHUP); gigaset_isdn_hupB(bcs);
} }
if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP); gigaset_isdn_hupD(bcs);
} }
gigaset_free_channel(bcs); gigaset_free_channel(bcs);
...@@ -894,15 +891,16 @@ static void bchannel_up(struct bc_state *bcs) ...@@ -894,15 +891,16 @@ static void bchannel_up(struct bc_state *bcs)
} }
bcs->chstate |= CHS_B_UP; bcs->chstate |= CHS_B_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BCONN); gigaset_isdn_connB(bcs);
} }
static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index) static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index)
{ {
struct bc_state *bcs = at_state->bcs; struct bc_state *bcs = at_state->bcs;
struct cardstate *cs = at_state->cs; struct cardstate *cs = at_state->cs;
int retval; char **commands = data;
unsigned long flags; unsigned long flags;
int i;
bcs->chstate |= CHS_NOTIFY_LL; bcs->chstate |= CHS_NOTIFY_LL;
...@@ -913,10 +911,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind ...@@ -913,10 +911,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
} }
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
retval = gigaset_isdn_setup_dial(at_state, data); for (i = 0; i < AT_NUM; ++i) {
if (retval != 0) kfree(bcs->commands[i]);
goto error; bcs->commands[i] = commands[i];
}
at_state->pending_commands |= PC_CID; at_state->pending_commands |= PC_CID;
gig_dbg(DEBUG_CMD, "Scheduling PC_CID"); gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
...@@ -924,6 +922,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind ...@@ -924,6 +922,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
return; return;
error: error:
for (i = 0; i < AT_NUM; ++i) {
kfree(commands[i]);
commands[i] = NULL;
}
at_state->pending_commands |= PC_NOCID; at_state->pending_commands |= PC_NOCID;
gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID"); gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
cs->commands_pending = 1; cs->commands_pending = 1;
...@@ -933,20 +935,31 @@ error: ...@@ -933,20 +935,31 @@ error:
static void start_accept(struct at_state_t *at_state) static void start_accept(struct at_state_t *at_state)
{ {
struct cardstate *cs = at_state->cs; struct cardstate *cs = at_state->cs;
int retval; struct bc_state *bcs = at_state->bcs;
int i;