Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha - 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 DEL 1ns 4cha - Software
Commits
0d10a8c5
Commit
0d10a8c5
authored
May 02, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: added internal sysfs function; check version in init
parent
70db5b2a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
1 deletion
+67
-1
fdelay-init.c
lib/fdelay-init.c
+15
-1
fdelay.h
lib/fdelay.h
+52
-0
No files found.
lib/fdelay-init.c
View file @
0d10a8c5
...
...
@@ -39,6 +39,7 @@ int fdelay_init(void)
glob_t
glob_dev
,
glob_sys
;
struct
__fdelay_board
*
b
;
int
i
,
j
;
uint32_t
v
;
/* Look for boards in /dev: old and new pathnames: only one matches */
glob
(
"/dev/zio-fd-*-0-0-ctrl"
,
0
,
NULL
,
&
glob_dev
);
...
...
@@ -77,7 +78,20 @@ int fdelay_init(void)
}
globfree
(
&
glob_dev
);
globfree
(
&
glob_sys
);
return
i
;
/* Now, if at least one board is there, check the version */
if
(
fd_nboards
==
0
)
return
0
;
if
(
fdelay_sysfs_get
(
fd_boards
,
"version"
,
&
v
)
<
0
)
return
-
1
;
if
(
v
!=
FDELAY_VERSION
)
{
fprintf
(
stderr
,
"%s: version mismatch, lib(%i) != drv(%i)
\n
"
,
__func__
,
FDELAY_VERSION
,
v
);
errno
=
EIO
;
return
-
1
;
}
return
fd_nboards
;
}
/* Free and check */
...
...
lib/fdelay.h
View file @
0d10a8c5
...
...
@@ -11,6 +11,7 @@
*/
#ifndef __FDELAY_H__
#define __FDELAY_H__
#include <stdint.h>
/* Opaque data type used as token */
struct
fdelay_board
;
...
...
@@ -40,5 +41,56 @@ static inline int fdelay_is_verbose(void)
#define __define_board(b, ub) struct __fdelay_board *b = (void *)(ub)
/* These two from ../tools/fdelay-raw.h, used internally */
static
inline
int
__fdelay_sysfs_get
(
char
*
path
,
uint32_t
*
resp
)
{
FILE
*
f
=
fopen
(
path
,
"r"
);
if
(
!
f
)
return
-
1
;
if
(
fscanf
(
f
,
"%i"
,
resp
)
!=
1
)
{
fclose
(
f
);
errno
=
EINVAL
;
return
-
1
;
}
fclose
(
f
);
return
0
;
}
static
inline
int
__fdelay_sysfs_set
(
char
*
path
,
uint32_t
*
value
)
{
FILE
*
f
=
fopen
(
path
,
"w"
);
if
(
!
f
)
return
-
1
;
if
(
fprintf
(
f
,
"%i
\n
"
,
*
value
)
<
2
)
{
fclose
(
f
);
errno
=
EINVAL
;
return
-
1
;
}
fclose
(
f
);
return
0
;
}
/* And these two for the board structure */
static
inline
int
fdelay_sysfs_get
(
struct
__fdelay_board
*
b
,
char
*
name
,
uint32_t
*
resp
)
{
char
pathname
[
128
];
sprintf
(
pathname
,
"%s/%s"
,
b
->
sysbase
,
name
);
return
__fdelay_sysfs_get
(
pathname
,
resp
);
}
static
inline
int
fdelay_sysfs_set
(
struct
__fdelay_board
*
b
,
char
*
name
,
uint32_t
*
value
)
{
char
pathname
[
128
];
sprintf
(
pathname
,
"%s/%s"
,
b
->
sysbase
,
name
);
return
__fdelay_sysfs_set
(
pathname
,
value
);
}
#endif
/* FDELAY_INTERNAL */
#endif
/* __FDELAY_H__ */
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