@@ -306,6 +306,15 @@ static int usb_probe_interface(struct device *dev)
dev_dbg(dev, "%s - got id\n", __func__);
+ if (driver->num_endpoints &&
+ intf->altsetting[0].desc.bNumEndpoints < driver->num_endpoints) {
+
+ dev_err(dev, "Not enough endpoints %d (want %d)\n",
+ intf->altsetting[0].desc.bNumEndpoints,
+ driver->num_endpoints);
+ return -EINVAL;
+ }
+
error = usb_autoresume_device(udev);
if (error)
return error;
@@ -1051,6 +1051,11 @@ struct usbdrv_wrap {
* @id_table: USB drivers use ID table to support hotplugging.
* Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
* or your driver's probe function will never get called.
+ * @num_endpoints: Number of endpoints that should be present in default
+ * setting (altsetting 0) the driver needs to operate properly.
+ * The probe will be aborted if actual number of endpoints is less
+ * than what the driver specified here. 0 means no check should be
+ * performed.
* @dynids: used internally to hold the list of dynamically added device
* ids for this driver.
* @drvwrap: Driver-model core structure wrapper.
@@ -1099,6 +1104,8 @@ struct usb_driver {
const struct usb_device_id *id_table;
+ unsigned int num_endpoints;
+
struct usb_dynids dynids;
struct usbdrv_wrap drvwrap;
unsigned int no_dynamic_id:1;