On 07/01/2013 09:18 AM, Felipe Balbi wrote: > diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c > index 675384d..b87f202 100644 > --- a/drivers/usb/usb-common.c > +++ b/drivers/usb/usb-common.c > @@ -112,6 +112,41 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) > return USB_DR_MODE_UNKNOWN; > } > EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); > + > +static const char *const usb_maximum_speed[] = { > + [USB_SPEED_UNKNOWN] = "", > + [USB_SPEED_LOW] = "lowspeed", > + [USB_SPEED_FULL] = "fullspeed", > + [USB_SPEED_HIGH] = "highspeed", > + [USB_SPEED_SUPER] = "superspeed", I somehow would love if you could move that table + the lookup function into usb-common where allready have the reverse one called usb_speed_string(). Then we could have always "low-speed" instead mixing the wording. Also it would be nice if you would Cc: the devicetree-discuss@ folks and document the binding in Documentation/devicetree/bindings/usb/ > +}; > + > +/** > + * 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(usb_maximum_speed); i++) > + if (strcmp(maximum_speed, usb_maximum_speed[i]) == 0) > + return i; > + > + return USB_SPEED_UNKNOWN; This looks tricky. If you copy that property unconditionally than you will end up with UNKNOWN speed if that property is missing and no gadget will load, right? If so, maybe a second argument would be nice which would be used as the default speed if none is found in DT. Unless you want to do that check in each and every driver. Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html