Commit 29dbdf06 authored by Federico Vaga's avatar Federico Vaga

lib: do not allow open by offset

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 16aa7ca8
......@@ -82,15 +82,13 @@ void fmctdc_exit(void)
/**
* It opens one specific device. -1 arguments mean "not installed"
* @param[in] offset [deprecated] board enumeration offset [0, N].
* -1 to ignore it and use only dev_id
* @param[in] dev_id FMC device id. -1 to ignore it and use only the offset
* @return an instance token, otherwise NULL and errno is appripriately set.
* ENODEV if the device was not found. EINVAL there is a mismatch with
* the arguments
*/
#define __FMCTDC_OPEN_PATH_MAX 128
struct fmctdc_board *fmctdc_open(int offset, int dev_id)
struct fmctdc_board *fmctdc_open(int dev_id)
{
struct __fmctdc_board *b = NULL;
uint32_t nsamples = NSAMPLE;
......@@ -100,11 +98,6 @@ struct fmctdc_board *fmctdc_open(int offset, int dev_id)
int ret;
struct stat sb;
if (offset != -1) {
errno = EINVAL;
return NULL;
}
if (dev_id < 0) {
errno = EINVAL;
return NULL;
......@@ -231,7 +224,7 @@ struct fmctdc_board *fmctdc_open_by_lun(int lun)
errno = ENODEV;
return NULL;
}
return fmctdc_open(-1, dev_id);
return fmctdc_open(dev_id);
}
......
......@@ -218,7 +218,7 @@ extern int fmctdc_ts_mode_get(struct fmctdc_board *userb,
* Set of functions to read time-stamps from the board
* @{
*/
extern struct fmctdc_board *fmctdc_open(int offset, int dev_id);
extern struct fmctdc_board *fmctdc_open(int dev_id);
extern struct fmctdc_board *fmctdc_open_by_lun(int lun);
extern int fmctdc_close(struct fmctdc_board *);
extern int fmctdc_fread(struct fmctdc_board *b, unsigned int channel,
......
......@@ -267,7 +267,7 @@ int main(int argc, char **argv)
}
/* Open FMC TDC device */
brd = fmctdc_open(-1, dev_id); /* look for dev_id form the beginning */
brd = fmctdc_open(dev_id); /* look for dev_id form the beginning */
if (!brd)
{
if (dev_id == 0xFFFFFFFF)
......
......@@ -377,7 +377,7 @@ int main(int argc, char **argv)
/* Open FMC TDC device */
if (dev_id != 0xFFFFFFFF) {
brd = fmctdc_open(-1, dev_id);
brd = fmctdc_open(dev_id);
if (!brd) {
fprintf(stderr, "Can't open device id 0x%x: %s\n",
dev_id, strerror(errno));
......
......@@ -22,7 +22,8 @@ void open_board(char *dev_id_str)
exit(-1);
}
brd = fmctdc_open(-1, dev_id);
brd = fmctdc_open(dev_id);
if (!brd) {
fprintf(stderr, "Can't open device %s: %s\n", dev_id_str,
strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment