To avoid the code duplication, please add a static function with this code that usb_set_ep_rx_buf0_count() and usb_set_ep_rx_count() can both call out to.