X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Flascar-el-usb%2Fapi.c;h=4cef9f9698df9c0af2611166b457144ef77500a7;hb=4afdfd4628e9955af02a3ea619ecdfe469f9a9e2;hp=8ebb4ca0d4a3a6ba75aa420e2f31902ce0142e62;hpb=0d485e30c607b22b5f328512327e4e0fafc6cbb7;p=libsigrok.git diff --git a/hardware/lascar-el-usb/api.c b/hardware/lascar-el-usb/api.c index 8ebb4ca0..4cef9f96 100644 --- a/hardware/lascar-el-usb/api.c +++ b/hardware/lascar-el-usb/api.c @@ -70,17 +70,7 @@ static int clear_instances(void) static int hw_init(struct sr_context *sr_ctx) { - struct drv_context *drvc; - - if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) { - sr_err("Driver context malloc failed."); - return SR_ERR_MALLOC; - } - - drvc->sr_ctx = sr_ctx; - di->priv = drvc; - - return SR_OK; + return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN); } static GSList *hw_scan(GSList *options) @@ -95,10 +85,7 @@ static GSList *hw_scan(GSList *options) (void)options; - if (!(drvc = di->priv)) { - sr_err("Driver was not initialized."); - return NULL; - } + drvc = di->priv; /* USB scan is always authoritative. */ clear_instances(); @@ -140,14 +127,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - if (!(drvc = di->priv)) { - sr_err("Driver was not initialized."); - return NULL; - } - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) @@ -213,18 +193,6 @@ static int hw_cleanup(void) return SR_OK; } -static int config_get(int id, const void **data, const struct sr_dev_inst *sdi) -{ - (void)sdi; - - switch (id) { - default: - return SR_ERR_ARG; - } - - return SR_OK; -} - static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -345,7 +313,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct sr_datafeed_packet packet; - struct sr_datafeed_header header; struct dev_context *devc; struct drv_context *drvc = di->priv; struct libusb_transfer *xfer_in, *xfer_out; @@ -368,11 +335,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, sr_dbg("Starting log retrieval."); /* Send header packet to the session bus. */ - sr_dbg("Sending SR_DF_HEADER."); - packet.type = SR_DF_HEADER; - packet.payload = (uint8_t *)&header; - header.feed_version = 1; - sr_session_send(devc->cb_data, &packet); + std_session_send_df_header(cb_data, DRIVER_LOG_DOMAIN); if (devc->logged_samples == 0) { /* This ensures the frontend knows the session is done. */ @@ -491,7 +454,6 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, - .config_get = config_get, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open,