Skip to content

Commit

Permalink
IIOD: Support printing device label in debug output
Browse files Browse the repository at this point in the history
Print the label, or name, or ID as the IIO device identifier, instead of
printing just the name or ID.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed May 19, 2021
1 parent 70c7906 commit 44d0346
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions iiod/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ static unsigned int get_channel_number(const struct iio_channel *chn)
return i;
}

static inline const char *dev_label_or_name_or_id(const struct iio_device *dev)
{
const char *name;

name = iio_device_get_label(dev);
if (name)
return name;

name = iio_device_get_name(dev);
if (name)
return name;

return iio_device_get_id(dev);
}

#if WITH_AIO
static ssize_t async_io(struct parser_pdata *pdata, void *buf, size_t len,
bool do_read)
Expand Down Expand Up @@ -542,7 +557,7 @@ static void rw_thd(struct thread_pool *pool, void *d)
ssize_t ret = 0;

IIO_DEBUG("R/W thread started for device %s\n",
dev->name ? dev->name : dev->id);
dev_label_or_name_or_id(dev));

while (true) {
bool has_readers = false, has_writers = false,
Expand Down Expand Up @@ -602,7 +617,7 @@ static void rw_thd(struct thread_pool *pool, void *d)
}

IIO_DEBUG("IIO device %s reopened with new mask:\n",
dev->id);
dev_label_or_name_or_id(dev));
for (i = 0; i < nb_words; i++)
IIO_DEBUG("Mask[%i] = 0x%08x\n", i, entry->mask[i]);
entry->update_mask = false;
Expand Down Expand Up @@ -759,7 +774,7 @@ static void rw_thd(struct thread_pool *pool, void *d)
pthread_mutex_unlock(&devlist_lock);

IIO_DEBUG("Stopping R/W thread for device %s\n",
dev->name ? dev->name : dev->id);
dev_label_or_name_or_id(dev));

dev_entry_put(entry);
}
Expand Down

0 comments on commit 44d0346

Please sign in to comment.