sr: sr_hw_has_hwcap(): More docs, error checks.

This commit is contained in:
Uwe Hermann 2012-02-29 19:32:39 +01:00
parent 2f8cf27409
commit c496ac97a8
1 changed files with 13 additions and 2 deletions

View File

@ -264,13 +264,24 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial)
* @param driver The hardware driver in which to search for the capability.
* @param hwcap The capability to find in the list.
*
* @return TRUE if found, FALSE otherwise.
* @return TRUE if the specified capability exists in the specified driver,
* FALSE otherwise. Also, if 'driver' is NULL or the respective driver
* returns an invalid capability list, FALSE is returned.
*/
SR_API gboolean sr_hw_has_hwcap(struct sr_dev_driver *driver, int hwcap)
{
int *hwcaps, i;
hwcaps = driver->hwcap_get_all();
if (!driver) {
sr_err("hwdriver: %s: driver was NULL", __func__);
return FALSE;
}
if (!(hwcaps = driver->hwcap_get_all())) {
sr_err("hwdriver: %s: hwcap_get_all() returned NULL", __func__);
return FALSE;
}
for (i = 0; hwcaps[i]; i++) {
if (hwcaps[i] == hwcap)
return TRUE;