Commit 81fa7b82 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

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: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7643ffbd
...@@ -2077,16 +2077,14 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) ...@@ -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 /* Free hardware dependent part of the B channel structure
* parameter: * parameter:
* bcs B channel structure * 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; struct bas_bc_state *ubc = bcs->hw.bas;
int i; int i;
if (!ubc) if (!ubc)
return 0; return;
/* kill URBs and tasklets before freeing - better safe than sorry */ /* kill URBs and tasklets before freeing - better safe than sorry */
ubc->running = 0; ubc->running = 0;
...@@ -2104,14 +2102,13 @@ static int gigaset_freebcshw(struct bc_state *bcs) ...@@ -2104,14 +2102,13 @@ static int gigaset_freebcshw(struct bc_state *bcs)
kfree(ubc->isooutbuf); kfree(ubc->isooutbuf);
kfree(ubc); kfree(ubc);
bcs->hw.bas = NULL; bcs->hw.bas = NULL;
return 1;
} }
/* Initialize hardware dependent part of the B channel structure /* Initialize hardware dependent part of the B channel structure
* parameter: * parameter:
* bcs B channel structure * bcs B channel structure
* return value: * return value:
* !=0 on success * 0 on success, error code < 0 on failure
*/ */
static int gigaset_initbcshw(struct bc_state *bcs) static int gigaset_initbcshw(struct bc_state *bcs)
{ {
...@@ -2121,7 +2118,7 @@ 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); bcs->hw.bas = ubc = kmalloc(sizeof(struct bas_bc_state), GFP_KERNEL);
if (!ubc) { if (!ubc) {
pr_err("out of memory\n"); pr_err("out of memory\n");
return 0; return -ENOMEM;
} }
ubc->running = 0; ubc->running = 0;
...@@ -2138,7 +2135,7 @@ static int gigaset_initbcshw(struct bc_state *bcs) ...@@ -2138,7 +2135,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
pr_err("out of memory\n"); pr_err("out of memory\n");
kfree(ubc); kfree(ubc);
bcs->hw.bas = NULL; bcs->hw.bas = NULL;
return 0; return -ENOMEM;
} }
tasklet_init(&ubc->sent_tasklet, tasklet_init(&ubc->sent_tasklet,
write_iso_tasklet, (unsigned long) bcs); write_iso_tasklet, (unsigned long) bcs);
...@@ -2163,7 +2160,7 @@ static int gigaset_initbcshw(struct bc_state *bcs) ...@@ -2163,7 +2160,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
ubc->stolen0s = 0; ubc->stolen0s = 0;
tasklet_init(&ubc->rcvd_tasklet, tasklet_init(&ubc->rcvd_tasklet,
read_iso_tasklet, (unsigned long) bcs); read_iso_tasklet, (unsigned long) bcs);
return 1; return 0;
} }
static void gigaset_reinitbcshw(struct bc_state *bcs) static void gigaset_reinitbcshw(struct bc_state *bcs)
...@@ -2186,6 +2183,12 @@ static void gigaset_freecshw(struct cardstate *cs) ...@@ -2186,6 +2183,12 @@ static void gigaset_freecshw(struct cardstate *cs)
cs->hw.bas = NULL; 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) static int gigaset_initcshw(struct cardstate *cs)
{ {
struct bas_cardstate *ucs; struct bas_cardstate *ucs;
...@@ -2193,13 +2196,13 @@ static int gigaset_initcshw(struct cardstate *cs) ...@@ -2193,13 +2196,13 @@ static int gigaset_initcshw(struct cardstate *cs)
cs->hw.bas = ucs = kmalloc(sizeof *ucs, GFP_KERNEL); cs->hw.bas = ucs = kmalloc(sizeof *ucs, GFP_KERNEL);
if (!ucs) { if (!ucs) {
pr_err("out of memory\n"); pr_err("out of memory\n");
return 0; return -ENOMEM;
} }
ucs->int_in_buf = kmalloc(IP_MSGSIZE, GFP_KERNEL); ucs->int_in_buf = kmalloc(IP_MSGSIZE, GFP_KERNEL);
if (!ucs->int_in_buf) { if (!ucs->int_in_buf) {
kfree(ucs); kfree(ucs);
pr_err("out of memory\n"); pr_err("out of memory\n");
return 0; return -ENOMEM;
} }
ucs->urb_cmd_in = NULL; ucs->urb_cmd_in = NULL;
...@@ -2218,7 +2221,7 @@ static int gigaset_initcshw(struct cardstate *cs) ...@@ -2218,7 +2221,7 @@ static int gigaset_initcshw(struct cardstate *cs)
init_waitqueue_head(&ucs->waitqueue); init_waitqueue_head(&ucs->waitqueue);
INIT_WORK(&ucs->int_in_wq, int_in_work); INIT_WORK(&ucs->int_in_wq, int_in_work);
return 1; return 0;
} }
/* freeurbs /* freeurbs
...@@ -2378,18 +2381,20 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2378,18 +2381,20 @@ static int gigaset_probe(struct usb_interface *interface,
/* save address of controller structure */ /* save address of controller structure */
usb_set_intfdata(interface, cs); usb_set_intfdata(interface, cs);
if (!gigaset_start(cs)) rc = gigaset_start(cs);
if (rc < 0)
goto error; goto error;
return 0; return 0;
allocerr: allocerr:
dev_err(cs->dev, "could not allocate URBs\n"); dev_err(cs->dev, "could not allocate URBs\n");
rc = -ENOMEM;
error: error:
freeurbs(cs); freeurbs(cs);
usb_set_intfdata(interface, NULL); usb_set_intfdata(interface, NULL);
gigaset_freecs(cs); gigaset_freecs(cs);
return -ENODEV; return rc;
} }
/* gigaset_disconnect /* gigaset_disconnect
......
...@@ -2346,7 +2346,7 @@ static const struct file_operations gigaset_proc_fops = { ...@@ -2346,7 +2346,7 @@ static const struct file_operations gigaset_proc_fops = {
* @cs: device descriptor structure. * @cs: device descriptor structure.
* @isdnid: device name. * @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) int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
{ {
...@@ -2356,7 +2356,7 @@ 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); iif = kmalloc(sizeof(*iif), GFP_KERNEL);
if (!iif) { if (!iif) {
pr_err("%s: out of memory\n", __func__); pr_err("%s: out of memory\n", __func__);
return 0; return -ENOMEM;
} }
/* prepare controller structure */ /* prepare controller structure */
...@@ -2380,12 +2380,12 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) ...@@ -2380,12 +2380,12 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
if (rc) { if (rc) {
pr_err("attach_capi_ctr failed (%d)\n", rc); pr_err("attach_capi_ctr failed (%d)\n", rc);
kfree(iif); kfree(iif);
return 0; return rc;
} }
cs->iif = iif; cs->iif = iif;
cs->hw_hdr_len = CAPI_DATA_B3_REQ_LEN; cs->hw_hdr_len = CAPI_DATA_B3_REQ_LEN;
return 1; return 0;
} }
/** /**
......
...@@ -194,13 +194,13 @@ int gigaset_get_channel(struct bc_state *bcs) ...@@ -194,13 +194,13 @@ int gigaset_get_channel(struct bc_state *bcs)
gig_dbg(DEBUG_CHANNEL, "could not allocate channel %d", gig_dbg(DEBUG_CHANNEL, "could not allocate channel %d",
bcs->channel); bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags); spin_unlock_irqrestore(&bcs->cs->lock, flags);
return 0; return -EBUSY;
} }
++bcs->use_count; ++bcs->use_count;
bcs->busy = 1; bcs->busy = 1;
gig_dbg(DEBUG_CHANNEL, "allocated channel %d", bcs->channel); gig_dbg(DEBUG_CHANNEL, "allocated channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags); spin_unlock_irqrestore(&bcs->cs->lock, flags);
return 1; return 0;
} }
struct bc_state *gigaset_get_free_channel(struct cardstate *cs) struct bc_state *gigaset_get_free_channel(struct cardstate *cs)
...@@ -258,7 +258,7 @@ int gigaset_get_channels(struct cardstate *cs) ...@@ -258,7 +258,7 @@ int gigaset_get_channels(struct cardstate *cs)
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
gig_dbg(DEBUG_CHANNEL, gig_dbg(DEBUG_CHANNEL,
"could not allocate all channels"); "could not allocate all channels");
return 0; return -EBUSY;
} }
for (i = 0; i < cs->channels; ++i) for (i = 0; i < cs->channels; ++i)
++cs->bcs[i].use_count; ++cs->bcs[i].use_count;
...@@ -266,7 +266,7 @@ int gigaset_get_channels(struct cardstate *cs) ...@@ -266,7 +266,7 @@ int gigaset_get_channels(struct cardstate *cs)
gig_dbg(DEBUG_CHANNEL, "allocated all channels"); gig_dbg(DEBUG_CHANNEL, "allocated all channels");
return 1; return 0;
} }
void gigaset_free_channels(struct cardstate *cs) void gigaset_free_channels(struct cardstate *cs)
...@@ -388,8 +388,7 @@ static void gigaset_freebcs(struct bc_state *bcs) ...@@ -388,8 +388,7 @@ static void gigaset_freebcs(struct bc_state *bcs)
int i; int i;
gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel); gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
if (!bcs->cs->ops->freebcshw(bcs)) bcs->cs->ops->freebcshw(bcs);
gig_dbg(DEBUG_INIT, "failed");
gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
clear_at_state(&bcs->at_state); clear_at_state(&bcs->at_state);
...@@ -566,6 +565,8 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct cardstate *cs) ...@@ -566,6 +565,8 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct cardstate *cs)
* @inbuf: buffer structure. * @inbuf: buffer structure.
* @src: received data. * @src: received data.
* @numbytes: number of bytes received. * @numbytes: number of bytes received.
*
* Return value: !=0 if some data was appended
*/ */
int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
unsigned numbytes) unsigned numbytes)
...@@ -609,8 +610,8 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, ...@@ -609,8 +610,8 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
EXPORT_SYMBOL_GPL(gigaset_fill_inbuf); EXPORT_SYMBOL_GPL(gigaset_fill_inbuf);
/* Initialize the b-channel structure */ /* Initialize the b-channel structure */
static struct bc_state *gigaset_initbcs(struct bc_state *bcs, static int gigaset_initbcs(struct bc_state *bcs, struct cardstate *cs,
struct cardstate *cs, int channel) int channel)
{ {
int i; int i;
...@@ -649,11 +650,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, ...@@ -649,11 +650,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
bcs->apconnstate = 0; bcs->apconnstate = 0;
gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel); gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
if (cs->ops->initbcshw(bcs)) return cs->ops->initbcshw(bcs);
return bcs;
gig_dbg(DEBUG_INIT, " failed");
return NULL;
} }
/** /**
...@@ -752,7 +749,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -752,7 +749,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_isdn_regdev(cs, modulename)) { if (gigaset_isdn_regdev(cs, modulename) < 0) {
pr_err("error registering ISDN device\n"); pr_err("error registering ISDN device\n");
goto error; goto error;
} }
...@@ -760,7 +757,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -760,7 +757,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
make_valid(cs, VALID_ID); make_valid(cs, VALID_ID);
++cs->cs_init; ++cs->cs_init;
gig_dbg(DEBUG_INIT, "setting up hw"); gig_dbg(DEBUG_INIT, "setting up hw");
if (!cs->ops->initcshw(cs)) if (cs->ops->initcshw(cs) < 0)
goto error; goto error;
++cs->cs_init; ++cs->cs_init;
...@@ -774,7 +771,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -774,7 +771,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
/* set up channel data structures */ /* set up channel data structures */
for (i = 0; i < channels; ++i) { for (i = 0; i < channels; ++i) {
gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) { if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) {
pr_err("could not allocate channel %d data\n", i); pr_err("could not allocate channel %d data\n", i);
goto error; goto error;
} }
...@@ -869,7 +866,7 @@ static void cleanup_cs(struct cardstate *cs) ...@@ -869,7 +866,7 @@ static void cleanup_cs(struct cardstate *cs)
for (i = 0; i < cs->channels; ++i) { for (i = 0; i < cs->channels; ++i) {
gigaset_freebcs(cs->bcs + i); gigaset_freebcs(cs->bcs + i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) if (gigaset_initbcs(cs->bcs + i, cs, i) < 0)
pr_err("could not allocate channel %d data\n", i); pr_err("could not allocate channel %d data\n", i);
} }
...@@ -890,14 +887,14 @@ static void cleanup_cs(struct cardstate *cs) ...@@ -890,14 +887,14 @@ static void cleanup_cs(struct cardstate *cs)
* waiting for completion of the initialization. * waiting for completion of the initialization.
* *
* Return value: * Return value:
* 1 - success, 0 - error * 0 on success, error code < 0 on failure
*/ */
int gigaset_start(struct cardstate *cs) int gigaset_start(struct cardstate *cs)
{ {
unsigned long flags; unsigned long flags;
if (mutex_lock_interruptible(&cs->mutex)) if (mutex_lock_interruptible(&cs->mutex))
return 0; return -EBUSY;
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
cs->connected = 1; cs->connected = 1;
...@@ -921,11 +918,11 @@ int gigaset_start(struct cardstate *cs) ...@@ -921,11 +918,11 @@ int gigaset_start(struct cardstate *cs)
wait_event(cs->waitqueue, !cs->waiting); wait_event(cs->waitqueue, !cs->waiting);
mutex_unlock(&cs->mutex); mutex_unlock(&cs->mutex);
return 1; return 0;
error: error:
mutex_unlock(&cs->mutex); mutex_unlock(&cs->mutex);
return 0; return -ENOMEM;
} }
EXPORT_SYMBOL_GPL(gigaset_start); EXPORT_SYMBOL_GPL(gigaset_start);
...@@ -937,7 +934,7 @@ EXPORT_SYMBOL_GPL(gigaset_start); ...@@ -937,7 +934,7 @@ EXPORT_SYMBOL_GPL(gigaset_start);
* waiting for completion of the shutdown. * waiting for completion of the shutdown.
* *
* Return value: * Return value:
* 0 - success, -1 - error (no device associated) * 0 - success, -ENODEV - error (no device associated)
*/ */
int gigaset_shutdown(struct cardstate *cs) int gigaset_shutdown(struct cardstate *cs)
{ {
...@@ -945,7 +942,7 @@ int gigaset_shutdown(struct cardstate *cs) ...@@ -945,7 +942,7 @@ int gigaset_shutdown(struct cardstate *cs)
if (!(cs->flags & VALID_MINOR)) { if (!(cs->flags & VALID_MINOR)) {
mutex_unlock(&cs->mutex); mutex_unlock(&cs->mutex);
return -1; return -ENODEV;
} }
cs->waiting = 1; cs->waiting = 1;
......
...@@ -60,7 +60,7 @@ void gigaset_isdn_stop(struct cardstate *cs) ...@@ -60,7 +60,7 @@ void gigaset_isdn_stop(struct cardstate *cs)
int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
{ {
return 1; return 0;
} }
void gigaset_isdn_unregdev(struct cardstate *cs) void gigaset_isdn_unregdev(struct cardstate *cs)
......
...@@ -658,7 +658,7 @@ static inline struct at_state_t *get_free_channel(struct cardstate *cs, ...@@ -658,7 +658,7 @@ static inline struct at_state_t *get_free_channel(struct cardstate *cs,
struct at_state_t *ret; struct at_state_t *ret;
for (i = 0; i < cs->channels; ++i) 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 = &cs->bcs[i].at_state;
ret->cid = cid; ret->cid = cid;
return ret; return ret;
...@@ -923,18 +923,18 @@ static void do_stop(struct cardstate *cs) ...@@ -923,18 +923,18 @@ static void do_stop(struct cardstate *cs)
* channel >= 0: getting cid for the channel failed * channel >= 0: getting cid for the channel failed
* channel < 0: entering cid mode 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) static int reinit_and_retry(struct cardstate *cs, int channel)
{ {
int i; int i;
if (--cs->retry_count <= 0) if (--cs->retry_count <= 0)
return 0; return -EFAULT;
for (i = 0; i < cs->channels; ++i) for (i = 0; i < cs->channels; ++i)
if (cs->bcs[i].at_state.cid > 0) if (cs->bcs[i].at_state.cid > 0)
return 0; return -EBUSY;
if (channel < 0) if (channel < 0)
dev_warn(cs->dev, dev_warn(cs->dev,
...@@ -945,7 +945,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel) ...@@ -945,7 +945,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
cs->bcs[channel].at_state.pending_commands |= PC_CID; cs->bcs[channel].at_state.pending_commands |= PC_CID;
} }
schedule_init(cs, MS_INIT); schedule_init(cs, MS_INIT);
return 1; return 0;
} }
static int at_state_invalid(struct cardstate *cs, static int at_state_invalid(struct cardstate *cs,
...@@ -1016,7 +1016,7 @@ static int do_lock(struct cardstate *cs) ...@@ -1016,7 +1016,7 @@ static int do_lock(struct cardstate *cs)
if (cs->bcs[i].at_state.pending_commands) if (cs->bcs[i].at_state.pending_commands)
return -EBUSY; return -EBUSY;
if (!gigaset_get_channels(cs)) if (gigaset_get_channels(cs) < 0)
return -EBUSY; return -EBUSY;
break; break;
...@@ -1125,7 +1125,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1125,7 +1125,7 @@ static void do_action(int action, struct cardstate *cs,
init_failed(cs, M_UNKNOWN); init_failed(cs, M_UNKNOWN);
break; break;
} }
if (!reinit_and_retry(cs, -1)) if (reinit_and_retry(cs, -1) < 0)
schedule_init(cs, MS_RECOVER); schedule_init(cs, MS_RECOVER);
break; break;
case ACT_FAILUMODE: case ACT_FAILUMODE:
...@@ -1268,7 +1268,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1268,7 +1268,7 @@ static void do_action(int action, struct cardstate *cs,
case ACT_FAILCID: case ACT_FAILCID:
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
channel = cs->curchannel; channel = cs->curchannel;
if (!reinit_and_retry(cs, channel)) { if (reinit_and_retry(cs, channel) < 0) {
dev_warn(cs->dev, dev_warn(cs->dev,
"Could not get a call ID. Cannot dial.\n"); "Could not get a call ID. Cannot dial.\n");
at_state2 = &cs->bcs[channel].at_state; at_state2 = &cs->bcs[channel].at_state;
......
...@@ -583,7 +583,7 @@ struct gigaset_ops { ...@@ -583,7 +583,7 @@ struct gigaset_ops {
int (*initbcshw)(struct bc_state *bcs); int (*initbcshw)(struct bc_state *bcs);
/* Called by gigaset_freecs() for freeing bcs->hw.xxx */ /* 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 */ /* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */
void (*reinitbcshw)(struct bc_state *bcs); void (*reinitbcshw)(struct bc_state *bcs);
......
...@@ -229,7 +229,7 @@ static int command_from_LL(isdn_ctrl *cntrl) ...@@ -229,7 +229,7 @@ static int command_from_LL(isdn_ctrl *cntrl)
return -EINVAL; return -EINVAL;
} }
bcs = cs->bcs + ch; 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"); dev_err(cs->dev, "ISDN_CMD_DIAL: channel not free\n");
return -EBUSY; return -EBUSY;
} }
...@@ -618,7 +618,7 @@ void gigaset_isdn_stop(struct cardstate *cs) ...@@ -618,7 +618,7 @@ void gigaset_isdn_stop(struct cardstate *cs)
* @cs: device descriptor structure. * @cs: device descriptor structure.
* @isdnid: device name. * @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) int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
{ {
...@@ -627,14 +627,14 @@ 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); iif = kmalloc(sizeof *iif, GFP_KERNEL);
if (!iif) { if (!iif) {
pr_err("out of memory\n"); pr_err("out of memory\n");
return 0; return -ENOMEM;
} }
if (snprintf(iif->id, sizeof iif->id, "%s_%u", isdnid, cs->minor_index) if (snprintf(iif->id, sizeof iif->id, "%s_%u", isdnid, cs->minor_index)
>= sizeof iif->id) { >= sizeof iif->id) {
pr_err("ID too long: %s\n", isdnid); pr_err("ID too long: %s\n", isdnid);
kfree(iif); kfree(iif);
return 0; return -EINVAL;
} }
iif->owner = THIS_MODULE; iif->owner = THIS_MODULE;
...@@ -656,13 +656,13 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) ...@@ -656,13 +656,13 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid)
if (!register_isdn(iif)) { if (!register_isdn(iif)) {
pr_err("register_isdn failed\n"); pr_err("register_isdn failed\n");
kfree(iif); kfree(iif);
return 0; return -EINVAL;
} }
cs->iif = iif; cs->iif = iif;
cs->myid = iif->channels; /* Set my device id */ cs->myid = iif->channels; /* Set my device id */
cs->hw_hdr_len = HW_HDR_LEN; cs->hw_hdr_len = HW_HDR_LEN;
return 1; return 0;
} }
/** /**
......
...@@ -56,7 +56,7 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb) ...@@ -56,7 +56,7 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb)
/* start writing /* start writing
* acquire the write semaphore * 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) static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
{ {
...@@ -64,12 +64,12 @@ 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); atomic_inc(&iwb->writesem);
gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore", gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
__func__); __func__);
return 0; return -EBUSY;
} }
gig_dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO,
"%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
__func__, iwb->data[iwb->write], iwb->wbits); __func__, iwb->data[iwb->write], iwb->wbits);
return 1; return 0;
} }
/* finish writing /* finish writing
...@@ -158,7 +158,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size) ...@@ -158,7 +158,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
/* no wraparound in valid data */ /* no wraparound in valid data */
if (limit >= write) { if (limit >= write) {
/* append idle frame */ /* append idle frame */
if (!isowbuf_startwrite(iwb)) if (isowbuf_startwrite(iwb) < 0)
return -EBUSY; return -EBUSY;
/* write position could have changed */ /* write position could have changed */
write = iwb->write; write = iwb->write;
...@@ -403,7 +403,7 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb, ...@@ -403,7 +403,7 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
unsigned char c; unsigned char c;
if (isowbuf_freebytes(iwb) < count + count / 5 + 6 || if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
!isowbuf_startwrite(iwb)) { isowbuf_startwrite(iwb) < 0) {
gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN", gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
__func__, isowbuf_freebytes(iwb)); __func__, isowbuf_freebytes(iwb));
return -EAGAIN; return -EAGAIN;
...@@ -457,7 +457,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb, ...@@ -457,7 +457,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
return iwb->write; return iwb->write;
if (isowbuf_freebytes(iwb) < count || if (isowbuf_freebytes(iwb) < count ||
!isowbuf_startwrite(iwb)) { isowbuf_startwrite(iwb) < 0) {
gig_dbg(DEBUG_ISO, "can't put %d bytes", count); gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -340,17 +340,16 @@ static int gigaset_initbcshw(struct bc_state *bcs) ...@@ -340,17 +340,16 @@ static int gigaset_initbcshw(struct bc_state *bcs)
{ {
/* unused */ /* unused */
bcs->hw.ser = NULL; bcs->hw.ser = NULL;
return 1; return 0;
} }
/* /*
* Free B channel structure * Free B channel structure
* Called by "gigaset_freebcs" in common.c * Called by "gigaset_freebcs" in common.c
*/ */
static int gigaset_freebcshw(struct bc_state *bcs) static void gigaset_freebcshw(struct bc_state *bcs)
{ {
/* unused */ /* unused */
return 1;
} }
/* /*
...@@ -398,7 +397,7 @@ static int gigaset_initcshw(struct cardstate *cs) ...@@ -398,7 +397,7 @@ static int gigaset_initcshw(struct cardstate *cs)
scs = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL); scs = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL);
if (!scs) { if (!scs) {
pr_err("out of memory\n"); pr_err("out of memory\n");
return 0; return -ENOMEM;
} }
cs->hw.ser = scs; cs->hw.ser = scs;
...@@ -410,13 +409,13 @@ static int gigaset_initcshw(struct cardstate *cs) ...@@ -410,13 +409,13 @@ static int gigaset_initcshw(struct cardstate *cs)
pr_err("error %d registering platform device\n", rc); pr_err("error %d registering platform device\n", rc);
kfree(cs->hw.ser); kfree(cs->hw.ser);
cs->hw.ser = NULL; cs->hw.ser = NULL;
return 0; return rc;
} }
dev_set_drvdata(&cs->hw.ser->dev.dev, cs); dev_set_drvdata(&cs->hw.ser->dev.dev, cs);
tasklet_init(&cs->write_tasklet, tasklet_init(&cs->write_tasklet,
gigaset_modem_fill, (unsigned long) cs); gigaset_modem_fill, (unsigned long) cs);
return 1; return 0;
} }
/* /*
...@@ -503,6 +502,7 @@ static int ...@@ -503,6 +502,7 @@ static int
gigaset_tty_open(struct tty_struct *tty) gigaset_tty_open(struct tty_struct *tty)
{ {
struct cardstate *cs; struct cardstate *cs;
int rc;
gig_dbg(DEBUG_INIT, "Starting HLL for Gigaset M101"); gig_dbg(DEBUG_INIT, "Starting HLL for Gigaset M101");
...@@ -515,8 +515,10 @@ gigaset_tty_open(struct tty_struct *tty) ...@@ -515,8 +515,10 @@ gigaset_tty_open(struct tty_struct *tty)
/* allocate memory for our device state and initialize it */ /* allocate memory for our device state and initialize it */
cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME); cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME);
if (!cs) if (!cs) {
rc = -ENODEV;
goto error; goto error;
}
cs->dev = &cs->hw.ser->dev.dev; cs->dev = &cs->hw.ser->dev.dev;
cs->hw.ser->tty = tty; cs->hw.ser->tty = tty;
...@@ -530,7 +532,8 @@ gigaset_tty_open(struct tty_struct *tty) ...@@ -530,7 +532,8 @@ gigaset_tty_open(struct tty_struct *tty)
*/ */
if (startmode == SM_LOCKED) if (startmode == SM_LOCKED)
cs->mstate = MS_LOCKED; cs->mstate = MS_LOCKED;
if (!gigaset_start(cs)) { rc = gigaset_start(cs);
if (rc < 0) {
tasklet_kill(&cs->write_tasklet); tasklet_kill(&cs->write_tasklet);
goto error; goto error;
} }
...@@ -542,7 +545,7 @@ gigaset_tty_open(struct tty_struct *tty) ...@@ -542,7 +545,7 @@ gigaset_tty_open(struct tty_struct *tty)
gig_dbg(DEBUG_INIT, "Startup of HLL failed"); gig_dbg(DEBUG_INIT, "Startup of HLL failed");
tty->disc_data = NULL; tty->disc_data = NULL;
gigaset_freecs(cs); gigaset_freecs(cs);
return -ENODEV; return rc;
} }
/* /*
......
...@@ -549,10 +549,9 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) ...@@ -549,10 +549,9 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
0, 0, &buf, 6, 2000); 0, 0, &buf, 6, 2000);
} }
static int gigaset_freebcshw(struct bc_state *bcs) static void gigaset_freebcshw(struct bc_state *bcs)
{ {
/* unused */ /* unused */
return 1;
} }
/* Initialize the b-channel structure */ /* Initialize the b-channel structure */
...@@ -560,7 +559,7 @@ static int gigaset_initbcshw(struct bc_state *bcs) ...@@ -560,7 +559,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
{ {
/* unused */ /* unused */
bcs->hw.usb = NULL; bcs->hw.usb = NULL;
return 1; return 0;
} }
static void gigaset_reinitbcshw(struct bc_state *bcs) static void gigaset_reinitbcshw(struct bc_state *bcs)
...@@ -582,7 +581,7 @@ static int gigaset_initcshw(struct cardstate *cs) ...@@ -582,7 +581,7 @@ static int gigaset_initcshw(struct cardstate *cs)
kmalloc(sizeof(struct usb_cardstate), GFP_KERNEL); kmalloc(sizeof(struct usb_cardstate), GFP_KERNEL);
if (!ucs) { if (!ucs) {
pr_err("out of memory\n"); pr_err("out of memory\n");
return 0; return -ENOMEM;
} }
ucs->bchars[0] = 0; ucs->bchars[0] = 0;
...@@ -597,7 +596,7 @@ static int gigaset_initcshw(struct cardstate *cs) ...@@ -597,7 +596,7 @@ static int gigaset_initcshw(struct cardstate *cs)
tasklet_init(&cs->write_tasklet, tasklet_init(&cs->write_tasklet,
gigaset_modem_fill, (unsigned long) cs); gigaset_modem_fill, (unsigned long) cs);
return 1; return 0;
} }
/* Send data from current skb to the device. */ /* Send data from current skb to the device. */
...@@ -766,9 +765,9 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -766,9 +765,9 @@ static int gigaset_probe(struct usb_interface *interface,
if (startmode == SM_LOCKED) if (startmode == SM_LOCKED)
cs->mstate = MS_LOCKED; cs->mstate = MS_LOCKED;
if (!gigaset_start(cs)) { retval = gigaset_start(cs);
if (retval < 0) {
tasklet_kill(&cs->write_tasklet); tasklet_kill(&cs->write_tasklet);
retval = -ENODEV;
goto error; goto error;
} }
return 0; return 0;
...@@ -898,8 +897,10 @@ static int __init usb_gigaset_init(void) ...@@ -898,8 +897,10 @@ static int __init usb_gigaset_init(void)
driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
GIGASET_MODULENAME, GIGASET_DEVNAME, GIGASET_MODULENAME, GIGASET_DEVNAME,
&ops, THIS_MODULE); &ops, THIS_MODULE);
if (driver == NULL) if (driver == NULL) {
result = -ENOMEM;
goto error; goto error;
}
/* register this driver with the USB subsystem */ /* register this driver with the USB subsystem */
result = usb_register(&gigaset_usb_driver); result = usb_register(&gigaset_usb_driver);
...@@ -915,7 +916,7 @@ static int __init usb_gigaset_init(void) ...@@ -915,7 +916,7 @@ static int __init usb_gigaset_init(void)
if (driver) if (driver)
gigaset_freedriver(driver); gigaset_freedriver(driver);
driver = NULL; driver = NULL;
return -1; return result;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment