24 static inline const char *plural(
int n)
26 return (n == 1 ?
"" :
"s");
47 int insufficient_power = 0;
48 struct usb_host_config *
c, *best;
52 num_configs = udev->descriptor.bNumConfigurations;
53 for (i = 0; i < num_configs; (i++, c++)) {
57 if (c->desc.bNumInterfaces > 0)
58 desc = &c->intf_cache[0]->altsetting->desc;
82 if (bus_powered && (c->desc.bmAttributes &
100 if (c->desc.bMaxPower * 2 > udev->bus_mA) {
101 insufficient_power++;
110 if (i == 0 && num_configs > 1 && desc &&
112 #if !defined(CONFIG_USB_NET_RNDIS_HOST) && !defined(CONFIG_USB_NET_RNDIS_HOST_MODULE)
123 else if (udev->descriptor.bDeviceClass !=
137 if (insufficient_power > 0)
138 dev_info(&udev->dev,
"rejected %d configuration%s "
139 "due to insufficient available bus power\n",
140 insufficient_power, plural(insufficient_power));
143 i = best->desc.bConfigurationValue;
145 "configuration #%d chosen from %d choice%s\n",
146 i, num_configs, plural(num_configs));
150 "no configuration chosen from %d choice%s\n",
151 num_configs, plural(num_configs));
156 static int generic_probe(
struct usb_device *
udev)
165 else if (udev->authorized == 0)
166 dev_err(&udev->dev,
"Device is not authorized for usage\n");
172 dev_err(&udev->dev,
"can't set config #%d, error %d\n",
185 static void generic_disconnect(
struct usb_device *udev)
207 rc = hcd_bus_suspend(udev, msg);
213 rc = usb_port_suspend(udev, msg);
218 static int generic_resume(
struct usb_device *udev,
pm_message_t msg)
228 rc = hcd_bus_resume(udev, msg);
230 rc = usb_port_resume(udev, msg);
238 .probe = generic_probe,
239 .disconnect = generic_disconnect,
241 .suspend = generic_suspend,
242 .resume = generic_resume,
244 .supports_autosuspend = 1,