From: Bert Vermeulen Date: Thu, 12 Jul 2012 20:41:57 +0000 (+0200) Subject: sr: new sr_info_get() API call, wrapper for driver info_get() X-Git-Tag: dsupstream~832 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=df12380181f0af94fca382cd2ae6425bb1b51f73;p=libsigrok.git sr: new sr_info_get() API call, wrapper for driver info_get() This will replace sr_dev_info_get(), the wrapper for driver dev_info_get() --- diff --git a/hwdriver.c b/hwdriver.c index 77082367..b96e0b75 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -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) { diff --git a/proto.h b/proto.h index a1d6d7cc..ff5cb941 100644 --- a/proto.h +++ b/proto.h @@ -77,6 +77,8 @@ SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options); SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap); SR_API const struct sr_hwcap_option *sr_drvopt_get(int hwopt); SR_API const struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap); +SR_API int sr_info_get(struct sr_dev_driver *driver, int id, + const void **data, const struct sr_dev_inst *sdi); /*--- session.c -------------------------------------------------------------*/