-
Notifications
You must be signed in to change notification settings - Fork 7.6k
usb: device_next: allow to pass maximum possible MPS value to drivers #92831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,8 +198,36 @@ int udc_ep_enable_internal(const struct device *dev, | |
const uint8_t ep, | ||
const uint8_t attributes, | ||
const uint16_t mps, | ||
const uint16_t m_mps, | ||
const uint8_t interval); | ||
|
||
/** | ||
* @brief Helper function to enable control endpoint. | ||
* | ||
* This function can be used by the driver to enable control endpoint. | ||
* | ||
* @param[in] dev Pointer to device struct of the driver instance | ||
* @param[in] mps Maximum packet size (same as wMaxPacketSize) | ||
* | ||
* @return 0 on success, all other values should be treated as error. | ||
* @retval -ENODEV endpoint is not assigned or no configuration found | ||
* @retval -EALREADY endpoint is already enabled | ||
*/ | ||
static inline int udc_ep_enable_control(const struct device *dev, | ||
const uint16_t mps) | ||
{ | ||
int err; | ||
|
||
err = udc_ep_enable_internal(dev, USB_CONTROL_EP_OUT, | ||
USB_EP_TYPE_CONTROL, mps, mps, 0); | ||
if (err) { | ||
return err; | ||
} | ||
|
||
return udc_ep_enable_internal(dev, USB_CONTROL_EP_IN, | ||
USB_EP_TYPE_CONTROL, mps, mps, 0); | ||
} | ||
|
||
/** | ||
* @brief Helper function to disable endpoint. | ||
* | ||
|
@@ -215,6 +243,27 @@ int udc_ep_enable_internal(const struct device *dev, | |
int udc_ep_disable_internal(const struct device *dev, | ||
const uint8_t ep); | ||
|
||
/** | ||
* @brief Helper function to disable control endpoint. | ||
* | ||
* This function can be used by the driver to disable control endpoint. | ||
* | ||
* @param[in] dev Pointer to device struct of the driver instance | ||
* | ||
* @return 0 on success, all other values should be treated as error. | ||
* @retval -ENODEV endpoint is not assigned or no configuration found | ||
* @retval -EALREADY endpoint is already enabled | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
*/ | ||
static inline int udc_ep_disable_control(const struct device *dev) | ||
{ | ||
int err1, err2; | ||
|
||
err1 = udc_ep_disable_internal(dev, USB_CONTROL_EP_IN); | ||
err2 = udc_ep_disable_internal(dev, USB_CONTROL_EP_OUT); | ||
|
||
return err1 ? err1 : err2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This modifies the sequence that is performed on endpoint disable. Now the disable function will be called on both IN and OUT (before it was called first on OUT and then on IN) regardless of the returned error. Before first OUT endpoint was disabled and then IN endpoint was disabled only if OUT endpoint disable succeeded. |
||
} | ||
|
||
/** | ||
* @brief Helper function to register endpoint configuration. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like copy&paste error, if endpoint is "already enabled" then disable should succeed.