All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>, netdev@vger.kernel.org
Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch,
	f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	arinc.unal@arinc9.com
Subject: Re: [net-next 2/2] net: dsa: realtek: load switch variants on demand
Date: Mon, 20 Nov 2023 10:20:13 +0100	[thread overview]
Message-ID: <9460eced-5a3b-41c0-b821-e327f6bd06c9@kernel.org> (raw)
In-Reply-To: <20231117235140.1178-3-luizluca@gmail.com>

On 18/11/2023 00:50, Luiz Angelo Daros de Luca wrote:
> realtek-common had a hard dependency on both switch variants. As a
> result, it was not possible to selectively load only one model at
> runtime. Now, variants are registered in the realtek-common module, and
> interface modules look for a variant using the compatible string.

...

> diff --git a/drivers/net/dsa/realtek/realtek-common.h b/drivers/net/dsa/realtek/realtek-common.h
> index 90a949386518..6de4991d8b5c 100644
> --- a/drivers/net/dsa/realtek/realtek-common.h
> +++ b/drivers/net/dsa/realtek/realtek-common.h
> @@ -5,6 +5,37 @@
>  
>  #include <linux/regmap.h>
>  
> +struct realtek_variant_entry {
> +	const struct realtek_variant *variant;
> +	const char *compatible;
> +	struct module *owner;
> +	struct list_head list;
> +};
> +
> +#define module_realtek_variant(__variant, __compatible)			\
> +static struct realtek_variant_entry __variant ## _entry = {		\
> +	.compatible = __compatible,					\
> +	.variant = &(__variant),					\
> +	.owner = THIS_MODULE,						\
> +};									\
> +static int __init realtek_variant_module_init(void)			\
> +{									\
> +	realtek_variant_register(&__variant ## _entry);			\
> +	return 0;							\
> +}									\
> +module_init(realtek_variant_module_init)				\
> +									\
> +static void __exit realtek_variant_module_exit(void)			\
> +{									\
> +	realtek_variant_unregister(&__variant ## _entry);		\
> +}									\
> +module_exit(realtek_variant_module_exit);				\
> +									\
> +MODULE_ALIAS(__compatible)

No, why do you need it? You should not need MODULE_ALIAS() in normal
cases. If you need it, usually it means your device ID table is wrong
(e.g. misses either entries or MODULE_DEVICE_TABLE()). MODULE_ALIAS() is
not a substitute for incomplete ID table.

Entire abstraction/macro is pointless and make the code less readable.


Best regards,
Krzysztof


  parent reply	other threads:[~2023-11-20  9:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 23:49 [net-next 0/2] net: dsa: realtek: Introduce realtek_common, load variants on demand Luiz Angelo Daros de Luca
2023-11-17 23:50 ` [net-next 1/2] net: dsa: realtek: create realtek-common Luiz Angelo Daros de Luca
2023-11-19 12:13   ` Vladimir Oltean
2023-11-19 12:20   ` Vladimir Oltean
2023-11-17 23:50 ` [net-next 2/2] net: dsa: realtek: load switch variants on demand Luiz Angelo Daros de Luca
2023-11-19 12:19   ` Vladimir Oltean
2023-11-20  9:20   ` Krzysztof Kozlowski [this message]
2023-11-20 13:48     ` Vladimir Oltean
2023-11-20 14:07       ` Krzysztof Kozlowski
2023-11-21 14:40         ` Luiz Angelo Daros de Luca
2023-11-21 22:15           ` Krzysztof Kozlowski
2023-11-21 22:35             ` Krzysztof Kozlowski
2023-11-22 22:44               ` Luiz Angelo Daros de Luca
2023-11-23  2:05                 ` Alvin Šipraga
2023-11-27 22:24                   ` Luiz Angelo Daros de Luca
2023-12-07 17:02                     ` Vladimir Oltean
2023-12-07 20:22                       ` Luiz Angelo Daros de Luca
2023-12-07 17:19                     ` Vladimir Oltean
2023-12-07 19:50                       ` Luiz Angelo Daros de Luca
2023-12-07 22:31                         ` Vladimir Oltean
2023-12-08  2:46                           ` Luiz Angelo Daros de Luca
2023-12-11 18:01                             ` Vladimir Oltean
2023-11-25  7:10   ` Dan Carpenter
2023-11-17 23:57 ` [net-next 0/2] net: dsa: realtek: Introduce realtek_common, load " Luiz Angelo Daros de Luca
2023-11-18  0:44   ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2023-11-25  6:20 [net-next 2/2] net: dsa: realtek: load switch " kernel test robot

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=9460eced-5a3b-41c0-b821-e327f6bd06c9@kernel.org \
    --to=krzk@kernel.org \
    --cc=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=arinc.unal@arinc9.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.