]> sigrok.org Git - libsigrok.git/blobdiff - hwplugin.c
sr: Random cosmetics, fix/amend Doxygen comments.
[libsigrok.git] / hwplugin.c
index a12501f0e8793de84999454245d0886b3284ba92..368bb82783577385acfa29f736f62296ffb8507b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the sigrok project.
  *
- * Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -68,7 +68,7 @@ extern struct sr_device_plugin alsa_plugin_info;
 #endif
 
 /* TODO: No linked list needed, this can be a simple array. */
-SR_PRIV int load_hwplugins(void)
+SR_PRIV int sr_hw_load_all(void)
 {
 #ifdef HAVE_LA_DEMO
        plugins = g_slist_append(plugins, (gpointer *)&demo_plugin_info);
@@ -101,16 +101,15 @@ SR_PRIV int load_hwplugins(void)
 }
 
 /**
- * Returns the list of loaded hardware plugins.
+ * Return the list of loaded hardware plugins.
  *
  * 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.
  */
-SR_API GSList *sr_list_hwplugins(void)
+SR_API GSList *sr_hw_list(void)
 {
-
        return plugins;
 }
 
@@ -124,7 +123,7 @@ SR_API GSList *sr_list_hwplugins(void)
  *
  * @return The number of devices found and instantiated by the plugin.
  */
-SR_API int sr_init_hwplugin(struct sr_device_plugin *plugin)
+SR_API int sr_hw_init(struct sr_device_plugin *plugin)
 {
        int num_devices, num_probes, i, j;
        int num_initialized_devices = 0;
@@ -154,7 +153,7 @@ SR_API int sr_init_hwplugin(struct sr_device_plugin *plugin)
        return num_initialized_devices;
 }
 
-SR_PRIV void sr_cleanup_hwplugins(void)
+SR_PRIV void sr_hw_cleanup_all(void)
 {
        struct sr_device_plugin *plugin;
        GSList *l;
@@ -166,7 +165,7 @@ SR_PRIV void sr_cleanup_hwplugins(void)
        }
 }
 
-SR_PRIV struct sr_device_instance *sr_device_instance_new(int index, int status,
+SR_PRIV struct sr_device_instance *sr_dev_inst_new(int index, int status,
                const char *vendor, const char *model, const char *version)
 {
        struct sr_device_instance *sdi;
@@ -187,7 +186,7 @@ SR_PRIV struct sr_device_instance *sr_device_instance_new(int index, int status,
        return sdi;
 }
 
-SR_PRIV struct sr_device_instance *sr_get_device_instance(
+SR_PRIV struct sr_device_instance *sr_dev_inst_get(
                GSList *device_instances, int device_index)
 {
        struct sr_device_instance *sdi;
@@ -203,7 +202,7 @@ SR_PRIV struct sr_device_instance *sr_get_device_instance(
        return NULL;
 }
 
-SR_PRIV void sr_device_instance_free(struct sr_device_instance *sdi)
+SR_PRIV void sr_dev_inst_free(struct sr_device_instance *sdi)
 {
        g_free(sdi->priv);
        g_free(sdi->vendor);
@@ -214,7 +213,7 @@ SR_PRIV void sr_device_instance_free(struct sr_device_instance *sdi)
 
 #ifdef HAVE_LIBUSB_1_0
 
-SR_PRIV struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
+SR_PRIV struct sr_usb_device_instance *sr_usb_dev_inst_new(uint8_t bus,
                        uint8_t address, struct libusb_device_handle *hdl)
 {
        struct sr_usb_device_instance *udi;
@@ -231,7 +230,7 @@ SR_PRIV struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
        return udi;
 }
 
-SR_PRIV void sr_usb_device_instance_free(struct sr_usb_device_instance *usb)
+SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_device_instance *usb)
 {
        /* Avoid compiler warnings. */
        (void)usb;
@@ -241,7 +240,7 @@ SR_PRIV void sr_usb_device_instance_free(struct sr_usb_device_instance *usb)
 
 #endif
 
-SR_PRIV struct sr_serial_device_instance *sr_serial_device_instance_new(
+SR_PRIV struct sr_serial_device_instance *sr_serial_dev_inst_new(
                                                const char *port, int fd)
 {
        struct sr_serial_device_instance *serial;
@@ -257,25 +256,25 @@ SR_PRIV struct sr_serial_device_instance *sr_serial_device_instance_new(
        return serial;
 }
 
-SR_PRIV void sr_serial_device_instance_free(
+SR_PRIV void sr_serial_dev_inst_free(
                struct sr_serial_device_instance *serial)
 {
        g_free(serial->port);
 }
 
 /**
- * Find out if a list of hardware plugin capabilities has a specific cap.
+ * Find out if a hardware plugin has a specific capability.
  *
- * @param capabilities A NULL-terminated integer array of capabilities, as
- * returned by a plugin's get_capabilities() function.
+ * @param plugin The hardware plugin in which to search for the capability.
  * @param hwcap The capability to find in the list.
  *
- * @return Returns TRUE if found, FALSE otherwise.
+ * @return TRUE if found, FALSE otherwise.
  */
-SR_API gboolean sr_has_hwcap(int *capabilities, int hwcap)
+SR_API gboolean sr_hw_has_hwcap(struct sr_device_plugin *plugin, int hwcap)
 {
-       int i;
+       int *capabilities, i;
 
+       capabilities = plugin->get_capabilities();
        for (i = 0; capabilities[i]; i++) {
                if (capabilities[i] == hwcap)
                        return TRUE;
@@ -285,14 +284,14 @@ SR_API gboolean sr_has_hwcap(int *capabilities, int hwcap)
 }
 
 /**
- * Find a hardware plugin capability option parameter structure.
+ * Get a hardware plugin capability option.
  *
- * @param hwcap The capability to find
+ * @param hwcap The capability to get.
  *
- * @return Returns a struct with information about the parameter, or NULL
- * if not found.
+ * @return A pointer to a struct with information about the parameter, or NULL
+ *         if the capability was not found.
  */
-SR_API struct sr_hwcap_option *sr_find_hwcap_option(int hwcap)
+SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap)
 {
        int i;