Drop unnecessary struct sr_dev_driver forward declarations

Most drivers have a forward declaration to their sr_dev_driver struct at
the beginning of the driver file. This is due to historic reasons and often
no longer required. So remove all the unnecessary forward declarations.

Some drivers still require the forward declaration, but only reference the
driver struct from within the driver scan() callback. Since the driver
struct is passed to the scan callback replace the references to the global
variable with the local parameter. In some cases this requires adding the
parameter to some of the helper functions that are called from the scan()
callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2016-05-08 14:26:56 +02:00 committed by Uwe Hermann
parent 4d399734b4
commit e32862ebcc
46 changed files with 27 additions and 118 deletions

View File

@ -70,8 +70,6 @@ static const struct agdmm_profile supported_agdmm[] = {
ALL_ZERO
};
SR_PRIV struct sr_dev_driver agdmm_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;

View File

@ -42,8 +42,6 @@ static const char *data_sources[] = {
"Memory",
};
SR_PRIV struct sr_dev_driver appa_55ii_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -56,8 +56,6 @@ static const uint32_t devopts_cg[] = {
SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE | SR_CONF_GET,
};
SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
@ -133,7 +131,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sdi->vendor = g_strdup("Arachnid Labs");
sdi->model = g_strdup("Re:load Pro");
sdi->version = g_strdup(buf + 8);
sdi->driver = &arachnid_labs_re_load_pro_driver_info;
sdi->driver = di;
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;

View File

@ -26,8 +26,6 @@
#include <config.h>
#include "protocol.h"
SR_PRIV struct sr_dev_driver asix_sigma_driver_info;
/*
* Channel numbers seem to go from 1-16, according to this image:
* http://tools.asix.net/img/sigma_sigmacab_pins_720.jpg

View File

@ -75,8 +75,6 @@ static const struct pps_model models[] = {
},
};
SR_PRIV struct sr_dev_driver atten_pps3203_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid)
{
struct sr_dev_inst *sdi;

View File

@ -22,8 +22,6 @@
#include <time.h>
#include <sys/timerfd.h>
SR_PRIV struct sr_dev_driver baylibre_acme_driver_info;
static const uint32_t devopts[] = {
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,

View File

@ -21,8 +21,6 @@
#include "protocol.h"
#include "beaglelogic.h"
SR_PRIV struct sr_dev_driver beaglelogic_driver_info;
/* Scan options */
static const uint32_t scanopts[] = {
SR_CONF_NUM_LOGIC_CHANNELS,

View File

@ -33,8 +33,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
GSList *usb_devices, *devices, *l;

View File

@ -32,10 +32,8 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver brymen_bm857_driver_info;
static struct sr_dev_driver *di = &brymen_bm857_driver_info;
static GSList *brymen_scan(const char *conn, const char *serialcomm)
static GSList *brymen_scan(struct sr_dev_driver *di, const char *conn,
const char *serialcomm)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
@ -118,10 +116,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (serialcomm) {
/* Use the provided comm specs. */
devices = brymen_scan(conn, serialcomm);
devices = brymen_scan(di, conn, serialcomm);
} else {
/* But 9600/8n1 should work all of the time. */
devices = brymen_scan(conn, "9600/8n1/dtr=1/rts=1");
devices = brymen_scan(di, conn, "9600/8n1/dtr=1/rts=1");
}
return devices;

View File

@ -69,8 +69,6 @@ static const char *data_sources[] = {
"Memory",
};
SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -21,9 +21,6 @@
#include <config.h>
#include "protocol.h"
SR_PRIV struct sr_dev_driver chronovu_la_driver_info;
static struct sr_dev_driver *di = &chronovu_la_driver_info;
static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
};
@ -64,9 +61,9 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, clear_helper);
}
static int add_device(int model, struct libusb_device_descriptor *des,
const char *serial_num, const char *connection_id,
libusb_device *usbdev, GSList **devices)
static int add_device(struct sr_dev_driver *di, int model,
struct libusb_device_descriptor *des, const char *serial_num,
const char *connection_id, libusb_device *usbdev, GSList **devices)
{
int ret;
unsigned int i;
@ -228,7 +225,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_get_bus_number(devlist[i]),
libusb_get_device_address(devlist[i]), connection_id);
if ((ret = add_device(model, &des, serial_num, connection_id,
if ((ret = add_device(di, model, &des, serial_num, connection_id,
devlist[i], &devices)) < 0) {
sr_dbg("Failed to add device: %d.", ret);
}

View File

@ -42,8 +42,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver colead_slm_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -39,8 +39,6 @@ static const uint32_t devopts[] = {
SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;

View File

@ -175,8 +175,6 @@ static const uint8_t pattern_sigrok[] = {
0xbe, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
SR_PRIV struct sr_dev_driver demo_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)

View File

@ -37,8 +37,6 @@ static void std_dev_attach(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
#define LOG_PREFIX "deree-de5000"
SR_PRIV struct sr_dev_driver deree_de5000_driver_info;
static int dev_clear(const struct sr_dev_driver *di)
{
return std_dev_clear(di, es51919_serial_clean);

View File

@ -39,8 +39,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver flukedmm_driver_info;
static const char *scan_conn[] = {
/* 287/289 */
"115200/8n1",

View File

@ -24,8 +24,6 @@
#include "libsigrok-internal.h"
#include "protocol.h"
SR_PRIV struct sr_dev_driver ftdi_la_driver_info;
static const uint32_t scanopts[] = {
SR_CONF_CONN,
};

View File

@ -207,8 +207,6 @@ static const uint64_t dslogic_samplerates[] = {
SR_MHZ(400),
};
SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -32,9 +32,6 @@
#define SERIALCOMM_2X "9600/8n1/dtr=1/rts=1/flow=0"
#define VENDOR_GMC "Gossen Metrawatt"
SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info;
SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info;
static const uint32_t scanopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,

View File

@ -74,13 +74,12 @@ static const uint64_t vdivs[][2] = {
VDIV_VALUES
};
SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info;
static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
static struct sr_dev_inst *hantek_6xxx_dev_new(struct sr_dev_driver *di,
const struct hantek_6xxx_profile *prof)
{
struct sr_dev_inst *sdi;
struct sr_channel *ch;
@ -93,7 +92,7 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(prof->vendor);
sdi->model = g_strdup(prof->model);
sdi->driver = &hantek_6xxx_driver_info;
sdi->driver = di;
for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
@ -223,7 +222,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
/* Device matches the pre-firmware profile. */
prof = &dev_profiles[j];
sr_dbg("Found a %s %s.", prof->vendor, prof->model);
sdi = hantek_6xxx_dev_new(prof);
sdi = hantek_6xxx_dev_new(di, prof);
sdi->connection_id = g_strdup(connection_id);
devices = g_slist_append(devices, sdi);
devc = sdi->priv;
@ -242,7 +241,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
/* Device matches the post-firmware profile. */
prof = &dev_profiles[j];
sr_dbg("Found a %s %s.", prof->vendor, prof->model);
sdi = hantek_6xxx_dev_new(prof);
sdi = hantek_6xxx_dev_new(di, prof);
sdi->connection_id = g_strdup(connection_id);
sdi->status = SR_ST_INACTIVE;
devices = g_slist_append(devices, sdi);

View File

@ -160,11 +160,10 @@ static const char *coupling[] = {
"GND",
};
SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
static struct sr_dev_inst *dso_dev_new(struct sr_dev_driver *di,
const struct dso_profile *prof)
{
struct sr_dev_inst *sdi;
struct sr_channel *ch;
@ -177,7 +176,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(prof->vendor);
sdi->model = g_strdup(prof->model);
sdi->driver = &hantek_dso_driver_info;
sdi->driver = di;
/*
* Add only the real channels -- EXT isn't a source of data, only
@ -209,7 +208,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS;
sdi->priv = devc;
drvc = hantek_dso_driver_info.context;
drvc = di->context;
drvc->instances = g_slist_append(drvc->instances, sdi);
return sdi;
@ -314,7 +313,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
/* Device matches the pre-firmware profile. */
prof = &dev_profiles[j];
sr_dbg("Found a %s %s.", prof->vendor, prof->model);
sdi = dso_dev_new(prof);
sdi = dso_dev_new(di, prof);
sdi->connection_id = g_strdup(connection_id);
devices = g_slist_append(devices, sdi);
devc = sdi->priv;
@ -333,7 +332,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
/* Device matches the post-firmware profile. */
prof = &dev_profiles[j];
sr_dbg("Found a %s %s.", prof->vendor, prof->model);
sdi = dso_dev_new(prof);
sdi = dso_dev_new(di, prof);
sdi->connection_id = g_strdup(connection_id);
sdi->status = SR_ST_INACTIVE;
devices = g_slist_append(devices, sdi);

View File

@ -29,8 +29,6 @@
#define NUM_CHANNELS 2
extern struct sr_dev_driver hantek_dso_driver_info;
static int send_begin(const struct sr_dev_inst *sdi)
{
struct sr_usb_dev_inst *usb;
@ -111,7 +109,7 @@ err:
SR_PRIV int dso_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct drv_context *drvc = hantek_dso_driver_info.context;
struct drv_context *drvc = sdi->driver->context;
struct sr_usb_dev_inst *usb;
struct libusb_device_descriptor des;
libusb_device **devlist;

View File

@ -22,8 +22,6 @@
#include <string.h>
#include "protocol.h"
SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info;
static const uint32_t scanopts[] = {
SR_CONF_CONN,
};

View File

@ -52,8 +52,6 @@ static const char *channel_names[] = {
"0", "1", "2", "3",
};
SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
GSList *usb_devices, *devices, *l;
@ -79,7 +77,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
for (l = usb_devices; l; l = l->next) {
usb = l->data;
if ((ret = sl2_get_device_info(*usb, &dev_info)) < 0) {
if ((ret = sl2_get_device_info(di, *usb, &dev_info)) < 0) {
sr_warn("Failed to get device information: %d.", ret);
sr_usb_dev_inst_free(usb);
continue;

View File

@ -20,8 +20,6 @@
#include <config.h>
#include "protocol.h"
extern struct sr_dev_driver ikalogic_scanalogic2_driver_info;
extern uint64_t sl2_samplerates[NUM_SAMPLERATES];
static void stop_acquisition(struct sr_dev_inst *sdi)
@ -627,14 +625,14 @@ SR_PRIV void sl2_calculate_trigger_samples(const struct sr_dev_inst *sdi)
devc->post_trigger_bytes = post_trigger_bytes;
}
SR_PRIV int sl2_get_device_info(struct sr_usb_dev_inst usb,
struct device_info *dev_info)
SR_PRIV int sl2_get_device_info(struct sr_dev_driver *di,
struct sr_usb_dev_inst usb, struct device_info *dev_info)
{
struct drv_context *drvc;
uint8_t buffer[PACKET_LENGTH];
int ret;
drvc = ikalogic_scanalogic2_driver_info.context;
drvc = di->context;
if (!dev_info)
return SR_ERR_ARG;

View File

@ -227,8 +227,8 @@ SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
uint64_t after_trigger_delay);
SR_PRIV void sl2_calculate_trigger_samples(const struct sr_dev_inst *sdi);
SR_PRIV int sl2_get_device_info(struct sr_usb_dev_inst usb,
struct device_info *dev_info);
SR_PRIV int sl2_get_device_info(struct sr_dev_driver *di,
struct sr_usb_dev_inst usb, struct device_info *dev_info);
SR_PRIV int sl2_transfer_in(libusb_device_handle *dev_handle, uint8_t *data);
SR_PRIV int sl2_transfer_out(libusb_device_handle *dev_handle, uint8_t *data);

View File

@ -44,8 +44,6 @@ static const char *channel_names[] = {
/* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */
static const uint64_t samplerates[1] = { SR_MHZ(100) };
SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static void clear_helper(void *priv)

View File

@ -61,8 +61,6 @@ static const char *data_sources[] = {
"Memory",
};
SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info;
static int scan_kecheng(struct sr_dev_driver *di,
struct sr_usb_dev_inst *usb, char **model)
{

View File

@ -20,8 +20,6 @@
#include <config.h>
#include <string.h>
#include "protocol.h"
extern struct sr_dev_driver kecheng_kc_330b_driver_info;
extern const uint64_t kecheng_kc_330b_sample_intervals[][2];
SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)

View File

@ -62,8 +62,6 @@ static const struct korad_kaxxxxp_model models[] = {
ALL_ZERO
};
SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -24,8 +24,6 @@
#include "libsigrok-internal.h"
#include "protocol.h"
SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info;
static const uint32_t scanopts[] = {
SR_CONF_CONN,
};

View File

@ -71,8 +71,6 @@ static const uint64_t samplerates[] = {
SR_MHZ(500),
};
SR_PRIV struct sr_dev_driver lecroy_logicstudio_driver_info;
static struct sr_dev_inst *create_device(struct sr_dev_driver *di,
struct sr_usb_dev_inst *usb, enum sr_dev_inst_status status,
int64_t fw_updated)

View File

@ -50,8 +50,6 @@ static const uint64_t samplerates[] = {
SR_HZ(100),
};
SR_PRIV struct sr_dev_driver link_mso19_driver_info;
/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
static int dev_clear(const struct sr_dev_driver *di)
{

View File

@ -30,8 +30,6 @@
static const char mso_head[] = { 0x40, 0x4c, 0x44, 0x53, 0x7e };
static const char mso_foot[] = { 0x7e };
extern SR_PRIV struct sr_dev_driver link_mso19_driver_info;
SR_PRIV int mso_send_control_message(struct sr_serial_dev_inst *serial,
uint16_t payload[], int n)
{

View File

@ -73,8 +73,6 @@ static const struct hcs_model models[] = {
ALL_ZERO
};
SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
int i, model_id;

View File

@ -28,9 +28,6 @@
#include <math.h>
#include <string.h>
#include "protocol.h"
/* Forward declarations */
SR_PRIV struct sr_dev_driver motech_lps_301_driver_info;
SR_PRIV int lps_read_reply(struct sr_serial_dev_inst *serial, char **buf, int *buflen);
SR_PRIV int lps_send_va(struct sr_serial_dev_inst *serial, const char *fmt, va_list args);
SR_PRIV int lps_cmd_ok(struct sr_serial_dev_inst *serial, const char *fmt, ...);

View File

@ -85,8 +85,6 @@ static const uint64_t samplerates[] = {
#define RESPONSE_DELAY_US (10 * 1000)
SR_PRIV struct sr_dev_driver ols_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_config *src;

View File

@ -75,8 +75,6 @@ static const uint64_t samplerates[] = {
SR_HZ(1),
};
SR_PRIV struct sr_dev_driver p_ols_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;

View File

@ -39,8 +39,6 @@
#define MAX_RENUM_DELAY_MS 3000
#define NUM_SIMUL_TRANSFERS 32
SR_PRIV struct sr_dev_driver saleae_logic16_driver_info;
static const uint32_t scanopts[] = {
SR_CONF_CONN,
};

View File

@ -36,8 +36,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver teleinfo_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -22,8 +22,6 @@
#include "protocol.h"
#define SERIALCOMM "115200/8n1"
SR_PRIV struct sr_dev_driver testo_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static const uint32_t scanopts[] = {

View File

@ -39,8 +39,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -37,8 +37,6 @@ static const char *data_sources[] = {
"Memory",
};
SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;

View File

@ -22,8 +22,6 @@
#include <math.h>
#include "protocol.h"
extern struct sr_dev_driver uni_t_ut32x_driver_info;
static float parse_temperature(unsigned char *buf)
{
float temp;

View File

@ -31,8 +31,6 @@
#define VICTOR_VENDOR "Victor"
#define VICTOR_INTERFACE 0
#define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1)
SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static const uint32_t drvopts[] = {

View File

@ -79,8 +79,6 @@ static const char *channel_names[] = {
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
};
SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info;
/*
* The hardware supports more samplerates than these, but these are the
* options hardcoded into the vendor's Windows GUI.