Skip to content

Commit 0194b84

Browse files
committed
use enum buf for process_set_config for ch34x and pl2303
1 parent f4d049e commit 0194b84

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/class/cdc/cdc_host.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,9 @@ static bool acm_open(uint8_t daddr, tusb_desc_interface_t const *itf_desc, uint1
10541054

10551055
static bool acm_process_set_config(cdch_interface_t *p_cdc, tuh_xfer_t *xfer) {
10561056
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS);
1057+
(void) p_cdc;
10571058
const uintptr_t state = xfer->user_data;
1059+
10581060
switch (state) {
10591061
case CONFIG_ACM_COMPLETE: {
10601062
xfer->user_data = 0; // kick-off set line state on enum
@@ -1767,15 +1769,16 @@ static bool ch34x_open(uint8_t daddr, tusb_desc_interface_t const * itf_desc, ui
17671769
}
17681770

17691771
static bool ch34x_process_set_config(cdch_interface_t *p_cdc, tuh_xfer_t *xfer) {
1770-
uint8_t buffer[2];// TODO remove
17711772
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS);
17721773
const uintptr_t state = xfer->user_data;
17731774

17741775
switch (state) {
1775-
case CONFIG_CH34X_READ_VERSION:
1776-
TU_ASSERT(ch34x_control_in(p_cdc, CH34X_REQ_READ_VERSION, 0, 0, buffer, 2,
1776+
case CONFIG_CH34X_READ_VERSION: {
1777+
uint8_t* enum_buf = usbh_get_enum_buf();
1778+
TU_ASSERT(ch34x_control_in(p_cdc, CH34X_REQ_READ_VERSION, 0, 0, enum_buf, 2,
17771779
cdch_process_set_config, CONFIG_CH34X_SERIAL_INIT));
17781780
break;
1781+
}
17791782

17801783
case CONFIG_CH34X_SERIAL_INIT: {
17811784
// handle version read data, set CH34x line coding (incl. baudrate)
@@ -2104,7 +2107,7 @@ static bool pl2303_process_set_config(cdch_interface_t *p_cdc, tuh_xfer_t *xfer)
21042107
// state CONFIG_PL2303_READ1 may have no success due to expected stall by pl2303_supports_hx_status()
21052108
const uintptr_t state = xfer->user_data;
21062109
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS || state == CONFIG_PL2303_READ1);
2107-
uint8_t buf = 0;
2110+
uint8_t* enum_buf = usbh_get_enum_buf();
21082111
pl2303_type_t type;
21092112

21102113
switch (state) {
@@ -2136,7 +2139,7 @@ static bool pl2303_process_set_config(cdch_interface_t *p_cdc, tuh_xfer_t *xfer)
21362139

21372140
// purpose unknown, overtaken from Linux Kernel driver
21382141
if (p_cdc->pl2303.type != PL2303_TYPE_HXN) {
2139-
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, &buf, cdch_process_set_config, CONFIG_PL2303_WRITE1));
2142+
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, enum_buf, cdch_process_set_config, CONFIG_PL2303_WRITE1));
21402143
break;
21412144
}// else: continue with next step
21422145
TU_ATTR_FALLTHROUGH;
@@ -2152,23 +2155,23 @@ static bool pl2303_process_set_config(cdch_interface_t *p_cdc, tuh_xfer_t *xfer)
21522155
case CONFIG_PL2303_READ2:
21532156
// purpose unknown, overtaken from Linux Kernel driver
21542157
if (p_cdc->pl2303.type != PL2303_TYPE_HXN) {
2155-
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, &buf, cdch_process_set_config, CONFIG_PL2303_READ3));
2158+
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, enum_buf, cdch_process_set_config, CONFIG_PL2303_READ3));
21562159
break;
21572160
}// else: continue with next step
21582161
TU_ATTR_FALLTHROUGH;
21592162

21602163
case CONFIG_PL2303_READ3:
21612164
// purpose unknown, overtaken from Linux Kernel driver
21622165
if (p_cdc->pl2303.type != PL2303_TYPE_HXN) {
2163-
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8383, &buf, cdch_process_set_config, CONFIG_PL2303_READ4));
2166+
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8383, enum_buf, cdch_process_set_config, CONFIG_PL2303_READ4));
21642167
break;
21652168
}// else: continue with next step
21662169
TU_ATTR_FALLTHROUGH;
21672170

21682171
case CONFIG_PL2303_READ4:
21692172
// purpose unknown, overtaken from Linux Kernel driver
21702173
if (p_cdc->pl2303.type != PL2303_TYPE_HXN) {
2171-
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, &buf, cdch_process_set_config, CONFIG_PL2303_WRITE2));
2174+
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, enum_buf, cdch_process_set_config, CONFIG_PL2303_WRITE2));
21722175
break;
21732176
}// else: continue with next step
21742177
TU_ATTR_FALLTHROUGH;
@@ -2184,15 +2187,15 @@ static bool pl2303_process_set_config(cdch_interface_t *p_cdc, tuh_xfer_t *xfer)
21842187
case CONFIG_PL2303_READ5:
21852188
// purpose unknown, overtaken from Linux Kernel driver
21862189
if (p_cdc->pl2303.type != PL2303_TYPE_HXN) {
2187-
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, &buf, cdch_process_set_config, CONFIG_PL2303_READ6));
2190+
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8484, enum_buf, cdch_process_set_config, CONFIG_PL2303_READ6));
21882191
break;
21892192
}// else: continue with next step
21902193
TU_ATTR_FALLTHROUGH;
21912194

21922195
case CONFIG_PL2303_READ6:
21932196
// purpose unknown, overtaken from Linux Kernel driver
21942197
if (p_cdc->pl2303.type != PL2303_TYPE_HXN) {
2195-
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8383, &buf, cdch_process_set_config, CONFIG_PL2303_WRITE3));
2198+
TU_ASSERT(pl2303_vendor_read(p_cdc, 0x8383, enum_buf, cdch_process_set_config, CONFIG_PL2303_WRITE3));
21962199
break;
21972200
}// else: continue with next step
21982201
TU_ATTR_FALLTHROUGH;

0 commit comments

Comments
 (0)