From: Krzysztof Halasa <khc@pm.waw.pl>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Christian Hohnstaedt <chohnstaedt@innominate.com>,
linux-crypto@vger.kernel.org
Subject: IXP4xx: Simplify get_crypt_desc() and get_crypt_desc_emerg() in ixp4xx_crypto.
Date: Sun, 10 Jan 2010 18:32:53 +0100 [thread overview]
Message-ID: <m3my0l3lx6.fsf@intrepid.localdomain> (raw)
In-Reply-To: <m34omu3rf7.fsf@intrepid.localdomain> (Krzysztof Halasa's message of "Sun, 10 Jan 2010 16:35:38 +0100")
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 99f06e1..0c7e4f5 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -277,26 +277,25 @@ static struct crypt_ctl *get_crypt_desc(void)
int i;
static int idx = 0;
unsigned long flags;
+ struct crypt_ctl *desc = NULL;
spin_lock_irqsave(&desc_lock, flags);
if (unlikely(!crypt_virt))
setup_crypt_desc();
- if (unlikely(!crypt_virt)) {
- spin_unlock_irqrestore(&desc_lock, flags);
- return NULL;
- }
+ if (unlikely(!crypt_virt))
+ goto out;
+
i = idx;
if (crypt_virt[i].ctl_flags == CTL_FLAG_UNUSED) {
if (++idx >= NPE_QLEN)
idx = 0;
crypt_virt[i].ctl_flags = CTL_FLAG_USED;
- spin_unlock_irqrestore(&desc_lock, flags);
- return crypt_virt +i;
- } else {
- spin_unlock_irqrestore(&desc_lock, flags);
- return NULL;
+ desc = crypt_virt + i;
}
+out:
+ spin_unlock_irqrestore(&desc_lock, flags);
+ return desc;
}
static spinlock_t emerg_lock;
@@ -319,12 +318,10 @@ static struct crypt_ctl *get_crypt_desc_emerg(void)
if (++idx >= NPE_QLEN_TOTAL)
idx = NPE_QLEN;
crypt_virt[i].ctl_flags = CTL_FLAG_USED;
- spin_unlock_irqrestore(&emerg_lock, flags);
- return crypt_virt +i;
- } else {
- spin_unlock_irqrestore(&emerg_lock, flags);
- return NULL;
+ desc = crypt_virt +i;
}
+ spin_unlock_irqrestore(&emerg_lock, flags);
+ return desc;
}
static void free_buf_chain(struct device *dev, struct buffer_desc *buf,u32 phys)
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-01-10 17:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-10 15:34 [6 PATCHes] IXP4xx crypto driver fixes Krzysztof Halasa
2010-01-10 17:30 ` Krzysztof Halasa
2010-01-11 9:07 ` Christian Hohnstaedt
2010-01-10 17:32 ` IXP4xx: Fix ixp4xx_crypto sparse warnings Krzysztof Halasa
2010-01-10 17:32 ` Krzysztof Halasa [this message]
2010-01-10 17:33 ` IXP4xx: Fix whitespace problems in ixp4xx_crypto Krzysztof Halasa
2010-01-12 17:12 ` Christian Hohnstaedt
2010-01-12 18:09 ` Krzysztof Halasa
2010-01-10 17:37 ` ixp4xx_crypto: Fix possible NULL ptr dereference Krzysztof Halasa
2010-01-11 10:07 ` Christian Hohnstaedt
2010-01-10 17:37 ` ixp4xx_crypto: simplyfy the code a bit Krzysztof Halasa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3my0l3lx6.fsf@intrepid.localdomain \
--to=khc@pm.waw.pl \
--cc=chohnstaedt@innominate.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox