omap: mailbox: convert rwlocks to spinlock
rwlocks are slower and have potential starvation issues therefore spinlocks are generally preferred. see also: http://lwn.net/Articles/364583/ Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Kanigeri Hari <h-kanigeri2@ti.com> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
This commit is contained in:
parent
1ea5d6d18b
commit
10d1a0028d
1 changed files with 10 additions and 10 deletions
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
static struct workqueue_struct *mboxd;
|
static struct workqueue_struct *mboxd;
|
||||||
static struct omap_mbox *mboxes;
|
static struct omap_mbox *mboxes;
|
||||||
static DEFINE_RWLOCK(mboxes_lock);
|
static DEFINE_SPINLOCK(mboxes_lock);
|
||||||
static bool rq_full;
|
static bool rq_full;
|
||||||
|
|
||||||
static int mbox_configured;
|
static int mbox_configured;
|
||||||
|
@ -341,14 +341,14 @@ struct omap_mbox *omap_mbox_get(const char *name)
|
||||||
struct omap_mbox *mbox;
|
struct omap_mbox *mbox;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
read_lock(&mboxes_lock);
|
spin_lock(&mboxes_lock);
|
||||||
mbox = *(find_mboxes(name));
|
mbox = *(find_mboxes(name));
|
||||||
if (mbox == NULL) {
|
if (mbox == NULL) {
|
||||||
read_unlock(&mboxes_lock);
|
spin_unlock(&mboxes_lock);
|
||||||
return ERR_PTR(-ENOENT);
|
return ERR_PTR(-ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
read_unlock(&mboxes_lock);
|
spin_unlock(&mboxes_lock);
|
||||||
|
|
||||||
ret = omap_mbox_startup(mbox);
|
ret = omap_mbox_startup(mbox);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -374,15 +374,15 @@ int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
|
||||||
if (mbox->next)
|
if (mbox->next)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
write_lock(&mboxes_lock);
|
spin_lock(&mboxes_lock);
|
||||||
tmp = find_mboxes(mbox->name);
|
tmp = find_mboxes(mbox->name);
|
||||||
if (*tmp) {
|
if (*tmp) {
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
write_unlock(&mboxes_lock);
|
spin_unlock(&mboxes_lock);
|
||||||
goto err_find;
|
goto err_find;
|
||||||
}
|
}
|
||||||
*tmp = mbox;
|
*tmp = mbox;
|
||||||
write_unlock(&mboxes_lock);
|
spin_unlock(&mboxes_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -395,18 +395,18 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
|
||||||
{
|
{
|
||||||
struct omap_mbox **tmp;
|
struct omap_mbox **tmp;
|
||||||
|
|
||||||
write_lock(&mboxes_lock);
|
spin_lock(&mboxes_lock);
|
||||||
tmp = &mboxes;
|
tmp = &mboxes;
|
||||||
while (*tmp) {
|
while (*tmp) {
|
||||||
if (mbox == *tmp) {
|
if (mbox == *tmp) {
|
||||||
*tmp = mbox->next;
|
*tmp = mbox->next;
|
||||||
mbox->next = NULL;
|
mbox->next = NULL;
|
||||||
write_unlock(&mboxes_lock);
|
spin_unlock(&mboxes_lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tmp = &(*tmp)->next;
|
tmp = &(*tmp)->next;
|
||||||
}
|
}
|
||||||
write_unlock(&mboxes_lock);
|
spin_unlock(&mboxes_lock);
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue