* 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_CONF_* 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.
+ * @param key The configuration key (SR_CONF_*).
+ * @param data Pointer where the value will be stored. Must not be NULL.
+ * @param sdi If the key is specific to a device, this must contain a
+ * pointer to the struct sr_dev_inst to be checked.
*
* @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,
+ * may be returned by the driver indicating it doesn't know that key,
* 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_config_get(struct sr_dev_driver *driver, int id,
+SR_API int sr_config_get(struct sr_dev_driver *driver, int key,
const void **data, const struct sr_dev_inst *sdi)
{
int ret;
- if (driver == NULL || data == NULL)
+ if (!driver || !data)
return SR_ERR;
- ret = driver->config_get(id, data, sdi);
+ if (!driver->config_get)
+ return SR_ERR_ARG;
+
+ ret = driver->config_get(key, data, sdi);
return ret;
}
-SR_API int sr_config_list(struct sr_dev_driver *driver, int id,
+/**
+ * Set a configuration key in a device instance.
+ *
+ * @param sdi The device instance.
+ * @param key The configuration key (SR_CONF_*).
+ * @param value The new value for the key, as a pointer to whatever type
+ * is appropriate for that key.
+ *
+ * @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 key,
+ * 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_config_set(const struct sr_dev_inst *sdi, int key,
+ const void *value)
+{
+ int ret;
+
+ if (!sdi || !sdi->driver)
+ return SR_ERR;
+
+ if (!sdi->driver->config_set)
+ return SR_ERR_ARG;
+
+ ret = sdi->driver->config_set(key, value, sdi);
+
+ return ret;
+}
+
+/**
+ * List all possible values for a configuration key.
+ *
+ * @param driver The sr_dev_driver struct to query.
+ * @param key The configuration key (SR_CONF_*).
+ * @param data A pointer to a list of values, in whatever format is
+ * appropriate for that key.
+ * @param sdi If the key is specific to a device, this must contain a
+ * pointer to the struct sr_dev_inst to be checked.
+ *
+ * @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 key,
+ * 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_config_list(struct sr_dev_driver *driver, int key,
const void **data, const struct sr_dev_inst *sdi)
{
int ret;
- if (driver == NULL || data == NULL)
+ if (!driver || !data)
return SR_ERR;
if (!driver->config_list)
- return SR_ERR;
+ return SR_ERR_ARG;
- ret = driver->config_list(id, data, sdi);
+ ret = driver->config_list(key, data, sdi);
return ret;
}
/**
- * Get information about an sr_config key.
+ * Get information about a configuration key.
*
- * @param opt The sr_config key.
+ * @param opt The configuration key.
*
* @return A pointer to a struct sr_config_info, or NULL if the key
* was not found.
}
/**
- * Get information about an sr_config key, by name.
+ * Get information about an configuration key, by name.
*
- * @param optname The sr_config key.
+ * @param optname The configuration key.
*
* @return A pointer to a struct sr_config_info, or NULL if the key
* was not found.
SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
const char *trigger);
SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key);
-SR_API int sr_config_set(const struct sr_dev_inst *sdi, int hwcap,
- const void *value);
SR_API GSList *sr_dev_inst_list(const struct sr_dev_driver *driver);
SR_API int sr_dev_inst_clear(const struct sr_dev_driver *driver);
SR_API int sr_driver_init(struct sr_context *ctx,
struct sr_dev_driver *driver);
SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options);
-SR_API int sr_config_get(struct sr_dev_driver *driver, int id,
+SR_API int sr_config_get(struct sr_dev_driver *driver, int key,
const void **data, const struct sr_dev_inst *sdi);
-SR_API int sr_config_list(struct sr_dev_driver *driver, int id,
+SR_API int sr_config_set(const struct sr_dev_inst *sdi, int key,
+ const void *value);
+SR_API int sr_config_list(struct sr_dev_driver *driver, int key,
const void **data, const struct sr_dev_inst *sdi);
SR_API const struct sr_config_info *sr_config_info_get(int key);
SR_API const struct sr_config_info *sr_config_info_name_get(const char *optname);