Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92a0e909 authored by Linus Walleij's avatar Linus Walleij Committed by Greg Kroah-Hartman
Browse files

usb: fotg210-udc: Fix ages old endianness issues



[ Upstream commit 46ed6026ca2181c917c8334a82e3eaf40a6234dd ]

The code in the FOTG210 driver isn't entirely endianness-agnostic
as reported by the kernel robot sparse testing. This came to
the surface while moving the files around.

The driver is only used on little-endian systems, so this causes
no real-world regression, but it is nice to be strict and have
some compile coverage also on big endian machines, so fix it
up with the right LE accessors.

Fixes: b84a8dee ("usb: gadget: add Faraday fotg210_udc driver")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-usb/202211110910.0dJ7nZCn-lkp@intel.com/


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20221111090317.94228-1-linus.walleij@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 35a27f38
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -636,10 +636,10 @@ static void fotg210_request_error(struct fotg210_udc *fotg210)
static void fotg210_set_address(struct fotg210_udc *fotg210,
				struct usb_ctrlrequest *ctrl)
{
	if (ctrl->wValue >= 0x0100) {
	if (le16_to_cpu(ctrl->wValue) >= 0x0100) {
		fotg210_request_error(fotg210);
	} else {
		fotg210_set_dev_addr(fotg210, ctrl->wValue);
		fotg210_set_dev_addr(fotg210, le16_to_cpu(ctrl->wValue));
		fotg210_set_cxdone(fotg210);
	}
}
@@ -720,17 +720,17 @@ static void fotg210_get_status(struct fotg210_udc *fotg210,

	switch (ctrl->bRequestType & USB_RECIP_MASK) {
	case USB_RECIP_DEVICE:
		fotg210->ep0_data = 1 << USB_DEVICE_SELF_POWERED;
		fotg210->ep0_data = cpu_to_le16(1 << USB_DEVICE_SELF_POWERED);
		break;
	case USB_RECIP_INTERFACE:
		fotg210->ep0_data = 0;
		fotg210->ep0_data = cpu_to_le16(0);
		break;
	case USB_RECIP_ENDPOINT:
		epnum = ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK;
		if (epnum)
			fotg210->ep0_data =
				fotg210_is_epnstall(fotg210->ep[epnum])
				<< USB_ENDPOINT_HALT;
				cpu_to_le16(fotg210_is_epnstall(fotg210->ep[epnum])
					    << USB_ENDPOINT_HALT);
		else
			fotg210_request_error(fotg210);
		break;