From patchwork Sun Apr 18 21:26:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12210409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33620C433B4 for ; Sun, 18 Apr 2021 21:26:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1745D61027 for ; Sun, 18 Apr 2021 21:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232480AbhDRV1E (ORCPT ); Sun, 18 Apr 2021 17:27:04 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:21529 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbhDRV1D (ORCPT ); Sun, 18 Apr 2021 17:27:03 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d25 with ME id uMSY2400B21Fzsu03MSZFK; Sun, 18 Apr 2021 23:26:33 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Apr 2021 23:26:33 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET 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 Subject: [PATCH 2/2] net/mlx5: Simplify workqueue name creation Date: Sun, 18 Apr 2021 23:26:31 +0200 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org 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 --- 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);