Am Montag, den 03.08.2015, 15:11 -0700 schrieb Greg KH: > On Thu, Jul 30, 2015 at 08:19:24AM +0200, Stefan Koch wrote: > > With this patch a flag instead of a variable > > is used for the default device authorization. > > > > Signed-off-by: Stefan Koch <skoch@xxxxxxx> > > --- > > drivers/usb/core/hcd.c | 31 +++++++++++++++++++++---------- > > drivers/usb/core/usb.c | 2 +- > > include/linux/usb/hcd.h | 6 ++++-- > > 3 files changed, 26 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c > > index 84b5923..a567647 100644 > > --- a/drivers/usb/core/hcd.c > > +++ b/drivers/usb/core/hcd.c > > @@ -854,10 +854,10 @@ static ssize_t authorized_default_show(struct device *dev, > > { > > struct usb_device *rh_usb_dev = to_usb_device(dev); > > struct usb_bus *usb_bus = rh_usb_dev->bus; > > - struct usb_hcd *usb_hcd; > > + struct usb_hcd *hcd; > > > > - usb_hcd = bus_to_hcd(usb_bus); > > - return snprintf(buf, PAGE_SIZE, "%u\n", usb_hcd->authorized_default); > > + hcd = bus_to_hcd(usb_bus); > > + return snprintf(buf, PAGE_SIZE, "%u\n", !!HCD_DEV_AUTHORIZED(hcd)); > > } > > > > static ssize_t authorized_default_store(struct device *dev, > > @@ -868,12 +868,16 @@ static ssize_t authorized_default_store(struct device *dev, > > unsigned val; > > struct usb_device *rh_usb_dev = to_usb_device(dev); > > struct usb_bus *usb_bus = rh_usb_dev->bus; > > - struct usb_hcd *usb_hcd; > > + struct usb_hcd *hcd; > > > > - usb_hcd = bus_to_hcd(usb_bus); > > + hcd = bus_to_hcd(usb_bus); > > result = sscanf(buf, "%u\n", &val); > > if (result == 1) { > > - usb_hcd->authorized_default = val ? 1 : 0; > > + if (val) > > + set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); > > + else > > + clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); > > + > > result = size; > > } else { > > result = -EINVAL; > > @@ -2720,10 +2724,17 @@ int usb_add_hcd(struct usb_hcd *hcd, > > dev_info(hcd->self.controller, "%s\n", hcd->product_desc); > > > > /* Keep old behaviour if authorized_default is not in [0, 1]. */ > > - if (authorized_default < 0 || authorized_default > 1) > > - hcd->authorized_default = hcd->wireless ? 0 : 1; > > - else > > - hcd->authorized_default = authorized_default; > > + if (authorized_default < 0 || authorized_default > 1) { > > + if (hcd->wireless) > > + clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); > > + else > > + set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); > > + } else { > > + if (authorized_default) > > + set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); > > + else > > + clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); > > + } > > set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); > > > > /* per default all interfaces are authorized */ > > diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c > > index 8d5b2f4..f8bbd0b 100644 > > --- a/drivers/usb/core/usb.c > > +++ b/drivers/usb/core/usb.c > > @@ -510,7 +510,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, > > if (root_hub) /* Root hub always ok [and always wired] */ > > dev->authorized = 1; > > else { > > - dev->authorized = usb_hcd->authorized_default; > > + dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd); > > dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0; > > } > > return dev; > > diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h > > index 7b8ddae..f7c6dd1 100644 > > --- a/include/linux/usb/hcd.h > > +++ b/include/linux/usb/hcd.h > > @@ -59,7 +59,7 @@ > > * Since "struct usb_bus" is so thin, you can't share much code in it. > > * This framework is a layer over that, and should be more sharable. > > * > > - * @authorized_default: Specifies if new devices are authorized to > > + * @HCD_DEV_AUTHORIZED: Specifies if new devices are authorized to > > That's not really the way to specify a field in this structure. I agree > it still should be documented, but docbook will complain about this > change. > > thanks, > > greg k-h What way should be choosen for documentating it? Thanks Stefan -- 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