]> sigrok.org Git - libsigrok.git/blobdiff - src/hwdriver.c
global: Treat SR_CONF_OUTPUT_FREQUENCY as float instead of uint64_t
[libsigrok.git] / src / hwdriver.c
index 148ea8a230470eeafbc757bb2679a464f556c80b..c6c5645659e44a50d81c230f0b1dcc70a97722a0 100644 (file)
@@ -31,8 +31,6 @@
 #define LOG_PREFIX "hwdriver"
 /** @endcond */
 
-extern SR_PRIV struct sr_dev_driver **drivers_lists[];
-
 /**
  * @file
  *
@@ -159,7 +157,7 @@ static struct sr_config_info sr_config_info_data[] = {
                "Output channel regulation", NULL},
        {SR_CONF_OVER_TEMPERATURE_PROTECTION, SR_T_BOOL, "otp",
                "Over-temperature protection", NULL},
-       {SR_CONF_OUTPUT_FREQUENCY, SR_T_UINT64, "output_frequency",
+       {SR_CONF_OUTPUT_FREQUENCY, SR_T_FLOAT, "output_frequency",
                "Output frequency", NULL},
        {SR_CONF_MEASURED_QUANTITY, SR_T_STRING, "measured_quantity",
                "Measured quantity", NULL},
@@ -259,27 +257,20 @@ SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *value)
 /**
  * Return the list of supported hardware drivers.
  *
- * @return Pointer to the NULL-terminated list of hardware driver pointers.
+ * @param[in] ctx Pointer to a libsigrok context struct. Must not be NULL.
+ *
+ * @retval NULL The ctx argument was NULL, or there are no supported drivers.
+ * @retval Other Pointer to the NULL-terminated list of hardware drivers.
+ *               The user should NOT g_free() this list, sr_exit() will do that.
  *
- * @since 0.1.0
+ * @since 0.4.0
  */
-SR_API struct sr_dev_driver **sr_driver_list(void)
+SR_API struct sr_dev_driver **sr_driver_list(const struct sr_context *ctx)
 {
-       static struct sr_dev_driver **combined_list = NULL;
-       struct sr_dev_driver ***lists, **drivers;
-       GArray *array;
-
-       if (combined_list)
-               return combined_list;
-
-       array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *));
-       for (lists = drivers_lists; *lists; lists++)
-               for (drivers = *lists; *drivers; drivers++)
-                       g_array_append_val(array, *drivers);
-       combined_list = (struct sr_dev_driver **)array->data;
-       g_array_free(array, FALSE);
+       if (!ctx)
+               return NULL;
 
-       return combined_list;
+       return ctx->driver_list;
 }
 
 /**
@@ -418,14 +409,22 @@ SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options)
        return l;
 }
 
-/** Call driver cleanup function for all drivers.
- *  @private */
-SR_PRIV void sr_hw_cleanup_all(void)
+/**
+ * Call driver cleanup function for all drivers.
+ *
+ * @param[in] ctx Pointer to a libsigrok context struct. Must not be NULL.
+ *
+ * @private
+ */
+SR_PRIV void sr_hw_cleanup_all(const struct sr_context *ctx)
 {
        int i;
        struct sr_dev_driver **drivers;
 
-       drivers = sr_driver_list();
+       if (!ctx)
+               return;
+
+       drivers = sr_driver_list(ctx);
        for (i = 0; drivers[i]; i++) {
                if (drivers[i]->cleanup)
                        drivers[i]->cleanup(drivers[i]);