From: Simon Horman <horms@kernel•org>
To: "Ricardo B. Marliere" <ricardo@marliere•net>
Cc: Yisen Zhuang <yisen.zhuang@huawei•com>,
Salil Mehta <salil.mehta@huawei•com>,
"David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
Loic Poulain <loic.poulain@linaro•org>,
Sergey Ryazanov <ryazanov.s.a@gmail•com>,
Johannes Berg <johannes@sipsolutions•net>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro•org>,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
netdev@vger•kernel.org, linux-kernel@vger•kernel.org,
linux-ppp@vger•kernel.org,
Herve Codina <herve.codina@bootlin•com>
Subject: Re: [PATCH net-next 2/6] net: wan: framer: make framer_class constant
Date: Mon, 4 Mar 2024 17:52:46 +0000 [thread overview]
Message-ID: <20240304175246.GO403078@kernel.org> (raw)
In-Reply-To: <20240302-class_cleanup-net-next-v1-2-8fa378595b93@marliere.net>
+ Herve Codina <herve.codina@bootlin•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@linuxfoundation•org>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere•net>
Reviewed-by: Simon Horman <horms@kernel•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
>
>
next prev parent reply other threads:[~2024-03-04 17:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-02 17:05 [PATCH net-next 0/6] net: constify struct class usage Ricardo B. Marliere
2024-03-02 17:05 ` [PATCH net-next 1/6] net: hns: make hnae_class constant Ricardo B. Marliere
2024-03-04 17:52 ` Simon Horman
2024-03-02 17:05 ` [PATCH net-next 2/6] net: wan: framer: make framer_class constant Ricardo B. Marliere
2024-03-04 17:52 ` Simon Horman [this message]
2024-03-05 7:17 ` Herve Codina
2024-03-02 17:05 ` [PATCH net-next 3/6] net: ppp: make ppp_class constant Ricardo B. Marliere
2024-03-04 17:53 ` Simon Horman
2024-03-04 20:19 ` Breno Leitao
2024-03-02 17:06 ` [PATCH net-next 4/6] net: wwan: hwsim: make wwan_hwsim_class constant Ricardo B. Marliere
2024-03-03 22:22 ` Sergey Ryazanov
2024-03-02 17:06 ` [PATCH net-next 5/6] net: wwan: core: make wwan_class constant Ricardo B. Marliere
2024-03-03 22:24 ` Sergey Ryazanov
2024-03-02 17:06 ` [PATCH net-next 6/6] nfc: core: make nfc_class constant Ricardo B. Marliere
2024-03-04 17:53 ` Simon Horman
2024-03-04 20:19 ` Breno Leitao
2024-03-05 20:00 ` [PATCH net-next 0/6] net: constify struct class usage patchwork-bot+netdevbpf
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=20240304175246.GO403078@kernel.org \
--to=horms@kernel$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=herve.codina@bootlin$(echo .)com \
--cc=johannes@sipsolutions$(echo .)net \
--cc=krzysztof.kozlowski@linaro$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-ppp@vger$(echo .)kernel.org \
--cc=loic.poulain@linaro$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=ricardo@marliere$(echo .)net \
--cc=ryazanov.s.a@gmail$(echo .)com \
--cc=salil.mehta@huawei$(echo .)com \
--cc=yisen.zhuang@huawei$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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