ISDN patches for net-next
Subsystems (2)
PATCH 1/8 isdn/gigaset: ratelimit CAPI message dumps
In reply to Tilman SchmidtIntroduce a global ratelimit for CAPI message dumps to protect against possible log flood.
Drop the ratelimit for ignored messages which is now covered by the global one.
--- drivers/isdn/gigaset/capi.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)
drivers/isdn/gigaset/capi.c +9 -13
@@ -14,6 +14,7 @@#include "gigaset.h" #include <linux/proc_fs.h> #include <linux/seq_file.h> +#include <linux/ratelimit.h> #include <linux/isdn/capilli.h> #include <linux/isdn/capicmd.h> #include <linux/isdn/capiutil.h>
@@ -223,10 +224,14 @@ get_appl(struct gigaset_capi_ctr *iif, u16 appl)static inline void dump_cmsg (enum debuglevel level,const char *tag,_cmsg *p) {#ifdef CONFIG_GIGASET_DEBUG +/* dump at most 20 messages in 20 secs */ + static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20);_cdebbuf *cdb;if (!(gigaset_debuglevel & level))return ; +if (!___ratelimit (&msg_dump_ratelimit, tag)) +return ; cdb =capi_cmsg2str (p);if (cdb) {
@@ -2059,12 +2064,6 @@ static void do_reset_b3_req(struct gigaset_capi_ctr *iif, }/* -* dump unsupported/ignored messages at most twice per minute, -* some apps send those very frequently -*/ -static unsigned long ignored_msg_dump_time; - -/* * unsupported CAPI message handler */ static void do_unsupported(struct gigaset_capi_ctr *iif,
@@ -2073,8 +2072,7 @@ static void do_unsupported(struct gigaset_capi_ctr *iif, {/* decode message */ capi_message2cmsg (&iif->acmsg, skb->data); -if (printk_timed_ratelimit (&ignored_msg_dump_time,30 *1000 )) -dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg); +dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg);send_conf (iif, ap, skb, CapiMessageNotSupportedInCurrentState); }
@@ -2085,11 +2083,9 @@ static void do_nothing(struct gigaset_capi_ctr *iif,struct gigaset_capi_appl *ap, struct sk_buff *skb) { -if (printk_timed_ratelimit (&ignored_msg_dump_time,30 *1000 )) { -/* decode message */ -capi_message2cmsg (&iif->acmsg, skb->data); -dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg); - } +/* decode message */ + capi_message2cmsg(&iif->acmsg, skb->data); +dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg);dev_kfree_skb_any (skb); }
Signature · 1 line
1.7.3.4
PATCH 2/8 isdn/gigaset: fix CAPI disconnect B3 handling
In reply to Tilman SchmidtIf DISCONNECT_B3_IND was synthesized because of a DISCONNECT_REQ with existing logical connections, the connection state wasn't updated accordingly. Also the emitted DISCONNECT_B3_IND message wasn't included in the debug log as requested.
This patch fixes both of these issues.
--- drivers/isdn/gigaset/capi.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/isdn/gigaset/capi.c +4 -0
@@ -1887,6 +1887,9 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,/* check for active logical connection */ if (bcs->apconnstate >=APCONN_ACTIVE ) { +/* clear it */ + bcs->apconnstate =APCONN_SETUP ; +/* * emit DISCONNECT_B3_IND with cause 0x3301 * use separate cmsg structure, as the content of iif->acmsg
@@ -1911,6 +1914,7 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif, }capi_cmsg2message (b3cmsg,__skb_put (b3skb,CAPI_DISCONNECT_B3_IND_BASELEN )); +dump_cmsg (DEBUG_CMD , __func__, b3cmsg);kfree (b3cmsg);capi_ctr_handle_message (&iif->ctr, ap->id, b3skb); }
Signature · 1 line
1.7.3.4
PATCH 3/8 isdn/gigaset: improve error handling querying firmware version
In reply to Tilman SchmidtAn out-of-place "OK" response to the "AT+GMR" (get firmware version) command turns out to be, more often than not, a delayed response to a previous command rather than an actual error, so continue waiting for the version number in that case.
--- drivers/isdn/gigaset/ev-layer.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/isdn/gigaset/ev-layer.c +3 -1
@@ -190,6 +190,7 @@ struct reply_t gigaset_tab_nocid[] = ACT_INIT} }, {RSP_OK, 121, 121, -1, 0, 0, {ACT_GOTVER, ACT_INIT} }, + {RSP_NONE, 121, 121, -1, 120, 0, {ACT_GETSTRING} },/* leave dle mode */ {RSP_INIT, 0, 0, SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"},
@@ -1314,8 +1315,9 @@ static void do_action(int action, struct cardstate *cs, s = ev->ptr;if (!strcmp (s,"OK" )) { +/* OK without version string: assume old response */ *p_genresp =1 ; - *p_resp_code =RSP_ERROR ; + *p_resp_code =RSP_NONE ;break ; }
Signature · 1 line
1.7.3.4
PATCH 5/8 isdn/gigaset: internal function name cleanup
In reply to Tilman SchmidtFunctions clear_at_state and free_strings did the same thing; drop one of them, keeping the more descriptive name. Drop a redundant call.
Rename function dealloc_at_states to dealloc_temp_at_states to clarify its purpose.
--- drivers/isdn/gigaset/common.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
drivers/isdn/gigaset/common.c +5 -11
@@ -362,7 +362,7 @@ struct event_t *gigaset_add_event(struct cardstate *cs, }EXPORT_SYMBOL_GPL (gigaset_add_event); -static void free_strings (struct at_state_t *at_state) +static void clear_at_state (struct at_state_t *at_state) {int i;
@@ -372,18 +372,13 @@ static void free_strings(struct at_state_t *at_state) } } -static void clear_at_state (struct at_state_t *at_state) -{ -free_strings (at_state); -} - -static void dealloc_at_states (struct cardstate *cs) +static void dealloc_temp_at_states (struct cardstate *cs) {struct at_state_t *cur, *next;list_for_each_entry_safe (cur, next, &cs->temp_at_states, list) {list_del (&cur->list); -free_strings (cur); +clear_at_state (cur);kfree (cur); } }
@@ -512,7 +507,7 @@ void gigaset_freecs(struct cardstate *cs)case 1 :/* error when registering to LL */ gig_dbg (DEBUG_INIT ,"clearing at_state" );clear_at_state (&cs->at_state); -dealloc_at_states (cs); +dealloc_temp_at_states (cs);/* fall through */ case 0 :/* error in basic setup */
@@ -848,8 +843,7 @@ static void cleanup_cs(struct cardstate *cs) cs->mstate =MS_UNINITIALIZED ;clear_at_state (&cs->at_state); -dealloc_at_states (cs); -free_strings (&cs->at_state); +dealloc_temp_at_states (cs);gigaset_at_init (&cs->at_state,NULL , cs,0 ); cs->inbuf->inputstate = INS_command;
Signature · 1 line
1.7.3.4
PATCH 8/8 isdn/capi: elliminate capincci_find() in non-middleware case
In reply to Tilman SchmidtIf Kernel CAPI is compiled without CONFIG_ISDN_CAPI_MIDDLEWARE, the structure retrieved via capincci_find() is never actually used, so don't compile that function in that case.
--- drivers/isdn/capi/capi.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-)
drivers/isdn/capi/capi.c +13 -14
@@ -336,11 +336,6 @@ static inline void capincci_alloc_minor(struct capidev *cdev, struct capincci *np) { }static inline void capincci_free_minor (struct capincci *np) { } -static inline unsigned int capincci_minor_opencount (struct capincci *np) -{ -return 0 ; -} -#endif /* !CONFIG_ISDN_CAPI_MIDDLEWARE */ static struct capincci *capincci_alloc (struct capidev *cdev,u32 ncci)
@@ -372,6 +367,7 @@ static void capincci_free(struct capidev *cdev, u32 ncci) } } +#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE static struct capincci *capincci_find (struct capidev *cdev,u32 ncci) {struct capincci *np;
@@ -382,7 +378,6 @@ static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)return NULL ; } -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE /* -------- handle data queue --------------------------------------- */ static struct sk_buff *
@@ -578,8 +573,8 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)struct tty_struct *tty;struct capiminor *mp;u16 datahandle; -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ struct capincci *np; +#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ mutex_lock (&cdev->lock);
@@ -597,6 +592,12 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) goto unlock_out; } +#ifndef CONFIG_ISDN_CAPI_MIDDLEWARE +skb_queue_tail (&cdev->recvqueue, skb); +wake_up_interruptible (&cdev->recvwait); + +#else /* CONFIG_ISDN_CAPI_MIDDLEWARE */ + np =capincci_find (cdev,CAPIMSG_CONTROL (skb->data));if (!np) {printk (KERN_ERR "BUG: capi_signal: ncci not found\n" );
@@ -605,12 +606,6 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) goto unlock_out; } -#ifndef CONFIG_ISDN_CAPI_MIDDLEWARE -skb_queue_tail (&cdev->recvqueue, skb); -wake_up_interruptible (&cdev->recvwait); - -#else /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - mp = np->minorp;if (!mp) {skb_queue_tail (&cdev->recvqueue, skb);
@@ -893,6 +888,11 @@ register_out:return -EFAULT ;return 0 ; +#ifndef CONFIG_ISDN_CAPI_MIDDLEWARE +case CAPI_NCCI_OPENCOUNT : +return 0 ; + +#else /* CONFIG_ISDN_CAPI_MIDDLEWARE */ case CAPI_NCCI_OPENCOUNT : {struct capincci *nccip;unsigned ncci;
@@ -909,7 +909,6 @@ register_out:return count; } -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE case CAPI_NCCI_GETUNIT : {struct capincci *nccip;struct capiminor *mp;
Signature · 1 line
1.7.3.4
cover ISDN patches for net-next
Karsten, David,
here's a series of eight patches to the Kernel CAPI subsystem and the Gigaset driver. Please consider for application to net-next. The first three should also go into -stable and are tagged accordingly.
Thanks,
Tilman
Tilman Schmidt (8):
isdn/gigaset: ratelimit CAPI message dumps isdn/gigaset: fix CAPI disconnect B3 handling isdn/gigaset: improve error handling querying firmware version isdn/gigaset: fix readability damage
isdn/gigaset: internal function name cleanup isdn/gigaset: unify function return values isdn/capi: fix readability damage
isdn/capi: elliminate capincci_find() in non-middleware case
drivers/isdn/capi/capi.c | 50 ++--- drivers/isdn/capi/capidrv.c | 8 drivers/isdn/gigaset/bas-gigaset.c | 44 ++--- drivers/isdn/gigaset/capi.c | 118 ++++++------- drivers/isdn/gigaset/common.c | 59 ++---- drivers/isdn/gigaset/dummyll.c | 2 drivers/isdn/gigaset/ev-layer.c | 321 ++++++++++++++++++------------------- drivers/isdn/gigaset/gigaset.h | 30 +-- drivers/isdn/gigaset/i4l.c | 12 - drivers/isdn/gigaset/isocdata.c | 12 - drivers/isdn/gigaset/ser-gigaset.c | 21 +- drivers/isdn/gigaset/usb-gigaset.c | 19 +- 12 files changed, 341 insertions(+), 355 deletions(-)
PATCH 4/8 isdn/gigaset: fix readability damage
Fix up some of the readibility deterioration caused by the recent whitespace coding style cleanup.
--- drivers/isdn/gigaset/bas-gigaset.c | 11 +- drivers/isdn/gigaset/capi.c | 84 +++++------ drivers/isdn/gigaset/ev-layer.c | 301 ++++++++++++++++++------------------ drivers/isdn/gigaset/gigaset.h | 28 ++-- 4 files changed, 208 insertions(+), 216 deletions(-)
drivers/isdn/gigaset/bas-gigaset.c +5 -6
@@ -410,10 +410,10 @@ static void check_pending(struct bas_cardstate *ucs)if (!(ucs->basstate &BS_RESETTING )) ucs->pending =0 ;break ; -/* -* HD_READ_ATMESSAGE and HD_WRITE_ATMESSAGE are handled separately -* and should never end up here -*/ +/* +* HD_READ_ATMESSAGE and HD_WRITE_ATMESSAGE are handled separately +* and should never end up here +*/ default : dev_warn(&ucs->interface->dev, "unknown pending request 0x%02x cleared\n",
@@ -877,8 +877,7 @@ static void read_iso_callback(struct urb *urb)for (i =0 ; i <BAS_NUMFRAMES ; i++) { ubc->isoinlost += urb->iso_frame_desc[i].actual_length;if (unlikely (urb->iso_frame_desc[i].status !=0 && - urb->iso_frame_desc[i].status != - -EINPROGRESS )) + urb->iso_frame_desc[i].status != -EINPROGRESS )) ubc->loststatus = urb->iso_frame_desc[i].status; urb->iso_frame_desc[i].status =0 ; urb->iso_frame_desc[i].actual_length =0 ;
drivers/isdn/gigaset/capi.c +36 -48
108 lines not on this page · raw message
drivers/isdn/gigaset/ev-layer.c +153 -148
391 lines not on this page · raw message
drivers/isdn/gigaset/gigaset.h +14 -14
@@ -163,8 +163,8 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,#define BAS_LOWFRAME 5/* " " with negative flow control */ #define BAS_CORRFRAMES 4/* flow control multiplicator */ -#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) -/* size of isoc in buf per URB */ +#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES)/* size of isoc in buf +* per URB */ #define BAS_OUTBUFSIZE 4096/* size of common isoc out buffer */ #define BAS_OUTBUFPAD BAS_MAXFRAME/* size of pad area for isoc out buf */
@@ -471,18 +471,18 @@ struct cardstate {for */ int commands_pending;/* flag(s) in xxx.commands_pending have been set */ -struct tasklet_struct event_tasklet; -/* tasklet for serializing AT commands. -* Scheduled -* -> for modem reponses (and -* incoming data for M10x) -* -> on timeout -* -> after setting bits in -* xxx.at_state.pending_command -* (e.g. command from LL) */ -struct tasklet_struct write_tasklet; -/* tasklet for serial output -* (not used in base driver) */ +struct tasklet_struct + event_tasklet;/* tasklet for serializing AT commands. +* Scheduled +* -> for modem reponses (and +* incoming data for M10x) +* -> on timeout +* -> after setting bits in +* xxx.at_state.pending_command +* (e.g. command from LL) */ +struct tasklet_struct + write_tasklet;/* tasklet for serial output +* (not used in base driver) */ /* event queue */ struct event_t events[MAX_EVENTS ];
Signature · 1 line
1.7.3.4
PATCH 6/8 isdn/gigaset: unify function return values
In reply to Tilman SchmidtVarious functions in the Gigaset driver were using different conventions for the meaning of their int return values. Align them to the usual negative error numbers convention.
--- drivers/isdn/gigaset/bas-gigaset.c | 33 ++++++++++++++++----------- drivers/isdn/gigaset/capi.c | 8 +++--- drivers/isdn/gigaset/common.c | 43 ++++++++++++++++------------------- drivers/isdn/gigaset/dummyll.c | 2 +- drivers/isdn/gigaset/ev-layer.c | 16 ++++++------ drivers/isdn/gigaset/gigaset.h | 2 +- drivers/isdn/gigaset/i4l.c | 12 +++++----- drivers/isdn/gigaset/isocdata.c | 12 +++++----- drivers/isdn/gigaset/ser-gigaset.c | 21 ++++++++++------- drivers/isdn/gigaset/usb-gigaset.c | 19 ++++++++------- 10 files changed, 87 insertions(+), 81 deletions(-)
drivers/isdn/gigaset/bas-gigaset.c +19 -14
@@ -2077,16 +2077,14 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])/* Free hardware dependent part of the B channel structure * parameter: * bcs B channel structure -* return value: -* !=0 on success */ -static int gigaset_freebcshw (struct bc_state *bcs) +static void gigaset_freebcshw (struct bc_state *bcs) {struct bas_bc_state *ubc = bcs->hw.bas;int i;if (!ubc) -return 0 ; +return ;/* kill URBs and tasklets before freeing - better safe than sorry */ ubc->running =0 ;
@@ -2104,14 +2102,13 @@ static int gigaset_freebcshw(struct bc_state *bcs)kfree (ubc->isooutbuf);kfree (ubc); bcs->hw.bas =NULL ; -return 1 ; }/* Initialize hardware dependent part of the B channel structure * parameter: * bcs B channel structure * return value: -* !=0 on success +* 0 on success, error code < 0 on failure */ static int gigaset_initbcshw (struct bc_state *bcs) {
@@ -2121,7 +2118,7 @@ static int gigaset_initbcshw(struct bc_state *bcs) bcs->hw.bas = ubc =kmalloc (sizeof (struct bas_bc_state ),GFP_KERNEL );if (!ubc) {pr_err ("out of memory\n" ); -return 0 ; +return -ENOMEM ; } ubc->running =0 ;
@@ -2138,7 +2135,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)pr_err ("out of memory\n" );kfree (ubc); bcs->hw.bas =NULL ; -return 0 ; +return -ENOMEM ; }tasklet_init (&ubc->sent_tasklet, write_iso_tasklet, (unsigned long ) bcs);
@@ -2163,7 +2160,7 @@ static int gigaset_initbcshw(struct bc_state *bcs) ubc->stolen0s =0 ;tasklet_init (&ubc->rcvd_tasklet, read_iso_tasklet, (unsigned long ) bcs); -return 1 ; +return 0 ; }static void gigaset_reinitbcshw (struct bc_state *bcs)
@@ -2186,6 +2183,12 @@ static void gigaset_freecshw(struct cardstate *cs) cs->hw.bas =NULL ; } +/* Initialize hardware dependent part of the cardstate structure +* parameter: +* cs cardstate structure +* return value: +* 0 on success, error code < 0 on failure +*/ static int gigaset_initcshw (struct cardstate *cs) {struct bas_cardstate *ucs;
@@ -2193,13 +2196,13 @@ static int gigaset_initcshw(struct cardstate *cs) cs->hw.bas = ucs =kmalloc (sizeof *ucs,GFP_KERNEL );if (!ucs) {pr_err ("out of memory\n" ); -return 0 ; +return -ENOMEM ; } ucs->int_in_buf =kmalloc (IP_MSGSIZE ,GFP_KERNEL );if (!ucs->int_in_buf) {kfree (ucs);pr_err ("out of memory\n" ); -return 0 ; +return -ENOMEM ; } ucs->urb_cmd_in =NULL ;
@@ -2218,7 +2221,7 @@ static int gigaset_initcshw(struct cardstate *cs)init_waitqueue_head (&ucs->waitqueue);INIT_WORK (&ucs->int_in_wq, int_in_work); -return 1 ; +return 0 ; }/* freeurbs
@@ -2378,18 +2381,20 @@ static int gigaset_probe(struct usb_interface *interface,/* save address of controller structure */ usb_set_intfdata (interface, cs); -if (!gigaset_start (cs)) + rc =gigaset_start (cs); +if (rc <0 ) goto error;return 0 ; allocerr:dev_err (cs->dev,"could not allocate URBs\n" ); + rc = -ENOMEM ; error:freeurbs (cs);usb_set_intfdata (interface,NULL );gigaset_freecs (cs); -return -ENODEV ; +return rc; }/* gigaset_disconnect
drivers/isdn/gigaset/capi.c +4 -4
@@ -2346,7 +2346,7 @@ static const struct file_operations gigaset_proc_fops = {* @cs: device descriptor structure. * @isdnid: device name. * -* Return value: 1 for success, 0 for failure +* Return value: 0 on success, error code < 0 on failure */ int gigaset_isdn_regdev (struct cardstate *cs,const char *isdnid) {
@@ -2356,7 +2356,7 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) iif =kmalloc (sizeof (*iif),GFP_KERNEL );if (!iif) {pr_err ("%s: out of memory\n" , __func__); -return 0 ; +return -ENOMEM ; }/* prepare controller structure */
@@ -2380,12 +2380,12 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)if (rc) {pr_err ("attach_capi_ctr failed (%d)\n" , rc);kfree (iif); -return 0 ; +return rc; } cs->iif = iif; cs->hw_hdr_len =CAPI_DATA_B3_REQ_LEN ; -return 1 ; +return 0 ; }/**
drivers/isdn/gigaset/common.c +20 -23
147 lines not on this page · raw message
drivers/isdn/gigaset/dummyll.c +1 -1
@@ -60,7 +60,7 @@ void gigaset_isdn_stop(struct cardstate *cs)int gigaset_isdn_regdev (struct cardstate *cs,const char *isdnid) { -return 1 ; +return 0 ; }void gigaset_isdn_unregdev (struct cardstate *cs)
drivers/isdn/gigaset/ev-layer.c +8 -8
@@ -658,7 +658,7 @@ static inline struct at_state_t *get_free_channel(struct cardstate *cs,struct at_state_t *ret;for (i =0 ; i < cs->channels; ++i) -if (gigaset_get_channel (cs->bcs + i)) { +if (gigaset_get_channel (cs->bcs + i) >=0 ) { ret = &cs->bcs[i].at_state; ret->cid = cid;return ret;
@@ -923,18 +923,18 @@ static void do_stop(struct cardstate *cs)* channel >= 0: getting cid for the channel failed * channel < 0: entering cid mode failed * -* returns 0 on failure +* returns 0 on success, <0 on failure */ static int reinit_and_retry (struct cardstate *cs,int channel) {int i;if (--cs->retry_count <=0 ) -return 0 ; +return -EFAULT ;for (i =0 ; i < cs->channels; ++i)if (cs->bcs[i].at_state.cid >0 ) -return 0 ; +return -EBUSY ;if (channel <0 ) dev_warn(cs->dev,
@@ -945,7 +945,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel) cs->bcs[channel].at_state.pending_commands |=PC_CID ; }schedule_init (cs,MS_INIT ); -return 1 ; +return 0 ; } static int at_state_invalid(struct cardstate *cs,
@@ -1016,7 +1016,7 @@ static int do_lock(struct cardstate *cs)if (cs->bcs[i].at_state.pending_commands)return -EBUSY ; -if (!gigaset_get_channels (cs)) +if (gigaset_get_channels (cs) <0 )return -EBUSY ;break ;
@@ -1125,7 +1125,7 @@ static void do_action(int action, struct cardstate *cs,init_failed (cs,M_UNKNOWN );break ; } -if (!reinit_and_retry (cs,-1 )) +if (reinit_and_retry (cs,-1 ) <0 )schedule_init (cs,MS_RECOVER );break ;case ACT_FAILUMODE :
@@ -1268,7 +1268,7 @@ static void do_action(int action, struct cardstate *cs,case ACT_FAILCID : cs->cur_at_seq =SEQ_NONE ; channel = cs->curchannel; -if (!reinit_and_retry (cs, channel)) { +if (reinit_and_retry (cs, channel) <0 ) {dev_warn (cs->dev,"Could not get a call ID. Cannot dial.\n" ); at_state2 = &cs->bcs[channel].at_state;
drivers/isdn/gigaset/gigaset.h +1 -1
@@ -583,7 +583,7 @@ struct gigaset_ops {int (*initbcshw)(struct bc_state *bcs);/* Called by gigaset_freecs() for freeing bcs->hw.xxx */ -int (*freebcshw)(struct bc_state *bcs); +void (*freebcshw)(struct bc_state *bcs);/* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */ void (*reinitbcshw)(struct bc_state *bcs);
drivers/isdn/gigaset/i4l.c +6 -6
@@ -229,7 +229,7 @@ static int command_from_LL(isdn_ctrl *cntrl)return -EINVAL ; } bcs = cs->bcs + ch; -if (!gigaset_get_channel (bcs)) { +if (gigaset_get_channel (bcs) <0 ) {dev_err (cs->dev,"ISDN_CMD_DIAL: channel not free\n" );return -EBUSY ; }
@@ -618,7 +618,7 @@ void gigaset_isdn_stop(struct cardstate *cs)* @cs: device descriptor structure. * @isdnid: device name. * -* Return value: 1 for success, 0 for failure +* Return value: 0 on success, error code < 0 on failure */ int gigaset_isdn_regdev (struct cardstate *cs,const char *isdnid) {
@@ -627,14 +627,14 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) iif =kmalloc (sizeof *iif,GFP_KERNEL );if (!iif) {pr_err ("out of memory\n" ); -return 0 ; +return -ENOMEM ; }if (snprintf (iif->id,sizeof iif->id,"%s_%u" , isdnid, cs->minor_index) >=sizeof iif->id) {pr_err ("ID too long: %s\n" , isdnid);kfree (iif); -return 0 ; +return -EINVAL ; } iif->owner =THIS_MODULE ;
@@ -656,13 +656,13 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)if (!register_isdn (iif)) {pr_err ("register_isdn failed\n" );kfree (iif); -return 0 ; +return -EINVAL ; } cs->iif = iif; cs->myid = iif->channels;/* Set my device id */ cs->hw_hdr_len =HW_HDR_LEN ; -return 1 ; +return 0 ; }/**
drivers/isdn/gigaset/isocdata.c +6 -6
@@ -56,7 +56,7 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb)/* start writing * acquire the write semaphore -* return true if acquired, false if busy +* return 0 if acquired, <0 if busy */ static inline int isowbuf_startwrite (struct isowbuf_t *iwb) {
@@ -64,12 +64,12 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)atomic_inc (&iwb->writesem);gig_dbg (DEBUG_ISO ,"%s: couldn't acquire iso write semaphore" , __func__); -return 0 ; +return -EBUSY ; }gig_dbg (DEBUG_ISO ,"%s: acquired iso write semaphore, data[write]=%02x, nbits=%d" , __func__, iwb->data[iwb->write], iwb->wbits); -return 1 ; +return 0 ; }/* finish writing
@@ -158,7 +158,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)/* no wraparound in valid data */ if (limit >= write) {/* append idle frame */ -if (!isowbuf_startwrite (iwb)) +if (isowbuf_startwrite (iwb) <0 )return -EBUSY ;/* write position could have changed */ write = iwb->write;
@@ -403,7 +403,7 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,unsigned char c;if (isowbuf_freebytes (iwb) < count + count /5 +6 || - !isowbuf_startwrite (iwb)) { +isowbuf_startwrite (iwb) <0 ) {gig_dbg (DEBUG_ISO ,"%s: %d bytes free -> -EAGAIN" , __func__,isowbuf_freebytes (iwb));return -EAGAIN ;
@@ -457,7 +457,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,return iwb->write;if (isowbuf_freebytes (iwb) < count || - !isowbuf_startwrite (iwb)) { +isowbuf_startwrite (iwb) <0 ) {gig_dbg (DEBUG_ISO ,"can't put %d bytes" , count);return -EAGAIN ; }
drivers/isdn/gigaset/ser-gigaset.c +12 -9
@@ -340,17 +340,16 @@ static int gigaset_initbcshw(struct bc_state *bcs) {/* unused */ bcs->hw.ser =NULL ; -return 1 ; +return 0 ; }/* * Free B channel structure * Called by "gigaset_freebcs" in common.c */ -static int gigaset_freebcshw (struct bc_state *bcs) +static void gigaset_freebcshw (struct bc_state *bcs) {/* unused */ -return 1 ; }/*
@@ -398,7 +397,7 @@ static int gigaset_initcshw(struct cardstate *cs) scs =kzalloc (sizeof (struct ser_cardstate ),GFP_KERNEL );if (!scs) {pr_err ("out of memory\n" ); -return 0 ; +return -ENOMEM ; } cs->hw.ser = scs;
@@ -410,13 +409,13 @@ static int gigaset_initcshw(struct cardstate *cs)pr_err ("error %d registering platform device\n" , rc);kfree (cs->hw.ser); cs->hw.ser =NULL ; -return 0 ; +return rc; }dev_set_drvdata (&cs->hw.ser->dev.dev, cs);tasklet_init (&cs->write_tasklet, gigaset_modem_fill, (unsigned long ) cs); -return 1 ; +return 0 ; }/*
@@ -503,6 +502,7 @@ static int gigaset_tty_open(struct tty_struct *tty) {struct cardstate *cs; +int rc;gig_dbg (DEBUG_INIT ,"Starting HLL for Gigaset M101" );
@@ -515,8 +515,10 @@ gigaset_tty_open(struct tty_struct *tty)/* allocate memory for our device state and initialize it */ cs =gigaset_initcs (driver,1 ,1 ,0 , cidmode,GIGASET_MODULENAME ); -if (!cs) +if (!cs) { + rc = -ENODEV ; goto error; + } cs->dev = &cs->hw.ser->dev.dev; cs->hw.ser->tty = tty;
@@ -530,7 +532,8 @@ gigaset_tty_open(struct tty_struct *tty)*/ if (startmode ==SM_LOCKED ) cs->mstate =MS_LOCKED ; -if (!gigaset_start (cs)) { + rc =gigaset_start (cs); +if (rc <0 ) {tasklet_kill (&cs->write_tasklet); goto error; }
@@ -542,7 +545,7 @@ error:gig_dbg (DEBUG_INIT ,"Startup of HLL failed" ); tty->disc_data =NULL ;gigaset_freecs (cs); -return -ENODEV ; +return rc; }/*
drivers/isdn/gigaset/usb-gigaset.c +10 -9
@@ -549,10 +549,9 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) 0, 0, &buf, 6, 2000); } -static int gigaset_freebcshw (struct bc_state *bcs) +static void gigaset_freebcshw (struct bc_state *bcs) {/* unused */ -return 1 ; }/* Initialize the b-channel structure */
@@ -560,7 +559,7 @@ static int gigaset_initbcshw(struct bc_state *bcs) {/* unused */ bcs->hw.usb =NULL ; -return 1 ; +return 0 ; }static void gigaset_reinitbcshw (struct bc_state *bcs)
@@ -582,7 +581,7 @@ static int gigaset_initcshw(struct cardstate *cs)kmalloc (sizeof (struct usb_cardstate ),GFP_KERNEL );if (!ucs) {pr_err ("out of memory\n" ); -return 0 ; +return -ENOMEM ; } ucs->bchars[0 ] =0 ;
@@ -597,7 +596,7 @@ static int gigaset_initcshw(struct cardstate *cs)tasklet_init (&cs->write_tasklet, gigaset_modem_fill, (unsigned long ) cs); -return 1 ; +return 0 ; }/* Send data from current skb to the device. */
@@ -766,9 +765,9 @@ static int gigaset_probe(struct usb_interface *interface,if (startmode ==SM_LOCKED ) cs->mstate =MS_LOCKED ; -if (!gigaset_start (cs)) { + retval =gigaset_start (cs); +if (retval <0 ) {tasklet_kill (&cs->write_tasklet); - retval = -ENODEV ; goto error; }return 0 ;
@@ -898,8 +897,10 @@ static int __init usb_gigaset_init(void) driver =gigaset_initdriver (GIGASET_MINOR ,GIGASET_MINORS ,GIGASET_MODULENAME ,GIGASET_DEVNAME , &ops,THIS_MODULE ); -if (driver ==NULL ) +if (driver ==NULL ) { + result = -ENOMEM ; goto error; + }/* register this driver with the USB subsystem */ result =usb_register (&gigaset_usb_driver);
@@ -915,7 +916,7 @@ error:if (driver)gigaset_freedriver (driver); driver =NULL ; -return -1 ; +return result; }/*
Signature · 1 line
1.7.3.4
PATCH 7/8 isdn/capi: fix readability damage
In reply to Tilman SchmidtFix up some of the readibility deterioration caused by the recent whitespace coding style cleanup.
--- drivers/isdn/capi/capi.c | 23 +++++++---------------- drivers/isdn/capi/capidrv.c | 8 +++++--- 2 files changed, 12 insertions(+), 19 deletions(-)
drivers/isdn/capi/capi.c +7 -16
@@ -786,7 +786,6 @@ register_out:return retval;case CAPI_GET_VERSION : - {if (copy_from_user (&data.contr, argp,sizeof (data.contr)))return -EFAULT ;
@@ -796,11 +795,9 @@ register_out:if (copy_to_user (argp, &data.version,sizeof (data.version)))return -EFAULT ; - } -return 0 ; +return 0 ;case CAPI_GET_SERIAL : - {if (copy_from_user (&data.contr, argp,sizeof (data.contr)))return -EFAULT ;
@@ -810,10 +807,9 @@ register_out:if (copy_to_user (argp, data.serial,sizeof (data.serial)))return -EFAULT ; - } -return 0 ; +return 0 ; +case CAPI_GET_PROFILE : - {if (copy_from_user (&data.contr, argp,sizeof (data.contr)))return -EFAULT ;
@@ -837,11 +833,9 @@ register_out: }if (retval)return -EFAULT ; - } -return 0 ; +return 0 ;case CAPI_GET_MANUFACTURER : - {if (copy_from_user (&data.contr, argp,sizeof (data.contr)))return -EFAULT ;
@@ -853,8 +847,8 @@ register_out: sizeof(data.manufacturer)))return -EFAULT ; - } -return 0 ; +return 0 ; +case CAPI_GET_ERRCODE : data.errcode = cdev->errcode; cdev->errcode =CAPI_NOERROR ;
@@ -870,8 +864,7 @@ register_out:return 0 ;return -ENXIO ; -case CAPI_MANUFACTURER_CMD : - { +case CAPI_MANUFACTURER_CMD : {struct capi_manufacturer_cmd mcmd;if (!capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -879,8 +872,6 @@ register_out:return -EFAULT ;return capi20_manufacturer (mcmd.cmd, mcmd.data); } -return 0 ; -case CAPI_SET_FLAGS :case CAPI_CLR_FLAGS : {unsigned userflags;
drivers/isdn/capi/capidrv.c +5 -3
@@ -1593,7 +1593,7 @@ static int capidrv_command(isdn_ctrl *c, capidrv_contr *card)return capidrv_ioctl (c, card);switch (c->command) { -case ISDN_CMD_DIAL :{ +case ISDN_CMD_DIAL : {u8 calling[ISDN_MSNLEN +3 ];u8 called[ISDN_MSNLEN +2 ];
@@ -2072,7 +2072,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) card->interface.writebuf_skb = if_sendbuf; card->interface.writecmd =NULL ; card->interface.readstat = if_readstat; - card->interface.features =ISDN_FEATURE_L2_HDLC | + card->interface.features = +ISDN_FEATURE_L2_HDLC |ISDN_FEATURE_L2_TRANS |ISDN_FEATURE_L3_TRANS | ISDN_FEATURE_P_UNKNOWN |
@@ -2080,7 +2081,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)ISDN_FEATURE_L2_X75UI |ISDN_FEATURE_L2_X75BUI ;if (profp->support1 & (1 <<2 )) - card->interface.features |=ISDN_FEATURE_L2_V11096 | + card->interface.features |= +ISDN_FEATURE_L2_V11096 |ISDN_FEATURE_L2_V11019 |ISDN_FEATURE_L2_V11038 ;if (profp->support1 & (1 <<8 ))
Signature · 1 line
1.7.3.4
Re: [PATCH 1/8] isdn/gigaset: ratelimit CAPI message dumps
In reply to Tilman SchmidtAm 26.04.2012 01:02, schrieb Tilman Schmidt:
Quoted 5 lines
Introduce a global ratelimit for CAPI message dumps to protect against possible log flood.
Drop the ratelimit for ignored messages which is now covered by the global one.
Hmm, I think the only CAPI messages which would need a ratelimit are related to the DATA_B3 messages. If you need CAPI debug messages in most cases you do not need all of the DATA_B3, but you do not want to miss any other message related to the call control. With a general rate limit you do not have the control, which messages are logged and which are not. And here maybe some cases, when even the DATA_B3 are important (e.g. searching bugs in flow control), so I would make it still conditional to allow to print all messages.
And I'm not sure, if this is really something for stable.
Quoted 71 lines
Signed-off-by Tilman Schmidt <[email protected]>CC stable <[email protected]>--- drivers/isdn/gigaset/capi.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)drivers/isdn/gigaset/capi.c +9
-13@@ -14,6 +14,7 @@#include "gigaset.h" #include <linux/proc_fs.h> #include <linux/seq_file.h> +#include <linux/ratelimit.h> #include <linux/isdn/capilli.h> #include <linux/isdn/capicmd.h> #include <linux/isdn/capiutil.h> @@ -223,10 +224,14 @@ get_appl(struct gigaset_capi_ctr *iif, u16 appl)static inline void dump_cmsg (enum debuglevel level,const char *tag,_cmsg *p) {#ifdef CONFIG_GIGASET_DEBUG +/* dump at most 20 messages in 20 secs */ + static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20);_cdebbuf *cdb;if (!(gigaset_debuglevel & level))return ; +if (!___ratelimit (&msg_dump_ratelimit, tag)) +return ; cdb =capi_cmsg2str (p);if (cdb) {@@ -2059,12 +2064,6 @@ static void do_reset_b3_req(struct gigaset_capi_ctr *iif, }/* -* dump unsupported/ignored messages at most twice per minute, -* some apps send those very frequently -*/ -static unsigned long ignored_msg_dump_time; - -/* * unsupported CAPI message handler */ static void do_unsupported(struct gigaset_capi_ctr *iif,@@ -2073,8 +2072,7 @@ static void do_unsupported(struct gigaset_capi_ctr *iif, {/* decode message */ capi_message2cmsg (&iif->acmsg, skb->data); -if (printk_timed_ratelimit (&ignored_msg_dump_time,30 *1000 )) -dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg); +dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg);send_conf (iif, ap, skb, CapiMessageNotSupportedInCurrentState); }@@ -2085,11 +2083,9 @@ static void do_nothing(struct gigaset_capi_ctr *iif,struct gigaset_capi_appl *ap, struct sk_buff *skb) { -if (printk_timed_ratelimit (&ignored_msg_dump_time,30 *1000 )) { -/* decode message */ -capi_message2cmsg (&iif->acmsg, skb->data); -dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg); - } +/* decode message */ + capi_message2cmsg(&iif->acmsg, skb->data); +dump_cmsg (DEBUG_CMD , __func__, &iif->acmsg);dev_kfree_skb_any (skb); }
Signature · 8 lines
Karsten Keil Linux Kernel Development Tel: +49 175 7249132 Mail: [email protected] B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
Re: [PATCH 1/8] isdn/gigaset: ratelimit CAPI message dumps
Am 26.04.2012 08:39, schrieb Karsten Keil:
Quoted 11 lines
Am 26.04.2012 01:02, schrieb Tilman Schmidt:
Quoted 4 lines
Introduce a global ratelimit for CAPI message dumps to protect against possible log flood.
Drop the ratelimit for ignored messages which is now covered by the global one.Hmm, I think the only CAPI messages which would need a ratelimit are related to the
DATA_B3messages. If you need CAPI debug messages in most cases you do not need all of theDATA_B3, but you do not want to miss any other message related to the call control. With a general rate limit you do not have the control, which messages are logged and which are not.
The ratelimit introduced by this patch only applies to messages other than DATA_B3. Logging DATA_B3 messages is not done via dump_cmsg().
I'd like to ratelimit specifically non-DATA_B3 messages because I saw a (possibly buggy) CAPI application flooding the log with FACILITY messages. Equally important, I'd like to make the ratelimit in do_nothing() / do_unsupported() bursty because I had a case where I needed to see several ignored/unhandled CAPI messages in quick succession. So this patch is killing two birds with one stone for me.
The burst limit of 20 messages in 20 seconds is chosen to allow a complete call setup sequence to be logged, while limiting to one message per second in the long run.
Quoted 3 lines
And here maybe some cases, when even the
DATA_B3are important (e.g. searching bugs in flow control), so I would make it still conditional to allow to print all messages.
DATA_B3 dumps produce an enormous amount of log data and are therefore controlled separately by the DEBUG_MCMD flag. Someone who enables that should know what she or he does. But if you need them, you need them all. A ratelimit doesn't make sense there in my experience.
Quoted 1 line
And I'm not sure, if this is really something for stable.
It's pretty simple and localized, a net simplification, and only affects generation of debugging messages, so I think it's safe. But if you see a problem there I can drop the "CC: stable" line.
Thanks,
Tilman
Signature · 4 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
Re: [PATCH 1/8] isdn/gigaset: ratelimit CAPI message dumps
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 27.04.2012 12:29, schrieb Tilman Schmidt:
Quoted 13 lines
Am 26.04.2012 08:39, schrieb Karsten Keil:
Quoted 11 lines
Am 26.04.2012 01:02, schrieb Tilman Schmidt:
Quoted 3 lines
Introduce a global ratelimit for CAPI message dumps to protect
against possible log flood. Drop the ratelimit for ignored
messages which is now covered by the global one.Hmm, I think the only CAPI messages which would need a ratelimit are related to the
DATA_B3messages. If you need CAPI debug messages in most cases you do not need all of theDATA_B3, but you do not want to miss any other message related to the call control. With a general rate limit you do not have the control, which messages are logged and which are not.
Quoted 4 lines
The ratelimit introduced by this patch only applies to messages other than
DATA_B3. LoggingDATA_B3messages is not done viadump_cmsg().
Thanks for the clarification, forget about my objection. I ack this patch now.
Quoted 22 lines
I'd like to ratelimit specifically non-DATA_B3 messages because I saw a (possibly buggy) CAPI application flooding the log with FACILITY messages. Equally important, I'd like to make the ratelimit in
do_nothing()/do_unsupported()bursty because I had a case where I needed to see several ignored/unhandled CAPI messages in quick succession. So this patch is killing two birds with one stone for me.The burst limit of 20 messages in 20 seconds is chosen to allow a complete call setup sequence to be logged, while limiting to one message per second in the long run.
Quoted 3 lines
And here maybe some cases, when even the
DATA_B3are important (e.g. searching bugs in flow control), so I would make it still conditional to allow to print all messages.
DATA_B3dumps produce an enormous amount of log data and are therefore controlled separately by theDEBUG_MCMDflag. Someone who enables that should know what she or he does. But if you need them, you need them all. A ratelimit doesn't make sense there in my experience.
Quoted 6 lines
Quoted 1 line
And I'm not sure, if this is really something for stable.
It's pretty simple and localized, a net simplification, and only affects generation of debugging messages, so I think it's safe. But if you see a problem there I can drop the "CC: stable" line.
I let the decision about it to you and the stable maintainers.
- --
Karsten Keil
Linux Kernel Development
Tel: +49 175 7249132
Mail: [email protected]
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 -----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk+buHwACgkQo5VVC52CNcRoygCfWwPlWZ+A48OwEkr/MtK6PeNG 0UEAnipdxPSZDKa4s99LlGYwvggWIIAJ
=CLr6
-----END PGP SIGNATURE-----
Quoted 3 lines · /me
here's a series of eight patches to the Kernel CAPI subsystem and the Gigaset driver. Please consider for application to net-next. The first three should also go into -stable and are tagged accordingly.
Is there anything missing for these to be accepted into net-next? Or should I just be patient?
Thanks,
Tilman
Quoted 9 lines
Tilman Schmidt (8):
isdn/gigaset: ratelimit CAPI message dumps isdn/gigaset: fix CAPI disconnect B3 handling isdn/gigaset: improve error handling querying firmware version isdn/gigaset: fix readability damage
isdn/gigaset: internal function name cleanup isdn/gigaset: unify function return values isdn/capi: fix readability damage
isdn/capi: elliminatecapincci_find()in non-middleware case
Signature · 4 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
David Miller
maintainerFrom: Tilman Schmidt <[email protected]>
Date: Tue, 08 May 2012 02:24:17 +0200
Quoted 7 lines · /me
Quoted 3 lines
here's a series of eight patches to the Kernel CAPI subsystem and the Gigaset driver. Please consider for application to net-next. The first three should also go into -stable and are tagged accordingly.
Is there anything missing for these to be accepted into net-next? Or should I just be patient?
I'll take care of it, I just put them back into "under review" state in patchwork.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Mon, 07 May 2012 22:29:12 -0400 (EDT)
Quoted 8 lines
From: Tilman Schmidt <[email protected]>
Date: Tue, 08 May 2012 02:24:17 +0200Quoted 5 lines · /me
Quoted 3 lines
here's a series of eight patches to the Kernel CAPI subsystem and the Gigaset driver. Please consider for application to net-next. The first three should also go into -stable and are tagged accordingly.
Quoted 5 lines
Quoted 2 lines
Is there anything missing for these to be accepted into net-next? Or should I just be patient?
I'll take care of it, I just put them back into "under review" state in patchwork.
All applied and pushed out to net-next, thanks Tilman.