Locks are an unpleasant fact of life
This commit is contained in:
parent
45c6c2012d
commit
a1c272e8b0
@ -113,9 +113,9 @@ EXPORT_SYMBOL(sst_init);
|
|||||||
|
|
||||||
int sst_produce_question(sst_info_t *info, char *value) {
|
int sst_produce_question(sst_info_t *info, char *value) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
spin_lock_bh(&info->lock_questions);
|
spin_lock(&info->lock_questions);
|
||||||
err = produce(&info->questions, value);
|
err = produce(&info->questions, value);
|
||||||
spin_unlock_bh(&info->lock_questions);
|
spin_unlock(&info->lock_questions);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
wake_up_interruptible(&info->wait);
|
wake_up_interruptible(&info->wait);
|
||||||
}
|
}
|
||||||
@ -125,10 +125,9 @@ EXPORT_SYMBOL(sst_produce_question);
|
|||||||
|
|
||||||
int sst_produce_answer(sst_info_t *info, char *value) {
|
int sst_produce_answer(sst_info_t *info, char *value) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned long flags;
|
spin_lock(&info->lock_answers);
|
||||||
spin_lock_irqsave(&info->lock_answers, flags);
|
|
||||||
err = produce(&info->answers, value);
|
err = produce(&info->answers, value);
|
||||||
spin_unlock_irqrestore(&info->lock_answers, flags);
|
spin_unlock(&info->lock_answers);
|
||||||
up(&info->answers_rdy);
|
up(&info->answers_rdy);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -136,23 +135,22 @@ EXPORT_SYMBOL(sst_produce_answer);
|
|||||||
|
|
||||||
int sst_consume_question(sst_info_t *info, char **value) {
|
int sst_consume_question(sst_info_t *info, char **value) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
spin_lock_bh(&info->lock_questions);
|
spin_lock(&info->lock_questions);
|
||||||
err = consume(&info->questions, value);
|
err = consume(&info->questions, value);
|
||||||
spin_unlock_bh(&info->lock_questions);
|
spin_unlock(&info->lock_questions);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(sst_consume_question);
|
EXPORT_SYMBOL(sst_consume_question);
|
||||||
|
|
||||||
int sst_consume_answer(sst_info_t *info, char **value) {
|
int sst_consume_answer(sst_info_t *info, char **value) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned long flags;
|
|
||||||
if (down_trylock(&info->answers_rdy)) {
|
if (down_trylock(&info->answers_rdy)) {
|
||||||
sst_debug("Sry. No answer for you!\n");
|
sst_debug("Sry. No answer for you!\n");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
spin_lock_irqsave(&info->lock_answers, flags);
|
spin_lock(&info->lock_answers);
|
||||||
err = consume(&info->answers, value);
|
err = consume(&info->answers, value);
|
||||||
spin_unlock_irqrestore(&info->lock_answers, flags);
|
spin_unlock(&info->lock_answers);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(sst_consume_answer);
|
EXPORT_SYMBOL(sst_consume_answer);
|
||||||
|
Loading…
Reference in New Issue
Block a user