--- zzzz-none-000/linux-5.4.213/drivers/usb/core/sysfs.c 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/drivers/usb/core/sysfs.c 2024-08-14 09:02:08.000000000 +0000 @@ -434,6 +434,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; } @@ -795,6 +802,73 @@ } static DEVICE_ATTR_IGNORE_LOCKDEP(remove, S_IWUSR, NULL, remove_store); +#if defined(CONFIG_AVM_ENHANCED) +/* == 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 int 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 */ @@ -830,6 +904,10 @@ #ifdef CONFIG_OF &dev_attr_devspec.attr, #endif +#if defined(CONFIG_AVM_ENHANCED) + /* == 20160222 AVM/VGJ - CHANGESET: noprobe Extension == */ + &dev_attr_noprobe.attr, +#endif NULL, }; static struct attribute_group dev_attr_grp = {