X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hwplugin.c;h=5204a0f02c7ba2341bd377495725ddb5ebb1cdc8;hb=187b358232aa90de8ee12df915506f839a98f2ad;hp=b924f0d65c3547871634fb0d61c3bf7ec19908f3;hpb=5097b0d0912165429aceddb5febbf68467b623f5;p=libsigrok.git diff --git a/hwplugin.c b/hwplugin.c index b924f0d6..5204a0f0 100644 --- a/hwplugin.c +++ b/hwplugin.c @@ -26,9 +26,6 @@ #include "sigrok.h" #include "sigrok-internal.h" -/* The list of loaded plugins lives here. */ -static GSList *plugins; - /* * This enumerates which plugin capabilities correspond to user-settable * options. @@ -43,62 +40,63 @@ SR_API struct sr_hwcap_option sr_hwcap_options[] = { }; #ifdef HAVE_LA_DEMO -extern struct sr_dev_plugin demo_plugin_info; +extern SR_PRIV struct sr_dev_plugin demo_plugin_info; #endif #ifdef HAVE_LA_SALEAE_LOGIC -extern struct sr_dev_plugin saleae_logic_plugin_info; +extern SR_PRIV struct sr_dev_plugin saleae_logic_plugin_info; #endif #ifdef HAVE_LA_OLS -extern struct sr_dev_plugin ols_plugin_info; +extern SR_PRIV struct sr_dev_plugin ols_plugin_info; #endif #ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE -extern struct sr_dev_plugin zeroplus_logic_cube_plugin_info; +extern SR_PRIV struct sr_dev_plugin zeroplus_logic_cube_plugin_info; #endif #ifdef HAVE_LA_ASIX_SIGMA -extern struct sr_dev_plugin asix_sigma_plugin_info; +extern SR_PRIV struct sr_dev_plugin asix_sigma_plugin_info; #endif #ifdef HAVE_LA_CHRONOVU_LA8 -extern SR_PRIV struct dev_plugin chronovu_la8_plugin_info; +extern SR_PRIV struct sr_dev_plugin chronovu_la8_plugin_info; #endif #ifdef HAVE_LA_LINK_MSO19 -extern struct sr_dev_plugin link_mso19_plugin_info; +extern SR_PRIV struct sr_dev_plugin link_mso19_plugin_info; #endif #ifdef HAVE_LA_ALSA -extern struct sr_dev_plugin alsa_plugin_info; +extern SR_PRIV struct sr_dev_plugin alsa_plugin_info; +#endif +#ifdef HAVE_LA_FX2LAFW +extern SR_PRIV struct sr_dev_plugin fx2lafw_plugin_info; #endif -/* TODO: No linked list needed, this can be a simple array. */ -SR_PRIV int sr_hw_load_all(void) -{ +static struct sr_dev_plugin *plugins_list[] = { #ifdef HAVE_LA_DEMO - plugins = g_slist_append(plugins, (gpointer *)&demo_plugin_info); + &demo_plugin_info, #endif #ifdef HAVE_LA_SALEAE_LOGIC - plugins = - g_slist_append(plugins, (gpointer *)&saleae_logic_plugin_info); + &saleae_logic_plugin_info, #endif #ifdef HAVE_LA_OLS - plugins = g_slist_append(plugins, (gpointer *)&ols_plugin_info); + &ols_plugin_info, #endif #ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE - plugins = g_slist_append(plugins, - (gpointer *)&zeroplus_logic_cube_plugin_info); + &zeroplus_logic_cube_plugin_info, #endif #ifdef HAVE_LA_ASIX_SIGMA - plugins = g_slist_append(plugins, (gpointer *)&asix_sigma_plugin_info); + &asix_sigma_plugin_info, #endif #ifdef HAVE_LA_CHRONOVU_LA8 - plugins = g_slist_append(plugins, (gpointer *)&chronovu_la8_plugin_info); + &chronovu_la8_plugin_info, #endif #ifdef HAVE_LA_LINK_MSO19 - plugins = g_slist_append(plugins, (gpointer *)&link_mso19_plugin_info); + &link_mso19_plugin_info, #endif #ifdef HAVE_LA_ALSA - plugins = g_slist_append(plugins, (gpointer *)&alsa_plugin_info); + &alsa_plugin_info, #endif - - return SR_OK; -} +#ifdef HAVE_LA_FX2LAFW + &fx2lafw_plugin_info, +#endif + NULL, +}; /** * Return the list of loaded hardware plugins. @@ -106,11 +104,11 @@ SR_PRIV int sr_hw_load_all(void) * The list of plugins is initialized from sr_init(), and can only be reset * by calling sr_exit(). * - * @return A GSList of pointers to loaded plugins. + * @return Pointer to the NULL-terminated list of hardware plugin pointers. */ -SR_API GSList *sr_hw_list(void) +SR_API struct sr_dev_plugin **sr_hw_list(void) { - return plugins; + return plugins_list; } /** @@ -155,13 +153,13 @@ SR_API int sr_hw_init(struct sr_dev_plugin *plugin) SR_PRIV void sr_hw_cleanup_all(void) { - struct sr_dev_plugin *plugin; - GSList *l; + int i; + struct sr_dev_plugin **plugins; - for (l = plugins; l; l = l->next) { - plugin = l->data; - if (plugin->cleanup) - plugin->cleanup(); + plugins = sr_hw_list(); + for (i = 0; plugins[i]; i++) { + if (plugins[i]->cleanup) + plugins[i]->cleanup(); } }