aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r--drivers/isdn/gigaset/common.c43
1 files changed, 20 insertions, 23 deletions
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;