mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-08 16:18:44 +08:00
chore: static code analysis
This commit is contained in:
parent
171b36e766
commit
02340e0f44
@ -28,11 +28,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_audio *usbh_audio_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_AUDIO_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_audio_class[devno], 0, sizeof(struct usbh_audio));
|
||||
g_audio_class[devno].minor = devno;
|
||||
return &g_audio_class[devno];
|
||||
@ -43,10 +43,10 @@ static struct usbh_audio *usbh_audio_class_alloc(void)
|
||||
|
||||
static void usbh_audio_class_free(struct usbh_audio *audio_class)
|
||||
{
|
||||
int devno = audio_class->minor;
|
||||
uint8_t devno = audio_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(audio_class, 0, sizeof(struct usbh_audio));
|
||||
}
|
||||
@ -330,7 +330,6 @@ static int usbh_audio_ctrl_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
memcpy(&audio_class->ac_msg_table[input_offset].ac_input, desc, sizeof(struct audio_cs_if_ac_input_terminal_descriptor));
|
||||
input_offset++;
|
||||
} break;
|
||||
break;
|
||||
case AUDIO_CONTROL_OUTPUT_TERMINAL: {
|
||||
struct audio_cs_if_ac_output_terminal_descriptor *desc = (struct audio_cs_if_ac_output_terminal_descriptor *)p;
|
||||
|
||||
|
@ -19,11 +19,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_cdc_acm *usbh_cdc_acm_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_CDC_ACM_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_cdc_acm_class[devno], 0, sizeof(struct usbh_cdc_acm));
|
||||
g_cdc_acm_class[devno].minor = devno;
|
||||
return &g_cdc_acm_class[devno];
|
||||
@ -34,10 +34,10 @@ static struct usbh_cdc_acm *usbh_cdc_acm_class_alloc(void)
|
||||
|
||||
static void usbh_cdc_acm_class_free(struct usbh_cdc_acm *cdc_acm_class)
|
||||
{
|
||||
int devno = cdc_acm_class->minor;
|
||||
uint8_t devno = cdc_acm_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(cdc_acm_class, 0, sizeof(struct usbh_cdc_acm));
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static int usbh_cdc_ncm_get_ntb_parameters(struct usbh_cdc_ncm *cdc_ncm_class, s
|
||||
setup->wLength = 28;
|
||||
|
||||
ret = usbh_control_transfer(cdc_ncm_class->hport, setup, g_cdc_ncm_buf);
|
||||
if (ret < 0) {
|
||||
if (ret < 8) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_hid *usbh_hid_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_HID_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_hid_class[devno], 0, sizeof(struct usbh_hid));
|
||||
g_hid_class[devno].minor = devno;
|
||||
return &g_hid_class[devno];
|
||||
@ -42,10 +42,10 @@ static struct usbh_hid *usbh_hid_class_alloc(void)
|
||||
|
||||
static void usbh_hid_class_free(struct usbh_hid *hid_class)
|
||||
{
|
||||
int devno = hid_class->minor;
|
||||
uint8_t devno = hid_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(hid_class, 0, sizeof(struct usbh_hid));
|
||||
}
|
||||
@ -67,7 +67,7 @@ static int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *b
|
||||
setup->wLength = hid_class->report_size;
|
||||
|
||||
ret = usbh_control_transfer(hid_class->hport, setup, g_hid_buf[hid_class->minor]);
|
||||
if (ret < 0) {
|
||||
if (ret < 8) {
|
||||
return ret;
|
||||
}
|
||||
memcpy(buffer, g_hid_buf[hid_class->minor], ret - 8);
|
||||
@ -109,7 +109,7 @@ int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer)
|
||||
setup->wLength = 1;
|
||||
|
||||
ret = usbh_control_transfer(hid_class->hport, setup, g_hid_buf[hid_class->minor]);
|
||||
if (ret < 0) {
|
||||
if (ret < 8) {
|
||||
return ret;
|
||||
}
|
||||
memcpy(buffer, g_hid_buf[hid_class->minor], ret - 8);
|
||||
@ -169,7 +169,7 @@ int usbh_hid_get_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t
|
||||
setup->wLength = buflen;
|
||||
|
||||
ret = usbh_control_transfer(hid_class->hport, setup, g_hid_buf[hid_class->minor]);
|
||||
if (ret < 0) {
|
||||
if (ret < 8) {
|
||||
return ret;
|
||||
}
|
||||
memcpy(buffer, g_hid_buf[hid_class->minor], ret - 8);
|
||||
|
@ -33,11 +33,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_hub *usbh_hub_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_EXTHUBS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_hub_class[devno], 0, sizeof(struct usbh_hub));
|
||||
g_hub_class[devno].index = EXTHUB_FIRST_INDEX + devno;
|
||||
return &g_hub_class[devno];
|
||||
@ -48,10 +48,10 @@ static struct usbh_hub *usbh_hub_class_alloc(void)
|
||||
|
||||
static void usbh_hub_class_free(struct usbh_hub *hub_class)
|
||||
{
|
||||
int devno = hub_class->index - EXTHUB_FIRST_INDEX;
|
||||
uint8_t devno = hub_class->index - EXTHUB_FIRST_INDEX;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(hub_class, 0, sizeof(struct usbh_hub));
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ static struct usbh_msc_modeswitch_config *g_msc_modeswitch_config = NULL;
|
||||
|
||||
static struct usbh_msc *usbh_msc_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_MSC_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_msc_class[devno], 0, sizeof(struct usbh_msc));
|
||||
g_msc_class[devno].sdchar = 'a' + devno;
|
||||
return &g_msc_class[devno];
|
||||
@ -38,10 +38,10 @@ static struct usbh_msc *usbh_msc_class_alloc(void)
|
||||
|
||||
static void usbh_msc_class_free(struct usbh_msc *msc_class)
|
||||
{
|
||||
int devno = msc_class->sdchar - 'a';
|
||||
uint8_t devno = msc_class->sdchar - 'a';
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(msc_class, 0, sizeof(struct usbh_msc));
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_xxx *usbh_xxx_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_CUSTOM_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_xxx_class[devno], 0, sizeof(struct usbh_xxx));
|
||||
g_xxx_class[devno].minor = devno;
|
||||
return &g_xxx_class[devno];
|
||||
@ -24,10 +24,10 @@ static struct usbh_xxx *usbh_xxx_class_alloc(void)
|
||||
|
||||
static void usbh_xxx_class_free(struct usbh_xxx *xxx_class)
|
||||
{
|
||||
int devno = xxx_class->minor;
|
||||
uint8_t devno = xxx_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(xxx_class, 0, sizeof(struct usbh_xxx));
|
||||
}
|
||||
|
11
class/vendor/net/usbh_asix.c
vendored
11
class/vendor/net/usbh_asix.c
vendored
@ -70,7 +70,7 @@ static int usbh_asix_read_cmd(struct usbh_asix *asix_class,
|
||||
setup->wLength = size;
|
||||
|
||||
ret = usbh_control_transfer(asix_class->hport, setup, g_asix_buf);
|
||||
if (ret < 0) {
|
||||
if (ret < 8) {
|
||||
return ret;
|
||||
}
|
||||
memcpy(data, g_asix_buf, ret - 8);
|
||||
@ -98,9 +98,12 @@ static int usbh_asix_write_cmd(struct usbh_asix *asix_class,
|
||||
setup->wIndex = index;
|
||||
setup->wLength = size;
|
||||
|
||||
memcpy(g_asix_buf, data, size);
|
||||
|
||||
return usbh_control_transfer(asix_class->hport, setup, g_asix_buf);
|
||||
if (data && size) {
|
||||
memcpy(g_asix_buf, data, size);
|
||||
return usbh_control_transfer(asix_class->hport, setup, g_asix_buf);
|
||||
} else {
|
||||
return usbh_control_transfer(asix_class->hport, setup, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int usbh_asix_mdio_write(struct usbh_asix *asix_class, int phy_id, int loc, int val)
|
||||
|
30
class/vendor/net/usbh_rtl8152.c
vendored
30
class/vendor/net/usbh_rtl8152.c
vendored
@ -961,7 +961,7 @@ static int usbh_rtl8152_read_regs(struct usbh_rtl8152 *rtl8152_class,
|
||||
setup->wLength = size;
|
||||
|
||||
ret = usbh_control_transfer(rtl8152_class->hport, setup, g_rtl8152_buf);
|
||||
if (ret < 0) {
|
||||
if (ret < 8) {
|
||||
return ret;
|
||||
}
|
||||
memcpy(data, g_rtl8152_buf, ret - 8);
|
||||
@ -997,9 +997,10 @@ static int generic_ocp_read(struct usbh_rtl8152 *tp, uint16_t index, uint16_t si
|
||||
{
|
||||
uint16_t limit = 64;
|
||||
int ret = 0;
|
||||
uint8_t *buf = data;
|
||||
|
||||
/* both size and indix must be 4 bytes align */
|
||||
if ((size & 3) || !size || (index & 3) || !data)
|
||||
if ((size & 3) || !size || (index & 3) || !buf)
|
||||
return -USB_ERR_INVAL;
|
||||
|
||||
if ((uint32_t)index + (uint32_t)size > 0xffff)
|
||||
@ -1007,20 +1008,20 @@ static int generic_ocp_read(struct usbh_rtl8152 *tp, uint16_t index, uint16_t si
|
||||
|
||||
while (size) {
|
||||
if (size > limit) {
|
||||
ret = usbh_rtl8152_read_regs(tp, index, type, limit, data);
|
||||
ret = usbh_rtl8152_read_regs(tp, index, type, limit, buf);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
index += limit;
|
||||
data += limit;
|
||||
buf += limit;
|
||||
size -= limit;
|
||||
} else {
|
||||
ret = usbh_rtl8152_read_regs(tp, index, type, size, data);
|
||||
ret = usbh_rtl8152_read_regs(tp, index, type, size, buf);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
index += size;
|
||||
data += size;
|
||||
buf += size;
|
||||
size = 0;
|
||||
break;
|
||||
}
|
||||
@ -1035,9 +1036,10 @@ static int generic_ocp_write(struct usbh_rtl8152 *tp, uint16_t index, uint16_t b
|
||||
int ret;
|
||||
uint16_t byteen_start, byteen_end, byen;
|
||||
uint16_t limit = 512;
|
||||
uint8_t *buf = data;
|
||||
|
||||
/* both size and indix must be 4 bytes align */
|
||||
if ((size & 3) || !size || (index & 3) || !data)
|
||||
if ((size & 3) || !size || (index & 3) || !buf)
|
||||
return -USB_ERR_INVAL;
|
||||
|
||||
if ((uint32_t)index + (uint32_t)size > 0xffff)
|
||||
@ -1050,12 +1052,12 @@ static int generic_ocp_write(struct usbh_rtl8152 *tp, uint16_t index, uint16_t b
|
||||
|
||||
/* Split the first DWORD if the byte_en is not 0xff */
|
||||
if (byen != BYTE_EN_DWORD) {
|
||||
ret = usbh_rtl8152_write_regs(tp, index, type | byen, 4, data);
|
||||
ret = usbh_rtl8152_write_regs(tp, index, type | byen, 4, buf);
|
||||
if (ret < 0)
|
||||
goto error1;
|
||||
|
||||
index += 4;
|
||||
data += 4;
|
||||
buf += 4;
|
||||
size -= 4;
|
||||
}
|
||||
|
||||
@ -1070,22 +1072,22 @@ static int generic_ocp_write(struct usbh_rtl8152 *tp, uint16_t index, uint16_t b
|
||||
if (size > limit) {
|
||||
ret = usbh_rtl8152_write_regs(tp, index,
|
||||
type | BYTE_EN_DWORD,
|
||||
limit, data);
|
||||
limit, buf);
|
||||
if (ret < 0)
|
||||
goto error1;
|
||||
|
||||
index += limit;
|
||||
data += limit;
|
||||
buf += limit;
|
||||
size -= limit;
|
||||
} else {
|
||||
ret = usbh_rtl8152_write_regs(tp, index,
|
||||
type | BYTE_EN_DWORD,
|
||||
size, data);
|
||||
size, buf);
|
||||
if (ret < 0)
|
||||
goto error1;
|
||||
|
||||
index += size;
|
||||
data += size;
|
||||
buf += size;
|
||||
size = 0;
|
||||
break;
|
||||
}
|
||||
@ -1093,7 +1095,7 @@ static int generic_ocp_write(struct usbh_rtl8152 *tp, uint16_t index, uint16_t b
|
||||
|
||||
/* Set the last DWORD */
|
||||
if (byen != BYTE_EN_DWORD)
|
||||
ret = usbh_rtl8152_write_regs(tp, index, type | byen, 4, data);
|
||||
ret = usbh_rtl8152_write_regs(tp, index, type | byen, 4, buf);
|
||||
}
|
||||
|
||||
error1:
|
||||
|
12
class/vendor/serial/usbh_ch34x.c
vendored
12
class/vendor/serial/usbh_ch34x.c
vendored
@ -17,11 +17,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_ch34x *usbh_ch34x_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_CP210X_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_ch34x_class[devno], 0, sizeof(struct usbh_ch34x));
|
||||
g_ch34x_class[devno].minor = devno;
|
||||
return &g_ch34x_class[devno];
|
||||
@ -32,10 +32,10 @@ static struct usbh_ch34x *usbh_ch34x_class_alloc(void)
|
||||
|
||||
static void usbh_ch34x_class_free(struct usbh_ch34x *ch34x_class)
|
||||
{
|
||||
int devno = ch34x_class->minor;
|
||||
uint8_t devno = ch34x_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(ch34x_class, 0, sizeof(struct usbh_ch34x));
|
||||
}
|
||||
|
12
class/vendor/serial/usbh_cp210x.c
vendored
12
class/vendor/serial/usbh_cp210x.c
vendored
@ -17,11 +17,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_cp210x *usbh_cp210x_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_CP210X_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_cp210x_class[devno], 0, sizeof(struct usbh_cp210x));
|
||||
g_cp210x_class[devno].minor = devno;
|
||||
return &g_cp210x_class[devno];
|
||||
@ -32,10 +32,10 @@ static struct usbh_cp210x *usbh_cp210x_class_alloc(void)
|
||||
|
||||
static void usbh_cp210x_class_free(struct usbh_cp210x *cp210x_class)
|
||||
{
|
||||
int devno = cp210x_class->minor;
|
||||
uint8_t devno = cp210x_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(cp210x_class, 0, sizeof(struct usbh_cp210x));
|
||||
}
|
||||
|
12
class/vendor/serial/usbh_ftdi.c
vendored
12
class/vendor/serial/usbh_ftdi.c
vendored
@ -17,11 +17,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_ftdi *usbh_ftdi_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_FTDI_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_ftdi_class[devno], 0, sizeof(struct usbh_ftdi));
|
||||
g_ftdi_class[devno].minor = devno;
|
||||
return &g_ftdi_class[devno];
|
||||
@ -32,10 +32,10 @@ static struct usbh_ftdi *usbh_ftdi_class_alloc(void)
|
||||
|
||||
static void usbh_ftdi_class_free(struct usbh_ftdi *ftdi_class)
|
||||
{
|
||||
int devno = ftdi_class->minor;
|
||||
uint8_t devno = ftdi_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(ftdi_class, 0, sizeof(struct usbh_ftdi));
|
||||
}
|
||||
|
12
class/vendor/serial/usbh_pl2303.c
vendored
12
class/vendor/serial/usbh_pl2303.c
vendored
@ -25,11 +25,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_pl2303 *usbh_pl2303_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_PL2303_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_pl2303_class[devno], 0, sizeof(struct usbh_pl2303));
|
||||
g_pl2303_class[devno].minor = devno;
|
||||
return &g_pl2303_class[devno];
|
||||
@ -40,10 +40,10 @@ static struct usbh_pl2303 *usbh_pl2303_class_alloc(void)
|
||||
|
||||
static void usbh_pl2303_class_free(struct usbh_pl2303 *pl2303_class)
|
||||
{
|
||||
int devno = pl2303_class->minor;
|
||||
uint8_t devno = pl2303_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(pl2303_class, 0, sizeof(struct usbh_pl2303));
|
||||
}
|
||||
|
12
class/vendor/xbox/usbh_xbox.c
vendored
12
class/vendor/xbox/usbh_xbox.c
vendored
@ -15,11 +15,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_xbox *usbh_xbox_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_XBOX_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_xbox_class[devno], 0, sizeof(struct usbh_xbox));
|
||||
g_xbox_class[devno].minor = devno;
|
||||
return &g_xbox_class[devno];
|
||||
@ -30,10 +30,10 @@ static struct usbh_xbox *usbh_xbox_class_alloc(void)
|
||||
|
||||
static void usbh_xbox_class_free(struct usbh_xbox *xbox_class)
|
||||
{
|
||||
int devno = xbox_class->minor;
|
||||
uint8_t devno = xbox_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(xbox_class, 0, sizeof(struct usbh_xbox));
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_video *usbh_video_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
uint8_t devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_VIDEO_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
memset(&g_video_class[devno], 0, sizeof(struct usbh_video));
|
||||
g_video_class[devno].minor = devno;
|
||||
return &g_video_class[devno];
|
||||
@ -49,10 +49,10 @@ static struct usbh_video *usbh_video_class_alloc(void)
|
||||
|
||||
static void usbh_video_class_free(struct usbh_video *video_class)
|
||||
{
|
||||
int devno = video_class->minor;
|
||||
uint8_t devno = video_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(video_class, 0, sizeof(struct usbh_video));
|
||||
}
|
||||
|
@ -387,14 +387,14 @@ static int usbh_rndis_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
}
|
||||
|
||||
uint32_t packet_filter = 0x0f;
|
||||
usbh_rndis_set_msg_transfer(rndis_class, OID_GEN_CURRENT_PACKET_FILTER, (uint8_t *)&packet_filter, 4);
|
||||
ret = usbh_rndis_set_msg_transfer(rndis_class, OID_GEN_CURRENT_PACKET_FILTER, (uint8_t *)&packet_filter, 4);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
USB_LOG_INFO("rndis set OID_GEN_CURRENT_PACKET_FILTER success\r\n");
|
||||
|
||||
uint8_t multicast_list[6] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0x01 };
|
||||
usbh_rndis_set_msg_transfer(rndis_class, OID_802_3_MULTICAST_LIST, multicast_list, 6);
|
||||
ret = usbh_rndis_set_msg_transfer(rndis_class, OID_802_3_MULTICAST_LIST, multicast_list, 6);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -1406,6 +1406,12 @@ int usbd_initialize(uint8_t busid, uintptr_t reg_base, void (*event_handler)(uin
|
||||
|
||||
int usbd_deinitialize(uint8_t busid)
|
||||
{
|
||||
if (busid >= CONFIG_USBDEV_MAX_BUS) {
|
||||
USB_LOG_ERR("bus overflow\r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
g_usbd_core[busid].event_handler(busid, USBD_EVENT_DEINIT);
|
||||
usbd_class_event_notify_handler(busid, USBD_EVENT_DEINIT, NULL);
|
||||
usb_dc_deinit(busid);
|
||||
|
@ -651,6 +651,12 @@ int usbh_deinitialize(uint8_t busid)
|
||||
{
|
||||
struct usbh_bus *bus;
|
||||
|
||||
if (busid >= CONFIG_USBHOST_MAX_BUS) {
|
||||
USB_LOG_ERR("bus overflow\r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
bus = &g_usbhost_bus[busid];
|
||||
|
||||
usbh_hub_deinitialize(bus);
|
||||
|
Loading…
x
Reference in New Issue
Block a user