Skip to content
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

Max power is limited to uint8_t #44

Open
jackhumbert opened this issue Nov 4, 2019 · 2 comments
Open

Max power is limited to uint8_t #44

jackhumbert opened this issue Nov 4, 2019 · 2 comments

Comments

@jackhumbert
Copy link

In this struct:

struct usbg_config_attrs
{
	uint8_t bmAttributes;
	uint8_t bMaxPower;
};

the max power is limited to the uint8_t type, but the system expects the power to be set in mA, not the 2mA units that the USB spec describes, so amounts like 500 get capped to 244. Would it be appropriate to change the type in this struct, or bit shift the value provided here before passing it along to gadget? Composite specifies MaxPower as u16.

@kopasiak
Copy link
Collaborator

kopasiak commented Nov 4, 2019

Thank you for catching this.

Taken into account that we expose this structure publicly and that the name is comes straight from the spec (bMaxPower) I'd prefer to keep the same meaning as has been defined in USB spec.

Having said that I'd rather prefer to keep the meaning of this field as defined in USB spec, improve the documentation and multiply this value by 2 while writing it to the kernel.

@pabs3
Copy link
Member

pabs3 commented Jul 13, 2021

@jackhumbert would you like to prepare a pull request for the method @kopasiak suggests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants