]> sigrok.org Git - libsigrok.git/commitdiff
Put driver pointers into special section
authorLars-Peter Clausen <redacted>
Thu, 12 May 2016 13:13:47 +0000 (15:13 +0200)
committerUwe Hermann <redacted>
Tue, 17 May 2016 23:41:55 +0000 (01:41 +0200)
The sigrok core needs a list of all available drivers. Currently this list
is manually maintained by updating a global list whenever a driver is added
or removed.

Introduce a new special section that contains the list of all drivers. The
SR_REGISTER_DEV_DRIVER() and SR_REGISTER_DEV_DRIVER_LIST() macro is used to
add drivers to this new list. This is done by placing the pointers to the
driver into a special section. Since nothing else is in this section it is
known that it is simply a list of driver pointers and the core can iterate
over it as if it was an array.

The advantage of this approach is that the code necessary to add a driver
to the list is completely contained to the driver source and it is no
longer necessary to maintain a global list. If a driver is built it will
automatically appear in the list, if it is not built in won't. This means
that the list is always correct, whereas the previous approach used ifdefs
in the global driver list file which could get out-of-sync with the actual
condition when the driver was built.

Any sr_dev_driver structs that are no longer used outside the driver module
are marked as static.

Signed-off-by: Lars-Peter Clausen <redacted>
60 files changed:
Makefile.am
src/backend.c
src/drivers.c [deleted file]
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/asix-sigma/api.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-dmm/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/center-3xx/api.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/demo.c
src/hardware/deree-de5000/api.c
src/hardware/driver_list_end.c [new file with mode: 0644]
src/hardware/driver_list_start.c [new file with mode: 0644]
src/hardware/fluke-dmm/api.c
src/hardware/ftdi-la/api.c
src/hardware/fx2lafw/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/gwinstek-gds-800/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hp-3457a/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/kern-scale/api.c
src/hardware/korad-kaxxxxp/api.c
src/hardware/lascar-el-usb/api.c
src/hardware/lecroy-logicstudio/api.c
src/hardware/link-mso19/api.c
src/hardware/manson-hcs-3xxx/api.c
src/hardware/maynuo-m97/api.c
src/hardware/mic-985xx/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/norma-dmm/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c
src/hardware/serial-dmm/api.c
src/hardware/sysclk-lwla/api.c
src/hardware/teleinfo/api.c
src/hardware/testo/api.c
src/hardware/tondaj-sl-814/api.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-ut32x/api.c
src/hardware/victor-dmm/api.c
src/hardware/yokogawa-dlm/api.c
src/hardware/zeroplus-logic-cube/api.c
src/libsigrok-internal.h

index 69080ba325ded5c094f71d71746b54c14afac556..16dd83abbb270cb7d5294576ee0e0c7c4b68b60e 100644 (file)
@@ -54,7 +54,6 @@ libsigrok_la_SOURCES = \
        src/session.c \
        src/session_file.c \
        src/session_driver.c \
-       src/drivers.c \
        src/hwdriver.c \
        src/trigger.c \
        src/soft-trigger.c \
@@ -168,6 +167,10 @@ libsigrok_la_SOURCES += \
        src/scale/kern.c
 
 # Hardware drivers
+
+# This entry must be placed before all drivers
+libsigrok_la_SOURCES += src/hardware/driver_list_start.c
+
 if HW_AGILENT_DMM
 libsigrok_la_SOURCES += \
        src/hardware/agilent-dmm/api.c \
@@ -500,6 +503,9 @@ libsigrok_la_SOURCES += \
        src/hardware/zeroplus-logic-cube/api.c
 endif
 
+# This entry must be placed after all drivers
+libsigrok_la_SOURCES += src/hardware/driver_list_end.c
+
 libsigrok_la_LIBADD = $(SR_EXTRA_LIBS) $(LIBSIGROK_LIBS)
 libsigrok_la_LDFLAGS = -version-info $(SR_LIB_VERSION) -no-undefined
 
index e829912e914d071dcebf3aa148b01f0bc6c52f1b..f58ab7e94ad0a50b24af319604f0606517ac7c21 100644 (file)
@@ -448,6 +448,8 @@ static int sanity_check_all_transform_modules(void)
        return ret;
 }
 
+extern struct sr_dev_driver *sr_driver_list_start;
+
 /**
  * Initialize libsigrok.
  *
@@ -468,7 +470,7 @@ SR_API int sr_init(struct sr_context **ctx)
 {
        int ret = SR_ERR;
        struct sr_context *context;
-       struct sr_dev_driver ***lists, **drivers;
+       struct sr_dev_driver **drivers;
        GArray *array;
 #ifdef _WIN32
        WSADATA wsadata;
@@ -485,9 +487,8 @@ SR_API int sr_init(struct sr_context **ctx)
 
        /* Generate ctx->driver_list at runtime. */
        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);
+       for (drivers = (&sr_driver_list_start) + 1; *drivers; drivers++)
+               g_array_append_val(array, *drivers);
        context->driver_list = (struct sr_dev_driver **)array->data;
        g_array_free(array, FALSE);
 
diff --git a/src/drivers.c b/src/drivers.c
deleted file mode 100644 (file)
index 1f55325..0000000
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * This file is part of the libsigrok project.
- *
- * Copyright (C) 2014 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-#include <libsigrok/libsigrok.h>
-#include "libsigrok-internal.h"
-
-/** @cond PRIVATE */
-#ifdef HAVE_HW_AGILENT_DMM
-extern SR_PRIV struct sr_dev_driver agdmm_driver_info;
-#endif
-#ifdef HAVE_HW_APPA_55II
-extern SR_PRIV struct sr_dev_driver appa_55ii_driver_info;
-#endif
-#ifdef HAVE_HW_ARACHNID_LABS_RE_LOAD_PRO
-extern SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info;
-#endif
-#ifdef HAVE_HW_ASIX_SIGMA
-extern SR_PRIV struct sr_dev_driver asix_sigma_driver_info;
-#endif
-#ifdef HAVE_HW_ATTEN_PPS3XXX
-extern SR_PRIV struct sr_dev_driver atten_pps3203_driver_info;
-#endif
-#ifdef HAVE_HW_BAYLIBRE_ACME
-extern SR_PRIV struct sr_dev_driver baylibre_acme_driver_info;
-#endif
-#ifdef HAVE_HW_BEAGLELOGIC
-extern SR_PRIV struct sr_dev_driver beaglelogic_driver_info;
-#endif
-#ifdef HAVE_HW_BRYMEN_BM86X
-extern SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info;
-#endif
-#ifdef HAVE_HW_BRYMEN_DMM
-extern SR_PRIV struct sr_dev_driver brymen_bm857_driver_info;
-#endif
-#ifdef HAVE_HW_CEM_DT_885X
-extern SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info;
-#endif
-#ifdef HAVE_HW_CENTER_3XX
-extern SR_PRIV struct sr_dev_driver center_309_driver_info;
-extern SR_PRIV struct sr_dev_driver voltcraft_k204_driver_info;
-#endif
-#ifdef HAVE_HW_CHRONOVU_LA
-extern SR_PRIV struct sr_dev_driver chronovu_la_driver_info;
-#endif
-#ifdef HAVE_HW_COLEAD_SLM
-extern SR_PRIV struct sr_dev_driver colead_slm_driver_info;
-#endif
-#ifdef HAVE_HW_CONRAD_DIGI_35_CPU
-extern SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
-#endif
-#ifdef HAVE_HW_DEMO
-extern SR_PRIV struct sr_dev_driver demo_driver_info;
-#endif
-#ifdef HAVE_HW_DEREE_DE5000
-extern SR_PRIV struct sr_dev_driver deree_de5000_driver_info;
-#endif
-#ifdef HAVE_HW_FLUKE_DMM
-extern SR_PRIV struct sr_dev_driver flukedmm_driver_info;
-#endif
-#ifdef HAVE_HW_FTDI_LA
-extern SR_PRIV struct sr_dev_driver ftdi_la_driver_info;
-#endif
-#ifdef HAVE_HW_FX2LAFW
-extern SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
-#endif
-#ifdef HAVE_HW_GMC_MH_1X_2X
-extern SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info;
-extern SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info;
-#endif
-#ifdef HAVE_HW_GWINSTEK_GDS_800
-extern SR_PRIV struct sr_dev_driver gwinstek_gds_800_driver_info;
-#endif
-#ifdef HAVE_HW_HAMEG_HMO
-extern SR_PRIV struct sr_dev_driver hameg_hmo_driver_info;
-#endif
-#ifdef HAVE_HW_HANTEK_6XXX
-extern SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info;
-#endif
-#ifdef HAVE_HW_HANTEK_DSO
-extern SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
-#endif
-#ifdef HAVE_HW_HP_3457A
-extern SR_PRIV struct sr_dev_driver hp_3457a_driver_info;
-#endif
-#ifdef HAVE_HW_HUNG_CHANG_DSO_2100
-extern SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info;
-#endif
-#ifdef HAVE_HW_IKALOGIC_SCANALOGIC2
-extern SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info;
-#endif
-#ifdef HAVE_HW_IKALOGIC_SCANAPLUS
-extern SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
-#endif
-#ifdef HAVE_HW_KECHENG_KC_330B
-extern SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info;
-#endif
-#ifdef HAVE_HW_KERN_SCALE
-extern SR_PRIV struct sr_dev_driver *kern_scale_drivers[];
-#endif
-#ifdef HAVE_HW_KORAD_KAXXXXP
-extern SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info;
-#endif
-#ifdef HAVE_HW_LASCAR_EL_USB
-extern SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info;
-#endif
-#ifdef HAVE_HW_LECROY_LOGICSTUDIO
-extern SR_PRIV struct sr_dev_driver lecroy_logicstudio_driver_info;
-#endif
-#ifdef HAVE_HW_LINK_MSO19
-extern SR_PRIV struct sr_dev_driver link_mso19_driver_info;
-#endif
-#ifdef HAVE_HW_MANSON_HCS_3XXX
-extern SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info;
-#endif
-#ifdef HAVE_HW_MAYNUO_M97
-extern SR_PRIV struct sr_dev_driver maynuo_m97_driver_info;
-#endif
-#ifdef HAVE_HW_MIC_985XX
-extern SR_PRIV struct sr_dev_driver mic_98581_driver_info;
-extern SR_PRIV struct sr_dev_driver mic_98583_driver_info;
-#endif
-#ifdef HAVE_HW_MOTECH_LPS_30X
-extern SR_PRIV struct sr_dev_driver motech_lps_301_driver_info;
-#endif
-#ifdef HAVE_HW_NORMA_DMM
-extern SR_PRIV struct sr_dev_driver norma_dmm_driver_info;
-extern SR_PRIV struct sr_dev_driver siemens_b102x_driver_info;
-#endif
-#ifdef HAVE_HW_OPENBENCH_LOGIC_SNIFFER
-extern SR_PRIV struct sr_dev_driver ols_driver_info;
-#endif
-#ifdef HAVE_HW_PIPISTRELLO_OLS
-extern SR_PRIV struct sr_dev_driver p_ols_driver_info;
-#endif
-#ifdef HAVE_HW_RIGOL_DS
-extern SR_PRIV struct sr_dev_driver rigol_ds_driver_info;
-#endif
-#ifdef HAVE_HW_SALEAE_LOGIC16
-extern SR_PRIV struct sr_dev_driver saleae_logic16_driver_info;
-#endif
-#ifdef HAVE_HW_SCPI_PPS
-extern SR_PRIV struct sr_dev_driver scpi_pps_driver_info;
-#endif
-#ifdef HAVE_HW_SERIAL_DMM
-extern SR_PRIV struct sr_dev_driver *serial_dmm_drivers[];
-#endif
-#ifdef HAVE_HW_SYSCLK_LWLA
-extern SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info;
-#endif
-#ifdef HAVE_HW_TELEINFO
-extern SR_PRIV struct sr_dev_driver teleinfo_driver_info;
-#endif
-#ifdef HAVE_HW_TESTO
-extern SR_PRIV struct sr_dev_driver testo_driver_info;
-#endif
-#ifdef HAVE_HW_TONDAJ_SL_814
-extern SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info;
-#endif
-#ifdef HAVE_HW_UNI_T_DMM
-extern SR_PRIV struct sr_dev_driver *uni_t_dmm_drivers[];
-#endif
-#ifdef HAVE_HW_UNI_T_UT32X
-extern SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info;
-#endif
-#ifdef HAVE_HW_VICTOR_DMM
-extern SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
-#endif
-#ifdef HAVE_HW_YOKOGAWA_DLM
-extern SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info;
-#endif
-#ifdef HAVE_HW_ZEROPLUS_LOGIC_CUBE
-extern SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info;
-#endif
-
-#define DRVS struct sr_dev_driver *[]
-
-SR_PRIV struct sr_dev_driver **drivers_lists[] = {
-#ifdef HAVE_HW_AGILENT_DMM
-       (DRVS) {&agdmm_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_APPA_55II
-       (DRVS) {&appa_55ii_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_ARACHNID_LABS_RE_LOAD_PRO
-       (DRVS) {&arachnid_labs_re_load_pro_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_ASIX_SIGMA
-       (DRVS) {&asix_sigma_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_ATTEN_PPS3XXX
-       (DRVS) {&atten_pps3203_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_BAYLIBRE_ACME
-       (DRVS) {&baylibre_acme_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_BEAGLELOGIC
-       (DRVS) {&beaglelogic_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_BRYMEN_BM86X
-       (DRVS) {&brymen_bm86x_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_BRYMEN_DMM
-       (DRVS) {&brymen_bm857_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_CEM_DT_885X
-       (DRVS) {&cem_dt_885x_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_CENTER_3XX
-       (DRVS) {
-               &center_309_driver_info,
-               &voltcraft_k204_driver_info,
-               NULL
-       },
-#endif
-#ifdef HAVE_HW_CHRONOVU_LA
-       (DRVS) {&chronovu_la_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_COLEAD_SLM
-       (DRVS) {&colead_slm_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_CONRAD_DIGI_35_CPU
-       (DRVS) {&conrad_digi_35_cpu_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_DEMO
-       (DRVS) {&demo_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_DEREE_DE5000
-       (DRVS) {&deree_de5000_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_FLUKE_DMM
-       (DRVS) {&flukedmm_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_FTDI_LA
-       (DRVS) {&ftdi_la_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_FX2LAFW
-       (DRVS) {&fx2lafw_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_GMC_MH_1X_2X
-       (DRVS) {
-               &gmc_mh_1x_2x_rs232_driver_info,
-               &gmc_mh_2x_bd232_driver_info,
-               NULL
-       },
-#endif
-#ifdef HAVE_HW_GWINSTEK_GDS_800
-       (DRVS) {&gwinstek_gds_800_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_HAMEG_HMO
-       (DRVS) {&hameg_hmo_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_HANTEK_6XXX
-       (DRVS) {&hantek_6xxx_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_HANTEK_DSO
-       (DRVS) {&hantek_dso_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_HP_3457A
-       (DRVS) {&hp_3457a_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_HUNG_CHANG_DSO_2100
-       (DRVS) {&hung_chang_dso_2100_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_IKALOGIC_SCANALOGIC2
-       (DRVS) {&ikalogic_scanalogic2_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_IKALOGIC_SCANAPLUS
-       (DRVS) {&ikalogic_scanaplus_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_KECHENG_KC_330B
-       (DRVS) {&kecheng_kc_330b_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_KERN_SCALE
-       kern_scale_drivers,
-#endif
-#ifdef HAVE_HW_KORAD_KAXXXXP
-       (DRVS) {&korad_kaxxxxp_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_LASCAR_EL_USB
-       (DRVS) {&lascar_el_usb_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_LECROY_LOGICSTUDIO
-       (DRVS) {&lecroy_logicstudio_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_LINK_MSO19
-       (DRVS) {&link_mso19_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_MANSON_HCS_3XXX
-       (DRVS) {&manson_hcs_3xxx_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_MAYNUO_M97
-       (DRVS) {&maynuo_m97_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_MIC_985XX
-       (DRVS) {
-               &mic_98581_driver_info,
-               &mic_98583_driver_info,
-               NULL
-       },
-#endif
-#ifdef HAVE_HW_MOTECH_LPS_30X
-       (DRVS) {&motech_lps_301_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_NORMA_DMM
-       (DRVS) {
-               &norma_dmm_driver_info,
-               &siemens_b102x_driver_info,
-               NULL
-       },
-#endif
-#ifdef HAVE_HW_OPENBENCH_LOGIC_SNIFFER
-       (DRVS) {&ols_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_PIPISTRELLO_OLS
-       (DRVS) {&p_ols_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_RIGOL_DS
-       (DRVS) {&rigol_ds_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_SALEAE_LOGIC16
-       (DRVS) {&saleae_logic16_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_SCPI_PPS
-       (DRVS) {&scpi_pps_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_SERIAL_DMM
-       serial_dmm_drivers,
-#endif
-#ifdef HAVE_HW_SYSCLK_LWLA
-       (DRVS) {&sysclk_lwla_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_TELEINFO
-       (DRVS) {&teleinfo_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_TESTO
-       (DRVS) {&testo_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_TONDAJ_SL_814
-       (DRVS) {&tondaj_sl_814_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_UNI_T_DMM
-       uni_t_dmm_drivers,
-#endif
-#ifdef HAVE_HW_UNI_T_UT32X
-       (DRVS) {&uni_t_ut32x_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_VICTOR_DMM
-       (DRVS) {&victor_dmm_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_YOKOGAWA_DLM
-       (DRVS) {&yokogawa_dlm_driver_info, NULL},
-#endif
-#ifdef HAVE_HW_ZEROPLUS_LOGIC_CUBE
-       (DRVS) {&zeroplus_logic_cube_driver_info, NULL},
-#endif
-       NULL,
-};
-/** @endcond */
index bb7c53e48aefa683011b537331937e7c18840207..514a2d276881b8444f8099b2edbbe76285cf7e05 100644 (file)
@@ -229,7 +229,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver agdmm_driver_info = {
+static struct sr_dev_driver agdmm_driver_info = {
        .name = "agilent-dmm",
        .longname = "Agilent U12xx series DMMs",
        .api_version = 1,
@@ -247,3 +247,4 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(agdmm_driver_info);
index 4c297c18226d4fe107dda8fa6674ef35d25801cf..d6c5d6a93bdbfa656a59ae4df5175b9c5a7780cc 100644 (file)
@@ -226,7 +226,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver appa_55ii_driver_info = {
+static struct sr_dev_driver appa_55ii_driver_info = {
        .name = "appa-55ii",
        .longname = "APPA 55II",
        .api_version = 1,
@@ -244,3 +244,4 @@ SR_PRIV struct sr_dev_driver appa_55ii_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(appa_55ii_driver_info);
index 6683e28325e6c9bad95392e3cd09c19a257b3b67..aeacda1046d5a1cd39a5f2ec8f703e7cee8efd35 100644 (file)
@@ -358,7 +358,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info = {
+static struct sr_dev_driver arachnid_labs_re_load_pro_driver_info = {
        .name = "arachnid-labs-re-load-pro",
        .longname = "Arachnid Labs Re:load Pro",
        .api_version = 1,
@@ -375,3 +375,4 @@ SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(arachnid_labs_re_load_pro_driver_info);
index fb0c695219448073aff66cfa8a9f86db1e1b0774..255d3d542e3216081f33000d5530443e6dc659bc 100644 (file)
@@ -403,7 +403,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
+static struct sr_dev_driver asix_sigma_driver_info = {
        .name = "asix-sigma",
        .longname = "ASIX SIGMA/SIGMA2",
        .api_version = 1,
@@ -421,3 +421,4 @@ SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(asix_sigma_driver_info);
index e0e38389652a60b615bdd4f653a34666f7381229..e1ec5f0b2b87683c38afedf1d7307ea7a2589205 100644 (file)
@@ -485,7 +485,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver atten_pps3203_driver_info = {
+static struct sr_dev_driver atten_pps3203_driver_info = {
        .name = "atten-pps3203",
        .longname = "Atten PPS3203T-3S",
        .api_version = 1,
@@ -503,3 +503,4 @@ SR_PRIV struct sr_dev_driver atten_pps3203_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(atten_pps3203_driver_info);
index 6665369161002c3d4bb45c5cf2c9754dda0f72eb..1d83228c8b1baa9654a9210198c71ec53478f443 100644 (file)
@@ -386,7 +386,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver baylibre_acme_driver_info = {
+static struct sr_dev_driver baylibre_acme_driver_info = {
        .name = "baylibre-acme",
        .longname = "BayLibre ACME (Another Cute Measurement Equipment)",
        .api_version = 1,
@@ -403,3 +403,4 @@ SR_PRIV struct sr_dev_driver baylibre_acme_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(baylibre_acme_driver_info);
index e862d99ea90ea84af2a36ff032f9a642d3249466..6deafb8102f93234eb12e342a4b1870f9a2d1b0d 100644 (file)
@@ -356,7 +356,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver beaglelogic_driver_info = {
+static struct sr_dev_driver beaglelogic_driver_info = {
        .name = "beaglelogic",
        .longname = "BeagleLogic",
        .api_version = 1,
@@ -373,3 +373,4 @@ SR_PRIV struct sr_dev_driver beaglelogic_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(beaglelogic_driver_info);
index 9d1600e713f6bf011d70572a86a2e25ff4b7437b..eb41b845fdfc3f6d8bbf60679548169986b1ce03 100644 (file)
@@ -240,7 +240,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info = {
+static struct sr_dev_driver brymen_bm86x_driver_info = {
        .name = "brymen-bm86x",
        .longname = "Brymen BM86X",
        .api_version = 1,
@@ -258,3 +258,4 @@ SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(brymen_bm86x_driver_info);
index b38ba37585a335054f829a9365fc69107e920be6..595ea99b7e7298942a16bbec81d92f5a440eb232 100644 (file)
@@ -189,7 +189,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = {
+static struct sr_dev_driver brymen_bm857_driver_info = {
        .name = "brymen-bm857",
        .longname = "Brymen BM857",
        .api_version = 1,
@@ -207,3 +207,4 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(brymen_bm857_driver_info);
index 6134ba6dc5b4e323b25b91313b8d3e80f0ad7cb7..af3626b24dc0f09d4c8ce51aeaadb0551a4c06e0 100644 (file)
@@ -377,7 +377,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info = {
+static struct sr_dev_driver cem_dt_885x_driver_info = {
        .name = "cem-dt-885x",
        .longname = "CEM DT-885x",
        .api_version = 1,
@@ -395,3 +395,4 @@ SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(cem_dt_885x_driver_info);
index 40e8dbd66efc40f0402360edbf529bb662bc01a0..27c8d7e65e11e8963e9b61c1a086ce75730cca19 100644 (file)
@@ -40,8 +40,8 @@ static const char *channel_names[] = {
        "T1", "T2", "T3", "T4",
 };
 
-SR_PRIV struct sr_dev_driver center_309_driver_info;
-SR_PRIV struct sr_dev_driver voltcraft_k204_driver_info;
+static struct sr_dev_driver center_309_driver_info;
+static struct sr_dev_driver voltcraft_k204_driver_info;
 
 SR_PRIV const struct center_dev_info center_devs[] = {
        {
@@ -209,7 +209,7 @@ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
 #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
 HW_SCAN(ID_UPPER) \
 HW_DEV_ACQUISITION_START(ID_UPPER) \
-SR_PRIV struct sr_dev_driver ID##_driver_info = { \
+static struct sr_dev_driver ID##_driver_info = { \
        .name = NAME, \
        .longname = LONGNAME, \
        .api_version = 1, \
@@ -225,7 +225,8 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
        .dev_acquisition_stop = dev_acquisition_stop, \
        .context = NULL, \
-};
+}; \
+SR_REGISTER_DEV_DRIVER(ID##_driver_info);
 
 DRV(center_309, CENTER_309, "center-309", "Center 309")
 DRV(voltcraft_k204, VOLTCRAFT_K204, "voltcraft-k204", "Voltcraft K204")
index 329b45bd305148165a68e6b1a647a9002a9c56e8..5c58e4f96b1e3027f8860fd50aa39ca8e3ccb764 100644 (file)
@@ -566,7 +566,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver chronovu_la_driver_info = {
+static struct sr_dev_driver chronovu_la_driver_info = {
        .name = "chronovu-la",
        .longname = "ChronoVu LA8/LA16",
        .api_version = 1,
@@ -584,3 +584,4 @@ SR_PRIV struct sr_dev_driver chronovu_la_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(chronovu_la_driver_info);
index f83ca1c94aa253ca885a27c76f19fdb8bc9ef52d..bbb6a957e3f66b48bc7dafb78229cc5b26c8dcae 100644 (file)
@@ -152,7 +152,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
+static struct sr_dev_driver colead_slm_driver_info = {
        .name = "colead-slm",
        .longname = "Colead SLM",
        .api_version = 1,
@@ -170,3 +170,4 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(colead_slm_driver_info);
index 20382feba9d4c6ed7ce8cec6168a9853b139b67d..63c0e4f18703f2614b31740ce5fbeec3cd657a1c 100644 (file)
@@ -181,7 +181,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
+static struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
        .name = "conrad-digi-35-cpu",
        .longname = "Conrad DIGI 35 CPU",
        .api_version = 1,
@@ -199,3 +199,4 @@ SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(conrad_digi_35_cpu_driver_info);
index cf520ca4b6a59cef15144590bc7e682469cc179c..9fa744b1f4e965b448b5509ba277d068adedbc75 100644 (file)
@@ -876,7 +876,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver demo_driver_info = {
+static struct sr_dev_driver demo_driver_info = {
        .name = "demo",
        .longname = "Demo driver and pattern generator",
        .api_version = 1,
@@ -894,3 +894,4 @@ SR_PRIV struct sr_dev_driver demo_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(demo_driver_info);
index bbdb7b70a14048583ffd2cf31055d08dd6314e2d..675b332e63782b708f8c8ef6cc80f276be8adf7f 100644 (file)
@@ -54,7 +54,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return g_slist_append(NULL, sdi);
 }
 
-SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
+static struct sr_dev_driver deree_de5000_driver_info = {
        .name = "deree-de5000",
        .longname = "DER EE DE-5000",
        .api_version = 1,
@@ -72,3 +72,4 @@ SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
        .dev_acquisition_stop = es51919_serial_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(deree_de5000_driver_info);
diff --git a/src/hardware/driver_list_end.c b/src/hardware/driver_list_end.c
new file mode 100644 (file)
index 0000000..31d9716
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2016 Lars-Peter Clausen <lars@metafoo.de>
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libsigrok/libsigrok.h>
+#include "libsigrok-internal.h"
+
+/* End of the driver list */
+static struct sr_dev_driver *sr_driver_list_end
+               __attribute__((section (SR_DRIVER_LIST_SECTION), used,
+                       aligned(sizeof(struct sr_dev_driver *)))) = NULL;
diff --git a/src/hardware/driver_list_start.c b/src/hardware/driver_list_start.c
new file mode 100644 (file)
index 0000000..6cdae6b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2016 Lars-Peter Clausen <lars@metafoo.de>
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libsigrok/libsigrok.h>
+#include "libsigrok-internal.h"
+
+/* Beginning of the driver list */
+const struct sr_dev_driver *sr_driver_list_start
+               __attribute__((section (SR_DRIVER_LIST_SECTION), used,
+                       aligned(sizeof(struct sr_dev_driver *)))) = NULL;
index f0472411108ce4bedd651908dd55af2621000137..de4efcd55458c15b1d29f907332dc4159b85ca50 100644 (file)
@@ -264,7 +264,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
+static struct sr_dev_driver flukedmm_driver_info = {
        .name = "fluke-dmm",
        .longname = "Fluke 18x/28x series DMMs",
        .api_version = 1,
@@ -282,3 +282,4 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(flukedmm_driver_info);
index ad58c501056b7c390bad3fe07c84ca9792ad3129..34f79bf71b71d0066621a422f3cfa45b27a756b5 100644 (file)
@@ -480,7 +480,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver ftdi_la_driver_info = {
+static struct sr_dev_driver ftdi_la_driver_info = {
        .name = "ftdi-la",
        .longname = "FTDI LA",
        .api_version = 1,
@@ -498,3 +498,4 @@ SR_PRIV struct sr_dev_driver ftdi_la_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(ftdi_la_driver_info);
index 74293597bab1af9e316dfb37f0e8f25a641939ca..262f3cd662ce2a3d6c32f52ac445780bc2ffdaf7 100644 (file)
@@ -1037,7 +1037,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
+static struct sr_dev_driver fx2lafw_driver_info = {
        .name = "fx2lafw",
        .longname = "fx2lafw (generic driver for FX2 based LAs)",
        .api_version = 1,
@@ -1055,3 +1055,4 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(fx2lafw_driver_info);
index 049907ae61f100032aff4fbea2ce95ace49e5445..629a3f2b16c9916fc9d2df3fc24fa41c823367bf 100644 (file)
@@ -508,7 +508,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = {
+static struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = {
        .name = "gmc-mh-1x-2x-rs232",
        .longname = "Gossen Metrawatt Metrahit 1x/2x, RS232 interface",
        .api_version = 1,
@@ -526,8 +526,9 @@ SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(gmc_mh_1x_2x_rs232_driver_info);
 
-SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
+static struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
        .name = "gmc-mh-2x-bd232",
        .longname = "Gossen Metrawatt Metrahit 2x, BD232/SI232-II interface",
        .api_version = 1,
@@ -545,3 +546,4 @@ SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(gmc_mh_2x_bd232_driver_info);
index 45e861521d0f2bbe68c0567afabece855a87ce4e..656b61e331aa7981cf7f2b9caaaf0db39cf75325 100644 (file)
@@ -31,7 +31,7 @@ static const uint32_t devopts[] = {
        SR_CONF_SAMPLERATE | SR_CONF_GET,
 };
 
-SR_PRIV struct sr_dev_driver gwinstek_gds_800_driver_info;
+static struct sr_dev_driver gwinstek_gds_800_driver_info;
 
 static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
 {
@@ -239,7 +239,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver gwinstek_gds_800_driver_info = {
+static struct sr_dev_driver gwinstek_gds_800_driver_info = {
        .name = "gwinstek-gds-800",
        .longname = "GW Instek GDS-800 series",
        .api_version = 1,
@@ -256,3 +256,4 @@ SR_PRIV struct sr_dev_driver gwinstek_gds_800_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(gwinstek_gds_800_driver_info);
index 29dbe917968daad9189dbc60da5ae176903313a8..4ed9527e5a154a071d023a79505a859a0c572a91 100644 (file)
@@ -24,7 +24,7 @@
 
 #define SERIALCOMM "115200/8n1/flow=1"
 
-SR_PRIV struct sr_dev_driver hameg_hmo_driver_info;
+static struct sr_dev_driver hameg_hmo_driver_info;
 
 static const char *manufacturers[] = {
        "HAMEG",
@@ -773,7 +773,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = {
+static struct sr_dev_driver hameg_hmo_driver_info = {
        .name = "hameg-hmo",
        .longname = "Hameg HMO",
        .api_version = 1,
@@ -791,3 +791,4 @@ SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hameg_hmo_driver_info);
index 1227e7b9e24cb11dde2ca161ef0a4e5632f28993..65b5f04be96c2a44089526f37d21c462a1438d05 100644 (file)
@@ -803,7 +803,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = {
+static struct sr_dev_driver hantek_6xxx_driver_info = {
        .name = "hantek-6xxx",
        .longname = "Hantek 6xxx",
        .api_version = 1,
@@ -821,3 +821,4 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hantek_6xxx_driver_info);
index f8fdc1a4758cfbef83deeecf28771e352e19cde7..275bbf99d5f7775bf72ecbf1b5990764e9e29208 100644 (file)
@@ -994,7 +994,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
+static struct sr_dev_driver hantek_dso_driver_info = {
        .name = "hantek-dso",
        .longname = "Hantek DSO",
        .api_version = 1,
@@ -1012,3 +1012,4 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hantek_dso_driver_info);
index f9ea375932d43237429ad6f6c364b386e9446cae..16b44a77a4a4ce44515d7456cb5b0fbd867c80fe 100644 (file)
@@ -37,7 +37,7 @@ static const uint32_t devopts[] = {
        SR_CONF_ADC_POWERLINE_CYCLES | SR_CONF_SET | SR_CONF_GET,
 };
 
-SR_PRIV struct sr_dev_driver hp_3457a_driver_info;
+static struct sr_dev_driver hp_3457a_driver_info;
 
 static int create_front_channel(struct sr_dev_inst *sdi, int chan_idx)
 {
@@ -437,7 +437,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver hp_3457a_driver_info = {
+static struct sr_dev_driver hp_3457a_driver_info = {
        .name = "hp-3457a",
        .longname = "HP 3457A",
        .api_version = 1,
@@ -454,3 +454,4 @@ SR_PRIV struct sr_dev_driver hp_3457a_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hp_3457a_driver_info);
index dc575e4f363e9f1c0ee2a83238738d3ed6bfa25f..039ba3856d8d6a6af1b5726f90a4a99801b7df33 100644 (file)
@@ -712,7 +712,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return hung_chang_dso_2100_dev_acquisition_stop(sdi);
 }
 
-SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
+static struct sr_dev_driver hung_chang_dso_2100_driver_info = {
        .name = "hung-chang-dso-2100",
        .longname = "Hung-Chang DSO-2100",
        .api_version = 1,
@@ -732,3 +732,4 @@ SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hung_chang_dso_2100_driver_info);
index ad98cc9868eb24371454b45b3ce29def7d9c87f7..c30c605c88444a71da4bbad89083c4fe9092419f 100644 (file)
@@ -456,7 +456,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
+static struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
        .name = "ikalogic-scanalogic2",
        .longname = "IKALOGIC Scanalogic-2",
        .api_version = 1,
@@ -474,3 +474,4 @@ SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(ikalogic_scanalogic2_driver_info);
index 045476243e8ce7c1f5fa2baf901e84085f7cbc8c..9b4af07de364754aa143bc8165f583814833cc93 100644 (file)
@@ -376,7 +376,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info = {
+static struct sr_dev_driver ikalogic_scanaplus_driver_info = {
        .name = "ikalogic-scanaplus",
        .longname = "IKALOGIC ScanaPLUS",
        .api_version = 1,
@@ -394,3 +394,4 @@ SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(ikalogic_scanaplus_driver_info);
index 1cc84240fd8e9f4b768579dd36041f63885eb4a6..f67d253238dc1e3dfe88f73085585d6a6d9b55ea 100644 (file)
@@ -501,7 +501,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info = {
+static struct sr_dev_driver kecheng_kc_330b_driver_info = {
        .name = "kecheng-kc-330b",
        .longname = "Kecheng KC-330B",
        .api_version = 1,
@@ -519,3 +519,4 @@ SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(kecheng_kc_330b_driver_info);
index 6ec40a626642bd0338b9225fd658756a41483b3b..4d1d6bbcbb8f825746709f5b4aacd1707087d4ae 100644 (file)
@@ -186,7 +186,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
 #define SCALE(ID, CHIPSET, VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, \
                        VALID, PARSE) \
-       &(struct scale_info) { \
+       &((struct scale_info) { \
                { \
                        .name = ID, \
                        .longname = VENDOR " " MODEL, \
@@ -206,7 +206,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                }, \
                VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, \
                VALID, PARSE, sizeof(struct CHIPSET##_info) \
-       }
+       }).di
 
 /*
  * Some scales have (user-configurable) 14-byte or 15-byte packets.
@@ -218,11 +218,10 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
  * the user override them via "serialcomm".
  */
 
-SR_PRIV const struct scale_info *kern_scale_drivers[] = {
+SR_REGISTER_DEV_DRIVER_LIST(kern_scale_drivers,
        SCALE(
                "kern-ew-6200-2nm", kern,
                "KERN", "EW 6200-2NM", "1200/8n2", 1200,
                15 /* (or 14) */, sr_kern_packet_valid, sr_kern_parse
-       ),
-       NULL
-};
+       )
+);
index 8316690fc9c5f6068b6df46c140c437aea21fc16..02abc7ca4b3c960d729cf304f6d05d5cb801e2be 100644 (file)
@@ -378,7 +378,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info = {
+static struct sr_dev_driver korad_kaxxxxp_driver_info = {
        .name = "korad-kaxxxxp",
        .longname = "Korad KAxxxxP",
        .api_version = 1,
@@ -395,3 +395,4 @@ SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(korad_kaxxxxp_driver_info);
index ad2d18b8db5572a4212b636fe3c28768316e05ce..1fd86b7ea00052975b12d3780283cff3b7fd3929 100644 (file)
@@ -427,3 +427,4 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(lascar_el_usb_driver_info);
index ae73738a6f0b3d7cdca1cffb7d0b230a05cd2974..20ffcf2f8735c1b664ca9577ede3269ad0aabe7b 100644 (file)
@@ -498,7 +498,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return lls_stop_acquisition(sdi);
 }
 
-SR_PRIV struct sr_dev_driver lecroy_logicstudio_driver_info = {
+static struct sr_dev_driver lecroy_logicstudio_driver_info = {
        .name = "lecroy-logicstudio",
        .longname = "LeCroy LogicStudio",
        .api_version = 1,
@@ -516,3 +516,4 @@ SR_PRIV struct sr_dev_driver lecroy_logicstudio_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(lecroy_logicstudio_driver_info);
index f2b372eb303c89c2bf1a9b00611cac194444acaa..d95aaff6f29e76d0f2f831f9dae5da3d841ab04a 100644 (file)
@@ -447,7 +447,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
+static struct sr_dev_driver link_mso19_driver_info = {
        .name = "link-mso19",
        .longname = "Link Instruments MSO-19",
        .api_version = 1,
@@ -465,3 +465,4 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(link_mso19_driver_info);
index feeef963a93b06fe2bd5649108d8f3ed23c78585..52695b0bfdb95b4511639e2e4d43ca4f74711ea5 100644 (file)
@@ -385,7 +385,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = {
+static struct sr_dev_driver manson_hcs_3xxx_driver_info = {
        .name = "manson-hcs-3xxx",
        .longname = "Manson HCS-3xxx",
        .api_version = 1,
@@ -402,3 +402,4 @@ SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(manson_hcs_3xxx_driver_info);
index 7bf960d66ac11e244206f68056b4b2c8ed03003f..84e90b5e7bcd7e7d0e4fa4d06a18bae52e7c649a 100644 (file)
@@ -109,7 +109,7 @@ static const struct maynuo_m97_model supported_models[] = {
 //     { 102, "M9812B"    ,   15, 500,    300 },
 };
 
-SR_PRIV struct sr_dev_driver maynuo_m97_driver_info;
+static struct sr_dev_driver maynuo_m97_driver_info;
 
 static struct sr_dev_inst *probe_device(struct sr_modbus_dev_inst *modbus)
 {
@@ -465,7 +465,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver maynuo_m97_driver_info = {
+static struct sr_dev_driver maynuo_m97_driver_info = {
        .name = "maynuo-m97",
        .longname = "maynuo M97/M98 series",
        .api_version = 1,
@@ -482,3 +482,4 @@ SR_PRIV struct sr_dev_driver maynuo_m97_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(maynuo_m97_driver_info);
index 0e957febe3427019ada3d056f965fbc08316cad6..329a14b6da8335109fdc89291169d44587512aef 100644 (file)
@@ -41,8 +41,8 @@ static const uint32_t devopts[] = {
        SR_CONF_LIMIT_MSEC | SR_CONF_SET,
 };
 
-SR_PRIV struct sr_dev_driver mic_98581_driver_info;
-SR_PRIV struct sr_dev_driver mic_98583_driver_info;
+static struct sr_dev_driver mic_98581_driver_info;
+static struct sr_dev_driver mic_98583_driver_info;
 
 SR_PRIV const struct mic_dev_info mic_devs[] = {
        {
@@ -226,7 +226,7 @@ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
 HW_SCAN(ID_UPPER) \
 HW_CONFIG_LIST(ID_UPPER) \
 HW_DEV_ACQUISITION_START(ID_UPPER) \
-SR_PRIV struct sr_dev_driver ID##_driver_info = { \
+static struct sr_dev_driver ID##_driver_info = { \
        .name = NAME, \
        .longname = LONGNAME, \
        .api_version = 1, \
@@ -242,7 +242,8 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
        .dev_acquisition_stop = dev_acquisition_stop, \
        .context = NULL, \
-};
+}; \
+SR_REGISTER_DEV_DRIVER(ID##_driver_info)
 
 DRV(mic_98581, MIC_98581, "mic-98581", "MIC 98581")
 DRV(mic_98583, MIC_98583, "mic-98583", "MIC 98583")
index 7194f313af2c4396c3ef208bb1b132bebfab14a2..1c5e3876382464d03cf4ed2c774cca009c338ecd 100644 (file)
@@ -798,7 +798,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver motech_lps_301_driver_info = {
+static struct sr_dev_driver motech_lps_301_driver_info = {
        .name = "motech-lps-301",
        .longname = "Motech LPS-301",
        .api_version = 1,
@@ -816,3 +816,4 @@ SR_PRIV struct sr_dev_driver motech_lps_301_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(motech_lps_301_driver_info);
index 780111432fda09a4125e0d7a146af619823a007c..ee1c59ca30eb341cf2872204e92921e82c1795ce 100644 (file)
@@ -41,8 +41,8 @@ static const uint32_t devopts[] = {
 
 #define SERIALCOMM "4800/8n1/dtr=1/rts=0/flow=1"
 
-SR_PRIV struct sr_dev_driver norma_dmm_driver_info;
-SR_PRIV struct sr_dev_driver siemens_b102x_driver_info;
+static struct sr_dev_driver norma_dmm_driver_info;
+static struct sr_dev_driver siemens_b102x_driver_info;
 
 static const char *get_brandstr(struct sr_dev_driver *drv)
 {
@@ -246,7 +246,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver norma_dmm_driver_info = {
+static struct sr_dev_driver norma_dmm_driver_info = {
        .name = "norma-dmm",
        .longname = "Norma DM9x0 DMMs",
        .api_version = 1,
@@ -264,8 +264,9 @@ SR_PRIV struct sr_dev_driver norma_dmm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(norma_dmm_driver_info);
 
-SR_PRIV struct sr_dev_driver siemens_b102x_driver_info = {
+static struct sr_dev_driver siemens_b102x_driver_info = {
        .name = "siemens-b102x",
        .longname = "Siemens B102x DMMs",
        .api_version = 1,
@@ -283,3 +284,4 @@ SR_PRIV struct sr_dev_driver siemens_b102x_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(siemens_b102x_driver_info);
index d8f7cc4d47041a13aadc9d7f5117c7e569c01167..56161c5bcd7d5bbfda08e84e6ab0362881d4d426 100644 (file)
@@ -588,3 +588,4 @@ SR_PRIV struct sr_dev_driver ols_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(ols_driver_info);
index dd8155867d78639ba48d5eaf6016d60efc7b1ba2..eb81c781b5388116da19ab23207873a994871f5a 100644 (file)
@@ -718,3 +718,4 @@ SR_PRIV struct sr_dev_driver p_ols_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(p_ols_driver_info);
index e743608381952bc46825564cca42650bac46b028..6668d9cd63113e6faeace2983eecfa0cdeef02f3 100644 (file)
@@ -249,7 +249,7 @@ static const struct rigol_ds_model supported_models[] = {
        {SERIES(DS1000Z), "MSO1104Z-S", {5, 1000000000}, 4, true},
 };
 
-SR_PRIV struct sr_dev_driver rigol_ds_driver_info;
+static struct sr_dev_driver rigol_ds_driver_info;
 
 static void clear_helper(void *priv)
 {
@@ -1054,7 +1054,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver rigol_ds_driver_info = {
+static struct sr_dev_driver rigol_ds_driver_info = {
        .name = "rigol-ds",
        .longname = "Rigol DS",
        .api_version = 1,
@@ -1072,3 +1072,4 @@ SR_PRIV struct sr_dev_driver rigol_ds_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(rigol_ds_driver_info);
index 4c120b1ce3b037d790917bbf14bb9ce905ff4f75..95c9f9e72806ccbd097d9cd88eeecb72db54a595 100644 (file)
@@ -785,7 +785,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return ret;
 }
 
-SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = {
+static struct sr_dev_driver saleae_logic16_driver_info = {
        .name = "saleae-logic16",
        .longname = "Saleae Logic16",
        .api_version = 1,
@@ -803,3 +803,4 @@ SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(saleae_logic16_driver_info);
index 785deabb798525a06a3ff2b275900ac297cd2913..c3e5d5d4ad6a90607fcea56a9304ed94889cedba 100644 (file)
@@ -23,7 +23,7 @@
 #include "scpi.h"
 #include "protocol.h"
 
-SR_PRIV struct sr_dev_driver scpi_pps_driver_info;
+static struct sr_dev_driver scpi_pps_driver_info;
 
 static const uint32_t scanopts[] = {
        SR_CONF_CONN,
@@ -622,7 +622,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver scpi_pps_driver_info = {
+static struct sr_dev_driver scpi_pps_driver_info = {
        .name = "scpi-pps",
        .longname = "SCPI PPS",
        .api_version = 1,
@@ -640,3 +640,4 @@ SR_PRIV struct sr_dev_driver scpi_pps_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(scpi_pps_driver_info);
index a272cca29b8495e7dfc2af7b4ca3c4691faccda0..3ccce70c1bbe514df930dd1327d9ad1c734195eb 100644 (file)
@@ -207,7 +207,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
 #define DMM(ID, CHIPSET, VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, \
                        DELAY, REQUEST, VALID, PARSE, DETAILS) \
-       &(struct dmm_info) { \
+       &((struct dmm_info) { \
                { \
                        .name = ID, \
                        .longname = VENDOR " " MODEL, \
@@ -227,9 +227,9 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                }, \
                VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, DELAY, \
                REQUEST, VALID, PARSE, DETAILS, sizeof(struct CHIPSET##_info) \
-       }
+       }).di
 
-SR_PRIV const struct dmm_info *serial_dmm_drivers[] = {
+SR_REGISTER_DEV_DRIVER_LIST(serial_dmm_drivers,
        DMM(
                "bbcgm-2010", metex14,
                "BBC Goertz Metrawatt", "M2110", "1200/7n2", 1200,
@@ -564,5 +564,4 @@ SR_PRIV const struct dmm_info *serial_dmm_drivers[] = {
                2400, DTM0660_PACKET_SIZE, 0, 0, NULL,
                sr_dtm0660_packet_valid, sr_dtm0660_parse, NULL
        ),
-       NULL
-};
+);
index 99c73282bc8dfd16c544c9608274a5fdbfc8bf55..c66cbeb06a6ab71a15fd45b935732dc4815277e6 100644 (file)
@@ -774,7 +774,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
 /* SysClk LWLA driver descriptor.
  */
-SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info = {
+static struct sr_dev_driver sysclk_lwla_driver_info = {
        .name = "sysclk-lwla",
        .longname = "SysClk LWLA series",
        .api_version = 1,
@@ -794,3 +794,4 @@ SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(sysclk_lwla_driver_info);
index c9ea8c7d2dd4b3880a60ac72c71d65bd099bf31d..f05db75a5cfaba23715d38ac173c33dc502b6f70 100644 (file)
@@ -190,7 +190,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
+static struct sr_dev_driver teleinfo_driver_info = {
        .name = "teleinfo",
        .longname = "Teleinfo",
        .api_version = 1,
@@ -208,3 +208,4 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(teleinfo_driver_info);
index a2eae04d805b222e593ef2ad818cad7052bf8534..8e60f6b892fb72e03d4974e31a7a5819767ebe88 100644 (file)
@@ -422,7 +422,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver testo_driver_info = {
+static struct sr_dev_driver testo_driver_info = {
        .name = "testo",
        .longname = "Testo",
        .api_version = 1,
@@ -439,3 +439,4 @@ SR_PRIV struct sr_dev_driver testo_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(testo_driver_info);
index 4caae64202929578adea7a4aa066b2a08e9d5981..f647b6a9f26243cb92481c497ee93eff0c1ec271 100644 (file)
@@ -164,7 +164,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {
+static struct sr_dev_driver tondaj_sl_814_driver_info = {
        .name = "tondaj-sl-814",
        .longname = "Tondaj SL-814",
        .api_version = 1,
@@ -182,3 +182,4 @@ SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(tondaj_sl_814_driver_info);
index 8f1d83cdcee5c68a27ce1d5a3198766f69cbc2c5..c708d879d0beb8ed45b10f32163326ac517bc3e8 100644 (file)
@@ -185,7 +185,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
 #define DMM(ID, CHIPSET, VENDOR, MODEL, BAUDRATE, PACKETSIZE, \
                        VALID, PARSE, DETAILS) \
-    &(struct dmm_info) { \
+    &((struct dmm_info) { \
                { \
                        .name = ID, \
                        .longname = VENDOR " " MODEL, \
@@ -205,9 +205,9 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                }, \
                VENDOR, MODEL, BAUDRATE, PACKETSIZE, \
                VALID, PARSE, DETAILS, sizeof(struct CHIPSET##_info) \
-       }
+       }).di
 
-SR_PRIV const struct dmm_info *uni_t_dmm_drivers[] = {
+SR_REGISTER_DEV_DRIVER_LIST(uni_t_dmm_drivers,
        DMM(
                "tecpel-dmm-8061", fs9721,
                "Tecpel", "DMM-8061", 2400,
@@ -377,5 +377,4 @@ SR_PRIV const struct dmm_info *uni_t_dmm_drivers[] = {
                sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse,
                NULL
        ),
-       NULL
-};
+);
index aed53aad337b01de5030cc2bb1d0f01247fc90c9..789b72def626ca97bbbad01ae6965b3480d25093 100644 (file)
@@ -300,7 +300,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info = {
+static struct sr_dev_driver uni_t_ut32x_driver_info = {
        .name = "uni-t-ut32x",
        .longname = "UNI-T UT32x",
        .api_version = 1,
@@ -318,3 +318,4 @@ SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(uni_t_ut32x_driver_info);
index a53d8c51a5378bdca2cd44f2dd4cb09c9194e480..6a70b14537a1659cd895e3a64c3bc3c08c1186c5 100644 (file)
@@ -335,7 +335,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver victor_dmm_driver_info = {
+static struct sr_dev_driver victor_dmm_driver_info = {
        .name = "victor-dmm",
        .longname = "Victor DMMs",
        .api_version = 1,
@@ -353,3 +353,4 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(victor_dmm_driver_info);
index 1d69a7925d8f8d2ecf2c9163f5825e191fb89a16..103bb03054cca6ceeb46bc18061c7f2d26d743e1 100644 (file)
@@ -23,7 +23,7 @@
 #include "scpi.h"
 #include "protocol.h"
 
-SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info;
+static struct sr_dev_driver yokogawa_dlm_driver_info;
 
 static const char *MANUFACTURER_ID = "YOKOGAWA";
 static const char *MANUFACTURER_NAME = "Yokogawa";
@@ -676,7 +676,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = {
+static struct sr_dev_driver yokogawa_dlm_driver_info = {
        .name = "yokogawa-dlm",
        .longname = "Yokogawa DL/DLM",
        .api_version = 1,
@@ -695,3 +695,4 @@ SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(yokogawa_dlm_driver_info);
index dd001495828f3147ae5ca08f6ae8934b70a272ba..2cbb5f614357f83c290ae26a55ce1996ce8bbfb7 100644 (file)
@@ -655,7 +655,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
+static struct sr_dev_driver zeroplus_logic_cube_driver_info = {
        .name = "zeroplus-logic-cube",
        .longname = "ZEROPLUS Logic Cube LAP-C series",
        .api_version = 1,
@@ -673,3 +673,4 @@ SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(zeroplus_logic_cube_driver_info);
index 588d09080e52db997485f0a6834164efbf9c4bfd..68f0a296c1cc208c2571ca38352b6530b1ba82ad 100644 (file)
@@ -267,6 +267,71 @@ struct zip_stat;
 #define ALL_ZERO { 0 }
 #endif
 
+#ifdef __APPLE__
+#define SR_DRIVER_LIST_SECTION "__DATA,__sr_driver_list"
+#else
+#define SR_DRIVER_LIST_SECTION "sr_driver_list"
+#endif
+
+/**
+ * Register a list of hardware drivers.
+ *
+ * This macro can be used to register multiple hardware drivers to the library.
+ * This is useful when a driver supports multiple similar but slightly
+ * different devices that require different sr_dev_driver struct definitions.
+ *
+ * For registering only a single driver see SR_REGISTER_DEV_DRIVER().
+ *
+ * Example:
+ * @code{c}
+ * #define MY_DRIVER(_name) \
+ *     &(struct sr_dev_driver){ \
+ *         .name = _name, \
+ *         ...
+ *     };
+ *
+ * SR_REGISTER_DEV_DRIVER_LIST(my_driver_infos,
+ *     MY_DRIVER("driver 1"),
+ *     MY_DRIVER("driver 2"),
+ *     ...
+ * );
+ * @endcode
+ *
+ * @param name Name to use for the driver list identifier.
+ * @param ... Comma separated list of pointers to sr_dev_driver structs.
+ */
+#define SR_REGISTER_DEV_DRIVER_LIST(name, ...) \
+       static const struct sr_dev_driver *name[] \
+               __attribute__((section (SR_DRIVER_LIST_SECTION), used, \
+                       aligned(sizeof(struct sr_dev_driver *)))) \
+               = { \
+                       __VA_ARGS__ \
+               };
+
+/**
+ * Register a hardware driver.
+ *
+ * This macro is used to register a hardware driver with the library. It has
+ * to be used in order to make the driver accessible to applications using the
+ * library.
+ *
+ * The macro invocation should be placed directly under the struct
+ * sr_dev_driver definition.
+ *
+ * Example:
+ * @code{c}
+ * static struct sr_dev_driver driver_info = {
+ *     .name = "driver",
+ *     ....
+ * };
+ * SR_REGISTER_DEV_DRIVER(driver_info);
+ * @endcode
+ *
+ * @param name Identifier name of sr_dev_driver struct to register.
+ */
+#define SR_REGISTER_DEV_DRIVER(name) \
+       SR_REGISTER_DEV_DRIVER_LIST(name##_list, &name);
+
 struct sr_context {
        struct sr_dev_driver **driver_list;
 #ifdef HAVE_LIBUSB_1_0
@@ -760,8 +825,6 @@ SR_PRIV void sr_usbtmc_dev_inst_free(struct sr_usbtmc_dev_inst *usbtmc);
 
 /*--- hwdriver.c ------------------------------------------------------------*/
 
-extern SR_PRIV struct sr_dev_driver **drivers_lists[];
-
 SR_PRIV const GVariantType *sr_variant_type_get(int datatype);
 SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *data);
 SR_PRIV void sr_hw_cleanup_all(const struct sr_context *ctx);