From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: tj@kernel.org, jiangshanlai@gmail.com, saeedm@nvidia.com,
leon@kernel.org, davem@davemloft.net, kuba@kernel.org,
bvanassche@acm.org
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH 2/2] net/mlx5: Simplify workqueue name creation
Date: Sun, 18 Apr 2021 23:26:31 +0200 [thread overview]
Message-ID: <a32dccb98017715d54853ac2e2aee360851539ce.1618780558.git.christophe.jaillet@wanadoo.fr> (raw)
In-Reply-To: <cover.1618780558.git.christophe.jaillet@wanadoo.fr>
There is no need to explicitly allocate, populate and free some memory
just to pass a workqueue name to 'create_singlethread_workqueue()'.
This macro can do all this for us, so keep the code simple.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
A similar patch has also been sent. It was replacing the kmalloc/strcpy/
strcat with a kasprintf.
Updating 'create_singlethread_workqueue' gives an even more elegant solution.
---
drivers/net/ethernet/mellanox/mlx5/core/health.c | 9 +--------
1 file changed, 2 insertion(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 9ff163c5bcde..160f852b7bbe 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -797,19 +797,13 @@ void mlx5_health_cleanup(struct mlx5_core_dev *dev)
int mlx5_health_init(struct mlx5_core_dev *dev)
{
struct mlx5_core_health *health;
- char *name;
mlx5_fw_reporters_create(dev);
health = &dev->priv.health;
- name = kmalloc(64, GFP_KERNEL);
- if (!name)
- goto out_err;
- strcpy(name, "mlx5_health");
- strcat(name, dev_name(dev->device));
- health->wq = create_singlethread_workqueue(name);
- kfree(name);
+ health->wq = create_singlethread_workqueue("mlx5_health%s",
+ dev_name(dev->device));
if (!health->wq)
goto out_err;
spin_lock_init(&health->wq_lock);
--
2.27.0
next prev parent reply other threads:[~2021-04-18 21:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-18 21:25 [PATCH 0/2] workqueue: Have 'alloc_workqueue()' like macros accept a format specifier Christophe JAILLET
2021-04-18 21:26 ` [PATCH 1/2] " Christophe JAILLET
2021-04-18 23:03 ` Bart Van Assche
2021-04-19 6:36 ` Marion et Christophe JAILLET
2021-04-19 20:02 ` Bart Van Assche
2021-04-22 12:24 ` Jason Gunthorpe
2021-04-22 17:12 ` Bart Van Assche
2021-04-22 18:00 ` Leon Romanovsky
2021-04-22 20:30 ` Bart Van Assche
2021-04-23 14:02 ` Marco Elver
2021-04-23 14:27 ` Jason Gunthorpe
2021-04-29 10:31 ` Dan Carpenter
2021-04-19 6:56 ` Rasmus Villemoes
2021-04-18 21:26 ` Christophe JAILLET [this message]
2021-04-19 10:22 ` [PATCH 0/2] " Tejun Heo
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=a32dccb98017715d54853ac2e2aee360851539ce.1618780558.git.christophe.jaillet@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=bvanassche@acm.org \
--cc=davem@davemloft.net \
--cc=jiangshanlai@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=tj@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).