Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: common: of_usb_get_dr_mode to usb_get_dr_mode

By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Heikki Krogerus and committed by
Felipe Balbi
06e7114f 66647273

+21 -25
+1 -1
drivers/usb/chipidea/core.c
··· 611 611 platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); 612 612 613 613 if (!platdata->dr_mode) 614 - platdata->dr_mode = of_usb_get_dr_mode(dev->of_node); 614 + platdata->dr_mode = usb_get_dr_mode(dev); 615 615 616 616 if (platdata->dr_mode == USB_DR_MODE_UNKNOWN) 617 617 platdata->dr_mode = USB_DR_MODE_OTG;
+4 -11
drivers/usb/common/common.c
··· 99 99 } 100 100 EXPORT_SYMBOL_GPL(usb_state_string); 101 101 102 - #ifdef CONFIG_OF 103 102 static const char *const usb_dr_modes[] = { 104 103 [USB_DR_MODE_UNKNOWN] = "", 105 104 [USB_DR_MODE_HOST] = "host", ··· 106 107 [USB_DR_MODE_OTG] = "otg", 107 108 }; 108 109 109 - /** 110 - * of_usb_get_dr_mode - Get dual role mode for given device_node 111 - * @np: Pointer to the given device_node 112 - * 113 - * The function gets phy interface string from property 'dr_mode', 114 - * and returns the correspondig enum usb_dr_mode 115 - */ 116 - enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) 110 + enum usb_dr_mode usb_get_dr_mode(struct device *dev) 117 111 { 118 112 const char *dr_mode; 119 113 int err, i; 120 114 121 - err = of_property_read_string(np, "dr_mode", &dr_mode); 115 + err = device_property_read_string(dev, "dr_mode", &dr_mode); 122 116 if (err < 0) 123 117 return USB_DR_MODE_UNKNOWN; 124 118 ··· 121 129 122 130 return USB_DR_MODE_UNKNOWN; 123 131 } 124 - EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); 132 + EXPORT_SYMBOL_GPL(usb_get_dr_mode); 125 133 134 + #ifdef CONFIG_OF 126 135 /** 127 136 * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported 128 137 * for given targeted hosts (non-PC hosts)
+1 -1
drivers/usb/dwc2/platform.c
··· 220 220 dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n", 221 221 (unsigned long)res->start, hsotg->regs); 222 222 223 - hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node); 223 + hsotg->dr_mode = usb_get_dr_mode(&dev->dev); 224 224 225 225 /* 226 226 * Attempt to find a generic PHY, then look for an old style
+1 -1
drivers/usb/dwc3/core.c
··· 871 871 hird_threshold = 12; 872 872 873 873 dwc->maximum_speed = usb_get_maximum_speed(dev); 874 + dwc->dr_mode = usb_get_dr_mode(dev); 874 875 875 876 if (node) { 876 877 dwc->has_lpm_erratum = of_property_read_bool(node, ··· 887 886 888 887 dwc->needs_fifo_resize = of_property_read_bool(node, 889 888 "tx-fifo-resize"); 890 - dwc->dr_mode = of_usb_get_dr_mode(node); 891 889 892 890 dwc->disable_scramble_quirk = of_property_read_bool(node, 893 891 "snps,disable_scramble_quirk");
+1 -1
drivers/usb/dwc3/dwc3-st.c
··· 268 268 goto undo_softreset; 269 269 } 270 270 271 - dwc3_data->dr_mode = of_usb_get_dr_mode(child_pdev->dev.of_node); 271 + dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev); 272 272 273 273 /* 274 274 * Configure the USB port as device or host according to the static
+1 -1
drivers/usb/musb/musb_dsps.c
··· 666 666 { 667 667 enum usb_dr_mode mode; 668 668 669 - mode = of_usb_get_dr_mode(dev->of_node); 669 + mode = usb_get_dr_mode(dev); 670 670 switch (mode) { 671 671 case USB_DR_MODE_HOST: 672 672 return MUSB_PORT_MODE_HOST;
+1 -1
drivers/usb/musb/sunxi.c
··· 617 617 return -ENOMEM; 618 618 619 619 memset(&pdata, 0, sizeof(pdata)); 620 - switch (of_usb_get_dr_mode(np)) { 620 + switch (usb_get_dr_mode(&pdev->dev)) { 621 621 #if defined CONFIG_USB_MUSB_DUAL_ROLE || defined CONFIG_USB_MUSB_HOST 622 622 case USB_DR_MODE_HOST: 623 623 pdata.mode = MUSB_PORT_MODE_HOST;
+1 -1
drivers/usb/phy/phy-msm-usb.c
··· 1529 1529 if (IS_ERR(motg->phy_rst)) 1530 1530 motg->phy_rst = NULL; 1531 1531 1532 - pdata->mode = of_usb_get_dr_mode(node); 1532 + pdata->mode = usb_get_dr_mode(&pdev->dev); 1533 1533 if (pdata->mode == USB_DR_MODE_UNKNOWN) 1534 1534 pdata->mode = USB_DR_MODE_OTG; 1535 1535
+1 -1
drivers/usb/phy/phy-tegra-usb.c
··· 1029 1029 } 1030 1030 1031 1031 if (of_find_property(np, "dr_mode", NULL)) 1032 - tegra_phy->mode = of_usb_get_dr_mode(np); 1032 + tegra_phy->mode = usb_get_dr_mode(&pdev->dev); 1033 1033 else 1034 1034 tegra_phy->mode = USB_DR_MODE_HOST; 1035 1035
-6
include/linux/usb/of.h
··· 12 12 #include <linux/usb/phy.h> 13 13 14 14 #if IS_ENABLED(CONFIG_OF) 15 - enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); 16 15 bool of_usb_host_tpl_support(struct device_node *np); 17 16 int of_usb_update_otg_caps(struct device_node *np, 18 17 struct usb_otg_caps *otg_caps); 19 18 #else 20 - static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) 21 - { 22 - return USB_DR_MODE_UNKNOWN; 23 - } 24 - 25 19 static inline bool of_usb_host_tpl_support(struct device_node *np) 26 20 { 27 21 return false;
+9
include/linux/usb/otg.h
··· 119 119 USB_DR_MODE_OTG, 120 120 }; 121 121 122 + /** 123 + * usb_get_dr_mode - Get dual role mode for given device 124 + * @dev: Pointer to the given device 125 + * 126 + * The function gets phy interface string from property 'dr_mode', 127 + * and returns the correspondig enum usb_dr_mode 128 + */ 129 + extern enum usb_dr_mode usb_get_dr_mode(struct device *dev); 130 + 122 131 #endif /* __LINUX_USB_OTG_H */