From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7F8CC4332F for ; Mon, 5 Dec 2022 15:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232433AbiLEPpj (ORCPT ); Mon, 5 Dec 2022 10:45:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232850AbiLEPpM (ORCPT ); Mon, 5 Dec 2022 10:45:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9756FC758; Mon, 5 Dec 2022 07:45:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2F80A6116A; Mon, 5 Dec 2022 15:45:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F673C433D6; Mon, 5 Dec 2022 15:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670255109; bh=mwQrZYazPo/zTGa6o9BUoETFozZTAUE0m8JOQrpeE+c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GMhyQZx+aq4MP/W+8pZ145QY+JTwdQjFGaWd+NOrVR3wyPu44IwwndGNOrXt+RuM3 lzkuFTKdOcd0NqBATvTikpIuBBV1gTt4Kz/1J4FlJSjAZyJvQvV2lSUgLHy+XqNwix rTnWtOMgycMYlc2NYyqpFp69eaUVblG5mK610thc= Date: Mon, 5 Dec 2022 16:45:07 +0100 From: Greg Kroah-Hartman To: Allen Webb Cc: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Luis Chamberlain , "Rafael J. Wysocki" Subject: Re: [PATCH v6 2/5] drivers: Add bus_for_each for iterating over the subsystems Message-ID: References: <20221202224540.1446952-1-allenwebb@google.com> <20221202224744.1447448-1-allenwebb@google.com> <20221202224744.1447448-2-allenwebb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221202224744.1447448-2-allenwebb@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 02, 2022 at 04:47:41PM -0600, Allen Webb wrote: > In order to print the match-id-based modaliases it must be possible to > reach the match id tables of each driver. With this function it becomes > possible to iterate over each subsystem which can be paired with > iterating over each driver. > > Signed-off-by: Allen Webb > --- > drivers/base/bus.c | 42 ++++++++++++++++++++++++++++++++++++++ > include/linux/device/bus.h | 1 + > 2 files changed, 43 insertions(+) > > diff --git a/drivers/base/bus.c b/drivers/base/bus.c > index 7ca47e5b3c1f4..4e0c5925545e5 100644 > --- a/drivers/base/bus.c > +++ b/drivers/base/bus.c > @@ -178,6 +178,48 @@ static const struct kset_uevent_ops bus_uevent_ops = { > > static struct kset *bus_kset; > > +/** > + * bus_for_each - bus iterator. > + * @start: bus to start iterating from. > + * @data: data for the callback. > + * @fn: function to be called for each device. > + * > + * Iterate over list of buses, and call @fn for each, > + * passing it @data. If @start is not NULL, we use that bus to > + * begin iterating from. Where is there a list of all busses in the system? This feels very odd. A bus can list all devices on it, but busses have no relationship to each other at all and are independent. So to iterate over all busses in the system feels very wrong, and again, a layering violation as that would allow non-dependant busses to poke around in other busses. Not something you want to do at all. I guess I don't understand why this is needed, so some justification is required. thanks, greg k-h