diff --git a/context.c b/context.c index e78a16a87..425533cb3 100644 --- a/context.c +++ b/context.c @@ -232,7 +232,8 @@ struct iio_device * iio_context_find_device(const struct iio_context *ctx, for (i = 0; i < ctx->nb_devices; i++) { struct iio_device *dev = ctx->devices[i]; if (!strcmp(dev->id, name) || - (dev->name && !strcmp(dev->name, name))) + (dev->label && !strcmp(dev->label, name)) || + (dev->name && !strcmp(dev->name, name))) return dev; } return NULL; diff --git a/iio.h b/iio.h index c69dea6f2..5a30c0d4b 100644 --- a/iio.h +++ b/iio.h @@ -541,13 +541,13 @@ __api __check_ret __pure struct iio_device * iio_context_get_device( const struct iio_context *ctx, unsigned int index); -/** @brief Try to find a device structure by its name of ID +/** @brief Try to find a device structure by its ID, label or name * @param ctx A pointer to an iio_context structure - * @param name A NULL-terminated string corresponding to the name or the ID of - * the device to search for + * @param name A NULL-terminated string corresponding to the ID, label or name + * of the device to search for * @return On success, a pointer to an iio_device structure - * @return If the name or ID does not correspond to any known device, NULL is - * returned */ + * @return If the parameter does not correspond to the ID, label or name of + * any known device, NULL is returned */ __api __check_ret __pure struct iio_device * iio_context_find_device( const struct iio_context *ctx, const char *name);