summaryrefslogtreecommitdiff
path: root/class/cdc
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-05-22 17:09:47 +0800
committersakumisu <[email protected]>2022-05-22 17:09:47 +0800
commit56364f29036813ec698e4e93abd0f27db2b4e5cf (patch)
treeed147e38fe476967a418bec61bf09606a9f54a94 /class/cdc
parent16262f057520ed1e64fd50cbfe6e861bb4268853 (diff)
alloc class name after the necessary commands are completed
Diffstat (limited to 'class/cdc')
-rw-r--r--class/cdc/usbh_cdc_acm.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/class/cdc/usbh_cdc_acm.c b/class/cdc/usbh_cdc_acm.c
index 47eff5de..71d46699 100644
--- a/class/cdc/usbh_cdc_acm.c
+++ b/class/cdc/usbh_cdc_acm.c
@@ -147,13 +147,11 @@ static int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf)
}
memset(cdc_acm_class, 0, sizeof(struct usbh_cdc_acm));
+ usbh_cdc_acm_devno_alloc(cdc_acm_class);
cdc_acm_class->hport = hport;
cdc_acm_class->ctrl_intf = intf;
cdc_acm_class->data_intf = intf + 1;
- usbh_cdc_acm_devno_alloc(cdc_acm_class);
- snprintf(hport->config.intf[intf].devname, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, cdc_acm_class->minor);
-
hport->config.intf[intf].priv = cdc_acm_class;
hport->config.intf[intf + 1].priv = NULL;
@@ -169,11 +167,13 @@ static int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf)
cdc_acm_class->linecoding->bCharFormat = 0;
ret = usbh_cdc_acm_set_line_coding(cdc_acm_class, cdc_acm_class->linecoding);
if (ret < 0) {
+ USB_LOG_ERR("Fail to set linecoding\r\n");
return ret;
}
ret = usbh_cdc_acm_set_line_state(cdc_acm_class, true, true);
if (ret < 0) {
+ USB_LOG_ERR("Fail to set line state\r\n");
return ret;
}
@@ -202,6 +202,8 @@ static int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf)
}
}
+ snprintf(hport->config.intf[intf].devname, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, cdc_acm_class->minor);
+
USB_LOG_INFO("Register CDC ACM Class:%s\r\n", hport->config.intf[intf].devname);
extern int cdc_acm_test();
@@ -237,9 +239,10 @@ static int usbh_cdc_acm_disconnect(struct usbh_hubport *hport, uint8_t intf)
usb_free(cdc_acm_class);
- USB_LOG_INFO("Unregister CDC ACM Class:%s\r\n", hport->config.intf[intf].devname);
- memset(hport->config.intf[intf].devname, 0, CONFIG_USBHOST_DEV_NAMELEN);
+ if (hport->config.intf[intf].devname[0] != '\0')
+ USB_LOG_INFO("Unregister CDC ACM Class:%s\r\n", hport->config.intf[intf].devname);
+ memset(hport->config.intf[intf].devname, 0, CONFIG_USBHOST_DEV_NAMELEN);
hport->config.intf[intf].priv = NULL;
hport->config.intf[intf + 1].priv = NULL;
}