cli: don't initialize and scan for hardware unless needed
If the -d <plugin> option is used, only initialize the specified plugin.
This commit is contained in:
parent
eeebceea31
commit
e54bcdc5d1
29
device.c
29
device.c
|
@ -29,7 +29,6 @@ void device_scan(void)
|
|||
{
|
||||
GSList *plugins, *l;
|
||||
struct device_plugin *plugin;
|
||||
int num_devices, num_probes, i;
|
||||
|
||||
plugins = list_hwplugins();
|
||||
|
||||
|
@ -40,15 +39,23 @@ void device_scan(void)
|
|||
*/
|
||||
for (l = plugins; l; l = l->next) {
|
||||
plugin = l->data;
|
||||
g_message("initializing %s plugin", plugin->name);
|
||||
num_devices = plugin->init(NULL);
|
||||
for (i = 0; i < num_devices; i++) {
|
||||
num_probes
|
||||
= (int)(unsigned long)plugin->get_device_info(i,
|
||||
DI_NUM_PROBES);
|
||||
device_new(plugin, i, num_probes);
|
||||
}
|
||||
device_plugin_init(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int device_plugin_init(struct device_plugin *plugin)
|
||||
{
|
||||
int num_devices, num_probes, i;
|
||||
|
||||
g_message("initializing %s plugin", plugin->name);
|
||||
num_devices = plugin->init(NULL);
|
||||
for (i = 0; i < num_devices; i++) {
|
||||
num_probes = (int)plugin->get_device_info(i, DI_NUM_PROBES);
|
||||
device_new(plugin, i, num_probes);
|
||||
}
|
||||
|
||||
return num_devices;
|
||||
}
|
||||
|
||||
void device_close_all(void)
|
||||
|
@ -65,6 +72,10 @@ void device_close_all(void)
|
|||
|
||||
GSList *device_list(void)
|
||||
{
|
||||
|
||||
if (!devices)
|
||||
device_scan();
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ void datastore_put(struct datastore *ds, void *data, unsigned int length,
|
|||
/*--- device.c --------------------------------------------------------------*/
|
||||
|
||||
void device_scan(void);
|
||||
int device_plugin_init(struct device_plugin *plugin);
|
||||
void device_close_all(void);
|
||||
GSList *device_list(void);
|
||||
struct device *device_new(struct device_plugin *plugin, int plugin_index,
|
||||
|
|
Loading…
Reference in New Issue