From: Joel Holdsworth Date: Mon, 7 May 2012 12:57:43 +0000 (+0100) Subject: sr: Made hwcap const X-Git-Tag: dsupstream~934 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=915f7cc87a8dce688ab99fc67005ef77e0d028a2;p=libsigrok.git sr: Made hwcap const --- diff --git a/device.c b/device.c index 6b56da3a..15809e17 100644 --- a/device.c +++ b/device.c @@ -375,7 +375,8 @@ SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum, */ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap) { - int *hwcaps, i; + const int *hwcaps; + int i; sr_spew("dev: %s: requesting hwcap %d", __func__, hwcap); diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index f15e91db..119a46f2 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -42,7 +42,7 @@ struct sr_analog_sample { struct sr_analog_probe probes[]; }; -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_SAMPLERATE, SR_HWCAP_LIMIT_SAMPLES, SR_HWCAP_CONTINUOUS, @@ -207,7 +207,7 @@ static int hw_dev_status_get(int dev_index) return SR_ST_ACTIVE; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 39e2dbed..e5bd5505 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -88,7 +88,7 @@ static struct sr_samplerates samplerates = { supported_samplerates, }; -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, SR_HWCAP_CAPTURE_RATIO, @@ -801,7 +801,7 @@ static int hw_dev_status_get(int dev_index) return SR_ST_NOT_FOUND; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index ee112ed0..a08b4b7f 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -128,7 +128,7 @@ static struct sr_samplerates samplerates = { }; /* Note: Continuous sampling is not supported by the hardware. */ -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, SR_HWCAP_LIMIT_MSEC, /* TODO: Not yet implemented. */ @@ -753,7 +753,7 @@ static int hw_dev_status_get(int dev_index) return sdi->status; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { sr_spew("la8: Returning list of device capabilities."); diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 51644fc4..ca572af8 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -76,7 +76,7 @@ struct context { GTimer *timer; }; -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_DEMO_DEV, SR_HWCAP_SAMPLERATE, @@ -226,7 +226,7 @@ static int hw_dev_status_get(int dev_index) return SR_ST_ACTIVE; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 0f839b57..ccaf7d0d 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -70,7 +70,7 @@ static const struct fx2lafw_profile supported_fx2[] = { { 0, 0, 0, 0, 0, 0, 0 } }; -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, @@ -584,7 +584,7 @@ static int hw_dev_status_get(int dev_index) return sdi->status; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index 024e67b8..cce8d87c 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -37,7 +37,7 @@ #define NUM_PROBES 8 -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, // SR_HWCAP_OSCILLOSCOPE, // SR_HWCAP_PAT_GENERATOR, @@ -650,7 +650,7 @@ static int hw_dev_status_get(int dev_index) return sdi->status; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 8862db24..ef7e3ebd 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -46,7 +46,7 @@ #define O_NONBLOCK FIONBIO #endif -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, SR_HWCAP_CAPTURE_RATIO, @@ -602,7 +602,7 @@ static int hw_dev_status_get(int dev_index) return sdi->status; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index d27fb39b..1b779878 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -65,7 +65,7 @@ static model_t zeroplus_models[] = { {0x7016, "LAP-C(162000)", 16, 2048, 200}, }; -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, SR_HWCAP_PROBECONFIG, @@ -566,7 +566,7 @@ static int hw_dev_status_get(int dev_index) return SR_ST_NOT_FOUND; } -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/hwdriver.c b/hwdriver.c index 94603db6..bbaccc8c 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -276,7 +276,8 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial) */ SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap) { - int *hwcaps, i; + const int *hwcaps; + int i; if (!driver) { sr_err("hwdriver: %s: driver was NULL", __func__); @@ -304,7 +305,7 @@ SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap) * @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_hw_hwcap_get(int hwcap) +SR_API const struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap) { int i; diff --git a/session_driver.c b/session_driver.c index 32b8e905..5d2d446d 100644 --- a/session_driver.c +++ b/session_driver.c @@ -41,7 +41,7 @@ struct session_vdev { static char *sessionfile = NULL; static GSList *dev_insts = NULL; -static int hwcaps[] = { +static const int hwcaps[] = { SR_HWCAP_CAPTUREFILE, SR_HWCAP_CAPTURE_UNITSIZE, 0, @@ -193,7 +193,7 @@ static int hw_dev_open(int dev_index) return SR_OK; } -static void *hw_dev_info_get(int dev_index, int dev_info_id) +static const void *hw_dev_info_get(int dev_index, int dev_info_id) { struct session_vdev *vdev; void *info; @@ -226,7 +226,7 @@ static int hw_dev_status_get(int dev_index) * @return A pointer to the (hardware) capabilities of this virtual session * driver. This could be NULL, if no such capabilities exist. */ -static int *hw_hwcap_get_all(void) +static const int *hw_hwcap_get_all(void) { return hwcaps; } diff --git a/sigrok-proto.h b/sigrok-proto.h index ed6dd8d8..3481c582 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -74,7 +74,7 @@ SR_API int sr_filter_probes(int in_unitsize, int out_unitsize, SR_API struct sr_dev_driver **sr_driver_list(void); SR_API int sr_driver_init(struct sr_dev_driver *driver); SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap); -SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap); +SR_API const struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap); /*--- session.c -------------------------------------------------------------*/ diff --git a/sigrok.h.in b/sigrok.h.in index 18f9404a..04d58720 100644 --- a/sigrok.h.in +++ b/sigrok.h.in @@ -465,7 +465,7 @@ struct sr_dev_driver { int (*dev_close) (int dev_index); void *(*dev_info_get) (int dev_index, int dev_info_id); int (*dev_status_get) (int dev_index); - int *(*hwcap_get_all) (void); + const int *(*hwcap_get_all) (void); int (*dev_config_set) (int dev_index, int hwcap, void *value); int (*dev_acquisition_start) (int dev_index, void *session_dev_id); int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);