--- zzzz-none-000/linux-4.4.271/drivers/usb/core/sysfs.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/drivers/usb/core/sysfs.c 2023-04-19 10:22:29.000000000 +0000 @@ -382,6 +382,13 @@ value <= -INT_MAX/1000) return -EINVAL; +/* == 20171115 AVM/VGJ Prevent suspension of blacklisted devices == */ +#if defined (CONFIG_AVM_USB_PM) + if (avm_usb_pm_is_blacklisted(to_usb_device(dev))) { + value = -1; + } +#endif + pm_runtime_set_autosuspend_delay(dev, value * 1000); return count; } @@ -731,6 +738,68 @@ } static DEVICE_ATTR_IGNORE_LOCKDEP(remove, S_IWUSR, NULL, remove_store); +#if 1 /* == 20160222 AVM/VGJ - CHANGESET: noprobe Extension for AURA == */ + +/* 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 + * writing a 2 prevents probing and resets the device + * + */ +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); + /* == 20160219 AVM/VGJ - CHANGESET: 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 */ @@ -761,6 +830,9 @@ &dev_attr_remove.attr, &dev_attr_removable.attr, &dev_attr_ltm_capable.attr, +#if 1 /* == 20160222 AVM/VGJ - CHANGESET: noprobe Extension == */ + &dev_attr_noprobe.attr, +#endif NULL, }; static struct attribute_group dev_attr_grp = {