aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2012-04-25 09:02:20 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-07 22:37:56 -0400
commit81fa7b82570ec4337d328e6aee45689455508821 (patch)
tree79cdb018f497a18635ea78a171cd211845e0b605 /drivers/isdn
parent7643ffbd02ac46f880f64bed24a85d453b501418 (diff)
isdn/gigaset: unify function return values
Various 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. Inspired-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c33
-rw-r--r--drivers/isdn/gigaset/capi.c8
-rw-r--r--drivers/isdn/gigaset/common.c43
-rw-r--r--drivers/isdn/gigaset/dummyll.c2
-rw-r--r--drivers/isdn/gigaset/ev-layer.c16
-rw-r--r--drivers/isdn/gigaset/gigaset.h2
-rw-r--r--drivers/isdn/gigaset/i4l.c12
-rw-r--r--drivers/isdn/gigaset/isocdata.c12
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c21
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c19
10 files changed, 87 insertions, 81 deletions
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index d6515237c0ec..3b9278b333ba 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -2077,16 +2077,14 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
2077/* Free hardware dependent part of the B channel structure 2077/* Free hardware dependent part of the B channel structure
2078 * parameter: 2078 * parameter:
2079 * bcs B channel structure 2079 * bcs B channel structure
2080 * return value:
2081 * !=0 on success
2082 */ 2080 */
2083static int gigaset_freebcshw(struct bc_state *bcs) 2081static void gigaset_freebcshw(struct bc_state *bcs)
2084{ 2082{
2085 struct bas_bc_state *ubc = bcs->hw.bas; 2083 struct bas_bc_state *ubc = bcs->hw.bas;
2086 int i; 2084 int i;
2087 2085
2088 if (!ubc) 2086 if (!ubc)
2089 return 0; 2087 return;
2090 2088
2091 /* kill URBs and tasklets before freeing - better safe than sorry */ 2089 /* kill URBs and tasklets before freeing - better safe than sorry */
2092 ubc->running = 0; 2090 ubc->running = 0;
@@ -2104,14 +2102,13 @@ static int gigaset_freebcshw(struct bc_state *bcs)
2104 kfree(ubc->isooutbuf); 2102 kfree(ubc->isooutbuf);
2105 kfree(ubc); 2103 kfree(ubc);
2106 bcs->hw.bas = NULL; 2104 bcs->hw.bas = NULL;
2107 return 1;
2108} 2105}
2109 2106
2110/* Initialize hardware dependent part of the B channel structure 2107/* Initialize hardware dependent part of the B channel structure
2111 * parameter: 2108 * parameter:
2112 * bcs B channel structure 2109 * bcs B channel structure
2113 * return value: 2110 * return value:
2114 * !=0 on success 2111 * 0 on success, error code < 0 on failure
2115 */ 2112 */
2116static int gigaset_initbcshw(struct bc_state *bcs) 2113static int gigaset_initbcshw(struct bc_state *bcs)
2117{ 2114{
@@ -2121,7 +2118,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
2121 bcs->hw.bas = ubc = kmalloc(sizeof(struct bas_bc_state), GFP_KERNEL); 2118 bcs->hw.bas = ubc = kmalloc(sizeof(struct bas_bc_state), GFP_KERNEL);
2122 if (!ubc) { 2119 if (!ubc) {
2123 pr_err("out of memory\n"); 2120 pr_err("out of memory\n");
2124 return 0; 2121 return -ENOMEM;
2125 } 2122 }
2126 2123
2127 ubc->running = 0; 2124 ubc->running = 0;
@@ -2138,7 +2135,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
2138 pr_err("out of memory\n"); 2135 pr_err("out of memory\n");
2139 kfree(ubc); 2136 kfree(ubc);
2140 bcs->hw.bas = NULL; 2137 bcs->hw.bas = NULL;
2141 return 0; 2138 return -ENOMEM;
2142 } 2139 }
2143 tasklet_init(&ubc->sent_tasklet, 2140 tasklet_init(&ubc->sent_tasklet,
2144 write_iso_tasklet, (unsigned long) bcs); 2141 write_iso_tasklet, (unsigned long) bcs);
@@ -2163,7 +2160,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
2163 ubc->stolen0s = 0; 2160 ubc->stolen0s = 0;
2164 tasklet_init(&ubc->rcvd_tasklet, 2161 tasklet_init(&ubc->rcvd_tasklet,
2165 read_iso_tasklet, (unsigned long) bcs); 2162 read_iso_tasklet, (unsigned long) bcs);
2166 return 1; 2163 return 0;
2167} 2164}
2168 2165
2169static void gigaset_reinitbcshw(struct bc_state *bcs) 2166static void gigaset_reinitbcshw(struct bc_state *bcs)
@@ -2186,6 +2183,12 @@ static void gigaset_freecshw(struct cardstate *cs)
2186 cs->hw.bas = NULL; 2183 cs->hw.bas = NULL;
2187} 2184}
2188 2185
2186/* Initialize hardware dependent part of the cardstate structure
2187 * parameter:
2188 * cs cardstate structure
2189 * return value:
2190 * 0 on success, error code < 0 on failure
2191 */
2189static int gigaset_initcshw(struct cardstate *cs) 2192static int gigaset_initcshw(struct cardstate *cs)
2190{ 2193{
2191 struct bas_cardstate *ucs; 2194 struct bas_cardstate *ucs;
@@ -2193,13 +2196,13 @@ static int gigaset_initcshw(struct cardstate *cs)
2193 cs->hw.bas = ucs = kmalloc(sizeof *ucs, GFP_KERNEL); 2196 cs->hw.bas = ucs = kmalloc(sizeof *ucs, GFP_KERNEL);
2194 if (!ucs) { 2197 if (!ucs) {
2195 pr_err("out of memory\n"); 2198 pr_err("out of memory\n");
2196 return 0; 2199 return -ENOMEM;
2197 } 2200 }
2198 ucs->int_in_buf = kmalloc(IP_MSGSIZE, GFP_KERNEL); 2201 ucs->int_in_buf = kmalloc(IP_MSGSIZE, GFP_KERNEL);
2199 if (!ucs->int_in_buf) { 2202 if (!ucs->int_in_buf) {
2200 kfree(ucs); 2203 kfree(ucs);
2201 pr_err("out of memory\n"); 2204 pr_err("out of memory\n");
2202 return 0; 2205 return -ENOMEM;
2203 } 2206 }
2204 2207
2205 ucs->urb_cmd_in = NULL; 2208 ucs->urb_cmd_in = NULL;
@@ -2218,7 +2221,7 @@ static int gigaset_initcshw(struct cardstate *cs)
2218 init_waitqueue_head(&ucs->waitqueue); 2221 init_waitqueue_head(&ucs->waitqueue);
2219 INIT_WORK(&ucs->int_in_wq, int_in_work); 2222 INIT_WORK(&ucs->int_in_wq, int_in_work);
2220 2223
2221 return 1; 2224 return 0;
2222} 2225}
2223 2226
2224/* freeurbs 2227/* freeurbs
@@ -2378,18 +2381,20 @@ static int gigaset_probe(struct usb_interface *interface,
2378 /* save address of controller structure */ 2381 /* save address of controller structure */
2379 usb_set_intfdata(interface, cs); 2382 usb_set_intfdata(interface, cs);
2380 2383
2381 if (!gigaset_start(cs)) 2384 rc = gigaset_start(cs);
2385 if (rc < 0)
2382 goto error; 2386 goto error;
2383 2387
2384 return 0; 2388 return 0;
2385 2389
2386allocerr: 2390allocerr:
2387 dev_err(cs->dev, "could not allocate URBs\n"); 2391 dev_err(cs->dev, "could not allocate URBs\n");
2392 rc = -ENOMEM;
2388error: 2393error:
2389 freeurbs(cs); 2394 freeurbs(cs);
2390 usb_set_intfdata(interface, NULL); 2395 usb_set_intfdata(interface, NULL);
2391 gigaset_freecs(cs); 2396 gigaset_freecs(cs);
2392 return -ENODEV; 2397 return rc;
2393} 2398}
2394 2399
2395/* gigaset_disconnect 2400/* gigaset_disconnect
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 86cee65d2e9f..27e4a3e21d64 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -2346,7 +2346,7 @@ static const struct file_operations gigaset_proc_fops = {
2346 * @cs: device descriptor structure. 2346 * @cs: device descriptor structure.
2347 * @isdnid: device name. 2347 * @isdnid: device name.
2348 * 2348 *
2349 * Return value: 1 for success, 0 for failure 2349 * Return value: 0 on success, error code < 0 on failure
2350 */ 2350 */
2351int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) 2351int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
2352{ 2352{
@@ -2356,7 +2356,7 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
2356 iif = kmalloc(sizeof(*iif), GFP_KERNEL); 2356 iif = kmalloc(sizeof(*iif), GFP_KERNEL);
2357 if (!iif) { 2357 if (!iif) {
2358 pr_err("%s: out of memory\n", __func__); 2358 pr_err("%s: out of memory\n", __func__);
2359 return 0; 2359 return -ENOMEM;
2360 } 2360 }
2361 2361
2362 /* prepare controller structure */ 2362 /* prepare controller structure */
@@ -2380,12 +2380,12 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
2380 if (rc) { 2380 if (rc) {
2381 pr_err("attach_capi_ctr failed (%d)\n", rc); 2381 pr_err("attach_capi_ctr failed (%d)\n", rc);
2382 kfree(iif); 2382 kfree(iif);
2383 return 0; 2383 return rc;
2384 } 2384 }
2385 2385
2386 cs->iif = iif; 2386 cs->iif = iif;
2387 cs->hw_hdr_len = CAPI_DATA_B3_REQ_LEN; 2387 cs->hw_hdr_len = CAPI_DATA_B3_REQ_LEN;
2388 return 1; 2388 return 0;
2389} 2389}
2390 2390
2391/** 2391/**
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 6c306d4551dc..aa41485bc594 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -194,13 +194,13 @@ int gigaset_get_channel(struct bc_state *bcs)
194 gig_dbg(DEBUG_CHANNEL, "could not allocate channel %d", 194 gig_dbg(DEBUG_CHANNEL, "could not allocate channel %d",
195 bcs->channel); 195 bcs->channel);
196 spin_unlock_irqrestore(&bcs->cs->lock, flags); 196 spin_unlock_irqrestore(&bcs->cs->lock, flags);
197 return 0; 197 return -EBUSY;
198 } 198 }
199 ++bcs->use_count; 199 ++bcs->use_count;
200 bcs->busy = 1; 200 bcs->busy = 1;
201 gig_dbg(DEBUG_CHANNEL, "allocated channel %d", bcs->channel); 201 gig_dbg(DEBUG_CHANNEL, "allocated channel %d", bcs->channel);
202 spin_unlock_irqrestore(&bcs->cs->lock, flags); 202 spin_unlock_irqrestore(&bcs->cs->lock, flags);
203 return 1; 203 return 0;
204} 204}
205 205
206struct bc_state *gigaset_get_free_channel(struct cardstate *cs) 206struct bc_state *gigaset_get_free_channel(struct cardstate *cs)
@@ -258,7 +258,7 @@ int gigaset_get_channels(struct cardstate *cs)
258 spin_unlock_irqrestore(&cs->lock, flags); 258 spin_unlock_irqrestore(&cs->lock, flags);
259 gig_dbg(DEBUG_CHANNEL, 259 gig_dbg(DEBUG_CHANNEL,
260 "could not allocate all channels"); 260 "could not allocate all channels");
261 return 0; 261 return -EBUSY;
262 } 262 }
263 for (i = 0; i < cs->channels; ++i) 263 for (i = 0; i < cs->channels; ++i)
264 ++cs->bcs[i].use_count; 264 ++cs->bcs[i].use_count;
@@ -266,7 +266,7 @@ int gigaset_get_channels(struct cardstate *cs)
266 266
267 gig_dbg(DEBUG_CHANNEL, "allocated all channels"); 267 gig_dbg(DEBUG_CHANNEL, "allocated all channels");
268 268
269 return 1; 269 return 0;
270} 270}
271 271
272void gigaset_free_channels(struct cardstate *cs) 272void gigaset_free_channels(struct cardstate *cs)
@@ -388,8 +388,7 @@ static void gigaset_freebcs(struct bc_state *bcs)
388 int i; 388 int i;
389 389
390 gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel); 390 gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
391 if (!bcs->cs->ops->freebcshw(bcs)) 391 bcs->cs->ops->freebcshw(bcs);
392 gig_dbg(DEBUG_INIT, "failed");
393 392
394 gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); 393 gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
395 clear_at_state(&bcs->at_state); 394 clear_at_state(&bcs->at_state);
@@ -566,6 +565,8 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct cardstate *cs)
566 * @inbuf: buffer structure. 565 * @inbuf: buffer structure.
567 * @src: received data. 566 * @src: received data.
568 * @numbytes: number of bytes received. 567 * @numbytes: number of bytes received.
568 *
569 * Return value: !=0 if some data was appended
569 */ 570 */
570int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, 571int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
571 unsigned numbytes) 572 unsigned numbytes)
@@ -609,8 +610,8 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
609EXPORT_SYMBOL_GPL(gigaset_fill_inbuf); 610EXPORT_SYMBOL_GPL(gigaset_fill_inbuf);
610 611
611/* Initialize the b-channel structure */ 612/* Initialize the b-channel structure */
612static struct bc_state *gigaset_initbcs(struct bc_state *bcs, 613static int gigaset_initbcs(struct bc_state *bcs, struct cardstate *cs,
613 struct cardstate *cs, int channel) 614 int channel)
614{ 615{
615 int i; 616 int i;
616 617
@@ -649,11 +650,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
649 bcs->apconnstate = 0; 650 bcs->apconnstate = 0;
650 651
651 gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel); 652 gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
652 if (cs->ops->initbcshw(bcs)) 653 return cs->ops->initbcshw(bcs);
653 return bcs;
654
655 gig_dbg(DEBUG_INIT, " failed");
656 return NULL;
657} 654}
658 655
659/** 656/**
@@ -752,7 +749,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
752 cs->cmdbytes = 0; 749 cs->cmdbytes = 0;
753 750
754 gig_dbg(DEBUG_INIT, "setting up iif"); 751 gig_dbg(DEBUG_INIT, "setting up iif");
755 if (!gigaset_isdn_regdev(cs, modulename)) { 752 if (gigaset_isdn_regdev(cs, modulename) < 0) {
756 pr_err("error registering ISDN device\n"); 753 pr_err("error registering ISDN device\n");
757 goto error; 754 goto error;
758 } 755 }
@@ -760,7 +757,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
760 make_valid(cs, VALID_ID); 757 make_valid(cs, VALID_ID);
761 ++cs->cs_init; 758 ++cs->cs_init;
762 gig_dbg(DEBUG_INIT, "setting up hw"); 759 gig_dbg(DEBUG_INIT, "setting up hw");
763 if (!cs->ops->initcshw(cs)) 760 if (cs->ops->initcshw(cs) < 0)
764 goto error; 761 goto error;
765 762
766 ++cs->cs_init; 763 ++cs->cs_init;
@@ -774,7 +771,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
774 /* set up channel data structures */ 771 /* set up channel data structures */
775 for (i = 0; i < channels; ++i) { 772 for (i = 0; i < channels; ++i) {
776 gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); 773 gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i);
777 if (!gigaset_initbcs(cs->bcs + i, cs, i)) { 774 if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) {
778 pr_err("could not allocate channel %d data\n", i); 775 pr_err("could not allocate channel %d data\n", i);
779 goto error; 776 goto error;
780 } 777 }
@@ -869,7 +866,7 @@ static void cleanup_cs(struct cardstate *cs)
869 866
870 for (i = 0; i < cs->channels; ++i) { 867 for (i = 0; i < cs->channels; ++i) {
871 gigaset_freebcs(cs->bcs + i); 868 gigaset_freebcs(cs->bcs + i);
872 if (!gigaset_initbcs(cs->bcs + i, cs, i)) 869 if (gigaset_initbcs(cs->bcs + i, cs, i) < 0)
873 pr_err("could not allocate channel %d data\n", i); 870 pr_err("could not allocate channel %d data\n", i);
874 } 871 }
875 872
@@ -890,14 +887,14 @@ static void cleanup_cs(struct cardstate *cs)
890 * waiting for completion of the initialization. 887 * waiting for completion of the initialization.
891 * 888 *
892 * Return value: 889 * Return value:
893 * 1 - success, 0 - error 890 * 0 on success, error code < 0 on failure
894 */ 891 */
895int gigaset_start(struct cardstate *cs) 892int gigaset_start(struct cardstate *cs)
896{ 893{
897 unsigned long flags; 894 unsigned long flags;
898 895
899 if (mutex_lock_interruptible(&cs->mutex)) 896 if (mutex_lock_interruptible(&cs->mutex))
900 return 0; 897 return -EBUSY;
901 898
902 spin_lock_irqsave(&cs->lock, flags); 899 spin_lock_irqsave(&cs->lock, flags);
903 cs->connected = 1; 900 cs->connected = 1;
@@ -921,11 +918,11 @@ int gigaset_start(struct cardstate *cs)
921 wait_event(cs->waitqueue, !cs->waiting); 918 wait_event(cs->waitqueue, !cs->waiting);
922 919
923 mutex_unlock(&cs->mutex); 920 mutex_unlock(&cs->mutex);
924 return 1; 921 return 0;
925 922
926error: 923error:
927 mutex_unlock(&cs->mutex); 924 mutex_unlock(&cs->mutex);
928 return 0; 925 return -ENOMEM;
929} 926}
930EXPORT_SYMBOL_GPL(gigaset_start); 927EXPORT_SYMBOL_GPL(gigaset_start);
931 928
@@ -937,7 +934,7 @@ EXPORT_SYMBOL_GPL(gigaset_start);
937 * waiting for completion of the shutdown. 934 * waiting for completion of the shutdown.
938 * 935 *
939 * Return value: 936 * Return value:
940 * 0 - success, -1 - error (no device associated) 937 * 0 - success, -ENODEV - error (no device associated)
941 */ 938 */
942int gigaset_shutdown(struct cardstate *cs) 939int gigaset_shutdown(struct cardstate *cs)
943{ 940{
@@ -945,7 +942,7 @@ int gigaset_shutdown(struct cardstate *cs)
945 942
946 if (!(cs->flags & VALID_MINOR)) { 943 if (!(cs->flags & VALID_MINOR)) {
947 mutex_unlock(&cs->mutex); 944 mutex_unlock(&cs->mutex);
948 return -1; 945 return -ENODEV;
949 } 946 }
950 947
951 cs->waiting = 1; 948 cs->waiting = 1;
diff --git a/drivers/isdn/gigaset/dummyll.c b/drivers/isdn/gigaset/dummyll.c
index 19b1c779d50f..570c2d53b84e 100644
--- a/drivers/isdn/gigaset/dummyll.c
+++ b/drivers/isdn/gigaset/dummyll.c
@@ -60,7 +60,7 @@ void gigaset_isdn_stop(struct cardstate *cs)
60 60
61int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) 61int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
62{ 62{
63 return 1; 63 return 0;
64} 64}
65 65
66void gigaset_isdn_unregdev(struct cardstate *cs) 66void gigaset_isdn_unregdev(struct cardstate *cs)
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index 8391e09a698a..2e6963dc740e 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -658,7 +658,7 @@ static inline struct at_state_t *get_free_channel(struct cardstate *cs,
658 struct at_state_t *ret; 658 struct at_state_t *ret;
659 659
660 for (i = 0; i < cs->channels; ++i) 660 for (i = 0; i < cs->channels; ++i)
661 if (gigaset_get_channel(cs->bcs + i)) { 661 if (gigaset_get_channel(cs->bcs + i) >= 0) {
662 ret = &cs->bcs[i].at_state; 662 ret = &cs->bcs[i].at_state;
663 ret->cid = cid; 663 ret->cid = cid;
664 return ret; 664 return ret;
@@ -923,18 +923,18 @@ static void do_stop(struct cardstate *cs)
923 * channel >= 0: getting cid for the channel failed 923 * channel >= 0: getting cid for the channel failed
924 * channel < 0: entering cid mode failed 924 * channel < 0: entering cid mode failed
925 * 925 *
926 * returns 0 on failure 926 * returns 0 on success, <0 on failure
927 */ 927 */
928static int reinit_and_retry(struct cardstate *cs, int channel) 928static int reinit_and_retry(struct cardstate *cs, int channel)
929{ 929{
930 int i; 930 int i;
931 931
932 if (--cs->retry_count <= 0) 932 if (--cs->retry_count <= 0)
933 return 0; 933 return -EFAULT;
934 934
935 for (i = 0; i < cs->channels; ++i) 935 for (i = 0; i < cs->channels; ++i)
936 if (cs->bcs[i].at_state.cid > 0) 936 if (cs->bcs[i].at_state.cid > 0)
937 return 0; 937 return -EBUSY;
938 938
939 if (channel < 0) 939 if (channel < 0)
940 dev_warn(cs->dev, 940 dev_warn(cs->dev,
@@ -945,7 +945,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
945 cs->bcs[channel].at_state.pending_commands |= PC_CID; 945 cs->bcs[channel].at_state.pending_commands |= PC_CID;
946 } 946 }
947 schedule_init(cs, MS_INIT); 947 schedule_init(cs, MS_INIT);
948 return 1; 948 return 0;
949} 949}
950 950
951static int at_state_invalid(struct cardstate *cs, 951static int at_state_invalid(struct cardstate *cs,
@@ -1016,7 +1016,7 @@ static int do_lock(struct cardstate *cs)
1016 if (cs->bcs[i].at_state.pending_commands) 1016 if (cs->bcs[i].at_state.pending_commands)
1017 return -EBUSY; 1017 return -EBUSY;
1018 1018
1019 if (!gigaset_get_channels(cs)) 1019 if (gigaset_get_channels(cs) < 0)
1020 return -EBUSY; 1020 return -EBUSY;
1021 1021
1022 break; 1022 break;
@@ -1125,7 +1125,7 @@ static void do_action(int action, struct cardstate *cs,
1125 init_failed(cs, M_UNKNOWN); 1125 init_failed(cs, M_UNKNOWN);
1126 break; 1126 break;
1127 } 1127 }
1128 if (!reinit_and_retry(cs, -1)) 1128 if (reinit_and_retry(cs, -1) < 0)
1129 schedule_init(cs, MS_RECOVER); 1129 schedule_init(cs, MS_RECOVER);
1130 break; 1130 break;
1131 case ACT_FAILUMODE: 1131 case ACT_FAILUMODE:
@@ -1268,7 +1268,7 @@ static void do_action(int action, struct cardstate *cs,
1268 case ACT_FAILCID: 1268 case ACT_FAILCID:
1269 cs->cur_at_seq = SEQ_NONE; 1269 cs->cur_at_seq = SEQ_NONE;
1270 channel = cs->curchannel; 1270 channel = cs->curchannel;
1271 if (!reinit_and_retry(cs, channel)) { 1271 if (reinit_and_retry(cs, channel) < 0) {
1272 dev_warn(cs->dev, 1272 dev_warn(cs->dev,
1273 "Could not get a call ID. Cannot dial.\n"); 1273 "Could not get a call ID. Cannot dial.\n");
1274 at_state2 = &cs->bcs[channel].at_state; 1274 at_state2 = &cs->bcs[channel].at_state;
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index eae7351a3f42..8e2fc8f31d16 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -583,7 +583,7 @@ struct gigaset_ops {
583 int (*initbcshw)(struct bc_state *bcs); 583 int (*initbcshw)(struct bc_state *bcs);
584 584
585 /* Called by gigaset_freecs() for freeing bcs->hw.xxx */ 585 /* Called by gigaset_freecs() for freeing bcs->hw.xxx */
586 int (*freebcshw)(struct bc_state *bcs); 586 void (*freebcshw)(struct bc_state *bcs);
587 587
588 /* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */ 588 /* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */
589 void (*reinitbcshw)(struct bc_state *bcs); 589 void (*reinitbcshw)(struct bc_state *bcs);
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c
index 0f13eb1de657..2d75329007f1 100644
--- a/drivers/isdn/gigaset/i4l.c
+++ b/drivers/isdn/gigaset/i4l.c
@@ -229,7 +229,7 @@ static int command_from_LL(isdn_ctrl *cntrl)
229 return -EINVAL; 229 return -EINVAL;
230 } 230 }
231 bcs = cs->bcs + ch; 231 bcs = cs->bcs + ch;
232 if (!gigaset_get_channel(bcs)) { 232 if (gigaset_get_channel(bcs) < 0) {
233 dev_err(cs->dev, "ISDN_CMD_DIAL: channel not free\n"); 233 dev_err(cs->dev, "ISDN_CMD_DIAL: channel not free\n");
234 return -EBUSY; 234 return -EBUSY;
235 } 235 }
@@ -618,7 +618,7 @@ void gigaset_isdn_stop(struct cardstate *cs)
618 * @cs: device descriptor structure. 618 * @cs: device descriptor structure.
619 * @isdnid: device name. 619 * @isdnid: device name.
620 * 620 *
621 * Return value: 1 for success, 0 for failure 621 * Return value: 0 on success, error code < 0 on failure
622 */ 622 */
623int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) 623int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
624{ 624{
@@ -627,14 +627,14 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
627 iif = kmalloc(sizeof *iif, GFP_KERNEL); 627 iif = kmalloc(sizeof *iif, GFP_KERNEL);
628 if (!iif) { 628 if (!iif) {
629 pr_err("out of memory\n"); 629 pr_err("out of memory\n");
630 return 0; 630 return -ENOMEM;
631 } 631 }
632 632
633 if (snprintf(iif->id, sizeof iif->id, "%s_%u", isdnid, cs->minor_index) 633 if (snprintf(iif->id, sizeof iif->id, "%s_%u", isdnid, cs->minor_index)
634 >= sizeof iif->id) { 634 >= sizeof iif->id) {
635 pr_err("ID too long: %s\n", isdnid); 635 pr_err("ID too long: %s\n", isdnid);
636 kfree(iif); 636 kfree(iif);
637 return 0; 637 return -EINVAL;
638 } 638 }
639 639
640 iif->owner = THIS_MODULE; 640 iif->owner = THIS_MODULE;
@@ -656,13 +656,13 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
656 if (!register_isdn(iif)) { 656 if (!register_isdn(iif)) {
657 pr_err("register_isdn failed\n"); 657 pr_err("register_isdn failed\n");
658 kfree(iif); 658 kfree(iif);
659 return 0; 659 return -EINVAL;
660 } 660 }
661 661
662 cs->iif = iif; 662 cs->iif = iif;
663 cs->myid = iif->channels; /* Set my device id */ 663 cs->myid = iif->channels; /* Set my device id */
664 cs->hw_hdr_len = HW_HDR_LEN; 664 cs->hw_hdr_len = HW_HDR_LEN;
665 return 1; 665 return 0;
666} 666}
667 667
668/** 668/**
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index a351c16705bd..bc29f1d52a2f 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -56,7 +56,7 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb)
56 56
57/* start writing 57/* start writing
58 * acquire the write semaphore 58 * acquire the write semaphore
59 * return true if acquired, false if busy 59 * return 0 if acquired, <0 if busy
60 */ 60 */
61static inline int isowbuf_startwrite(struct isowbuf_t *iwb) 61static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
62{ 62{
@@ -64,12 +64,12 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
64 atomic_inc(&iwb->writesem); 64 atomic_inc(&iwb->writesem);
65 gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore", 65 gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
66 __func__); 66 __func__);
67 return 0; 67 return -EBUSY;
68 } 68 }
69 gig_dbg(DEBUG_ISO, 69 gig_dbg(DEBUG_ISO,
70 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", 70 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
71 __func__, iwb->data[iwb->write], iwb->wbits); 71 __func__, iwb->data[iwb->write], iwb->wbits);
72 return 1; 72 return 0;
73} 73}
74 74
75/* finish writing 75/* finish writing
@@ -158,7 +158,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
158 /* no wraparound in valid data */ 158 /* no wraparound in valid data */
159 if (limit >= write) { 159 if (limit >= write) {
160 /* append idle frame */ 160 /* append idle frame */
161 if (!isowbuf_startwrite(iwb)) 161 if (isowbuf_startwrite(iwb) < 0)
162 return -EBUSY; 162 return -EBUSY;
163 /* write position could have changed */ 163 /* write position could have changed */
164 write = iwb->write; 164 write = iwb->write;
@@ -403,7 +403,7 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
403 unsigned char c; 403 unsigned char c;
404 404
405 if (isowbuf_freebytes(iwb) < count + count / 5 + 6 || 405 if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
406 !isowbuf_startwrite(iwb)) { 406 isowbuf_startwrite(iwb) < 0) {
407 gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN", 407 gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
408 __func__, isowbuf_freebytes(iwb)); 408 __func__, isowbuf_freebytes(iwb));
409 return -EAGAIN; 409 return -EAGAIN;
@@ -457,7 +457,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
457 return iwb->write; 457 return iwb->write;
458 458
459 if (isowbuf_freebytes(iwb) < count || 459 if (isowbuf_freebytes(iwb) < count ||
460 !isowbuf_startwrite(iwb)) { 460 isowbuf_startwrite(iwb) < 0) {
461 gig_dbg(DEBUG_ISO, "can't put %d bytes", count); 461 gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
462 return -EAGAIN; 462 return -EAGAIN;
463 } 463 }
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 6f3fd4cf4378..8c91fd5eb6fd 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -340,17 +340,16 @@ static int gigaset_initbcshw(struct bc_state *bcs)
340{ 340{
341 /* unused */ 341 /* unused */
342 bcs->hw.ser = NULL; 342 bcs->hw.ser = NULL;
343 return 1; 343 return 0;
344} 344}
345 345
346/* 346/*
347 * Free B channel structure 347 * Free B channel structure
348 * Called by "gigaset_freebcs" in common.c 348 * Called by "gigaset_freebcs" in common.c
349 */ 349 */
350static int gigaset_freebcshw(struct bc_state *bcs) 350static void gigaset_freebcshw(struct bc_state *bcs)
351{ 351{
352 /* unused */ 352 /* unused */
353 return 1;
354} 353}
355 354
356/* 355/*
@@ -398,7 +397,7 @@ static int gigaset_initcshw(struct cardstate *cs)
398 scs = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL); 397 scs = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL);
399 if (!scs) { 398 if (!scs) {
400 pr_err("out of memory\n"); 399 pr_err("out of memory\n");
401 return 0; 400 return -ENOMEM;
402 } 401 }
403 cs->hw.ser = scs; 402 cs->hw.ser = scs;
404 403
@@ -410,13 +409,13 @@ static int gigaset_initcshw(struct cardstate *cs)
410 pr_err("error %d registering platform device\n", rc); 409 pr_err("error %d registering platform device\n", rc);
411 kfree(cs->hw.ser); 410 kfree(cs->hw.ser);
412 cs->hw.ser = NULL; 411 cs->hw.ser = NULL;
413 return 0; 412 return rc;
414 } 413 }
415 dev_set_drvdata(&cs->hw.ser->dev.dev, cs); 414 dev_set_drvdata(&cs->hw.ser->dev.dev, cs);
416 415
417 tasklet_init(&cs->write_tasklet, 416 tasklet_init(&cs->write_tasklet,
418 gigaset_modem_fill, (unsigned long) cs); 417 gigaset_modem_fill, (unsigned long) cs);
419 return 1; 418 return 0;
420} 419}
421 420
422/* 421/*
@@ -503,6 +502,7 @@ static int
503gigaset_tty_open(struct tty_struct *tty) 502gigaset_tty_open(struct tty_struct *tty)
504{ 503{
505 struct cardstate *cs; 504 struct cardstate *cs;
505 int rc;
506 506
507 gig_dbg(DEBUG_INIT, "Starting HLL for Gigaset M101"); 507 gig_dbg(DEBUG_INIT, "Starting HLL for Gigaset M101");
508 508
@@ -515,8 +515,10 @@ gigaset_tty_open(struct tty_struct *tty)
515 515
516 /* allocate memory for our device state and initialize it */ 516 /* allocate memory for our device state and initialize it */
517 cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME); 517 cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME);
518 if (!cs) 518 if (!cs) {
519 rc = -ENODEV;
519 goto error; 520 goto error;
521 }
520 522
521 cs->dev = &cs->hw.ser->dev.dev; 523 cs->dev = &cs->hw.ser->dev.dev;
522 cs->hw.ser->tty = tty; 524 cs->hw.ser->tty = tty;
@@ -530,7 +532,8 @@ gigaset_tty_open(struct tty_struct *tty)
530 */ 532 */
531 if (startmode == SM_LOCKED) 533 if (startmode == SM_LOCKED)
532 cs->mstate = MS_LOCKED; 534 cs->mstate = MS_LOCKED;
533 if (!gigaset_start(cs)) { 535 rc = gigaset_start(cs);
536 if (rc < 0) {
534 tasklet_kill(&cs->write_tasklet); 537 tasklet_kill(&cs->write_tasklet);
535 goto error; 538 goto error;
536 } 539 }
@@ -542,7 +545,7 @@ error:
542 gig_dbg(DEBUG_INIT, "Startup of HLL failed"); 545 gig_dbg(DEBUG_INIT, "Startup of HLL failed");
543 tty->disc_data = NULL; 546 tty->disc_data = NULL;
544 gigaset_freecs(cs); 547 gigaset_freecs(cs);
545 return -ENODEV; 548 return rc;
546} 549}
547 550
548/* 551/*
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 049da67f6392..bb12d8051732 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -549,10 +549,9 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
549 0, 0, &buf, 6, 2000); 549 0, 0, &buf, 6, 2000);
550} 550}
551 551
552static int gigaset_freebcshw(struct bc_state *bcs) 552static void gigaset_freebcshw(struct bc_state *bcs)
553{ 553{
554 /* unused */ 554 /* unused */
555 return 1;
556} 555}
557 556
558/* Initialize the b-channel structure */ 557/* Initialize the b-channel structure */
@@ -560,7 +559,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
560{ 559{
561 /* unused */ 560 /* unused */
562 bcs->hw.usb = NULL; 561 bcs->hw.usb = NULL;
563 return 1; 562 return 0;
564} 563}
565 564
566static void gigaset_reinitbcshw(struct bc_state *bcs) 565static void gigaset_reinitbcshw(struct bc_state *bcs)
@@ -582,7 +581,7 @@ static int gigaset_initcshw(struct cardstate *cs)
582 kmalloc(sizeof(struct usb_cardstate), GFP_KERNEL); 581 kmalloc(sizeof(struct usb_cardstate), GFP_KERNEL);
583 if (!ucs) { 582 if (!ucs) {
584 pr_err("out of memory\n"); 583 pr_err("out of memory\n");
585 return 0; 584 return -ENOMEM;
586 } 585 }
587 586
588 ucs->bchars[0] = 0; 587 ucs->bchars[0] = 0;
@@ -597,7 +596,7 @@ static int gigaset_initcshw(struct cardstate *cs)
597 tasklet_init(&cs->write_tasklet, 596 tasklet_init(&cs->write_tasklet,
598 gigaset_modem_fill, (unsigned long) cs); 597 gigaset_modem_fill, (unsigned long) cs);
599 598
600 return 1; 599 return 0;
601} 600}
602 601
603/* Send data from current skb to the device. */ 602/* Send data from current skb to the device. */
@@ -766,9 +765,9 @@ static int gigaset_probe(struct usb_interface *interface,
766 if (startmode == SM_LOCKED) 765 if (startmode == SM_LOCKED)
767 cs->mstate = MS_LOCKED; 766 cs->mstate = MS_LOCKED;
768 767
769 if (!gigaset_start(cs)) { 768 retval = gigaset_start(cs);
769 if (retval < 0) {
770 tasklet_kill(&cs->write_tasklet); 770 tasklet_kill(&cs->write_tasklet);
771 retval = -ENODEV;
772 goto error; 771 goto error;
773 } 772 }
774 return 0; 773 return 0;
@@ -898,8 +897,10 @@ static int __init usb_gigaset_init(void)
898 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 897 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
899 GIGASET_MODULENAME, GIGASET_DEVNAME, 898 GIGASET_MODULENAME, GIGASET_DEVNAME,
900 &ops, THIS_MODULE); 899 &ops, THIS_MODULE);
901 if (driver == NULL) 900 if (driver == NULL) {
901 result = -ENOMEM;
902 goto error; 902 goto error;
903 }
903 904
904 /* register this driver with the USB subsystem */ 905 /* register this driver with the USB subsystem */
905 result = usb_register(&gigaset_usb_driver); 906 result = usb_register(&gigaset_usb_driver);
@@ -915,7 +916,7 @@ error:
915 if (driver) 916 if (driver)
916 gigaset_freedriver(driver); 917 gigaset_freedriver(driver);
917 driver = NULL; 918 driver = NULL;
918 return -1; 919 return result;
919} 920}
920 921
921/* 922/*