Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+19 −14
Original line number Diff line number Diff line
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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;
}

/**
+20 −23
Original line number Diff line number Diff line
@@ -194,13 +194,13 @@ int gigaset_get_channel(struct bc_state *bcs)
		gig_dbg(DEBUG_CHANNEL, "could not allocate channel %d",
			bcs->channel);
		spin_unlock_irqrestore(&bcs->cs->lock, flags);
		return 0;
		return -EBUSY;
	}
	++bcs->use_count;
	bcs->busy = 1;
	gig_dbg(DEBUG_CHANNEL, "allocated channel %d", bcs->channel);
	spin_unlock_irqrestore(&bcs->cs->lock, flags);
	return 1;
	return 0;
}

struct bc_state *gigaset_get_free_channel(struct cardstate *cs)
@@ -258,7 +258,7 @@ int gigaset_get_channels(struct cardstate *cs)
			spin_unlock_irqrestore(&cs->lock, flags);
			gig_dbg(DEBUG_CHANNEL,
				"could not allocate all channels");
			return 0;
			return -EBUSY;
		}
	for (i = 0; i < cs->channels; ++i)
		++cs->bcs[i].use_count;
@@ -266,7 +266,7 @@ int gigaset_get_channels(struct cardstate *cs)

	gig_dbg(DEBUG_CHANNEL, "allocated all channels");

	return 1;
	return 0;
}

void gigaset_free_channels(struct cardstate *cs)
@@ -388,8 +388,7 @@ static void gigaset_freebcs(struct bc_state *bcs)
	int i;

	gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
	if (!bcs->cs->ops->freebcshw(bcs))
		gig_dbg(DEBUG_INIT, "failed");
	bcs->cs->ops->freebcshw(bcs);

	gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
	clear_at_state(&bcs->at_state);
@@ -566,6 +565,8 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct cardstate *cs)
 * @inbuf:	buffer structure.
 * @src:	received data.
 * @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,
		       unsigned numbytes)
@@ -609,8 +610,8 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
EXPORT_SYMBOL_GPL(gigaset_fill_inbuf);

/* Initialize the b-channel structure */
static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
					struct cardstate *cs, int channel)
static int gigaset_initbcs(struct bc_state *bcs, struct cardstate *cs,
			   int channel)
{
	int i;

@@ -649,11 +650,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
	bcs->apconnstate = 0;

	gig_dbg(DEBUG_INIT, "  setting up bcs[%d]->hw", channel);
	if (cs->ops->initbcshw(bcs))
		return bcs;

	gig_dbg(DEBUG_INIT, "  failed");
	return NULL;
	return cs->ops->initbcshw(bcs);
}

/**
@@ -752,7 +749,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
	cs->cmdbytes = 0;

	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");
		goto error;
	}
@@ -760,7 +757,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
	make_valid(cs, VALID_ID);
	++cs->cs_init;
	gig_dbg(DEBUG_INIT, "setting up hw");
	if (!cs->ops->initcshw(cs))
	if (cs->ops->initcshw(cs) < 0)
		goto error;

	++cs->cs_init;
@@ -774,7 +771,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
	/* set up channel data structures */
	for (i = 0; i < channels; ++i) {
		gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i);
		if (!gigaset_initbcs(cs->bcs + i, cs, i)) {
		if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) {
			pr_err("could not allocate channel %d data\n", i);
			goto error;
		}
@@ -869,7 +866,7 @@ static void cleanup_cs(struct cardstate *cs)

	for (i = 0; i < cs->channels; ++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);
	}

@@ -890,14 +887,14 @@ static void cleanup_cs(struct cardstate *cs)
 * waiting for completion of the initialization.
 *
 * Return value:
 *	1 - success, 0 - error
 *	0 on success, error code < 0 on failure
 */
int gigaset_start(struct cardstate *cs)
{
	unsigned long flags;

	if (mutex_lock_interruptible(&cs->mutex))
		return 0;
		return -EBUSY;

	spin_lock_irqsave(&cs->lock, flags);
	cs->connected = 1;
@@ -921,11 +918,11 @@ int gigaset_start(struct cardstate *cs)
	wait_event(cs->waitqueue, !cs->waiting);

	mutex_unlock(&cs->mutex);
	return 1;
	return 0;

error:
	mutex_unlock(&cs->mutex);
	return 0;
	return -ENOMEM;
}
EXPORT_SYMBOL_GPL(gigaset_start);

@@ -937,7 +934,7 @@ EXPORT_SYMBOL_GPL(gigaset_start);
 * waiting for completion of the shutdown.
 *
 * Return value:
 *	0 - success, -1 - error (no device associated)
 *	0 - success, -ENODEV - error (no device associated)
 */
int gigaset_shutdown(struct cardstate *cs)
{
@@ -945,7 +942,7 @@ int gigaset_shutdown(struct cardstate *cs)

	if (!(cs->flags & VALID_MINOR)) {
		mutex_unlock(&cs->mutex);
		return -1;
		return -ENODEV;
	}

	cs->waiting = 1;
+1 −1
Original line number Diff line number Diff line
@@ -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)
+8 −8
Original line number Diff line number Diff line
@@ -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;
Loading