From: Joel Holdsworth Date: Mon, 7 May 2012 14:02:02 +0000 (+0100) Subject: sr: Made the dev_config_set parameter a const pointer X-Git-Tag: dsupstream~932 X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=1b79df2f57012926927983a8e2829004f0eee4fa sr: Made the dev_config_set parameter a const pointer --- diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index 7c77bfbc..d86ac05f 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -212,7 +212,7 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; struct context *ctx; @@ -225,10 +225,10 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) case SR_HWCAP_PROBECONFIG: return SR_OK; case SR_HWCAP_SAMPLERATE: - ctx->cur_rate = *(uint64_t *)value; + ctx->cur_rate = *(const uint64_t *)value; return SR_OK; case SR_HWCAP_LIMIT_SAMPLES: - ctx->limit_samples = *(uint64_t *)value; + ctx->limit_samples = *(const uint64_t *)value; return SR_OK; default: return SR_ERR; diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 12d31244..59faa6e2 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -633,11 +633,11 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) * The Sigma supports complex triggers using boolean expressions, but this * has not been implemented yet. */ -static int configure_probes(struct sr_dev_inst *sdi, GSList *probes) +static int configure_probes(struct sr_dev_inst *sdi, const GSList *probes) { struct context *ctx = sdi->priv; - struct sr_probe *probe; - GSList *l; + const struct sr_probe *probe; + const GSList *l; int trigger_set = 0; int probebit; @@ -806,7 +806,7 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; struct context *ctx; @@ -818,17 +818,17 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) ctx = sdi->priv; if (hwcap == SR_HWCAP_SAMPLERATE) { - ret = set_samplerate(sdi, *(uint64_t *)value); + ret = set_samplerate(sdi, *(const uint64_t *)value); } else if (hwcap == SR_HWCAP_PROBECONFIG) { ret = configure_probes(sdi, value); } else if (hwcap == SR_HWCAP_LIMIT_MSEC) { - ctx->limit_msec = *(uint64_t *)value; + ctx->limit_msec = *(const uint64_t *)value; if (ctx->limit_msec > 0) ret = SR_OK; else ret = SR_ERR; } else if (hwcap == SR_HWCAP_CAPTURE_RATIO) { - ctx->capture_ratio = *(uint64_t *)value; + ctx->capture_ratio = *(const uint64_t *)value; if (ctx->capture_ratio < 0 || ctx->capture_ratio > 100) ret = SR_ERR; else diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index 38902908..ad3e7601 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -400,10 +400,10 @@ static int la8_reset(struct context *ctx) return SR_OK; } -static int configure_probes(struct context *ctx, GSList *probes) +static int configure_probes(struct context *ctx, const GSList *probes) { - struct sr_probe *probe; - GSList *l; + const struct sr_probe *probe; + const GSList *l; uint8_t probe_bit; char *tc; @@ -760,7 +760,7 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; struct context *ctx; @@ -779,32 +779,32 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) switch (hwcap) { case SR_HWCAP_SAMPLERATE: - if (set_samplerate(sdi, *(uint64_t *)value) == SR_ERR) { + if (set_samplerate(sdi, *(const uint64_t *)value) == SR_ERR) { sr_err("la8: %s: setting samplerate failed.", __func__); return SR_ERR; } sr_dbg("la8: SAMPLERATE = %" PRIu64, ctx->cur_samplerate); break; case SR_HWCAP_PROBECONFIG: - if (configure_probes(ctx, (GSList *)value) != SR_OK) { + if (configure_probes(ctx, (const GSList *)value) != SR_OK) { sr_err("la8: %s: probe config failed.", __func__); return SR_ERR; } break; case SR_HWCAP_LIMIT_MSEC: - if (*(uint64_t *)value == 0) { + if (*(const uint64_t *)value == 0) { sr_err("la8: %s: LIMIT_MSEC can't be 0.", __func__); return SR_ERR; } - ctx->limit_msec = *(uint64_t *)value; + ctx->limit_msec = *(const uint64_t *)value; sr_dbg("la8: LIMIT_MSEC = %" PRIu64, ctx->limit_msec); break; case SR_HWCAP_LIMIT_SAMPLES: - if (*(uint64_t *)value < MIN_NUM_SAMPLES) { + if (*(const uint64_t *)value < MIN_NUM_SAMPLES) { sr_err("la8: %s: LIMIT_SAMPLES too small.", __func__); return SR_ERR; } - ctx->limit_samples = *(uint64_t *)value; + ctx->limit_samples = *(const uint64_t *)value; sr_dbg("la8: LIMIT_SAMPLES = %" PRIu64, ctx->limit_samples); break; default: diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index adf87304..c5a7719c 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -231,10 +231,10 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { int ret; - char *stropt; + const char *stropt; /* Avoid compiler warnings. */ (void)dev_index; @@ -243,17 +243,17 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) /* Nothing to do, but must be supported */ ret = SR_OK; } else if (hwcap == SR_HWCAP_SAMPLERATE) { - cur_samplerate = *(uint64_t *)value; + cur_samplerate = *(const uint64_t *)value; sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__, cur_samplerate); ret = SR_OK; } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) { - limit_samples = *(uint64_t *)value; + limit_samples = *(const uint64_t *)value; sr_dbg("demo: %s: setting limit_samples to %" PRIu64, __func__, limit_samples); ret = SR_OK; } else if (hwcap == SR_HWCAP_LIMIT_MSEC) { - limit_msec = *(uint64_t *)value; + limit_msec = *(const uint64_t *)value; sr_dbg("demo: %s: setting limit_msec to %" PRIu64, __func__, limit_msec); ret = SR_OK; diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 38f3d14d..9897fb9e 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -125,7 +125,7 @@ static struct sr_samplerates samplerates = { static GSList *dev_insts = NULL; static libusb_context *usb_context = NULL; -static int hw_dev_config_set(int dev_index, int hwcap, void *value); +static int hw_dev_config_set(int dev_index, int hwcap, const void *value); static int hw_dev_acquisition_stop(int dev_index, void *cb_data); /** @@ -589,7 +589,7 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; struct context *ctx; @@ -600,12 +600,12 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) ctx = sdi->priv; if (hwcap == SR_HWCAP_SAMPLERATE) { - ctx->cur_samplerate = *(uint64_t *)value; + ctx->cur_samplerate = *(const uint64_t *)value; ret = SR_OK; } else if (hwcap == SR_HWCAP_PROBECONFIG) { ret = configure_probes(ctx, (GSList *) value); } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) { - ctx->limit_samples = *(uint64_t *)value; + ctx->limit_samples = *(const uint64_t *)value; ret = SR_OK; } else { ret = SR_ERR; diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index 30449e08..19aa5225 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -655,7 +655,7 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; @@ -664,7 +664,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) switch (hwcap) { case SR_HWCAP_SAMPLERATE: - return mso_configure_rate(sdi, *(uint64_t *) value); + return mso_configure_rate(sdi, *(const uint64_t *) value); case SR_HWCAP_PROBECONFIG: case SR_HWCAP_LIMIT_SAMPLES: default: diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 05e138e9..7cdd77e6 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -131,10 +131,10 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data) return SR_OK; } -static int configure_probes(struct context *ctx, GSList *probes) +static int configure_probes(struct context *ctx, const GSList *probes) { - struct sr_probe *probe; - GSList *l; + const struct sr_probe *probe; + const GSList *l; int probe_bit, stage, i; char *tc; @@ -146,7 +146,7 @@ static int configure_probes(struct context *ctx, GSList *probes) ctx->num_stages = 0; for (l = probes; l; l = l->next) { - probe = (struct sr_probe *)l->data; + probe = (const struct sr_probe *)l->data; if (!probe->enabled) continue; @@ -639,12 +639,12 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) return SR_OK; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; struct context *ctx; int ret; - uint64_t *tmp_u64; + const uint64_t *tmp_u64; if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) return SR_ERR; @@ -655,10 +655,10 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) switch (hwcap) { case SR_HWCAP_SAMPLERATE: - ret = set_samplerate(sdi, *(uint64_t *)value); + ret = set_samplerate(sdi, *(const uint64_t *)value); break; case SR_HWCAP_PROBECONFIG: - ret = configure_probes(ctx, (GSList *)value); + ret = configure_probes(ctx, (const GSList *)value); break; case SR_HWCAP_LIMIT_SAMPLES: tmp_u64 = value; @@ -671,7 +671,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) ret = SR_OK; break; case SR_HWCAP_CAPTURE_RATIO: - ctx->capture_ratio = *(uint64_t *)value; + ctx->capture_ratio = *(const uint64_t *)value; if (ctx->capture_ratio < 0 || ctx->capture_ratio > 100) { ctx->capture_ratio = 0; ret = SR_ERR; diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 95033ccd..5066a9c8 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -157,7 +157,7 @@ struct context { struct sr_usb_dev_inst *usb; }; -static int hw_dev_config_set(int dev_index, int hwcap, void *value); +static int hw_dev_config_set(int dev_index, int hwcap, const void *value); static unsigned int get_memory_size(int type) { @@ -282,11 +282,11 @@ static void close_dev(struct sr_dev_inst *sdi) sdi->status = SR_ST_INACTIVE; } -static int configure_probes(struct sr_dev_inst *sdi, GSList *probes) +static int configure_probes(struct sr_dev_inst *sdi, const GSList *probes) { struct context *ctx; - struct sr_probe *probe; - GSList *l; + const struct sr_probe *probe; + const GSList *l; int probe_bit, stage, i; char *tc; @@ -599,7 +599,7 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) return SR_OK; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct sr_dev_inst *sdi; struct context *ctx; @@ -616,11 +616,11 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value) switch (hwcap) { case SR_HWCAP_SAMPLERATE: - return set_samplerate(sdi, *(uint64_t *)value); + return set_samplerate(sdi, *(const uint64_t *)value); case SR_HWCAP_PROBECONFIG: - return configure_probes(sdi, (GSList *)value); + return configure_probes(sdi, (const GSList *)value); case SR_HWCAP_LIMIT_SAMPLES: - ctx->limit_samples = *(uint64_t *)value; + ctx->limit_samples = *(const uint64_t *)value; return SR_OK; default: return SR_ERR; diff --git a/session_driver.c b/session_driver.c index 5d2d446d..301df7d2 100644 --- a/session_driver.c +++ b/session_driver.c @@ -231,10 +231,10 @@ static const int *hw_hwcap_get_all(void) return hwcaps; } -static int hw_dev_config_set(int dev_index, int hwcap, void *value) +static int hw_dev_config_set(int dev_index, int hwcap, const void *value) { struct session_vdev *vdev; - uint64_t *tmp_u64; + const uint64_t *tmp_u64; if (!(vdev = get_vdev_by_index(dev_index))) return SR_ERR; diff --git a/sigrok.h.in b/sigrok.h.in index 759565df..87749d60 100644 --- a/sigrok.h.in +++ b/sigrok.h.in @@ -466,7 +466,7 @@ struct sr_dev_driver { const void *(*dev_info_get) (int dev_index, int dev_info_id); int (*dev_status_get) (int dev_index); const int *(*hwcap_get_all) (void); - int (*dev_config_set) (int dev_index, int hwcap, void *value); + int (*dev_config_set) (int dev_index, int hwcap, const void *value); int (*dev_acquisition_start) (int dev_index, void *session_dev_id); int (*dev_acquisition_stop) (int dev_index, void *session_dev_id); };