Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp397256pxb; Thu, 30 Sep 2021 08:21:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFZLVA5ykgFAVW3IdR3yjVkDty1PB0dj2iRJDo2MOG3U/Q3FhZueyz/k0xL2InGzovkPz3 X-Received: by 2002:a63:4b5a:: with SMTP id k26mr5501520pgl.241.1633015296910; Thu, 30 Sep 2021 08:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633015296; cv=none; d=google.com; s=arc-20160816; b=IN/5is43NW8OP4gz9ViZ88hPFwewVt1FvEeDFIxvPia5qJT763YKs31Yfan8z9ypWL V8iMEJXsZgUHBra0kZy+xDosuMThpCJfQQazd0FzzBFQ1Pz9VOeGs+KWH2eRBp0TTWrm ejHP7xv5F3tZORIlHYnrhCk44At1Qwug6lTc2kOsIzswyVS8NpxQXUTgONJ5nsrOlxnS nFX1x9E94WGfJnabF5j3T5Y77d6vLluVfjhPpLLoP1kakOsAtWVPCEhqmP3WpH9X7a/p Px1wiyCtZ0dh7aNVNW9HxokDq0IxoiUVaMcvYYJI6xom1roj0swulPh53M2n0mSlNrav patQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qr4Zrm/ATlzsQBfnJg0YpFhhm7HUDiUCoe6gNtVCIZc=; b=loY2xyJz55ID9AziZiNLy2iib/nkZs/JITZlIdpkNYpxlsee38E8YxZY+N5XWTKSPV 7zAeW1JkWvEeHM6AEjBcep9QIIqfnC84TISbYKQ73UjLWUaDPCb+I47ARdHZHtpjpy9A kOvjfb1QkOcDk+PXuUQUrr3B2bkbMHITNfVq9DBI0vThjOVopUQze9Ka7dPbnfk84NY+ tKVkkUz8Qen9OlWxc86H+8Bwjzlmm0C6rIGebHcCWKIdRWWEbVtsC3tex43WIA35QbQh pbXGDSVwFW97g9Dt7gqJR1nxz+cPpJYqg5d/Ts/PaJxoYjHpKIk/U2yOmo6wAhdSM2rU 0UGA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si3722809plt.67.2021.09.30.08.21.22; Thu, 30 Sep 2021 08:21:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352078AbhI3PBR (ORCPT + 99 others); Thu, 30 Sep 2021 11:01:17 -0400 Received: from netrider.rowland.org ([192.131.102.5]:36643 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1352084AbhI3PBP (ORCPT ); Thu, 30 Sep 2021 11:01:15 -0400 Received: (qmail 471447 invoked by uid 1000); 30 Sep 2021 10:59:32 -0400 Date: Thu, 30 Sep 2021 10:59:32 -0400 From: Alan Stern To: Dan Williams Cc: Kuppuswamy Sathyanarayanan , 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 Subject: Re: [PATCH v2 1/6] driver core: Move the "authorized" attribute from USB/Thunderbolt to core Message-ID: <20210930145932.GB464826@rowland.harvard.edu> References: <20210930010511.3387967-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210930010511.3387967-2-sathyanarayanan.kuppuswamy@linux.intel.com> <20210930014229.GA447956@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 06:55:12PM -0700, Dan Williams wrote: > On Wed, Sep 29, 2021 at 6:43 PM Alan Stern wrote: > > > > On Wed, Sep 29, 2021 at 06:05:06PM -0700, Kuppuswamy Sathyanarayanan wrote: > > > Currently bus drivers like "USB" or "Thunderbolt" implement a custom > > > version of device authorization to selectively authorize the driver > > > probes. Since there is a common requirement, move the "authorized" > > > attribute support to the driver core in order to allow it to be used > > > by other subsystems / buses. > > > > > > Similar requirements have been discussed in the PCI [1] community for > > > PCI bus drivers as well. > > > > > > No functional changes are intended. It just converts authorized > > > attribute from int to bool and moves it to the driver core. There > > > should be no user-visible change in the location or semantics of > > > attributes for USB devices. > > > > > > Regarding thunderbolt driver, although it declares sw->authorized as > > > "int" and allows 0,1,2 as valid values for sw->authorized attribute, > > > but within the driver, in all authorized attribute related checks, > > > it is treated as bool value. So when converting the authorized > > > attribute from int to bool value, there should be no functional > > > changes other than value 2 being not visible to the user. > > > > > > [1]: https://lore.kernel.org/all/CACK8Z6E8pjVeC934oFgr=VB3pULx_GyT2NkzAogdRQJ9TKSX9A@mail.gmail.com/ > > > > > > Reviewed-by: Dan Williams > > > Signed-off-by: Kuppuswamy Sathyanarayanan > > > > Since you're moving the authorized flag from the USB core to the > > driver core, the corresponding sysfs attribute functions should be > > moved as well. > > Unlike when 'removable' moved from USB to the driver core there isn't > a common definition for how the 'authorized' sysfs-attribute behaves > across buses. The only common piece is where this flag is stored in > the data structure, i.e. the 'authorized' sysfs interface is > purposefully left bus specific. How about implementing "library" versions of show_authorized() and store_authorized() that the bus-specific attribute routines can call? These library routines would handle parsing the input values, storing the new flag, and displaying the stored flag value. That way at least the common parts of these APIs would be centralized in the driver core, and any additional functionality could easily be added by the bus-specific attribute routine. Alan Stern