allow for intermediate stage in stopping acquisition

In the case of USB drivers, a driver's dev_acquisition_stop() cannot
simply remove its fd sources from the session and close its devices:
a USB transfer might still be underway, and it needs to be finished
(and its memory freed) properly.

An sr_dev_inst->status value is added: SR_ST_STOPPING, which should
be set when the driver's dev_acquisition_stop() is called, and acts
as a marker for the USB event handler to wind up its operations.

In order for dev_acquisition_stop() to be able to set the sdi status,
however, it needs to be unconstified.
This commit is contained in:
Bert Vermeulen 2012-11-06 15:02:37 +01:00
parent ac3898d2d0
commit 69b07d14db
15 changed files with 23 additions and 42 deletions

View File

@ -397,8 +397,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;

View File

@ -42,6 +42,7 @@
SR_PRIV struct sr_dev_driver asix_sigma_driver_info;
static struct sr_dev_driver *adi = &asix_sigma_driver_info;
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static const uint64_t supported_samplerates[] = {
SR_KHZ(200),
@ -122,9 +123,6 @@ static const char *firmware_files[] = {
"asix-sigma-phasor.fw", /* Frequency counter */
};
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
static int sigma_read(void *buf, size_t size, struct dev_context *devc)
{
int ret;
@ -1419,8 +1417,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;
uint8_t modestatus;

View File

@ -38,8 +38,7 @@ static const uint16_t usb_pids[] = {
};
/* Function prototypes. */
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static int clear_instances(void)
{
@ -506,8 +505,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;

View File

@ -305,8 +305,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;

View File

@ -137,8 +137,7 @@ static int default_pattern = PATTERN_SIGROK;
static GThread *my_thread;
static int thread_running;
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static int hw_init(void)
{
@ -512,8 +511,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;

View File

@ -380,8 +380,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;

View File

@ -143,8 +143,7 @@ static struct sr_dev_driver *fdi = &fx2lafw_driver_info;
static int hw_dev_close(struct sr_dev_inst *sdi);
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value);
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
/**
* Check the USB configuration to determine if this is an fx2lafw device.
@ -1027,8 +1026,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
}
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
/* Avoid compiler warnings. */

View File

@ -63,8 +63,7 @@ SR_PRIV struct sr_dev_driver genericdmm_driver_info;
static struct sr_dev_driver *gdi = &genericdmm_driver_info;
/* TODO need a way to keep this local to the static library */
static libusb_context *genericdmm_usb_context = NULL;
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static GSList *connect_serial(const char *conn, const char *serialcomm)
{
@ -556,8 +555,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;

View File

@ -145,8 +145,7 @@ static const char *coupling[] = {
SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
static struct sr_dev_driver *hdi = &hantek_dso_driver_info;
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof)
{
@ -886,8 +885,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;

View File

@ -1073,8 +1073,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
}
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
/* Avoid compiler warnings. */
(void)cb_data;

View File

@ -376,8 +376,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;

View File

@ -373,8 +373,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;

View File

@ -291,8 +291,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;

View File

@ -799,8 +799,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
}
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;

View File

@ -547,6 +547,8 @@ enum {
SR_ST_INACTIVE,
/** The device instance is actively in use in a session. */
SR_ST_ACTIVE,
/** The device is winding down its session. */
SR_ST_STOPPING,
};
/*
@ -618,7 +620,7 @@ struct sr_dev_driver {
const void *value);
int (*dev_acquisition_start) (const struct sr_dev_inst *sdi,
void *cb_data);
int (*dev_acquisition_stop) (const struct sr_dev_inst *sdi,
int (*dev_acquisition_stop) (struct sr_dev_inst *sdi,
void *cb_data);
/* Dynamic */