diff options
author | Heikki Krogerus <heikki.krogerus@linux.intel.com> | 2015-09-21 04:14:32 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-09-27 11:54:31 -0400 |
commit | 63863b988eeca2823ce76b28b104e0b8366cafec (patch) | |
tree | 7b30daaebfda473f60805afeef2ed696305ddf51 /drivers/usb/common/common.c | |
parent | 58efd4b06df4a421652cb2c8a850a9697a37915c (diff) |
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>
Diffstat (limited to 'drivers/usb/common/common.c')
-rw-r--r-- | drivers/usb/common/common.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 9e39286a4e5a..b25a111903ab 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c | |||
@@ -60,6 +60,24 @@ const char *usb_speed_string(enum usb_device_speed speed) | |||
60 | } | 60 | } |
61 | EXPORT_SYMBOL_GPL(usb_speed_string); | 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 | const char *usb_state_string(enum usb_device_state state) | 81 | const char *usb_state_string(enum usb_device_state state) |
64 | { | 82 | { |
65 | static const char *const names[] = { | 83 | static const char *const names[] = { |
@@ -114,32 +132,6 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) | |||
114 | EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); | 132 | EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); |
115 | 133 | ||
116 | /** | 134 | /** |
117 | * of_usb_get_maximum_speed - Get maximum requested speed for a given USB | ||
118 | * controller. | ||
119 | * @np: Pointer to the given device_node | ||
120 | * | ||
121 | * The function gets the maximum speed string from property "maximum-speed", | ||
122 | * and returns the corresponding enum usb_device_speed. | ||
123 | */ | ||
124 | enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np) | ||
125 | { | ||
126 | const char *maximum_speed; | ||
127 | int err; | ||
128 | int i; | ||
129 | |||
130 | err = of_property_read_string(np, "maximum-speed", &maximum_speed); | ||
131 | if (err < 0) | ||
132 | return USB_SPEED_UNKNOWN; | ||
133 | |||
134 | for (i = 0; i < ARRAY_SIZE(speed_names); i++) | ||
135 | if (strcmp(maximum_speed, speed_names[i]) == 0) | ||
136 | return i; | ||
137 | |||
138 | return USB_SPEED_UNKNOWN; | ||
139 | } | ||
140 | EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed); | ||
141 | |||
142 | /** | ||
143 | * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported | 135 | * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported |
144 | * for given targeted hosts (non-PC hosts) | 136 | * for given targeted hosts (non-PC hosts) |
145 | * @np: Pointer to the given device_node | 137 | * @np: Pointer to the given device_node |