Re: [PATCH v6 2/5] drivers: Add bus_for_each for iterating over the subsystems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <allenwebb@xxxxxxxxxx>
> ---
>  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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux