usb gadget: USB_GADGET_VBUS_DRAW Kconfig option
[deliverable/linux.git] / drivers / usb / gadget / composite.c
index f79fdb839cb8face68082e289d9d54cde4bee250..f2da0269e1b11fa8123e6b83eadbcbd689687a33 100644 (file)
@@ -245,7 +245,7 @@ static int config_buf(struct usb_configuration *config,
        c->bConfigurationValue = config->bConfigurationValue;
        c->iConfiguration = config->iConfiguration;
        c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;
-       c->bMaxPower = config->bMaxPower;
+       c->bMaxPower = config->bMaxPower ? : (CONFIG_USB_GADGET_VBUS_DRAW / 2);
 
        /* There may be e.g. OTG descriptors */
        if (config->descriptors) {
@@ -432,7 +432,7 @@ static int set_config(struct usb_composite_dev *cdev,
        }
 
        /* when we return, be sure our power usage is valid */
-       power = 2 * c->bMaxPower;
+       power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW;
 done:
        usb_gadget_vbus_draw(gadget, power);
        return result;
This page took 0.026307 seconds and 5 git commands to generate.