1 From a44701abd995b3db80001d0c5d88e9ead05972c1 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 24/26] 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 Change-Id: I980170969410381973ce75f6679a4a1401738847
16 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
17 Reviewed-on: http://git.am.freescale.net:8181/34219
19 crypto/engine/eng_cryptodev.c | 50 +++++++++++++++++++++----------------------
20 1 file changed, 24 insertions(+), 26 deletions(-)
22 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
23 index dceb4f5..b74fc7c 100644
24 --- a/crypto/engine/eng_cryptodev.c
25 +++ b/crypto/engine/eng_cryptodev.c
26 @@ -306,47 +306,45 @@ static void ctr64_inc(unsigned char *counter) {
31 - * Return a fd if /dev/crypto seems usable, 0 otherwise.
34 -open_dev_crypto(void)
36 +static int open_dev_crypto(void)
42 - if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
45 - if (fcntl(fd, F_SETFD, 1) == -1) {
50 + fd = open("/dev/crypto", O_RDWR, 0);
55 + if (fcntl(fd, F_SETFD, 1) == -1) {
66 +static int get_dev_crypto(void)
72 - if ((fd = open_dev_crypto()) == -1)
74 -#ifndef CRIOGET_NOT_NEEDED
76 + fd = open_dev_crypto();
77 +#ifdef CRIOGET_NOT_NEEDED
82 if (ioctl(fd, CRIOGET, &retfd) == -1)
86 if (fcntl(retfd, F_SETFD, 1) == -1) {
97 static void put_dev_crypto(int fd)