[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240304175246.GO403078@kernel.org>
Date: Mon, 4 Mar 2024 17:52:46 +0000
From: Simon Horman <horms@...nel.org>
To: "Ricardo B. Marliere" <ricardo@...liere.net>
Cc: Yisen Zhuang <yisen.zhuang@...wei.com>,
Salil Mehta <salil.mehta@...wei.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Loic Poulain <loic.poulain@...aro.org>,
Sergey Ryazanov <ryazanov.s.a@...il.com>,
Johannes Berg <johannes@...solutions.net>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-ppp@...r.kernel.org, Herve Codina <herve.codina@...tlin.com>
Subject: Re: [PATCH net-next 2/6] net: wan: framer: make framer_class constant
+ Herve Codina <herve.codina@...tlin.com>
On Sat, Mar 02, 2024 at 02:05:58PM -0300, Ricardo B. Marliere wrote:
> Since commit 43a7206b0963 ("driver core: class: make class_register() take
> a const *"), the driver core allows for struct class to be in read-only
> memory, so move the framer_class structure to be declared at build time
> placing it into read-only memory, instead of having to be dynamically
> allocated at boot time.
>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@...liere.net>
Reviewed-by: Simon Horman <horms@...nel.org>
> ---
> drivers/net/wan/framer/framer-core.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/wan/framer/framer-core.c b/drivers/net/wan/framer/framer-core.c
> index 33b358b99f70..f547c22e26ac 100644
> --- a/drivers/net/wan/framer/framer-core.c
> +++ b/drivers/net/wan/framer/framer-core.c
> @@ -18,7 +18,12 @@
> #include <linux/regulator/consumer.h>
> #include <linux/slab.h>
>
> -static struct class *framer_class;
> +static void framer_release(struct device *dev);
> +static const struct class framer_class = {
> + .name = "framer",
> + .dev_release = framer_release,
> +};
> +
> static DEFINE_MUTEX(framer_provider_mutex);
> static LIST_HEAD(framer_provider_list);
> static DEFINE_IDA(framer_ida);
> @@ -627,7 +632,7 @@ struct framer *framer_create(struct device *dev, struct device_node *node,
> INIT_DELAYED_WORK(&framer->polling_work, framer_polling_work);
> BLOCKING_INIT_NOTIFIER_HEAD(&framer->notifier_list);
>
> - framer->dev.class = framer_class;
> + framer->dev.class = &framer_class;
> framer->dev.parent = dev;
> framer->dev.of_node = node ? node : dev->of_node;
> framer->id = id;
> @@ -741,7 +746,7 @@ struct framer *framer_provider_simple_of_xlate(struct device *dev,
> struct class_dev_iter iter;
> struct framer *framer;
>
> - class_dev_iter_init(&iter, framer_class, NULL, NULL);
> + class_dev_iter_init(&iter, &framer_class, NULL, NULL);
> while ((dev = class_dev_iter_next(&iter))) {
> framer = dev_to_framer(dev);
> if (args->np != framer->dev.of_node)
> @@ -870,14 +875,6 @@ static void framer_release(struct device *dev)
>
> static int __init framer_core_init(void)
> {
> - framer_class = class_create("framer");
> - if (IS_ERR(framer_class)) {
> - pr_err("failed to create framer class (%pe)\n", framer_class);
> - return PTR_ERR(framer_class);
> - }
> -
> - framer_class->dev_release = framer_release;
> -
> - return 0;
> + return class_register(&framer_class);
> }
> device_initcall(framer_core_init);
>
> --
> 2.43.0
>
>
Powered by blists - more mailing lists