提交 1fac1c4d 编写于 作者: L Linus Walleij 提交者: Greg Kroah-Hartman

usb: fotg210: Select subdriver by mode

Check which mode the hardware is in, and selecte the peripheral
driver if the hardware is in explicit peripheral mode, otherwise
select host mode.

This should solve the immediate problem that both subdrivers
can get probed.

Cc: Fabian Vogt <fabian@ritter-vogt.de>
Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Cc: Felipe Balbi <balbi@kernel.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20221023144708.3596563-3-linus.walleij@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 aeffd2c3
...@@ -10,30 +10,37 @@ ...@@ -10,30 +10,37 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/otg.h>
#include "fotg210.h" #include "fotg210.h"
static int fotg210_probe(struct platform_device *pdev) static int fotg210_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
enum usb_dr_mode mode;
int ret; int ret;
if (IS_ENABLED(CONFIG_USB_FOTG210_HCD)) { mode = usb_get_dr_mode(dev);
ret = fotg210_hcd_probe(pdev);
if (ret) if (mode == USB_DR_MODE_PERIPHERAL)
return ret;
}
if (IS_ENABLED(CONFIG_USB_FOTG210_UDC))
ret = fotg210_udc_probe(pdev); ret = fotg210_udc_probe(pdev);
else
ret = fotg210_hcd_probe(pdev);
return ret; return ret;
} }
static int fotg210_remove(struct platform_device *pdev) static int fotg210_remove(struct platform_device *pdev)
{ {
if (IS_ENABLED(CONFIG_USB_FOTG210_HCD)) struct device *dev = &pdev->dev;
fotg210_hcd_remove(pdev); enum usb_dr_mode mode;
if (IS_ENABLED(CONFIG_USB_FOTG210_UDC))
mode = usb_get_dr_mode(dev);
if (mode == USB_DR_MODE_PERIPHERAL)
fotg210_udc_remove(pdev); fotg210_udc_remove(pdev);
else
fotg210_hcd_remove(pdev);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册