Skip to content

Commit

Permalink
crypto: ccp - fix lock acquisition code
Browse files Browse the repository at this point in the history
This patch simplifies an unneeded read-write lock.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Gary R Hook authored and Herbert Xu committed Mar 17, 2016
1 parent d1558f4 commit 03a6f29
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/crypto/ccp/ccp-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static DEFINE_RWLOCK(ccp_unit_lock);
static LIST_HEAD(ccp_units);

/* Round-robin counter */
static DEFINE_RWLOCK(ccp_rr_lock);
static DEFINE_SPINLOCK(ccp_rr_lock);
static struct ccp_device *ccp_rr;

/* Ever-increasing value to produce unique unit numbers */
Expand Down Expand Up @@ -128,14 +128,14 @@ static struct ccp_device *ccp_get_device(void)
*/
read_lock_irqsave(&ccp_unit_lock, flags);
if (!list_empty(&ccp_units)) {
write_lock_irqsave(&ccp_rr_lock, flags);
spin_lock(&ccp_rr_lock);
dp = ccp_rr;
if (list_is_last(&ccp_rr->entry, &ccp_units))
ccp_rr = list_first_entry(&ccp_units, struct ccp_device,
entry);
else
ccp_rr = list_next_entry(ccp_rr, entry);
write_unlock_irqrestore(&ccp_rr_lock, flags);
spin_unlock(&ccp_rr_lock);
}
read_unlock_irqrestore(&ccp_unit_lock, flags);

Expand Down

0 comments on commit 03a6f29

Please sign in to comment.