From: Oliver Neukum Date: Fri, 1 Feb 2008 21:44:40 +0000 (+0100) Subject: USB: power availability check for berry_charge X-Git-Tag: v2.6.29-rc1~182^2~107 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=b404299f6bfdf5aa7315e521b570e33f082b2f9e;p=linux-2.6-omap-h63xx.git USB: power availability check for berry_charge this introduces a sanity check into berry_charge to give up before damage is done if we lack juice. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/misc/berry_charge.c b/drivers/usb/misc/berry_charge.c index 24e2dc3148a..c05a85bc592 100644 --- a/drivers/usb/misc/berry_charge.c +++ b/drivers/usb/misc/berry_charge.c @@ -123,6 +123,11 @@ static int berry_probe(struct usb_interface *intf, { struct usb_device *udev = interface_to_usbdev(intf); + if (udev->bus_mA < 500) { + dbg(&udev->dev, "Not enough power to charge available\n"); + return -ENODEV; + } + dbg(&udev->dev, "Power is set to %dmA\n", udev->actconfig->desc.bMaxPower * 2);