summaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/berry_charge.c
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2008-02-01 22:44:40 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 09:59:51 -0800
commitb404299f6bfdf5aa7315e521b570e33f082b2f9e (patch)
tree1af44c227e952a47c386d4b5d2b9b50ad1de00c8 /drivers/usb/misc/berry_charge.c
parentff8973d9468ea07e61ef492dd8c806a6e1a76ac1 (diff)
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 <oneukum@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc/berry_charge.c')
-rw-r--r--drivers/usb/misc/berry_charge.c5
1 files changed, 5 insertions, 0 deletions
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);