Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC TDC 1ns 5cha - Software
Commits
f2a1998d
Commit
f2a1998d
authored
Sep 06, 2012
by
Miguel Gómez Sexto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdc: added helper functions to read/write sysfs files to the library.
Signed-off-by:
Miguel Gómez
<
magomez@igalia.com
>
parent
8b486d46
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
libtdc.c
lib/libtdc.c
+45
-0
No files found.
lib/libtdc.c
View file @
f2a1998d
...
...
@@ -5,6 +5,7 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include "libtdc.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
...
...
@@ -12,6 +13,50 @@
static
int
tdc_nboards
;
static
struct
tdc_board
*
tdc_boards
;
static
inline
int
fdelay_sysfs_get
(
struct
tdc_board
*
b
,
char
*
name
,
uint32_t
*
resp
)
{
char
path
[
128
];
FILE
*
f
;
sprintf
(
path
,
"%s/%s"
,
b
->
sysbase
,
name
);
f
=
fopen
(
path
,
"r"
);
if
(
!
f
)
return
-
1
;
errno
=
0
;
if
(
fscanf
(
f
,
"%i"
,
resp
)
!=
1
)
{
fclose
(
f
);
if
(
!
errno
)
errno
=
EINVAL
;
return
-
1
;
}
fclose
(
f
);
return
0
;
}
static
inline
int
fdelay_sysfs_set
(
struct
tdc_board
*
b
,
char
*
name
,
uint32_t
*
value
)
{
char
path
[
128
];
char
s
[
16
];
int
fd
,
ret
,
len
;
sprintf
(
path
,
"%s/%s"
,
b
->
sysbase
,
name
);
len
=
sprintf
(
s
,
"%i
\n
"
,
*
value
);
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
)
return
-
1
;
ret
=
write
(
fd
,
s
,
len
);
close
(
fd
);
if
(
ret
<
0
)
return
-
1
;
if
(
ret
==
len
)
return
0
;
errno
=
EINVAL
;
return
-
1
;
}
int
tdc_init
(
void
)
{
glob_t
glob_dev
,
glob_sys
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment