mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/4] base: add class device support
Date: Mon, 10 Jun 2024 10:33:43 +0200	[thread overview]
Message-ID: <9544d04c-6d5e-4a5b-93cf-7cfabf9a90ae@pengutronix.de> (raw)
In-Reply-To: <20240610081213.858714-3-s.hauer@pengutronix.de>

Hello Sascha,

On 10.06.24 10:12, Sascha Hauer wrote:
> This introduces the concept of class devices in barebox. Class devices
> group together devices of the same type. Several subsystems like
> watchdog and network devices have a struct device embedded in their
> subsystem specific struct anyway, so we can use this as a class device.
> As these class devices are collected on a list we can use this list to
> iterate over all network/watchdog devices and thus free the subsystems
> from the burden of keeping a list themselves.
> 
> There is a 'class' command added in this patch which can be used to show
> all registered classes along with the devices registered for each class.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  commands/Kconfig                  |  6 +++++
>  commands/Makefile                 |  1 +
>  commands/class.c                  | 30 ++++++++++++++++++++++
>  drivers/base/Makefile             |  1 +
>  drivers/base/class.c              | 41 +++++++++++++++++++++++++++++++
>  include/asm-generic/barebox.lds.h |  7 ++++++
>  include/device.h                  | 21 ++++++++++++++++
>  7 files changed, 107 insertions(+)
>  create mode 100644 commands/class.c
>  create mode 100644 drivers/base/class.c
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 899673bfee..7831e6276d 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -68,6 +68,12 @@ config CMD_BOOTROM
>  
>  	  bootrom [-la]
>  
> +config CMD_CLASS
> +	tristate
> +	prompt "class"
> +	help
> +	  Show information about registered classes and devices

s/classes and devices/device classes/.

> +#define BAREBOX_CLASSES				\
> +	STRUCT_ALIGN();				\
> +	__barebox_class_start = .;		\
> +	KEEP(*(SORT_BY_NAME(.barebox_class*)))	\
> +	__barebox_class_end = .;

While I don't mind using linker lists for this, can you add a note
to the commit message why you decided against dynamic allocation?

> +struct class {
> +	const char *name;
> +	struct list_head devices;
> +	struct list_head list;
> +};
> +
> +#define DECLARE_CLASS(_name, _classname)					\

This is a definition, not ony a declaration and
Linux has DEFINE_CLASS defined in <linux/cleanup.h>.

How about DEFINE_DEV_CLASS?

> +	struct class _name __ll_elem(.barebox_class_##_name) = {		\
> +		.name = _classname,						\
> +		.devices = LIST_HEAD_INIT(_name.devices),			\
> +	}

Cheers,
Ahmad

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2024-06-10  8:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10  8:12 [PATCH 0/4] Introduce class devices Sascha Hauer
2024-06-10  8:12 ` [PATCH 1/4] net: use for_each_netdev() Sascha Hauer
2024-06-10  8:12 ` [PATCH 2/4] base: add class device support Sascha Hauer
2024-06-10  8:33   ` Ahmad Fatoum [this message]
2024-06-10  8:57     ` Sascha Hauer
2024-06-10  8:12 ` [PATCH 3/4] net: register eth class Sascha Hauer
2024-06-10  8:12 ` [PATCH 4/4] watchdog: register watchdog class Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9544d04c-6d5e-4a5b-93cf-7cfabf9a90ae@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox