All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Max Staudt <max@enpas.org>,
	Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Subject: [PATCH 3/9] can: slcan: add DRV_NAME and define pr_fmt to replace hardcoded names
Date: Tue, 26 Jul 2022 00:31:18 +0900	[thread overview]
Message-ID: <20220725153124.467061-4-mailhol.vincent@wanadoo.fr> (raw)
In-Reply-To: <20220725153124.467061-1-mailhol.vincent@wanadoo.fr>

The driver uses the string "slcan" to populate
tty_ldisc_ops::name. Add a new macro DRV_NAME which evaluates to
"slcan" and then use DRV_NAME and to get rid on the hardcoded string
names.

Similarly, the pr_info() and pr_err() hardcoded the "slcan"
prefix. Define pr_fmt so that the "slcan" prefix gets automatically
added.

CC: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---

@Dario, because you are also doing a lot of changes on slcan, our
patches might conflict. Do not hesitate to take this one and add it to
your series to simplify the merge.
---
 drivers/net/can/slcan/slcan-core.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
index dc28e715bbe1..d1562f9474c9 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -35,6 +35,9 @@
  *
  */
 
+#define DRV_NAME "slcan"
+#define pr_fmt(fmt) DRV_NAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 
@@ -864,7 +867,7 @@ static struct slcan *slc_alloc(void)
 	if (!dev)
 		return NULL;
 
-	snprintf(dev->name, sizeof(dev->name), "slcan%d", i);
+	snprintf(dev->name, sizeof(dev->name), DRV_NAME "%d", i);
 	dev->netdev_ops = &slc_netdev_ops;
 	dev->base_addr  = i;
 	slcan_set_ethtool_ops(dev);
@@ -937,7 +940,7 @@ static int slcan_open(struct tty_struct *tty)
 		rtnl_unlock();
 		err = register_candev(sl->dev);
 		if (err) {
-			pr_err("slcan: can't register candev\n");
+			pr_err("can't register candev\n");
 			goto err_free_chan;
 		}
 	} else {
@@ -1028,7 +1031,7 @@ static int slcan_ioctl(struct tty_struct *tty, unsigned int cmd,
 static struct tty_ldisc_ops slc_ldisc = {
 	.owner		= THIS_MODULE,
 	.num		= N_SLCAN,
-	.name		= "slcan",
+	.name		= DRV_NAME,
 	.open		= slcan_open,
 	.close		= slcan_close,
 	.hangup		= slcan_hangup,
@@ -1044,8 +1047,8 @@ static int __init slcan_init(void)
 	if (maxdev < 4)
 		maxdev = 4; /* Sanity */
 
-	pr_info("slcan: serial line CAN interface driver\n");
-	pr_info("slcan: %d dynamic interface channels.\n", maxdev);
+	pr_info("serial line CAN interface driver\n");
+	pr_info("%d dynamic interface channels.\n", maxdev);
 
 	slcan_devs = kcalloc(maxdev, sizeof(struct net_device *), GFP_KERNEL);
 	if (!slcan_devs)
@@ -1054,7 +1057,7 @@ static int __init slcan_init(void)
 	/* Fill in our line protocol discipline, and register it */
 	status = tty_register_ldisc(&slc_ldisc);
 	if (status)  {
-		pr_err("slcan: can't register line discipline\n");
+		pr_err("can't register line discipline\n");
 		kfree(slcan_devs);
 	}
 	return status;
-- 
2.35.1


  parent reply	other threads:[~2022-07-25 15:32 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 15:31 [PATCH 0/9] can: remove litteral strings used for driver name and remove DRV_VERSION Vincent Mailhol
2022-07-25 15:31 ` [PATCH 1/9] can: can327: use KBUILD_MODNAME instead of hard coded name Vincent Mailhol
2022-07-25 15:31 ` [PATCH 2/9] can: ems_ubs: " Vincent Mailhol
2022-07-25 17:34   ` Marc Kleine-Budde
2022-07-25 15:31 ` Vincent Mailhol [this message]
2022-07-25 15:31 ` [PATCH 4/9] can: softing: add DRV_NAME to replace hardcoded names Vincent Mailhol
2022-07-25 20:53   ` Marc Kleine-Budde
2022-07-25 15:31 ` [PATCH 5/9] can: esd_usb: use KBUILD_MODNAME instead of hard coded name Vincent Mailhol
2022-07-25 20:46   ` Marc Kleine-Budde
2022-07-25 15:31 ` [PATCH 6/9] can: gs_ubs: " Vincent Mailhol
2022-07-25 15:31 ` [PATCH 7/9] can: softing: add DRV_NAME to replace hardcoded names Vincent Mailhol
2022-07-25 20:50   ` Marc Kleine-Budde
2022-07-25 15:31 ` [PATCH 8/9] can: ubs_8dev: use KBUILD_MODNAME instead of hard coded name Vincent Mailhol
2022-07-25 15:31 ` [PATCH 9/9] can: etas_es58x: remove DRV_VERSION Vincent Mailhol
2022-07-26  8:26 ` [PATCH v2 00/10] can: remove litteral strings used for driver names and " Vincent Mailhol
2022-07-26  8:26   ` [PATCH v2 01/10] can: can327: use KBUILD_MODNAME instead of hard coded names Vincent Mailhol
2022-07-26  8:26   ` [PATCH v2 02/10] can: ems_usb: " Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 03/10] can: slcan: use KBUILD_MODNAME and define pr_fmt to replace hardcoded names Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 04/10] can: softing: use KBUILD_MODNAME instead of hard coded names Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 05/10] can: esd_usb: " Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 06/10] can: gs_ubs: " Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 07/10] can: kvaser_usb: " Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 08/10] can: ubs_8dev: " Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 09/10] can: etas_es58x: replace ES58X_MODULE_NAME with KBUILD_MODNAME Vincent Mailhol
2022-07-26  8:27   ` [PATCH v2 10/10] can: etas_es58x: remove DRV_VERSION Vincent Mailhol
2022-07-26  8:54   ` [PATCH v2 00/10] can: remove litteral strings used for driver names and " Marc Kleine-Budde
2022-07-26  9:58     ` Dario Binacchi
2022-07-26 12:43       ` Marc Kleine-Budde
2022-09-15 12:18   ` andy.shevchenko
2022-09-15 12:24     ` Marc Kleine-Budde
2022-09-15 12:27       ` Andy Shevchenko
2022-09-15 12:31         ` Marc Kleine-Budde

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=20220725153124.467061-4-mailhol.vincent@wanadoo.fr \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=linux-can@vger.kernel.org \
    --cc=max@enpas.org \
    --cc=mkl@pengutronix.de \
    /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.