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
54eafb43
Commit
54eafb43
authored
May 20, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cppcheck fixes
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
718f35cf
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
50 deletions
+63
-50
fine-delay.h
kernel/fine-delay.h
+2
-2
fdelay-init.c
lib/fdelay-init.c
+26
-22
fdelay-lib.h
lib/fdelay-lib.h
+3
-2
fdelay-output.c
lib/fdelay-output.c
+4
-3
fdelay-tdc.c
lib/fdelay-tdc.c
+9
-4
Makefile
tools/Makefile
+4
-3
fmc-fdelay-board-time.c
tools/fmc-fdelay-board-time.c
+3
-3
fmc-fdelay-input.c
tools/fmc-fdelay-input.c
+1
-1
fmc-fdelay-term.c
tools/fmc-fdelay-term.c
+1
-1
tools-util.c
tools/tools-util.c
+10
-9
No files found.
kernel/fine-delay.h
View file @
54eafb43
...
...
@@ -280,11 +280,11 @@ static inline void fd_iowrite(struct fd_dev *fd,
static
inline
uint32_t
fd_readl
(
struct
fd_dev
*
fd
,
unsigned
long
reg
)
{
return
fd_ioread
(
fd
,
fd
->
fd_regs_base
+
reg
);
return
fd_ioread
(
fd
,
(
char
*
)
fd
->
fd_regs_base
+
reg
);
}
static
inline
void
fd_writel
(
struct
fd_dev
*
fd
,
uint32_t
v
,
unsigned
long
reg
)
{
fd_iowrite
(
fd
,
v
,
fd
->
fd_regs_base
+
reg
);
fd_iowrite
(
fd
,
v
,
(
char
*
)
fd
->
fd_regs_base
+
reg
);
}
static
inline
void
__check_chan
(
int
x
)
...
...
lib/fdelay-init.c
View file @
54eafb43
...
...
@@ -128,28 +128,32 @@ err_stat_s:
* The function uses a symbolic link in /dev, created by the local
* installation procedure.
*/
struct
fdelay_board
*
fdelay_open_by_lun
(
int
lun
)
{
ssize_t
ret
;
char
dev_id_str
[
4
];
char
path_pattern
[]
=
"/dev/fine-delay.%d"
;
char
path
[
sizeof
(
path_pattern
)
+
1
];
int
dev_id
;
if
(
fdelay_is_verbose
())
fprintf
(
stderr
,
"called: %s(lun %i);
\n
"
,
__func__
,
lun
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
path_pattern
,
lun
);
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
{
errno
=
EINVAL
;
return
NULL
;
}
ret
=
readlink
(
path
,
dev_id_str
,
sizeof
(
dev_id_str
));
if
(
sscanf
(
dev_id_str
,
"%4x"
,
&
dev_id
)
!=
1
)
{
errno
=
ENODEV
;
return
NULL
;
}
return
fdelay_open
(
dev_id
);
}
struct
fdelay_board
*
fdelay_open_by_lun
(
int
lun
)
{
ssize_t
ret
;
char
dev_id_str
[
4
];
char
path_pattern
[]
=
"/dev/fine-delay.%d"
;
char
path
[
sizeof
(
path_pattern
)
+
1
];
uint32_t
dev_id
;
if
(
fdelay_is_verbose
())
fprintf
(
stderr
,
"called: %s(lun %i);
\n
"
,
__func__
,
lun
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
path_pattern
,
lun
);
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
{
errno
=
EINVAL
;
return
NULL
;
}
ret
=
readlink
(
path
,
dev_id_str
,
sizeof
(
dev_id_str
));
if
(
ret
<
0
)
{
errno
=
ENODEV
;
return
NULL
;
}
if
(
sscanf
(
dev_id_str
,
"%4"
SCNu32
,
&
dev_id
)
!=
1
)
{
errno
=
ENODEV
;
return
NULL
;
}
return
fdelay_open
(
dev_id
);
}
/**
* Close an FMC Fine Delay device opened with one of the following functions:
...
...
lib/fdelay-lib.h
View file @
54eafb43
...
...
@@ -136,6 +136,7 @@ enum fmctdc_error_numbers {
#ifdef FDELAY_INTERNAL
/* Libray users should ignore what follows */
#include <unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
...
...
@@ -162,7 +163,7 @@ static inline int __fdelay_sysfs_get(char *path, uint32_t *resp)
if
(
!
f
)
return
-
1
;
errno
=
0
;
if
(
fscanf
(
f
,
"%
i"
,
resp
)
!=
1
)
{
if
(
fscanf
(
f
,
"%
"
SCNu32
,
resp
)
!=
1
)
{
fclose
(
f
);
if
(
!
errno
)
errno
=
EINVAL
;
...
...
@@ -177,7 +178,7 @@ static inline int __fdelay_sysfs_set(char *path, uint32_t *value)
char
s
[
16
];
int
fd
,
ret
,
len
;
len
=
sprintf
(
s
,
"%
i
\n
"
,
*
value
);
len
=
sprintf
(
s
,
"%
"
PRIu32
"
\n
"
,
*
value
);
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
)
return
-
1
;
...
...
lib/fdelay-output.c
View file @
54eafb43
...
...
@@ -60,13 +60,14 @@ static int __fdelay_get_ch_fd(struct __fdelay_board *b,
int
channel
,
int
*
fdc
)
{
int
ch14
=
channel
+
1
;
char
fname
[
128
];
if
(
channel
<
0
||
channel
>
3
)
{
errno
=
EINVAL
;
return
-
1
;
}
if
(
b
->
fdc
[
ch14
]
<=
0
)
{
char
fname
[
128
];
sprintf
(
fname
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
ch14
);
b
->
fdc
[
ch14
]
=
open
(
fname
,
O_WRONLY
|
O_NONBLOCK
);
if
(
b
->
fdc
[
ch14
]
<
0
)
...
...
@@ -113,7 +114,7 @@ int fdelay_config_pulse(struct fdelay_board *userb,
a
[
FD_ATTR_OUT_DELTA_FINE
]
=
pulse
->
loop
.
frac
;
/* only 0..f */
int
mode
=
pulse
->
mode
&
0x7f
;
/* hotfix: the ZIO has a bug blocking the output when the output raw_io function returns an error.
therefore we temporarily have to check the output programming correctness in the user library. */
if
(
mode
==
FD_OUT_MODE_DELAY
||
mode
==
FD_OUT_MODE_DISABLED
)
...
...
@@ -339,7 +340,7 @@ int fdelay_get_config_pulse_ps(struct fdelay_board *userb,
if
(
fdelay_get_config_pulse
(
userb
,
channel
,
&
pulse
)
<
0
)
return
-
1
;
memset
(
ps
,
0
,
sizeof
(
struct
fdelay_pulse_ps
));
ps
->
mode
=
pulse
.
mode
;
ps
->
rep
=
pulse
.
rep
;
...
...
lib/fdelay-tdc.c
View file @
54eafb43
...
...
@@ -67,8 +67,9 @@ int fdelay_get_config_tdc(struct fdelay_board *userb)
static
int
__fdelay_open_tdc
(
struct
__fdelay_board
*
b
)
{
char
fname
[
128
];
if
(
b
->
fdc
[
0
]
<=
0
)
{
char
fname
[
128
];
sprintf
(
fname
,
"%s-0-0-ctrl"
,
b
->
devbase
);
b
->
fdc
[
0
]
=
open
(
fname
,
O_RDONLY
|
O_NONBLOCK
);
}
...
...
@@ -102,12 +103,12 @@ int fdelay_fileno_tdc(struct fdelay_board *userb)
* empty
*/
int
fdelay_read
(
struct
fdelay_board
*
userb
,
struct
fdelay_time
*
t
,
int
n
,
int
flags
)
int
flags
)
{
__define_board
(
b
,
userb
);
struct
zio_control
ctrl
;
uint32_t
*
attrs
;
int
i
,
j
,
fd
;
int
i
,
fd
;
fd_set
set
;
fd
=
__fdelay_open_tdc
(
b
);
...
...
@@ -115,6 +116,8 @@ int fdelay_read(struct fdelay_board *userb, struct fdelay_time *t, int n,
return
fd
;
/* errno already set */
for
(
i
=
0
;
i
<
n
;)
{
int
j
;
j
=
read
(
fd
,
&
ctrl
,
sizeof
(
ctrl
));
if
(
j
<
0
&&
errno
!=
EAGAIN
)
return
-
1
;
...
...
@@ -166,9 +169,11 @@ int fdelay_read(struct fdelay_board *userb, struct fdelay_time *t, int n,
*/
int
fdelay_fread
(
struct
fdelay_board
*
userb
,
struct
fdelay_time
*
t
,
int
n
)
{
int
i
,
loop
;
int
i
;
for
(
i
=
0
;
i
<
n
;
)
{
int
loop
;
loop
=
fdelay_read
(
userb
,
t
+
i
,
n
-
i
,
0
);
if
(
loop
<
0
)
return
-
1
;
...
...
tools/Makefile
View file @
54eafb43
...
...
@@ -13,10 +13,11 @@ DESTDIR ?= /usr/local
GIT_VERSION
:=
$(
shell
git describe
--dirty
--long
--tags
)
CFLAGS
+=
-I
../kernel
-I
../lib
-Wno-trigraphs
-Wall
-Werror
-ggdb
$(EXTRACFLAGS)
LIBFD
:=
../lib
CFLAGS
+=
-I
../kernel
-I
$(LIBFD)
-Wno-trigraphs
-Wall
-Werror
-ggdb
$(EXTRACFLAGS)
CFLAGS
+=
-DGIT_VERSION
=
"
\"
$(GIT_VERSION)
\"
"
LDFLAGS
=
-L
../lib
LDFLAGS
=
-L
$(LIBFD)
LDLIBS
=
-lfdelay
CC
?=
$(CROSS_COMPILE)
gcc
...
...
@@ -50,4 +51,4 @@ install:
install
-D
$(progs)
$(DESTDIR)
/bin
cppcheck
:
$(CPPCHECK)
-q
-I
.
-I
../kernel
-I
$(LIB
TDC
)
--suppress
=
missingIncludeSystem
--enable
=
all
*
.c
*
.h
$(CPPCHECK)
-q
-I
.
-I
../kernel
-I
$(LIB
FD
)
--suppress
=
missingIncludeSystem
--enable
=
all
*
.c
*
.h
tools/fmc-fdelay-board-time.c
View file @
54eafb43
...
...
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
exit
(
1
);
}
int
err
=
fdelay_check_wr_mode
(
b
);
err
=
fdelay_check_wr_mode
(
b
);
printf
(
"WR Status: "
);
switch
(
err
)
{
...
...
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
default:
printf
(
"error: %s
\n
"
,
strerror
(
errno
));
break
;
}
printf
(
"Time: %lli.%09li
\n
"
,
(
long
long
)
t
.
utc
,
(
long
)
t
.
coarse
*
8
);
fdelay_close
(
b
);
fdelay_exit
();
return
0
;
...
...
@@ -130,7 +130,7 @@ int main(int argc, char **argv)
setbuf
(
stdout
,
NULL
);
printf
(
"Locking the card to WR: "
);
int
err
=
fdelay_wr_mode
(
b
,
1
);
err
=
fdelay_wr_mode
(
b
,
1
);
if
(
err
==
ENOTSUP
)
{
...
...
tools/fmc-fdelay-input.c
View file @
54eafb43
...
...
@@ -30,7 +30,7 @@ void dump_input(struct fdelay_time *t, int np, int umode)
int
i
;
for
(
i
=
0
;
i
<
np
;
i
++
,
t
++
)
{
printf
(
"seq %5
i
: "
,
t
->
seq_id
);
printf
(
"seq %5
u
: "
,
t
->
seq_id
);
tools_report_time
(
""
,
t
,
umode
);
}
}
...
...
tools/fmc-fdelay-term.c
View file @
54eafb43
...
...
@@ -85,7 +85,7 @@ int main(int argc, char **argv)
}
printf
(
"%s: termination is %s
\n
"
,
argv
[
0
],
hwval
&
FD_TDCF_TERM_50
?
"on"
:
"off"
);
(
hwval
&
FD_TDCF_TERM_50
)
?
"on"
:
"off"
);
fdelay_close
(
b
);
fdelay_exit
();
...
...
tools/tools-util.c
View file @
54eafb43
...
...
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include "fdelay-lib.h"
#include "tools-common.h"
...
...
@@ -60,20 +61,20 @@ void tools_report_time(char *name, struct fdelay_time *t, int umode)
printf
(
"%s "
,
name
);
switch
(
umode
)
{
case
TOOLS_UMODE_USER
:
printf
(
"%10
llu
:%03llu,%03llu,%03llu,%03llu ps
\n
"
,
(
long
long
)(
t
->
utc
)
,
(
picoseconds
/
(
1000LL
*
1000
*
1000
)),
(
picoseconds
/
(
1000LL
*
1000
)
%
1000
),
(
picoseconds
/
(
1000LL
)
%
1000
),
(
picoseconds
%
1000LL
));
printf
(
"%10
"
PRIu64
"
:%03llu,%03llu,%03llu,%03llu ps
\n
"
,
t
->
utc
,
(
picoseconds
/
(
1000
U
LL
*
1000
*
1000
)),
(
picoseconds
/
(
1000
U
LL
*
1000
)
%
1000
),
(
picoseconds
/
(
1000
U
LL
)
%
1000
),
(
picoseconds
%
1000
U
LL
));
break
;
case
TOOLS_UMODE_FLOAT
:
printf
(
"float %10
llu.%012llu
\n
"
,
(
long
long
)(
t
->
utc
)
,
printf
(
"float %10
"
PRIu64
".%012llu
\n
"
,
t
->
utc
,
picoseconds
);
break
;
case
TOOLS_UMODE_RAW
:
printf
(
"raw utc %10
lli, coarse %9li, frac %9li
\n
"
,
(
long
long
)
t
->
utc
,
(
long
)
t
->
coarse
,
(
long
)
t
->
frac
);
printf
(
"raw utc %10
"
PRIu64
", coarse %9"
PRIu32
", frac %9"
PRIu32
"
\n
"
,
t
->
utc
,
t
->
coarse
,
t
->
frac
);
break
;
}
}
...
...
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