Re: [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10.05.2019 16:55, Chris Brandt wrote:

+	} else {
+		/* Not OTG, so dr_mode should be set in PHY node */
+		mode = usb_get_dr_mode(channel->dev);
+		if (mode == USB_DR_MODE_HOST)
+			writel(0x00000000, usb2_base + USB2_COMMCTRL);
+		else if (mode == USB_DR_MODE_PERIPHERAL)
+			writel(0x80000000, usb2_base + USB2_COMMCTRL);

     Maybe a *switch* instead?

I like that idea because I can get rid of the dr_mode variable.

   Yes. :-)

However...
I just tried it, but if I only have a case for HOST and PERIPHERAL, I
get this gcc warning:

   warning: enumeration value ‘USB_DR_MODE_UNKNOWN’ not handled in switch [-Wswitch]
   warning: enumeration value ‘USB_DR_MODE_OTG’ not handled in switch [-Wswitch]


So, my code would have to be:

	} else {
		/* Not OTG, so dr_mode should be set in PHY node */
		switch (usb_get_dr_mode(channel->dev)) {
		case USB_DR_MODE_HOST:
			writel(0x00000000, usb2_base + USB2_COMMCTRL);
			break;
		case USB_DR_MODE_PERIPHERAL:
			writel(0x80000000, usb2_base + USB2_COMMCTRL);
			break;
		case USB_DR_MODE_UNKNOWN:
		case USB_DR_MODE_OTG:

   Maybe default: instead?

			break;
		}
	}

I guess that is still OK.

   Yes. :-)

Chris

MBR, Sergei



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux