Skip to content

Commit

Permalink
Merge patch series "can: remove litteral strings used for driver name…
Browse files Browse the repository at this point in the history
…s and remove DRV_VERSION"

Vincent Mailhol <[email protected]> says:

====================

This is a cleanup series.

The patches 1 to 8 get rid of any hardcoded strings and instead relies
on the KBUILD_MODNAME macros to get the device name. Patch 9 replaces
the ES58X_MODULE_NAME macro with KBUILD_MODNAME in
etas_es58x. Finally, also in etas_es58x, patch 10 removes the
DRV_VERSION so that the module uses the default behavior and advertise
the kernel version instead of a custom version.

* Changelog *

v1 -> v2:

  * The patch for esd_usb contained some changes for ems_usb.

  * v1 assumed that KBUILD_MODNAME could only be used when the file
    basename and the module had the same name (e.g. vcan.c for the
    vcan.ko). The fact is that KBUILD_NAME extends to the module name
    and can thus be used even if the basename is different
    (e.g. slcan-core.c and slcan.ko)

  * Add patch torvalds#9: can: etas_es58x: replace ES58X_MODULE_NAME with
    KBUILD_MODNAME

v1: https://lore.kernel.org/all/[email protected]

This series are the first 9 patches of:
https://lore.kernel.org/linux-can/[email protected]/T/

The initial intent of those 9 patches was to do so cleanup in order to
implement ethtool_ops::get_drvinfo but this appeared to be useless:
https://lore.kernel.org/linux-can/[email protected]/

Instead, those patch are send as a standalone series.

====================

Drop "[PATCH v2 03/10] can: slcan: use KBUILD_MODNAME and define
pr_fmt to replace hardcoded names" to avoid conflicts with Dario
Binacchi's work on the slcan driver.

Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
marckleinebudde committed Jul 26, 2022
2 parents 1dba745 + ddbce34 commit a6e6231
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions drivers/net/can/can327.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Fred N. van Kempen <[email protected]>
*/

#define pr_fmt(fmt) "can327: " fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/init.h>
#include <linux/module.h>
Expand Down Expand Up @@ -1100,7 +1100,7 @@ static int can327_ldisc_ioctl(struct tty_struct *tty, unsigned int cmd,

static struct tty_ldisc_ops can327_ldisc = {
.owner = THIS_MODULE,
.name = "can327",
.name = KBUILD_MODNAME,
.num = N_CAN327,
.receive_buf = can327_ldisc_rx,
.write_wakeup = can327_ldisc_tx_wakeup,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/can/softing/softing_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ static const struct net_device_ops softing_netdev_ops = {
};

static const struct can_bittiming_const softing_btr_const = {
.name = "softing",
.name = KBUILD_MODNAME,
.tseg1_min = 1,
.tseg1_max = 16,
.tseg2_min = 1,
Expand Down Expand Up @@ -846,7 +846,7 @@ static int softing_pdev_probe(struct platform_device *pdev)

static struct platform_driver softing_driver = {
.driver = {
.name = "softing",
.name = KBUILD_MODNAME,
},
.probe = softing_pdev_probe,
.remove = softing_pdev_remove,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/can/usb/ems_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static const struct net_device_ops ems_usb_netdev_ops = {
};

static const struct can_bittiming_const ems_usb_bittiming_const = {
.name = "ems_usb",
.name = KBUILD_MODNAME,
.tseg1_min = 1,
.tseg1_max = 16,
.tseg2_min = 1,
Expand Down Expand Up @@ -1074,7 +1074,7 @@ static void ems_usb_disconnect(struct usb_interface *intf)

/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver ems_usb_driver = {
.name = "ems_usb",
.name = KBUILD_MODNAME,
.probe = ems_usb_probe,
.disconnect = ems_usb_disconnect,
.id_table = ems_usb_table,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/usb/esd_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ static void esd_usb_disconnect(struct usb_interface *intf)

/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver esd_usb_driver = {
.name = "esd_usb",
.name = KBUILD_MODNAME,
.probe = esd_usb_probe,
.disconnect = esd_usb_disconnect,
.id_table = esd_usb_table,
Expand Down
14 changes: 5 additions & 9 deletions drivers/net/can/usb/etas_es58x/es58x_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@

#include "es58x_core.h"

#define DRV_VERSION "1.00"
MODULE_AUTHOR("Vincent Mailhol <[email protected]>");
MODULE_AUTHOR("Arunachalam Santhanam <[email protected]>");
MODULE_DESCRIPTION("Socket CAN driver for ETAS ES58X USB adapters");
MODULE_VERSION(DRV_VERSION);
MODULE_LICENSE("GPL v2");

#define ES58X_MODULE_NAME "etas_es58x"
#define ES58X_VENDOR_ID 0x108C
#define ES581_4_PRODUCT_ID 0x0159
#define ES582_1_PRODUCT_ID 0x0168
Expand Down Expand Up @@ -59,11 +56,11 @@ MODULE_DEVICE_TABLE(usb, es58x_id_table);

#define es58x_print_hex_dump(buf, len) \
print_hex_dump(KERN_DEBUG, \
ES58X_MODULE_NAME " " __stringify(buf) ": ", \
KBUILD_MODNAME " " __stringify(buf) ": ", \
DUMP_PREFIX_NONE, 16, 1, buf, len, false)

#define es58x_print_hex_dump_debug(buf, len) \
print_hex_dump_debug(ES58X_MODULE_NAME " " __stringify(buf) ": ",\
print_hex_dump_debug(KBUILD_MODNAME " " __stringify(buf) ": ",\
DUMP_PREFIX_NONE, 16, 1, buf, len, false)

/* The last two bytes of an ES58X command is a CRC16. The first two
Expand Down Expand Up @@ -2181,9 +2178,8 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf,
struct usb_endpoint_descriptor *ep_in, *ep_out;
int ret;

dev_info(dev,
"Starting %s %s (Serial Number %s) driver version %s\n",
udev->manufacturer, udev->product, udev->serial, DRV_VERSION);
dev_info(dev, "Starting %s %s (Serial Number %s)\n",
udev->manufacturer, udev->product, udev->serial);

ret = usb_find_common_endpoints(intf->cur_altsetting, &ep_in, &ep_out,
NULL, NULL);
Expand Down Expand Up @@ -2280,7 +2276,7 @@ static void es58x_disconnect(struct usb_interface *intf)
}

static struct usb_driver es58x_driver = {
.name = ES58X_MODULE_NAME,
.name = KBUILD_MODNAME,
.probe = es58x_probe,
.disconnect = es58x_disconnect,
.id_table = es58x_id_table
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/can/usb/gs_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
netdev->flags |= IFF_ECHO; /* we support full roundtrip echo */

/* dev setup */
strcpy(dev->bt_const.name, "gs_usb");
strcpy(dev->bt_const.name, KBUILD_MODNAME);
dev->bt_const.tseg1_min = le32_to_cpu(bt_const->tseg1_min);
dev->bt_const.tseg1_max = le32_to_cpu(bt_const->tseg1_max);
dev->bt_const.tseg2_min = le32_to_cpu(bt_const->tseg2_min);
Expand Down Expand Up @@ -1100,7 +1100,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
return ERR_PTR(rc);
}

strcpy(dev->data_bt_const.name, "gs_usb");
strcpy(dev->data_bt_const.name, KBUILD_MODNAME);
dev->data_bt_const.tseg1_min = le32_to_cpu(bt_const_extended->dtseg1_min);
dev->data_bt_const.tseg1_max = le32_to_cpu(bt_const_extended->dtseg1_max);
dev->data_bt_const.tseg2_min = le32_to_cpu(bt_const_extended->dtseg2_min);
Expand Down Expand Up @@ -1270,7 +1270,7 @@ static const struct usb_device_id gs_usb_table[] = {
MODULE_DEVICE_TABLE(usb, gs_usb_table);

static struct usb_driver gs_usb_driver = {
.name = "gs_usb",
.name = KBUILD_MODNAME,
.probe = gs_usb_probe,
.disconnect = gs_usb_disconnect,
.id_table = gs_usb_table,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ static void kvaser_usb_disconnect(struct usb_interface *intf)
}

static struct usb_driver kvaser_usb_driver = {
.name = "kvaser_usb",
.name = KBUILD_MODNAME,
.probe = kvaser_usb_probe,
.disconnect = kvaser_usb_disconnect,
.id_table = kvaser_usb_table,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/can/usb/usb_8dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ static const struct net_device_ops usb_8dev_netdev_ops = {
};

static const struct can_bittiming_const usb_8dev_bittiming_const = {
.name = "usb_8dev",
.name = KBUILD_MODNAME,
.tseg1_min = 1,
.tseg1_max = 16,
.tseg2_min = 1,
Expand Down Expand Up @@ -997,7 +997,7 @@ static void usb_8dev_disconnect(struct usb_interface *intf)
}

static struct usb_driver usb_8dev_driver = {
.name = "usb_8dev",
.name = KBUILD_MODNAME,
.probe = usb_8dev_probe,
.disconnect = usb_8dev_disconnect,
.id_table = usb_8dev_table,
Expand Down

0 comments on commit a6e6231

Please sign in to comment.