if (!cs)
return;
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->bcs)
goto f_cs;
f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
kfree(cs->bcs);
f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
free_cs(cs);
}
EXPORT_SYMBOL_GPL(gigaset_freecs);
spin_lock_init(&cs->ev_lock);
atomic_set(&cs->ev_tail, 0);
atomic_set(&cs->ev_head, 0);
- init_MUTEX_LOCKED(&cs->sem);
+ mutex_init(&cs->mutex);
+ mutex_lock(&cs->mutex);
+
tasklet_init(&cs->event_tasklet, &gigaset_handle_event,
(unsigned long) cs);
atomic_set(&cs->commands_pending, 0);
add_timer(&cs->timer);
gig_dbg(DEBUG_INIT, "cs initialized");
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return cs;
error: if (cs)
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
gig_dbg(DEBUG_INIT, "failed");
gigaset_freecs(cs);
return NULL;
int gigaset_start(struct cardstate *cs)
{
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return 0;
atomic_set(&cs->connected, 1);
/* set up device sysfs */
gigaset_init_dev_sysfs(cs);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return 1;
error:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return 0;
}
EXPORT_SYMBOL_GPL(gigaset_start);
void gigaset_shutdown(struct cardstate *cs)
{
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
cs->waiting = 1;
cleanup_cs(cs);
exit:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
EXPORT_SYMBOL_GPL(gigaset_shutdown);
void gigaset_stop(struct cardstate *cs)
{
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
/* clear device sysfs */
gigaset_free_dev_sysfs(cs);
cleanup_cs(cs);
exit:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
EXPORT_SYMBOL_GPL(gigaset_stop);
if (!cs)
return -ENODEV;
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
tty->driver_data = cs;
tty->low_latency = 1; //FIXME test
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return 0;
}
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count)
warn("%s: device not opened", __func__);
}
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
static int if_ioctl(struct tty_struct *tty, struct file *file,
gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
}
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
// FIXME read from device?
retval = cs->control_state & (TIOCM_RTS|TIOCM_DTR);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
cs->minor_index, __func__, set, clear);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!atomic_read(&cs->connected)) {
cs->control_state = mc;
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
&cs->if_wake_tasklet);
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
} else
retval = cs->ops->write_room(cs);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
} else
retval = cs->ops->chars_in_buffer(cs);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count)
warn("%s: device not opened", __func__);
//FIXME
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
static void if_unthrottle(struct tty_struct *tty)
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count)
warn("%s: device not opened", __func__);
//FIXME
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
static void if_set_termios(struct tty_struct *tty, struct termios *old)
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count) {
warn("%s: device not opened", __func__);
cs->control_state = control_state;
out:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}