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

usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed

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
63863b98 58efd4b0

+32 -36
+1 -1
drivers/usb/chipidea/core.c
··· 648 648 return ret; 649 649 } 650 650 651 - if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) 651 + if (usb_get_maximum_speed(dev) == USB_SPEED_FULL) 652 652 platdata->flags |= CI_HDRC_FORCE_FULLSPEED; 653 653 654 654 platdata->itc_setting = 1;
+18 -26
drivers/usb/common/common.c
··· 60 60 } 61 61 EXPORT_SYMBOL_GPL(usb_speed_string); 62 62 63 + enum usb_device_speed usb_get_maximum_speed(struct device *dev) 64 + { 65 + const char *maximum_speed; 66 + int err; 67 + int i; 68 + 69 + err = device_property_read_string(dev, "maximum-speed", &maximum_speed); 70 + if (err < 0) 71 + return USB_SPEED_UNKNOWN; 72 + 73 + for (i = 0; i < ARRAY_SIZE(speed_names); i++) 74 + if (strcmp(maximum_speed, speed_names[i]) == 0) 75 + return i; 76 + 77 + return USB_SPEED_UNKNOWN; 78 + } 79 + EXPORT_SYMBOL_GPL(usb_get_maximum_speed); 80 + 63 81 const char *usb_state_string(enum usb_device_state state) 64 82 { 65 83 static const char *const names[] = { ··· 130 112 return USB_DR_MODE_UNKNOWN; 131 113 } 132 114 EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); 133 - 134 - /** 135 - * of_usb_get_maximum_speed - Get maximum requested speed for a given USB 136 - * controller. 137 - * @np: Pointer to the given device_node 138 - * 139 - * The function gets the maximum speed string from property "maximum-speed", 140 - * and returns the corresponding enum usb_device_speed. 141 - */ 142 - enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np) 143 - { 144 - const char *maximum_speed; 145 - int err; 146 - int i; 147 - 148 - err = of_property_read_string(np, "maximum-speed", &maximum_speed); 149 - if (err < 0) 150 - return USB_SPEED_UNKNOWN; 151 - 152 - for (i = 0; i < ARRAY_SIZE(speed_names); i++) 153 - if (strcmp(maximum_speed, speed_names[i]) == 0) 154 - return i; 155 - 156 - return USB_SPEED_UNKNOWN; 157 - } 158 - EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed); 159 115 160 116 /** 161 117 * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported
+2 -1
drivers/usb/dwc3/core.c
··· 870 870 */ 871 871 hird_threshold = 12; 872 872 873 + dwc->maximum_speed = usb_get_maximum_speed(dev); 874 + 873 875 if (node) { 874 - dwc->maximum_speed = of_usb_get_maximum_speed(node); 875 876 dwc->has_lpm_erratum = of_property_read_bool(node, 876 877 "snps,has-lpm-erratum"); 877 878 of_property_read_u8(node, "snps,lpm-nyet-threshold",
+1 -1
drivers/usb/musb/musb_dsps.c
··· 747 747 if (!ret && val) 748 748 config->multipoint = true; 749 749 750 - config->maximum_speed = of_usb_get_maximum_speed(dn); 750 + config->maximum_speed = usb_get_maximum_speed(&parent->dev); 751 751 switch (config->maximum_speed) { 752 752 case USB_SPEED_LOW: 753 753 case USB_SPEED_FULL:
+10 -1
include/linux/usb/ch9.h
··· 32 32 #ifndef __LINUX_USB_CH9_H 33 33 #define __LINUX_USB_CH9_H 34 34 35 + #include <linux/device.h> 35 36 #include <uapi/linux/usb/ch9.h> 36 - 37 37 38 38 /** 39 39 * usb_speed_string() - Returns human readable-name of the speed. ··· 43 43 */ 44 44 extern const char *usb_speed_string(enum usb_device_speed speed); 45 45 46 + /** 47 + * usb_get_maximum_speed - Get maximum requested speed for a given USB 48 + * controller. 49 + * @dev: Pointer to the given USB controller device 50 + * 51 + * The function gets the maximum speed string from property "maximum-speed", 52 + * and returns the corresponding enum usb_device_speed. 53 + */ 54 + extern enum usb_device_speed usb_get_maximum_speed(struct device *dev); 46 55 47 56 /** 48 57 * usb_state_string - Returns human readable name for the state.
-6
include/linux/usb/of.h
··· 13 13 14 14 #if IS_ENABLED(CONFIG_OF) 15 15 enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); 16 - enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); 17 16 bool of_usb_host_tpl_support(struct device_node *np); 18 17 int of_usb_update_otg_caps(struct device_node *np, 19 18 struct usb_otg_caps *otg_caps); ··· 22 23 return USB_DR_MODE_UNKNOWN; 23 24 } 24 25 25 - static inline enum usb_device_speed 26 - of_usb_get_maximum_speed(struct device_node *np) 27 - { 28 - return USB_SPEED_UNKNOWN; 29 - } 30 26 static inline bool of_usb_host_tpl_support(struct device_node *np) 31 27 { 32 28 return false;