sr: Made the dev_config_set parameter a const pointer

This commit is contained in:
Joel Holdsworth 2012-05-07 15:02:02 +01:00
parent b7f578bef5
commit 1b79df2f57
10 changed files with 51 additions and 51 deletions

View File

@ -212,7 +212,7 @@ static const int *hw_hwcap_get_all(void)
return hwcaps; 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 sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
@ -225,10 +225,10 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
case SR_HWCAP_PROBECONFIG: case SR_HWCAP_PROBECONFIG:
return SR_OK; return SR_OK;
case SR_HWCAP_SAMPLERATE: case SR_HWCAP_SAMPLERATE:
ctx->cur_rate = *(uint64_t *)value; ctx->cur_rate = *(const uint64_t *)value;
return SR_OK; return SR_OK;
case SR_HWCAP_LIMIT_SAMPLES: case SR_HWCAP_LIMIT_SAMPLES:
ctx->limit_samples = *(uint64_t *)value; ctx->limit_samples = *(const uint64_t *)value;
return SR_OK; return SR_OK;
default: default:
return SR_ERR; return SR_ERR;

View File

@ -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 * The Sigma supports complex triggers using boolean expressions, but this
* has not been implemented yet. * 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 context *ctx = sdi->priv;
struct sr_probe *probe; const struct sr_probe *probe;
GSList *l; const GSList *l;
int trigger_set = 0; int trigger_set = 0;
int probebit; int probebit;
@ -806,7 +806,7 @@ static const int *hw_hwcap_get_all(void)
return hwcaps; 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 sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
@ -818,17 +818,17 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
ctx = sdi->priv; ctx = sdi->priv;
if (hwcap == SR_HWCAP_SAMPLERATE) { 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) { } else if (hwcap == SR_HWCAP_PROBECONFIG) {
ret = configure_probes(sdi, value); ret = configure_probes(sdi, value);
} else if (hwcap == SR_HWCAP_LIMIT_MSEC) { } 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) if (ctx->limit_msec > 0)
ret = SR_OK; ret = SR_OK;
else else
ret = SR_ERR; ret = SR_ERR;
} else if (hwcap == SR_HWCAP_CAPTURE_RATIO) { } 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) if (ctx->capture_ratio < 0 || ctx->capture_ratio > 100)
ret = SR_ERR; ret = SR_ERR;
else else

View File

@ -400,10 +400,10 @@ static int la8_reset(struct context *ctx)
return SR_OK; 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; const struct sr_probe *probe;
GSList *l; const GSList *l;
uint8_t probe_bit; uint8_t probe_bit;
char *tc; char *tc;
@ -760,7 +760,7 @@ static const int *hw_hwcap_get_all(void)
return hwcaps; 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 sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
@ -779,32 +779,32 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
switch (hwcap) { switch (hwcap) {
case SR_HWCAP_SAMPLERATE: 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__); sr_err("la8: %s: setting samplerate failed.", __func__);
return SR_ERR; return SR_ERR;
} }
sr_dbg("la8: SAMPLERATE = %" PRIu64, ctx->cur_samplerate); sr_dbg("la8: SAMPLERATE = %" PRIu64, ctx->cur_samplerate);
break; break;
case SR_HWCAP_PROBECONFIG: 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__); sr_err("la8: %s: probe config failed.", __func__);
return SR_ERR; return SR_ERR;
} }
break; break;
case SR_HWCAP_LIMIT_MSEC: 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__); sr_err("la8: %s: LIMIT_MSEC can't be 0.", __func__);
return SR_ERR; 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); sr_dbg("la8: LIMIT_MSEC = %" PRIu64, ctx->limit_msec);
break; break;
case SR_HWCAP_LIMIT_SAMPLES: 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__); sr_err("la8: %s: LIMIT_SAMPLES too small.", __func__);
return SR_ERR; 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); sr_dbg("la8: LIMIT_SAMPLES = %" PRIu64, ctx->limit_samples);
break; break;
default: default:

View File

@ -231,10 +231,10 @@ static const int *hw_hwcap_get_all(void)
return hwcaps; 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; int ret;
char *stropt; const char *stropt;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
(void)dev_index; (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 */ /* Nothing to do, but must be supported */
ret = SR_OK; ret = SR_OK;
} else if (hwcap == SR_HWCAP_SAMPLERATE) { } 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__, sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__,
cur_samplerate); cur_samplerate);
ret = SR_OK; ret = SR_OK;
} else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) { } 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__, sr_dbg("demo: %s: setting limit_samples to %" PRIu64, __func__,
limit_samples); limit_samples);
ret = SR_OK; ret = SR_OK;
} else if (hwcap == SR_HWCAP_LIMIT_MSEC) { } 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__, sr_dbg("demo: %s: setting limit_msec to %" PRIu64, __func__,
limit_msec); limit_msec);
ret = SR_OK; ret = SR_OK;

View File

@ -125,7 +125,7 @@ static struct sr_samplerates samplerates = {
static GSList *dev_insts = NULL; static GSList *dev_insts = NULL;
static libusb_context *usb_context = 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); 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; 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 sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
@ -600,12 +600,12 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
ctx = sdi->priv; ctx = sdi->priv;
if (hwcap == SR_HWCAP_SAMPLERATE) { if (hwcap == SR_HWCAP_SAMPLERATE) {
ctx->cur_samplerate = *(uint64_t *)value; ctx->cur_samplerate = *(const uint64_t *)value;
ret = SR_OK; ret = SR_OK;
} else if (hwcap == SR_HWCAP_PROBECONFIG) { } else if (hwcap == SR_HWCAP_PROBECONFIG) {
ret = configure_probes(ctx, (GSList *) value); ret = configure_probes(ctx, (GSList *) value);
} else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) { } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
ctx->limit_samples = *(uint64_t *)value; ctx->limit_samples = *(const uint64_t *)value;
ret = SR_OK; ret = SR_OK;
} else { } else {
ret = SR_ERR; ret = SR_ERR;

View File

@ -655,7 +655,7 @@ static const int *hw_hwcap_get_all(void)
return hwcaps; 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 sr_dev_inst *sdi;
@ -664,7 +664,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
switch (hwcap) { switch (hwcap) {
case SR_HWCAP_SAMPLERATE: 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_PROBECONFIG:
case SR_HWCAP_LIMIT_SAMPLES: case SR_HWCAP_LIMIT_SAMPLES:
default: default:

View File

@ -131,10 +131,10 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data)
return SR_OK; 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; const struct sr_probe *probe;
GSList *l; const GSList *l;
int probe_bit, stage, i; int probe_bit, stage, i;
char *tc; char *tc;
@ -146,7 +146,7 @@ static int configure_probes(struct context *ctx, GSList *probes)
ctx->num_stages = 0; ctx->num_stages = 0;
for (l = probes; l; l = l->next) { for (l = probes; l; l = l->next) {
probe = (struct sr_probe *)l->data; probe = (const struct sr_probe *)l->data;
if (!probe->enabled) if (!probe->enabled)
continue; continue;
@ -639,12 +639,12 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
return SR_OK; 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 sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
int ret; int ret;
uint64_t *tmp_u64; const uint64_t *tmp_u64;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR; return SR_ERR;
@ -655,10 +655,10 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
switch (hwcap) { switch (hwcap) {
case SR_HWCAP_SAMPLERATE: case SR_HWCAP_SAMPLERATE:
ret = set_samplerate(sdi, *(uint64_t *)value); ret = set_samplerate(sdi, *(const uint64_t *)value);
break; break;
case SR_HWCAP_PROBECONFIG: case SR_HWCAP_PROBECONFIG:
ret = configure_probes(ctx, (GSList *)value); ret = configure_probes(ctx, (const GSList *)value);
break; break;
case SR_HWCAP_LIMIT_SAMPLES: case SR_HWCAP_LIMIT_SAMPLES:
tmp_u64 = value; tmp_u64 = value;
@ -671,7 +671,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
ret = SR_OK; ret = SR_OK;
break; break;
case SR_HWCAP_CAPTURE_RATIO: 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) { if (ctx->capture_ratio < 0 || ctx->capture_ratio > 100) {
ctx->capture_ratio = 0; ctx->capture_ratio = 0;
ret = SR_ERR; ret = SR_ERR;

View File

@ -157,7 +157,7 @@ struct context {
struct sr_usb_dev_inst *usb; 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) 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; 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 context *ctx;
struct sr_probe *probe; const struct sr_probe *probe;
GSList *l; const GSList *l;
int probe_bit, stage, i; int probe_bit, stage, i;
char *tc; char *tc;
@ -599,7 +599,7 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
return SR_OK; 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 sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
@ -616,11 +616,11 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
switch (hwcap) { switch (hwcap) {
case SR_HWCAP_SAMPLERATE: case SR_HWCAP_SAMPLERATE:
return set_samplerate(sdi, *(uint64_t *)value); return set_samplerate(sdi, *(const uint64_t *)value);
case SR_HWCAP_PROBECONFIG: case SR_HWCAP_PROBECONFIG:
return configure_probes(sdi, (GSList *)value); return configure_probes(sdi, (const GSList *)value);
case SR_HWCAP_LIMIT_SAMPLES: case SR_HWCAP_LIMIT_SAMPLES:
ctx->limit_samples = *(uint64_t *)value; ctx->limit_samples = *(const uint64_t *)value;
return SR_OK; return SR_OK;
default: default:
return SR_ERR; return SR_ERR;

View File

@ -231,10 +231,10 @@ static const int *hw_hwcap_get_all(void)
return hwcaps; 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; struct session_vdev *vdev;
uint64_t *tmp_u64; const uint64_t *tmp_u64;
if (!(vdev = get_vdev_by_index(dev_index))) if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR; return SR_ERR;

View File

@ -466,7 +466,7 @@ struct sr_dev_driver {
const void *(*dev_info_get) (int dev_index, int dev_info_id); const void *(*dev_info_get) (int dev_index, int dev_info_id);
int (*dev_status_get) (int dev_index); int (*dev_status_get) (int dev_index);
const int *(*hwcap_get_all) (void); 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_start) (int dev_index, void *session_dev_id);
int (*dev_acquisition_stop) (int dev_index, void *session_dev_id); int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);
}; };