Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25570
b: refs/heads/master
c: 69049cc
h: refs/heads/master
v: v3
  • Loading branch information
Tilman Schmidt authored and Linus Torvalds committed Apr 11, 2006
1 parent a7f19f7 commit 886eee7
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 155 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 27d1ac2ef7d0b9250ca9fd2ef506e12866ce8fdf
refs/heads/master: 69049cc87dccb1e6fb54aa25c63033efac805dbd
9 changes: 6 additions & 3 deletions trunk/drivers/isdn/gigaset/asyncdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,22 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
{
unsigned len = skb->len;
unsigned long flags;

if (bcs->proto2 == ISDN_PROTO_L2_HDLC)
skb = HDLC_Encode(skb, HW_HDR_LEN, 0);
else
skb = iraw_encode(skb, HW_HDR_LEN, 0);
if (!skb) {
dev_err(bcs->cs->dev,
"unable to allocate memory for encoding!\n");
err("unable to allocate memory for encoding!\n");
return -ENOMEM;
}

skb_queue_tail(&bcs->squeue, skb);
tasklet_schedule(&bcs->cs->write_tasklet);
spin_lock_irqsave(&bcs->cs->lock, flags);
if (bcs->cs->connected)
tasklet_schedule(&bcs->cs->write_tasklet);
spin_unlock_irqrestore(&bcs->cs->lock, flags);

return len; /* ok so far */
}
48 changes: 22 additions & 26 deletions trunk/drivers/isdn/gigaset/bas-gigaset.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static void cmd_in_timeout(unsigned long data)
unsigned long flags;

spin_lock_irqsave(&cs->lock, flags);
if (unlikely(!atomic_read(&cs->connected))) {
if (unlikely(!cs->connected)) {
gig_dbg(DEBUG_USBREQ, "%s: disconnected", __func__);
spin_unlock_irqrestore(&cs->lock, flags);
return;
Expand Down Expand Up @@ -475,11 +475,6 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
unsigned l;
int channel;

if (unlikely(!atomic_read(&cs->connected))) {
warn("%s: disconnected", __func__);
return;
}

switch (urb->status) {
case 0: /* success */
break;
Expand Down Expand Up @@ -603,7 +598,9 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
check_pending(ucs);

resubmit:
status = usb_submit_urb(urb, SLAB_ATOMIC);
spin_lock_irqsave(&cs->lock, flags);
status = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
spin_unlock_irqrestore(&cs->lock, flags);
if (unlikely(status)) {
dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
get_usb_statmsg(status));
Expand All @@ -628,7 +625,7 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
unsigned long flags;

spin_lock_irqsave(&cs->lock, flags);
if (unlikely(!atomic_read(&cs->connected))) {
if (unlikely(!cs->connected)) {
warn("%s: disconnected", __func__);
spin_unlock_irqrestore(&cs->lock, flags);
return;
Expand Down Expand Up @@ -949,6 +946,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
struct bas_bc_state *ubc = ucx->bcs->hw.bas;
struct usb_iso_packet_descriptor *ifd;
int corrbytes, nframe, rc;
unsigned long flags;

/* urb->dev is clobbered by USB subsystem */
urb->dev = ucx->bcs->cs->hw.bas->udev;
Expand Down Expand Up @@ -995,7 +993,11 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
ifd->actual_length = 0;
}
if ((urb->number_of_packets = nframe) > 0) {
if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
spin_lock_irqsave(&ucx->bcs->cs->lock, flags);
rc = ucx->bcs->cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
spin_unlock_irqrestore(&ucx->bcs->cs->lock, flags);

if (rc) {
dev_err(ucx->bcs->cs->dev,
"could not submit isochronous write URB: %s\n",
get_usb_statmsg(rc));
Expand Down Expand Up @@ -1029,11 +1031,6 @@ static void write_iso_tasklet(unsigned long data)

/* loop while completed URBs arrive in time */
for (;;) {
if (unlikely(!atomic_read(&cs->connected))) {
warn("%s: disconnected", __func__);
return;
}

if (unlikely(!(atomic_read(&ubc->running)))) {
gig_dbg(DEBUG_ISO, "%s: not running", __func__);
return;
Expand Down Expand Up @@ -1190,11 +1187,6 @@ static void read_iso_tasklet(unsigned long data)

/* loop while more completed URBs arrive in the meantime */
for (;;) {
if (unlikely(!atomic_read(&cs->connected))) {
warn("%s: disconnected", __func__);
return;
}

/* retrieve URB */
spin_lock_irqsave(&ubc->isoinlock, flags);
if (!(urb = ubc->isoindone)) {
Expand Down Expand Up @@ -1298,7 +1290,10 @@ static void read_iso_tasklet(unsigned long data)
urb->dev = bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP;
urb->number_of_packets = BAS_NUMFRAMES;
if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
spin_lock_irqsave(&cs->lock, flags);
rc = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
spin_unlock_irqrestore(&cs->lock, flags);
if (rc) {
dev_err(cs->dev,
"could not resubmit isochronous read URB: %s\n",
get_usb_statmsg(rc));
Expand Down Expand Up @@ -1639,6 +1634,7 @@ static void atrdy_timeout(unsigned long data)
static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
{
struct bas_cardstate *ucs = cs->hw.bas;
unsigned long flags;
int ret;

gig_dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len);
Expand All @@ -1659,7 +1655,11 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
(unsigned char*) &ucs->dr_cmd_out, buf, len,
write_command_callback, cs);

if ((ret = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC)) != 0) {
spin_lock_irqsave(&cs->lock, flags);
ret = cs->connected ? usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC) : -ENODEV;
spin_unlock_irqrestore(&cs->lock, flags);

if (ret) {
dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
get_usb_statmsg(ret));
return ret;
Expand Down Expand Up @@ -1758,11 +1758,6 @@ static int gigaset_write_cmd(struct cardstate *cs,
DEBUG_TRANSCMD : DEBUG_LOCKCMD,
"CMD Transmit", len, buf);

if (unlikely(!atomic_read(&cs->connected))) {
err("%s: disconnected", __func__);
return -ENODEV;
}

if (len <= 0)
return 0; /* nothing to do */

Expand Down Expand Up @@ -2186,6 +2181,7 @@ static int gigaset_probe(struct usb_interface *interface,

error:
freeurbs(cs);
usb_set_intfdata(interface, NULL);
gigaset_unassign(cs);
return -ENODEV;
}
Expand Down
64 changes: 32 additions & 32 deletions trunk/drivers/isdn/gigaset/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ int gigaset_enterconfigmode(struct cardstate *cs)
{
int i, r;

if (!atomic_read(&cs->connected)) {
err("not connected!");
return -1;
}

cs->control_state = TIOCM_RTS; //FIXME

r = setflags(cs, TIOCM_DTR, 200);
Expand Down Expand Up @@ -176,7 +171,7 @@ static int test_timeout(struct at_state_t *at_state)
}

if (!gigaset_add_event(at_state->cs, at_state, EV_TIMEOUT, NULL,
atomic_read(&at_state->timer_index), NULL)) {
at_state->timer_index, NULL)) {
//FIXME what should we do?
}

Expand Down Expand Up @@ -204,7 +199,7 @@ static void timer_tick(unsigned long data)
if (test_timeout(at_state))
timeout = 1;

if (atomic_read(&cs->running)) {
if (cs->running) {
mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK));
if (timeout) {
gig_dbg(DEBUG_CMD, "scheduling timeout");
Expand Down Expand Up @@ -298,20 +293,22 @@ static void clear_events(struct cardstate *cs)
{
struct event_t *ev;
unsigned head, tail;
unsigned long flags;

/* no locking needed (no reader/writer allowed) */
spin_lock_irqsave(&cs->ev_lock, flags);

head = atomic_read(&cs->ev_head);
tail = atomic_read(&cs->ev_tail);
head = cs->ev_head;
tail = cs->ev_tail;

while (tail != head) {
ev = cs->events + head;
kfree(ev->ptr);

head = (head + 1) % MAX_EVENTS;
}

atomic_set(&cs->ev_head, tail);
cs->ev_head = tail;

spin_unlock_irqrestore(&cs->ev_lock, flags);
}

struct event_t *gigaset_add_event(struct cardstate *cs,
Expand All @@ -324,9 +321,9 @@ struct event_t *gigaset_add_event(struct cardstate *cs,

spin_lock_irqsave(&cs->ev_lock, flags);

tail = atomic_read(&cs->ev_tail);
tail = cs->ev_tail;
next = (tail + 1) % MAX_EVENTS;
if (unlikely(next == atomic_read(&cs->ev_head)))
if (unlikely(next == cs->ev_head))
err("event queue full");
else {
event = cs->events + tail;
Expand All @@ -336,7 +333,7 @@ struct event_t *gigaset_add_event(struct cardstate *cs,
event->ptr = ptr;
event->arg = arg;
event->parameter = parameter;
atomic_set(&cs->ev_tail, next);
cs->ev_tail = next;
}

spin_unlock_irqrestore(&cs->ev_lock, flags);
Expand Down Expand Up @@ -454,7 +451,7 @@ void gigaset_freecs(struct cardstate *cs)
goto f_bcs;

spin_lock_irqsave(&cs->lock, flags);
atomic_set(&cs->running, 0);
cs->running = 0;
spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are
not rescheduled below */

Expand Down Expand Up @@ -513,8 +510,8 @@ void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
at_state->pending_commands = 0;
at_state->timer_expires = 0;
at_state->timer_active = 0;
atomic_set(&at_state->timer_index, 0);
atomic_set(&at_state->seq_index, 0);
at_state->timer_index = 0;
at_state->seq_index = 0;
at_state->ConState = 0;
for (i = 0; i < STR_NUM; ++i)
at_state->str_var[i] = NULL;
Expand Down Expand Up @@ -665,6 +662,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
int cidmode, const char *modulename)
{
struct cardstate *cs = NULL;
unsigned long flags;
int i;

gig_dbg(DEBUG_INIT, "allocating cs");
Expand All @@ -685,11 +683,11 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->onechannel = onechannel;
cs->ignoreframes = ignoreframes;
INIT_LIST_HEAD(&cs->temp_at_states);
atomic_set(&cs->running, 0);
cs->running = 0;
init_timer(&cs->timer); /* clear next & prev */
spin_lock_init(&cs->ev_lock);
atomic_set(&cs->ev_tail, 0);
atomic_set(&cs->ev_head, 0);
cs->ev_tail = 0;
cs->ev_head = 0;
mutex_init(&cs->mutex);
mutex_lock(&cs->mutex);

Expand All @@ -701,7 +699,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->open_count = 0;
cs->dev = NULL;
cs->tty = NULL;
atomic_set(&cs->cidmode, cidmode != 0);
cs->cidmode = cidmode != 0;

//if(onechannel) { //FIXME
cs->tabnocid = gigaset_tab_nocid_m10x;
Expand Down Expand Up @@ -737,7 +735,8 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
} else
gigaset_inbuf_init(cs->inbuf, NULL, cs, INS_command);

atomic_set(&cs->connected, 0);
cs->connected = 0;
cs->isdn_up = 0;

gig_dbg(DEBUG_INIT, "setting up cmdbuf");
cs->cmdbuf = cs->lastcmdbuf = NULL;
Expand All @@ -761,7 +760,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,

gigaset_if_init(cs);

atomic_set(&cs->running, 1);
spin_lock_irqsave(&cs->lock, flags);
cs->running = 1;
spin_unlock_irqrestore(&cs->lock, flags);
setup_timer(&cs->timer, timer_tick, (unsigned long) cs);
cs->timer.expires = jiffies + msecs_to_jiffies(GIG_TICK);
/* FIXME: can jiffies increase too much until the timer is added?
Expand Down Expand Up @@ -871,10 +872,14 @@ static void cleanup_cs(struct cardstate *cs)

int gigaset_start(struct cardstate *cs)
{
unsigned long flags;

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

atomic_set(&cs->connected, 1);
spin_lock_irqsave(&cs->lock, flags);
cs->connected = 1;
spin_unlock_irqrestore(&cs->lock, flags);

if (atomic_read(&cs->mstate) != MS_LOCKED) {
cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
Expand Down Expand Up @@ -950,11 +955,6 @@ void gigaset_stop(struct cardstate *cs)
{
mutex_lock(&cs->mutex);

/* clear device sysfs */
gigaset_free_dev_sysfs(cs);

atomic_set(&cs->connected, 0);

cs->waiting = 1;

if (!gigaset_add_event(cs, &cs->at_state, EV_STOP, NULL, 0, NULL)) {
Expand All @@ -970,8 +970,8 @@ void gigaset_stop(struct cardstate *cs)
//FIXME
}

/* Tell the LL that the device is not available .. */
gigaset_i4l_cmd(cs, ISDN_STAT_STOP); // FIXME move to event layer?
/* clear device sysfs */
gigaset_free_dev_sysfs(cs);

cleanup_cs(cs);

Expand Down
Loading

0 comments on commit 886eee7

Please sign in to comment.