aboutsummaryrefslogtreecommitdiff
path: root/lib/libsmaf.c
diff options
context:
space:
mode:
authorBenjamin Gaignard <benjamin.gaignard@linaro.org>2015-07-10 13:26:53 +0200
committerBenjamin Gaignard <benjamin.gaignard@linaro.org>2015-07-10 13:26:53 +0200
commit66f990435773a6b09581d415842ac6f6a73c6d13 (patch)
tree30119941de7446319330b7d0899e59cc7c77c5d6 /lib/libsmaf.c
parent5e8098201f9aa60d5d4239e47e5f9fdb3f3d4a83 (diff)
downloadlibsmaf-66f990435773a6b09581d415842ac6f6a73c6d13.tar.gz
adapt lib to SMAF driver version 3 proposal
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Diffstat (limited to 'lib/libsmaf.c')
-rw-r--r--lib/libsmaf.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/lib/libsmaf.c b/lib/libsmaf.c
index 2025086..3584e54 100644
--- a/lib/libsmaf.c
+++ b/lib/libsmaf.c
@@ -41,30 +41,31 @@ static int smaf_fd = -1;
int smaf_open(void)
{
if (open_count)
- goto add;
+ return 0;
smaf_fd = open(SMAF_DEV, O_RDWR, 0);
if (smaf_fd == -1)
return -1;
-add:
open_count++;
return 0;
}
void smaf_close(void)
{
- open_count--;
-
if (open_count)
- return;
+ open_count--;
- close(smaf_fd);
- smaf_fd = -1;
+ if (!open_count) {
+ if (smaf_fd != -1)
+ close(smaf_fd);
+
+ smaf_fd = -1;
+ }
}
-int smaf_create_buffer(unsigned int length, unsigned int flags, int *fd)
+int smaf_create_buffer(unsigned int length, unsigned int flags, char *name, int *fd)
{
struct smaf_create_data create;
int ret;
@@ -72,10 +73,12 @@ int smaf_create_buffer(unsigned int length, unsigned int flags, int *fd)
if (smaf_fd == -1)
return -1;
- memset (&create, 0, sizeof (create));
+ memset(&create, 0, sizeof (create));
create.length = length;
create.flags = flags;
+ if (name)
+ strncpy(&create.name, name, sizeof(create.name));
ret = ioctl(smaf_fd, SMAF_IOC_CREATE, &create);
if (ret) {
@@ -95,7 +98,7 @@ int smaf_set_secure(int fd, int secure)
if (smaf_fd == -1)
return -1;
- memset (&flag, 0, sizeof(flag));
+ memset(&flag, 0, sizeof(flag));
flag.fd = fd;
flag.secure = secure;
@@ -112,27 +115,10 @@ int smaf_get_secure(int fd)
if (smaf_fd == -1)
return 0;
- memset (&flag, 0, sizeof(flag));
+ memset(&flag, 0, sizeof(flag));
flag.fd = fd;
ret = ioctl(smaf_fd, SMAF_IOC_GET_SECURE_FLAG, &flag);
return flag.secure;
}
-
-int smaf_select_allocator(int fd, char *name)
-{
- struct smaf_select_by_name select;
- int ret;
-
- if (smaf_fd == -1)
- return -1;
-
- memset(&select, 0, sizeof(select));
- select.fd = fd;
- strncpy(select.name, name, sizeof(select.name));
-
- ret = ioctl(smaf_fd, SMAF_IOC_SELECT_BY_NAME, &select);
-
- return ret;
-}