Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp93082pxb; Wed, 29 Sep 2021 22:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJXYhIiVCZODAhQXLJj+DQIyVxuBjB7csv+hpoGgRkpxkJJBILHt0Gw5T+TWPodYp/QjYS X-Received: by 2002:a17:906:7f01:: with SMTP id d1mr4533649ejr.318.1632978479616; Wed, 29 Sep 2021 22:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632978479; cv=none; d=google.com; s=arc-20160816; b=zMmFSjTM4rQRJbYAs1X7FQhzTmXI+pwYKtbfZ/2ARs+Edf6EbYVJBtPWbHeKFaOEN/ xdM5ySY6p5tV/s1y1xWuwQ66Vt68ENF6IKUv8cC3sDQFilp0lZTSgl4tcqmYElQZSXR6 seplgymwED/GtkcyxKTldWYFu0KXfW1Ngt8Imsp56tSqQ7hAnBmdJWePp9X7mI116YbK otBH4Q/seXs36mMgkKGDT/uGm5g4JgRpXAU8gJuG3ey2YaFe5MDaYEypFSWebIieIqeZ kCoGX4HcVrxSQOhoGCObVTIT+Wffq5SAfNA2pMr91dOBi/7m+LTJy69Fg9kOw9nXF9AS EjUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=VTM9z+DcTeYF3hZgKWEu9ebVrBPYT2J8Mz8sj8erXZk=; b=X6bAFeo8/xLiyPGe2P3/n5GbQz40TYR8ZDgX9zbk8+gvZFJaw76H+FQ+y7i4QbQo3a 6JQlHd5/VJwu6Lo6S5yhFK+W0e5hq14ngA3/92AO7aFcJlR/ohhjMLJGqlRUXGIdL8tT FidQQG+RtaOxUAxIUzMnCr1oeE5i8NDKi6od7oyTIg0ibdLtEu896R9GiZTsnO8QrLyQ JI00+FpSveBHhngNrLw3DKEdjoByjmyZK7MONh3p2MM1SS4BQ1hS7stROID9Prt5oC3a RZl2VEUmzgyb778diWJ2h+Dit3fMI5B18AZnBSDSDf3rhx4BFEvjC4QblOFUkyixDhRy n5zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b="PCpbwU/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pw19si1630231ejb.88.2021.09.29.22.07.35; Wed, 29 Sep 2021 22:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b="PCpbwU/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348032AbhI3FBT (ORCPT + 99 others); Thu, 30 Sep 2021 01:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbhI3FBS (ORCPT ); Thu, 30 Sep 2021 01:01:18 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC005C06161C for ; Wed, 29 Sep 2021 21:59:36 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id me3-20020a17090b17c300b0019f44d2e401so1734730pjb.5 for ; Wed, 29 Sep 2021 21:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VTM9z+DcTeYF3hZgKWEu9ebVrBPYT2J8Mz8sj8erXZk=; b=PCpbwU/Blt/pbMA6NT2nm2SIqNzMnAtcLzxhxbtj3rTw2MHvXasv4KZ/zpwWPlZn7y xPWsxFGYK8u70vbz7XcbGiHpsKtrQjK346ig5ArayijRkOVR0ZSgmSdFgnxE9i5Sf9pW 0deGfEYYnNhaWRDtv3KVBZBS8spTYrA43Nq9+AxcJVFP4EVbUPaWHgG3/ccF/i1QocQh Qw4w3IvzGqNsfXW9sLxObs8iR9rV/NKytwQ8uw+30BCP3sXi3JaL/1APxK4M9G1CofGl mDPEFjR6CHHEV+e1F5uOIa2vub/p77kBLKF9waZAxea7kzN/oqO6LWY664QZ4RAJnbzu 9G/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VTM9z+DcTeYF3hZgKWEu9ebVrBPYT2J8Mz8sj8erXZk=; b=wKKZx436VdCC956m09Y78fEdAbweN9nG/BjEiOkzWpXWWdobSCvQoJq2X0Gh2x4mzp gbc2SebLY1wNPNvUJ/M+U2Q6NN5dDv5IofTjyvre8lY4ui6EZUHBZmsrAvAV0wcNzoCL A5qm9KKrLxeXVQlubqUvmTRvFl8JuAr88x9ZtdLiJDdlAMEmcaE1na1EqVFocAs6y6DY H6okfIWw414GZYrZ0CVJ9+Z65VJ5dPVSiaWXPvoZBVEoCMmKfa9ap2fYOAQk2QwlZH2X nZMxcnkdnwyr/X4e40PZTpIYkiS0eyh04V9UDXGkBjML0dm48pZl9EHcy2/MKZ+M73A0 U82w== X-Gm-Message-State: AOAM530jp7xyh4ye6Gc5pPOscoxXXihHL841JSt6Op4uActY4k/GuOGU 3EbFcqkOMM5lPw6jDU5qSRO+nOgbw40Vuh82VJ9Hz2i/USM= X-Received: by 2002:a17:902:bd8d:b0:13a:8c8:a2b2 with SMTP id q13-20020a170902bd8d00b0013a08c8a2b2mr2377812pls.89.1632977976213; Wed, 29 Sep 2021 21:59:36 -0700 (PDT) MIME-Version: 1.0 References: <20210930010511.3387967-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210930010511.3387967-2-sathyanarayanan.kuppuswamy@linux.intel.com> <20210930014229.GA447956@rowland.harvard.edu> In-Reply-To: From: Dan Williams Date: Wed, 29 Sep 2021 21:59:25 -0700 Message-ID: Subject: Re: [PATCH v2 1/6] driver core: Move the "authorized" attribute from USB/Thunderbolt to core To: "Kuppuswamy, Sathyanarayanan" Cc: Alan Stern , Greg Kroah-Hartman , Borislav Petkov , X86 ML , Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Andreas Noever , "Michael S . Tsirkin" , Michael Jamet , Yehezkel Bernat , "Rafael J . Wysocki" , Mika Westerberg , Jonathan Corbet , Jason Wang , Andi Kleen , Kuppuswamy Sathyanarayanan , Linux Kernel Mailing List , Linux PCI , USB list , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 7:39 PM Kuppuswamy, Sathyanarayanan wrote: > > > > On 9/29/21 6:55 PM, Dan Williams wrote: > >> Also, you ignored the usb_[de]authorize_interface() functions and > >> their friends. > > Ugh, yes. > > I did not change it because I am not sure about the interface vs device > dependency. > This is was the rationale for has_probe_authorization flag. USB performs authorization of child devices based on the authorization state of the parent interface. > I think following change should work. > > diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c > index f57b5a7a90ca..84969732d09c 100644 > --- a/drivers/usb/core/driver.c > +++ b/drivers/usb/core/driver.c > @@ -334,7 +334,7 @@ static int usb_probe_interface(struct device *dev) > if (udev->dev.authorized == false) { > dev_err(&intf->dev, "Device is not authorized for usage\n"); > return error; > - } else if (intf->authorized == 0) { > + } else if (intf->dev.authorized == 0) { == false. > dev_err(&intf->dev, "Interface %d is not authorized for usage\n", > intf->altsetting->desc.bInterfaceNumber); > return error; > @@ -546,7 +546,7 @@ int usb_driver_claim_interface(struct usb_driver *driver, > return -EBUSY; > > /* reject claim if interface is not authorized */ > - if (!iface->authorized) > + if (!iface->dev.authorized) I'd do == false to keep it consistent with other conversions. > return -ENODEV; > > dev->driver = &driver->drvwrap.driver; > diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c > index 47548ce1cfb1..ab3c8d1e4db9 100644 > --- a/drivers/usb/core/message.c > +++ b/drivers/usb/core/message.c > @@ -1791,9 +1791,9 @@ void usb_deauthorize_interface(struct usb_interface *intf) > > device_lock(dev->parent); > > - if (intf->authorized) { > + if (intf->dev.authorized) { > device_lock(dev); > - intf->authorized = 0; > + intf->dev.authorized = 0; = false; > device_unlock(dev); > > usb_forced_unbind_intf(intf); > @@ -1811,9 +1811,9 @@ void usb_authorize_interface(struct usb_interface *intf) > { > struct device *dev = &intf->dev; > > - if (!intf->authorized) { > + if (!intf->dev.authorized) { > device_lock(dev); > - intf->authorized = 1; /* authorize interface */ > + intf->dev.authorized = 1; /* authorize interface */ = true ...not sure that comment is worth preserving.