X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=device.c;fp=device.c;h=212ddb7dc91c1f6289f4f09cc2753dd520fb8efa;hp=c0df1ecc4b4ee48e7f6bd641ab6b4f107e5761eb;hb=8102cee4d495c7402a7ca70ec40414312129c1f2;hpb=0294a409b80f21c8197fa4533fd9819f8274a381 diff --git a/device.c b/device.c index c0df1ecc..212ddb7d 100644 --- a/device.c +++ b/device.c @@ -456,20 +456,31 @@ SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver) } /** - * Clear all devices/instances of the specified driver. + * Clear the list of device instances a driver knows about. * - * @param driver The driver to use. Must not be NULL. + * @param driver The driver to use. This must be a pointer to one of + * the entries returned by sr_driver_list(). Must not be NULL. * - * @return SR_OK upon success, a negative error code upon errors. + * @retval SR_OK Success + * @retval SR_ERR_ARG Invalid driver * * @since 0.2.0 */ SR_API int sr_dev_clear(const struct sr_dev_driver *driver) { - if (driver && driver->dev_clear) - return driver->dev_clear(); + int ret; + + if (!driver) { + sr_err("Invalid driver."); + return SR_ERR_ARG; + } + + if (driver->dev_clear) + ret = driver->dev_clear(); else - return SR_OK; + ret = std_dev_clear(driver, NULL); + + return ret; } /**