1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-23 02:16:41 +00:00

usb: Refactor some variables

This commit is contained in:
CTCaer 2020-11-26 01:55:33 +02:00
parent caae685fab
commit b89bb35054

View file

@ -868,7 +868,7 @@ int usbd_set_ep_stall(u32 endpoint, int ep_stall)
return USB_RES_OK; return USB_RES_OK;
} }
static void _usbd_handle_get_class_request(bool *transmit_data, u8 *descriptor, int *size, int *ep_stall) static void _usbd_handle_get_class_request(bool *transmit_data, u8 *descriptor, int *size, bool *ep_stall)
{ {
u8 _bRequest = usbd_otg->control_setup.bRequest; u8 _bRequest = usbd_otg->control_setup.bRequest;
u16 _wIndex = usbd_otg->control_setup.wIndex; u16 _wIndex = usbd_otg->control_setup.wIndex;
@ -880,7 +880,7 @@ static void _usbd_handle_get_class_request(bool *transmit_data, u8 *descriptor,
if (!valid_interface || _wValue != 0 || _wLength != valid_len) if (!valid_interface || _wValue != 0 || _wLength != valid_len)
{ {
*ep_stall = 1; *ep_stall = true;
return; return;
} }
@ -897,12 +897,12 @@ static void _usbd_handle_get_class_request(bool *transmit_data, u8 *descriptor,
usbd_otg->max_lun_set = true; usbd_otg->max_lun_set = true;
break; break;
default: default:
*ep_stall = 1; *ep_stall = true;
break; break;
} }
} }
static void _usbd_handle_get_descriptor(bool *transmit_data, void **descriptor, int *size, int *ep_stall) static void _usbd_handle_get_descriptor(bool *transmit_data, void **descriptor, int *size, bool *ep_stall)
{ {
u8 descriptor_type = usbd_otg->control_setup.wValue >> 8; u8 descriptor_type = usbd_otg->control_setup.wValue >> 8;
u8 descriptor_subtype = usbd_otg->control_setup.wValue & 0xFF; u8 descriptor_subtype = usbd_otg->control_setup.wValue & 0xFF;
@ -1018,16 +1018,16 @@ static void _usbd_handle_get_descriptor(bool *transmit_data, void **descriptor,
return; return;
default: default:
*transmit_data = false; *transmit_data = false;
*ep_stall = 1; *ep_stall = true;
return; return;
} }
exit: exit:
*transmit_data = false; *transmit_data = false;
*ep_stall = 1; *ep_stall = true;
return; return;
} }
static int _usbd_handle_set_request(int *ep_stall) static int _usbd_handle_set_request(bool *ep_stall)
{ {
int res = USB_RES_OK; int res = USB_RES_OK;
u8 bRequest = usbd_otg->control_setup.bRequest; u8 bRequest = usbd_otg->control_setup.bRequest;
@ -1051,7 +1051,7 @@ static int _usbd_handle_set_request(int *ep_stall)
} }
} }
else else
*ep_stall = 1; *ep_stall = true;
return res; return res;
} }
@ -1059,11 +1059,11 @@ static int _usbd_handle_set_request(int *ep_stall)
static int _usbd_handle_ep0_control_transfer() static int _usbd_handle_ep0_control_transfer()
{ {
int res = USB_RES_OK; int res = USB_RES_OK;
bool ep_stall = false;
bool transmit_data = false; bool transmit_data = false;
u8 *descriptor = (u8 *)USB_DESCRIPTOR_ADDR; u8 *descriptor = (u8 *)USB_DESCRIPTOR_ADDR;
int size = 0; int size = 0;
int ep_stall = 0;
u8 _bmRequestType = usbd_otg->control_setup.bmRequestType; u8 _bmRequestType = usbd_otg->control_setup.bmRequestType;
u8 _bRequest = usbd_otg->control_setup.bRequest; u8 _bRequest = usbd_otg->control_setup.bRequest;
@ -1124,7 +1124,7 @@ static int _usbd_handle_ep0_control_transfer()
break; break;
default: default:
ep_stall = 1; ep_stall = true;
break; break;
} }
break; break;
@ -1152,7 +1152,7 @@ static int _usbd_handle_ep0_control_transfer()
transmit_data = true; transmit_data = true;
break; break;
default: default:
ep_stall = 1; ep_stall = true;
break; break;
} }
break; break;
@ -1186,7 +1186,7 @@ static int _usbd_handle_ep0_control_transfer()
} }
else else
{ {
ep_stall = 1; ep_stall = true;
break; break;
} }
@ -1201,17 +1201,17 @@ static int _usbd_handle_ep0_control_transfer()
int ep_req; int ep_req;
switch (_wIndex) switch (_wIndex)
{ {
case 0: case USB_EP_ADDR_CTRL_OUT:
ep_req = 0; ep_req = USB_EP_CTRL_OUT;
break; break;
case 1: case USB_EP_ADDR_BULK_OUT:
ep_req = 2; ep_req = USB_EP_BULK_OUT;
break; break;
case 0x80: case USB_EP_ADDR_CTRL_IN:
ep_req = 1; ep_req = USB_EP_CTRL_IN;
break; break;
case 0x81: case USB_EP_ADDR_BULK_IN:
ep_req = 3; ep_req = USB_EP_BULK_IN;
break; break;
default: default:
_usbd_stall_reset_ep1(3, USB_EP_CFG_STALL); _usbd_stall_reset_ep1(3, USB_EP_CFG_STALL);
@ -1254,16 +1254,16 @@ static int _usbd_handle_ep0_control_transfer()
transmit_data = true; transmit_data = true;
break; break;
default: default:
ep_stall = 1; ep_stall = true;
break; break;
} }
} }
else else
ep_stall = 1; ep_stall = true;
break; break;
default: default:
ep_stall = 1; ep_stall = true;
break; break;
} }