Skip to content

Commit

Permalink
USB: power availability check for berry_charge
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Jan 7, 2009
1 parent ff8973d commit b404299
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/usb/misc/berry_charge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b404299

Please sign in to comment.