Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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 ADC 100M 14b 4cha - Software
Commits
6b7610c1
Commit
6b7610c1
authored
Feb 11, 2014
by
Michel Arruat
Committed by
Alessandro Rubini
Mar 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: implement open_by_lun (undocumented and to be fixed)
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
27a347f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
boards.c
lib/boards.c
+22
-11
No files found.
lib/boards.c
View file @
6b7610c1
...
...
@@ -9,8 +9,11 @@
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
#include "fmcadc-lib.h"
#include "fmcadc-lib-int.h"
...
...
@@ -98,24 +101,32 @@ struct fmcadc_dev *fmcadc_open(char *name, unsigned int dev_id,
return
b
->
fa_op
->
open
(
b
,
dev_id
,
buffersize
,
nbuffer
,
flags
);
}
#define FMCADC_PATH_PATTERN "/dev/%s.%d"
/* Open by lun should lookup a database */
struct
fmcadc_dev
*
fmcadc_open_by_lun
(
char
*
name
,
int
lun
,
unsigned
long
buffersize
,
unsigned
int
nbuffer
,
unsigned
long
flags
)
{
const
struct
fmcadc_board_type
*
b
;
b
=
find_board
(
name
);
if
(
!
b
)
ssize_t
ret
;
char
dev_id_str
[
8
];
char
path
[
PATH_MAX
];
int
dev_id
;
ret
=
snprintf
(
path
,
sizeof
(
path
),
"/dev/%s.%d"
,
"adc-100m14b"
/* FIXME: this must be generic */
,
lun
);
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
{
errno
=
EINVAL
;
return
NULL
;
/*
* FIXME: open_by_lun should lookup the database and get dev_id
* return b->fa_op->open( .... dev_id ...)
;
*/
errno
=
ENOSYS
;
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
fmcadc_open
(
name
,
dev_id
,
buffersize
,
nbuffer
,
flags
)
;
}
...
...
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