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 Fri, May 10, 2019, Sergei Shtylyov 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.

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:
			break;
		}
	}

I guess that is still OK.

Chris





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux