sr/drivers: use sr_dev_inst instead of device index for dev_config_set()
All driver API calls using device index as a parameter will instead use a const struct sr_dev_inst.
This commit is contained in:
parent
9c4311c524
commit
6f4b1868e8
|
@ -633,7 +633,7 @@ static int hw_dev_open(int dev_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
{
|
||||
int i, ret;
|
||||
struct context *ctx = sdi->priv;
|
||||
|
@ -674,7 +674,7 @@ 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, const GSList *probes)
|
||||
static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes)
|
||||
{
|
||||
struct context *ctx = sdi->priv;
|
||||
const struct sr_probe *probe;
|
||||
|
@ -829,15 +829,12 @@ static int hw_dev_status_get(int dev_index)
|
|||
return SR_ST_NOT_FOUND;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
int ret;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(adi->instances, dev_index)))
|
||||
return SR_ERR;
|
||||
|
||||
ctx = sdi->priv;
|
||||
|
||||
if (hwcap == SR_HWCAP_SAMPLERATE) {
|
||||
|
|
|
@ -330,23 +330,16 @@ static int hw_dev_status_get(int dev_index)
|
|||
return sdi->status;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) {
|
||||
sr_err("la8: %s: sdi was NULL", __func__);
|
||||
return SR_ERR_BUG;
|
||||
}
|
||||
|
||||
if (!(ctx = sdi->priv)) {
|
||||
sr_err("la8: %s: sdi->priv was NULL", __func__);
|
||||
return SR_ERR_BUG;
|
||||
}
|
||||
|
||||
sr_spew("la8: %s: dev_index %d, hwcap %d", __func__, dev_index, hwcap);
|
||||
|
||||
switch (hwcap) {
|
||||
case SR_HWCAP_SAMPLERATE:
|
||||
if (set_samplerate(sdi, *(const uint64_t *)value) == SR_ERR) {
|
||||
|
|
|
@ -378,7 +378,7 @@ SR_PRIV int configure_probes(struct context *ctx, const GSList *probes)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
SR_PRIV int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
{
|
||||
struct context *ctx;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ SR_PRIV int la8_close(struct context *ctx);
|
|||
SR_PRIV int la8_close_usb_reset_sequencer(struct context *ctx);
|
||||
SR_PRIV int la8_reset(struct context *ctx);
|
||||
SR_PRIV int configure_probes(struct context *ctx, const GSList *probes);
|
||||
SR_PRIV int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate);
|
||||
SR_PRIV int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
|
||||
SR_PRIV int la8_read_block(struct context *ctx);
|
||||
SR_PRIV void send_block_to_session_bus(struct context *ctx, int block);
|
||||
|
||||
|
|
|
@ -237,13 +237,13 @@ static int hw_dev_status_get(int dev_index)
|
|||
return SR_ST_ACTIVE;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
int ret;
|
||||
const char *stropt;
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
(void)dev_index;
|
||||
(void)sdi;
|
||||
|
||||
if (hwcap == SR_HWCAP_PROBECONFIG) {
|
||||
/* Nothing to do, but must be supported */
|
||||
|
|
|
@ -143,7 +143,8 @@ static libusb_context *usb_context = NULL;
|
|||
|
||||
SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
|
||||
static struct sr_dev_driver *fdi = &fx2lafw_driver_info;
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value);
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value);
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
|
||||
|
||||
/**
|
||||
|
@ -575,7 +576,7 @@ static int hw_dev_open(int dev_index)
|
|||
|
||||
if (ctx->cur_samplerate == 0) {
|
||||
/* Samplerate hasn't been set; default to the slowest one. */
|
||||
if (hw_dev_config_set(dev_index, SR_HWCAP_SAMPLERATE,
|
||||
if (hw_dev_config_set(sdi, SR_HWCAP_SAMPLERATE,
|
||||
&supported_samplerates[0]) == SR_ERR)
|
||||
return SR_ERR;
|
||||
}
|
||||
|
@ -666,14 +667,12 @@ static int hw_dev_status_get(int dev_index)
|
|||
return sdi->status;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
int ret;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(fdi->instances, dev_index)))
|
||||
return SR_ERR;
|
||||
ctx = sdi->priv;
|
||||
|
||||
if (hwcap == SR_HWCAP_SAMPLERATE) {
|
||||
|
|
|
@ -488,23 +488,16 @@ static int hw_dev_status_get(int dev_index)
|
|||
return sdi->status;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
|
||||
sr_err("genericdmm: sdi was NULL.");
|
||||
return SR_ERR_BUG;
|
||||
}
|
||||
|
||||
if (!(ctx = sdi->priv)) {
|
||||
sr_err("genericdmm: sdi->priv was NULL.");
|
||||
return SR_ERR_BUG;
|
||||
}
|
||||
|
||||
sr_spew("genericdmm: dev_index %d, hwcap %d.", dev_index, hwcap);
|
||||
|
||||
switch (hwcap) {
|
||||
case SR_HWCAP_LIMIT_MSEC:
|
||||
if (*(const uint64_t *)value == 0) {
|
||||
|
|
|
@ -444,9 +444,9 @@ static int hw_dev_status_get(int dev_index)
|
|||
return sdi->status;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
struct sr_rational tmp_rat;
|
||||
float tmp_float;
|
||||
|
@ -454,9 +454,6 @@ static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
|||
int ret, i;
|
||||
char **targets;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(hdi->instances, dev_index)))
|
||||
return SR_ERR;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
return SR_ERR;
|
||||
|
||||
|
|
|
@ -632,7 +632,7 @@ static int hw_dev_status_get(int dev_index)
|
|||
return sdi->status;
|
||||
}
|
||||
|
||||
static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
{
|
||||
struct context *ctx;
|
||||
|
||||
|
@ -664,15 +664,13 @@ 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, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
int ret;
|
||||
const uint64_t *tmp_u64;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(odi->instances, dev_index)))
|
||||
return SR_ERR;
|
||||
ctx = sdi->priv;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
|
|
|
@ -159,7 +159,8 @@ struct context {
|
|||
struct sr_usb_dev_inst *usb;
|
||||
};
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value);
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value);
|
||||
|
||||
static unsigned int get_memory_size(int type)
|
||||
{
|
||||
|
@ -284,7 +285,7 @@ static void close_dev(struct sr_dev_inst *sdi)
|
|||
sdi->status = SR_ST_INACTIVE;
|
||||
}
|
||||
|
||||
static int configure_probes(struct sr_dev_inst *sdi, const GSList *probes)
|
||||
static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes)
|
||||
{
|
||||
struct context *ctx;
|
||||
const struct sr_probe *probe;
|
||||
|
@ -482,7 +483,7 @@ static int hw_dev_open(int dev_index)
|
|||
|
||||
if (ctx->cur_samplerate == 0) {
|
||||
/* Samplerate hasn't been set. Default to the slowest one. */
|
||||
if (hw_dev_config_set(dev_index, SR_HWCAP_SAMPLERATE,
|
||||
if (hw_dev_config_set(sdi, SR_HWCAP_SAMPLERATE,
|
||||
&samplerates.list[0]) == SR_ERR)
|
||||
return SR_ERR;
|
||||
}
|
||||
|
@ -578,7 +579,7 @@ static int hw_dev_status_get(int dev_index)
|
|||
return SR_ST_NOT_FOUND;
|
||||
}
|
||||
|
||||
static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
|
||||
{
|
||||
struct context *ctx;
|
||||
|
||||
|
@ -606,16 +607,11 @@ 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, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(zdi->instances, dev_index))) {
|
||||
sr_err("zp: %s: sdi was NULL", __func__);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
if (!(ctx = sdi->priv)) {
|
||||
sr_err("zp: %s: sdi->priv was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
|
|
|
@ -497,7 +497,8 @@ struct sr_dev_driver {
|
|||
int (*info_get) (int dev_info_id, const void **data,
|
||||
const struct sr_dev_inst *sdi);
|
||||
int (*dev_status_get) (int dev_index);
|
||||
int (*dev_config_set) (int dev_index, int hwcap, const void *value);
|
||||
int (*dev_config_set) (const struct sr_dev_inst *sdi, 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);
|
||||
|
||||
|
|
|
@ -224,13 +224,13 @@ static int hw_dev_status_get(int dev_index)
|
|||
return SR_ERR;
|
||||
}
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
|
||||
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
||||
const void *value)
|
||||
{
|
||||
struct session_vdev *vdev;
|
||||
const uint64_t *tmp_u64;
|
||||
|
||||
if (!(vdev = get_vdev_by_index(dev_index)))
|
||||
return SR_ERR;
|
||||
vdev = sdi->priv;
|
||||
|
||||
switch (hwcap) {
|
||||
case SR_HWCAP_SAMPLERATE:
|
||||
|
|
Loading…
Reference in New Issue