usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Mon, 21 Sep 2015 08:14:32 +0000 (11:14 +0300)
committerFelipe Balbi <balbi@ti.com>
Sun, 27 Sep 2015 15:54:31 +0000 (10:54 -0500)
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>
drivers/usb/chipidea/core.c
drivers/usb/common/common.c
drivers/usb/dwc3/core.c
drivers/usb/musb/musb_dsps.c
include/linux/usb/ch9.h
include/linux/usb/of.h

index 3feebf7f31f09259249c76fa121f747a2380ff9e..ce71532324252dafd2f232b8221317248e55a6ef 100644 (file)
@@ -648,7 +648,7 @@ static int ci_get_platdata(struct device *dev,
                        return ret;
        }
 
-       if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
+       if (usb_get_maximum_speed(dev) == USB_SPEED_FULL)
                platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
 
        platdata->itc_setting = 1;
index 9e39286a4e5a1df458339cfbfd3076a3d08125ad..b25a111903ab5f42f4e6e174e16299fe2d00296b 100644 (file)
@@ -60,6 +60,24 @@ const char *usb_speed_string(enum usb_device_speed speed)
 }
 EXPORT_SYMBOL_GPL(usb_speed_string);
 
+enum usb_device_speed usb_get_maximum_speed(struct device *dev)
+{
+       const char *maximum_speed;
+       int err;
+       int i;
+
+       err = device_property_read_string(dev, "maximum-speed", &maximum_speed);
+       if (err < 0)
+               return USB_SPEED_UNKNOWN;
+
+       for (i = 0; i < ARRAY_SIZE(speed_names); i++)
+               if (strcmp(maximum_speed, speed_names[i]) == 0)
+                       return i;
+
+       return USB_SPEED_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(usb_get_maximum_speed);
+
 const char *usb_state_string(enum usb_device_state state)
 {
        static const char *const names[] = {
@@ -113,32 +131,6 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
 }
 EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
 
-/**
- * of_usb_get_maximum_speed - Get maximum requested speed for a given USB
- * controller.
- * @np: Pointer to the given device_node
- *
- * The function gets the maximum speed string from property "maximum-speed",
- * and returns the corresponding enum usb_device_speed.
- */
-enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np)
-{
-       const char *maximum_speed;
-       int err;
-       int i;
-
-       err = of_property_read_string(np, "maximum-speed", &maximum_speed);
-       if (err < 0)
-               return USB_SPEED_UNKNOWN;
-
-       for (i = 0; i < ARRAY_SIZE(speed_names); i++)
-               if (strcmp(maximum_speed, speed_names[i]) == 0)
-                       return i;
-
-       return USB_SPEED_UNKNOWN;
-}
-EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed);
-
 /**
  * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported
  * for given targeted hosts (non-PC hosts)
index cfbcebe2cf8fa69a414b2c1008ef22650b362622..61a56357baf0e8130dcb4440da9d95eb1879fde6 100644 (file)
@@ -870,8 +870,9 @@ static int dwc3_probe(struct platform_device *pdev)
         */
        hird_threshold = 12;
 
+       dwc->maximum_speed = usb_get_maximum_speed(dev);
+
        if (node) {
-               dwc->maximum_speed = of_usb_get_maximum_speed(node);
                dwc->has_lpm_erratum = of_property_read_bool(node,
                                "snps,has-lpm-erratum");
                of_property_read_u8(node, "snps,lpm-nyet-threshold",
index c8b2ec9a79d6f6ea839764e66614fd2d73421d7f..c6a69eaf280f09170d56febc24ac8aef49102dc0 100644 (file)
@@ -747,7 +747,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
        if (!ret && val)
                config->multipoint = true;
 
-       config->maximum_speed = of_usb_get_maximum_speed(dn);
+       config->maximum_speed = usb_get_maximum_speed(&parent->dev);
        switch (config->maximum_speed) {
        case USB_SPEED_LOW:
        case USB_SPEED_FULL:
index 27603bcbb9b99dccd86f9ac7f720e13fde4c8bd0..6cc96bb12ddcf4f02fae841b801b3a9870ca5c2a 100644 (file)
@@ -32,9 +32,9 @@
 #ifndef __LINUX_USB_CH9_H
 #define __LINUX_USB_CH9_H
 
+#include <linux/device.h>
 #include <uapi/linux/usb/ch9.h>
 
-
 /**
  * usb_speed_string() - Returns human readable-name of the speed.
  * @speed: The speed to return human-readable name for.  If it's not
  */
 extern const char *usb_speed_string(enum usb_device_speed speed);
 
+/**
+ * usb_get_maximum_speed - Get maximum requested speed for a given USB
+ * controller.
+ * @dev: Pointer to the given USB controller device
+ *
+ * The function gets the maximum speed string from property "maximum-speed",
+ * and returns the corresponding enum usb_device_speed.
+ */
+extern enum usb_device_speed usb_get_maximum_speed(struct device *dev);
 
 /**
  * usb_state_string - Returns human readable name for the state.
index 8c5a818ec2447aca31ce542e1cbb087f7b6fb04e..ff23fea49fcade61141be25f6c45412b7d5de4dc 100644 (file)
@@ -13,7 +13,6 @@
 
 #if IS_ENABLED(CONFIG_OF)
 enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
-enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np);
 bool of_usb_host_tpl_support(struct device_node *np);
 int of_usb_update_otg_caps(struct device_node *np,
                        struct usb_otg_caps *otg_caps);
@@ -23,11 +22,6 @@ static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
        return USB_DR_MODE_UNKNOWN;
 }
 
-static inline enum usb_device_speed
-of_usb_get_maximum_speed(struct device_node *np)
-{
-       return USB_SPEED_UNKNOWN;
-}
 static inline bool of_usb_host_tpl_support(struct device_node *np)
 {
        return false;