--- zzzz-none-000/linux-2.6.39.4/drivers/usb/core/sysfs.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/drivers/usb/core/sysfs.c 2021-11-10 13:23:10.000000000 +0000 @@ -541,6 +541,67 @@ } static DEVICE_ATTR(remove, 0200, NULL, usb_remove_store); +#if 1 /* == 20101129 AVM/WK Extension: prevent probing for a device */ + +/* show if probing is allowed (0) or not allowed (1) for the device */ +static ssize_t usb_dev_noprobe_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct usb_device *usb_dev = to_usb_device(dev); + return snprintf(buf, PAGE_SIZE, "%u\n", usb_dev->noprobe); +} + +/* + * Prevent probing for a device + * (configures or deconfigures the device as a side effect) + * + * Writing a 0 allows probing and reconfigures the device + * writing a 1 prevents probing and unconfigures the device it + * + */ +static ssize_t usb_dev_noprobe_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + ssize_t result; + struct usb_device *usb_dev = to_usb_device(dev); + unsigned val; + result = sscanf(buf, "%u\n", &val); + if (result != 1) + result = -EINVAL; + else { + usb_lock_device(usb_dev); + if (val == 0) { + int c,err; + usb_dev->noprobe = 0; + c = usb_choose_configuration(usb_dev); + if (c >= 0) { + err = usb_set_configuration(usb_dev, c); + if (err) { + dev_err(&usb_dev->dev, + "can't set config #%d, error %d\n", c, err); + /* This need not be fatal. The user can try to + * set other configurations. */ + } + } + } else { + usb_dev->noprobe = 1; + usb_set_configuration(usb_dev, -1); + /* == 20110923 AVM/WK noprobe: extra value 2 resets device */ + if (val == 2) { + usb_reset_device (usb_dev); + } + } + usb_unlock_device(usb_dev); + } + return result < 0? result : size; +} + +static DEVICE_ATTR(noprobe, 0644, + usb_dev_noprobe_show, usb_dev_noprobe_store); +#endif + static struct attribute *dev_attrs[] = { /* current configuration's attributes */ @@ -569,6 +630,9 @@ &dev_attr_avoid_reset_quirk.attr, &dev_attr_authorized.attr, &dev_attr_remove.attr, +#if 1 /* AVM/WK Extension */ + &dev_attr_noprobe.attr, +#endif NULL, }; static struct attribute_group dev_attr_grp = { @@ -846,7 +910,7 @@ { struct usb_device *udev = interface_to_usbdev(intf); struct usb_host_interface *alt = intf->cur_altsetting; - int retval; + int retval = 0; if (intf->sysfs_files_created || intf->unregistering) return 0; @@ -857,7 +921,7 @@ if (alt->string) retval = device_create_file(&intf->dev, &dev_attr_interface); intf->sysfs_files_created = 1; - return 0; + return retval; } void usb_remove_sysfs_intf_files(struct usb_interface *intf)