Commit ae601b1a authored by Alessandro Rubini's avatar Alessandro Rubini

lib: add optional tracing of open/close

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent eb8e9d95
...@@ -122,17 +122,20 @@ void fdelay_exit(void) ...@@ -122,17 +122,20 @@ void fdelay_exit(void)
} }
/* Open one specific device. -1 arguments mean "not installed" */ /* Open one specific device. -1 arguments mean "not installed" */
struct fdelay_board *fdelay_open(int offset, int dev_id) struct fdelay_board *fdelay_open(int index, int dev_id)
{ {
struct __fdelay_board *b = NULL; struct __fdelay_board *b = NULL;
int i; int i;
if (offset >= fd_nboards) { if (fdelay_is_verbose())
fprintf(stderr, "called: %s(index %i, dev_id 0x%x);\n",
__func__, index, dev_id);
if (index >= fd_nboards) {
errno = ENODEV; errno = ENODEV;
return NULL; return NULL;
} }
if (offset >= 0) { if (index >= 0) {
b = fd_boards + offset; b = fd_boards + index;
if (dev_id >= 0 && dev_id != b->dev_id) { if (dev_id >= 0 && dev_id != b->dev_id) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
...@@ -166,6 +169,8 @@ struct fdelay_board *fdelay_open_by_lun(int lun) ...@@ -166,6 +169,8 @@ struct fdelay_board *fdelay_open_by_lun(int lun)
char path[sizeof(path_pattern) + 1]; char path[sizeof(path_pattern) + 1];
int dev_id; int dev_id;
if (fdelay_is_verbose())
fprintf(stderr, "called: %s(lun %i);\n", __func__, lun);
ret = snprintf(path, sizeof(path), path_pattern, lun); ret = snprintf(path, sizeof(path), path_pattern, lun);
if (ret < 0 || ret >= sizeof(path)) { if (ret < 0 || ret >= sizeof(path)) {
errno = EINVAL; errno = EINVAL;
...@@ -184,6 +189,9 @@ int fdelay_close(struct fdelay_board *userb) ...@@ -184,6 +189,9 @@ int fdelay_close(struct fdelay_board *userb)
__define_board(b, userb); __define_board(b, userb);
int j; int j;
if (fdelay_is_verbose())
fprintf(stderr, "called: %s(index %i, dev_id 0x%x);\n",
__func__, b - fd_boards, b->dev_id);
for (j = 0; j < ARRAY_SIZE(b->fdc); j++) { for (j = 0; j < ARRAY_SIZE(b->fdc); j++) {
if (b->fdc[j] >= 0) if (b->fdc[j] >= 0)
close(b->fdc[j]); close(b->fdc[j]);
......
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