On Wed, Jun 17, 2015 at 03:44:45PM +0200, Stefan Koch wrote: > There is an attribute for each interface to allow (1) or deny (0) it: > /sys/bus/usb/devices/*-*:*.*/authorized > > Signed-off-by: Stefan Koch <skoch@xxxxxxx> > --- > drivers/usb/core/sysfs.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c > index d269738..8e25292 100644 > --- a/drivers/usb/core/sysfs.c > +++ b/drivers/usb/core/sysfs.c > @@ -622,7 +622,6 @@ usb_descriptor_attr(bDeviceProtocol, "%02x\n"); > usb_descriptor_attr(bNumConfigurations, "%d\n"); > usb_descriptor_attr(bMaxPacketSize0, "%d\n"); > > - > /* show if the device is authorized (1) or not (0) */ > static ssize_t authorized_show(struct device *dev, > struct device_attribute *attr, char *buf) > @@ -926,6 +925,49 @@ static ssize_t supports_autosuspend_show(struct device *dev, > } > static DEVICE_ATTR_RO(supports_autosuspend); > > +/* > + * interface_authorized_show - show authorization status of an USB interface > + * 1 is authorized, 0 is deauthorized > + */ > +static ssize_t interface_authorized_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct usb_interface *intf = to_usb_interface(dev); > + > + if (!intf) > + return -ENODEV; That's an impossible thing, this will never happen even if dev is NULL so it's pointless to check, please remove. > + > + return sprintf(buf, "%u\n", intf->authorized); > +} > + > +/* > + * interface_authorized_store - authorize or deauthorize an USB interface > + * 1 is to authorize, 0 is to deauthorize > + */ > +static ssize_t interface_authorized_store(struct device *dev, > + struct device_attribute *attr, const char *buf, size_t count) > +{ > + struct usb_interface *intf = to_usb_interface(dev); > + unsigned val; > + > + if (sscanf(buf, "%u\n", &val) != 1) > + return -EINVAL; strtobool()? -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html