On Thu, 18 Jun 2015, Stefan Koch wrote:

> Interfaces are allowed per default.
> This can disabled or enabled (again) by writing 0 or 1 to
> /sys/bus/usb/devices/usbX/interface_authorized_default
> 
> Signed-off-by: Stefan Koch <sk...@suse.de>

> +/*
> + * interface_authorized_default_store - store default authorization status
> + * for USB interfaces
> + *
> + * note: interface_auhorized_default is the default value
> + *       for initializing the authorized attribute of interfaces
> + */
> +static ssize_t interface_authorized_default_store(struct device *dev,
> +             struct device_attribute *attr, const char *buf, size_t count)
> +{
> +     struct usb_device *usb_dev = to_usb_device(dev);
> +     struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus);
> +     int rc = count;
> +     bool val;
> +
> +     if (!usb_dev || !hcd)
> +             return -ENODEV;

This can never happen; you should get rid of it.

> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -120,6 +120,7 @@ struct usb_hcd {
>  #define HCD_FLAG_WAKEUP_PENDING              4       /* root hub is 
> resuming? */
>  #define HCD_FLAG_RH_RUNNING          5       /* root hub is running? */
>  #define HCD_FLAG_DEAD                        6       /* controller has died? 
> */
> +#define HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT        8
>  
>       /* The flags can be tested using these macros; they are likely to
>        * be slightly faster than test_bit().
> @@ -130,6 +131,8 @@ struct usb_hcd {
>  #define HCD_WAKEUP_PENDING(hcd)      ((hcd)->flags & (1U << 
> HCD_FLAG_WAKEUP_PENDING))
>  #define HCD_RH_RUNNING(hcd)  ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
>  #define HCD_DEAD(hcd)                ((hcd)->flags & (1U << HCD_FLAG_DEAD))
> +#define HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd)        \
> +     ((hcd)->flags & (1U << HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT))
>  
>       /* Flags that get set only during HCD registration or removal. */
>       unsigned                rh_registered:1;/* is root hub registered? */
> @@ -142,6 +145,7 @@ struct usb_hcd {
>       unsigned                uses_new_polling:1;
>       unsigned                wireless:1;     /* Wireless USB HCD */
>       unsigned                authorized_default:1;
> +     unsigned                interface_authorized_default:1;

What's this doing here?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to