device: sr_dev_clear() now always works.
If the driver does not provide a dev_clear() function, the wrapper now calls std_dev_clear() instead.
This commit is contained in:
parent
0294a409b8
commit
8102cee4d4
|
@ -166,10 +166,6 @@ static int sanity_check_all_drivers(void)
|
||||||
sr_err("No dev_list in driver %d ('%s').", i, d);
|
sr_err("No dev_list in driver %d ('%s').", i, d);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if (!drivers[i]->dev_clear) {
|
|
||||||
sr_err("No dev_clear in driver %d ('%s').", i, d);
|
|
||||||
errors++;
|
|
||||||
}
|
|
||||||
/* Note: config_get() is optional. */
|
/* Note: config_get() is optional. */
|
||||||
if (!drivers[i]->config_set) {
|
if (!drivers[i]->config_set) {
|
||||||
sr_err("No config_set in driver %d ('%s').", i, d);
|
sr_err("No config_set in driver %d ('%s').", i, d);
|
||||||
|
|
23
device.c
23
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
|
* @since 0.2.0
|
||||||
*/
|
*/
|
||||||
SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
|
SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
|
||||||
{
|
{
|
||||||
if (driver && driver->dev_clear)
|
int ret;
|
||||||
return driver->dev_clear();
|
|
||||||
|
if (!driver) {
|
||||||
|
sr_err("Invalid driver.");
|
||||||
|
return SR_ERR_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (driver->dev_clear)
|
||||||
|
ret = driver->dev_clear();
|
||||||
else
|
else
|
||||||
return SR_OK;
|
ret = std_dev_clear(driver, NULL);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue