1 From d9395f7d876f7dfaaae25867c88d1e1f684589de Mon Sep 17 00:00:00 2001
2 From: Cristian Stoica <cristian.stoica@freescale.com>
3 Date: Thu, 19 Feb 2015 16:43:29 +0200
4 Subject: [PATCH 21/48] cryptodev: do not cache file descriptor in 'open'
6 The file descriptor returned by get_dev_crypto is cached after a
7 successful return. The issue is, it is cached inside 'open_dev_crypto'
8 which is no longer useful as a general purpose open("/dev/crypto")
11 This patch is a refactoring that moves the caching operation from
12 open_dev_crypto to get_dev_crypto and leaves the former as a simpler
13 function true to its name
15 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
17 crypto/engine/eng_cryptodev.c | 43 +++++++++++++++++++++----------------------
18 1 file changed, 21 insertions(+), 22 deletions(-)
20 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
21 index 14dcddf..75fca7f 100644
22 --- a/crypto/engine/eng_cryptodev.c
23 +++ b/crypto/engine/eng_cryptodev.c
24 @@ -391,45 +391,44 @@ static void ctr64_inc(unsigned char *counter)
29 - * Return a fd if /dev/crypto seems usable, 0 otherwise.
31 static int open_dev_crypto(void)
37 - if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
40 - if (fcntl(fd, F_SETFD, 1) == -1) {
45 + fd = open("/dev/crypto", O_RDWR, 0);
50 + if (fcntl(fd, F_SETFD, 1) == -1) {
59 static int get_dev_crypto(void)
65 - if ((fd = open_dev_crypto()) == -1)
67 -# ifndef CRIOGET_NOT_NEEDED
69 + fd = open_dev_crypto();
70 +# ifdef CRIOGET_NOT_NEEDED
75 if (ioctl(fd, CRIOGET, &retfd) == -1)
79 if (fcntl(retfd, F_SETFD, 1) == -1) {
90 static void put_dev_crypto(int fd)