MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / dsl_dev_open

Function dsl_dev_open

libsigrok4DSL/hardware/DSL/dsl.c:1817–1968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1815}
1816
1817SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboolean *fpga_done)
1818{
1819 struct sr_usb_dev_inst *usb;
1820 struct DSL_context *devc;
1821 int ret;
1822 uint8_t hw_info;
1823 struct ctl_rd_cmd rd_cmd;
1824 int fdError = 0;
1825
1826 devc = sdi->priv;
1827 usb = sdi->conn;
1828
1829 /*
1830 * If the firmware was recently uploaded, no dev_open operation should be called.
1831 * Just wait for renumerate -> detach -> attach
1832 */
1833 ret = SR_ERR;
1834 ret = hw_dev_open(di, sdi);
1835
1836 if (ret != SR_OK) {
1837 sr_err("%s: Unable to open device.", __func__);
1838 return SR_ERR;
1839 }
1840
1841 assert(usb->devhdl);
1842
1843 ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
1844
1845 if (ret != LIBUSB_SUCCESS) {
1846 switch(ret) {
1847 case LIBUSB_ERROR_BUSY:
1848 sr_err("%s: Unable to claim USB interface. Another "
1849 "program or driver has already claimed it.", __func__);
1850 break;
1851 case LIBUSB_ERROR_NO_DEVICE:
1852 sr_err("%s: Device has been disconnected.", __func__);
1853 break;
1854 case LIBUSB_ERROR_NOT_FOUND:
1855 {
1856 sr_err("%s: Unable to claim interface, try again: LIBUSB_ERROR_NOT_FOUND.", __func__);
1857 ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
1858 fdError = 1;
1859 }
1860 break;
1861 default:
1862 sr_err("%s: Unable to claim interface, try again: %s.",
1863 __func__, libusb_error_name(ret));
1864 break;
1865 }
1866
1867 if (ret != LIBUSB_SUCCESS && fdError == 1){
1868 sr_err("%s: Unable to claim interface, the second time: %s.",
1869 __func__, libusb_error_name(ret));
1870 }
1871
1872 if (ret != LIBUSB_SUCCESS){
1873 dsl_dev_close(sdi);
1874 ds_set_last_error(SR_ERR_DEVICE_IS_EXCLUSIVE);

Callers 2

dev_openFunction · 0.85
dev_openFunction · 0.85

Calls 9

dsl_dev_closeFunction · 0.85
ds_set_last_errorFunction · 0.85
command_ctl_rdFunction · 0.85
dsl_fpga_configFunction · 0.85
dsl_wr_regFunction · 0.85
dsl_hdl_versionFunction · 0.85
dsl_rd_nvmFunction · 0.85
dsl_secuCheckFunction · 0.85
hw_dev_openFunction · 0.70

Tested by

no test coverage detected