]> sigrok.org Git - libsigrok.git/blobdiff - hwdriver.c
sr: deprecate driver API call hwcap_get_all()
[libsigrok.git] / hwdriver.c
index 770823672a95203c118417a608191ab770f43185..7effb6aa978d81b92341fab39d14c3f07a8aab61 100644 (file)
@@ -177,6 +177,32 @@ SR_PRIV void sr_hw_cleanup_all(void)
        }
 }
 
+/**
+ * Returns information about the given driver or device instance.
+ *
+ * @param driver The sr_dev_driver struct to query.
+ * @param id The type of information, in the form of an SR_HWCAP_* option.
+ * @param data Pointer where the value. will be stored. Must not be NULL.
+ * @param sdi Pointer to the struct sr_dev_inst to be checked. Must not be NULL.
+ *
+ * @return SR_OK upon success or SR_ERR in case of error. Note SR_ERR_ARG
+ *         may be returned by the driver indicating it doesn't know that id,
+ *         but this is not to be flagged as an error by the caller; merely
+ *         as an indication that it's not applicable.
+ */
+SR_API int sr_info_get(struct sr_dev_driver *driver, int id,
+               const void **data, const struct sr_dev_inst *sdi)
+{
+       int ret;
+
+       if (driver == NULL || data == NULL)
+               return SR_ERR;
+
+       ret = driver->info_get(id, data, sdi);
+
+       return ret;
+}
+
 SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
                const char *vendor, const char *model, const char *version)
 {
@@ -312,10 +338,8 @@ SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap)
                return FALSE;
        }
 
-       if (!(hwcaps = driver->hwcap_get_all())) {
-               sr_err("hwdriver: %s: hwcap_get_all() returned NULL", __func__);
+       if (driver->info_get(SR_DI_HWCAPS, (const void **)&hwcaps, NULL) != SR_OK)
                return FALSE;
-       }
 
        for (i = 0; hwcaps[i]; i++) {
                if (hwcaps[i] == hwcap)