Commit 404ffaa9 authored by Stephane Grosjean's avatar Stephane Grosjean Committed by Marc Kleine-Budde
Browse files

can: peak_usb: rename device_id to CAN channel ID



The so-called "device id" is a user-defined identifier value that can be
set individually for each CAN interface of a PEAK USB device.
Contrary to a static serial number, the value can be changed by the
user. With this ID, each CAN interface can be uniquely identified even if
the USB device does not export a proper serial number or the USB device
exports multiple CAN interfaces. In order to not confuse it with the
device ID used by the USB core and emphasize the link to the CAN
interface, the functions and variables for reading this user-defined
value are renamed to CAN channel ID.

Signed-off-by: default avatarStephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: default avatarLukas Magel <lukas.magel@posteo.net>
Link: https://lore.kernel.org/all/20230116200932.157769-2-lukas.magel@posteo.net


Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent e9ac502c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -381,19 +381,19 @@ static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number)
}

/*
 * read device id from device
 * read can channel id from device
 */
static int pcan_usb_get_device_id(struct peak_usb_device *dev, u32 *device_id)
static int pcan_usb_get_can_channel_id(struct peak_usb_device *dev, u32 *can_ch_id)
{
	u8 args[PCAN_USB_CMD_ARGS_LEN];
	int err;

	err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_DEVID, PCAN_USB_GET, args);
	if (err)
		netdev_err(dev->netdev, "getting device id failure: %d\n", err);
		netdev_err(dev->netdev, "getting can channel id failure: %d\n", err);

	else
		*device_id = args[0];
		*can_ch_id = args[0];

	return err;
}
@@ -1017,7 +1017,7 @@ const struct peak_usb_adapter pcan_usb = {
	.dev_init = pcan_usb_init,
	.dev_set_bus = pcan_usb_write_mode,
	.dev_set_bittiming = pcan_usb_set_bittiming,
	.dev_get_device_id = pcan_usb_get_device_id,
	.dev_get_can_channel_id = pcan_usb_get_can_channel_id,
	.dev_decode_buf = pcan_usb_decode_buf,
	.dev_encode_msg = pcan_usb_encode_msg,
	.dev_start = pcan_usb_start,
+4 −4
Original line number Diff line number Diff line
@@ -921,12 +921,12 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter,
			goto adap_dev_free;
	}

	/* get device number early */
	if (dev->adapter->dev_get_device_id)
		dev->adapter->dev_get_device_id(dev, &dev->device_number);
	/* get CAN channel id early */
	if (dev->adapter->dev_get_can_channel_id)
		dev->adapter->dev_get_can_channel_id(dev, &dev->can_channel_id);

	netdev_info(netdev, "attached to %s channel %u (device %u)\n",
			peak_usb_adapter->name, ctrl_idx, dev->device_number);
			peak_usb_adapter->name, ctrl_idx, dev->can_channel_id);

	return 0;

+3 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ struct peak_usb_adapter {
	int (*dev_set_data_bittiming)(struct peak_usb_device *dev,
				      struct can_bittiming *bt);
	int (*dev_set_bus)(struct peak_usb_device *dev, u8 onoff);
	int (*dev_get_device_id)(struct peak_usb_device *dev, u32 *device_id);
	int (*dev_get_can_channel_id)(struct peak_usb_device *dev, u32 *can_ch_id);
	int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
	int (*dev_encode_msg)(struct peak_usb_device *dev, struct sk_buff *skb,
					u8 *obuf, size_t *size);
@@ -122,7 +122,8 @@ struct peak_usb_device {
	u8 *cmd_buf;
	struct usb_anchor rx_submitted;

	u32 device_number;
	/* equivalent to the device ID in the Windows API */
	u32 can_channel_id;
	u8 device_rev;

	u8 ep_msg_in;
+1 −1
Original line number Diff line number Diff line
@@ -972,7 +972,7 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev)
	}

	pdev->usb_if->dev[dev->ctrl_idx] = dev;
	dev->device_number =
	dev->can_channel_id =
		le32_to_cpu(pdev->usb_if->fw_info.dev_id[dev->ctrl_idx]);

	/* if vendor rsp is of type 2, then it contains EP numbers to
+4 −4
Original line number Diff line number Diff line
@@ -419,8 +419,8 @@ static int pcan_usb_pro_set_led(struct peak_usb_device *dev, u8 mode,
	return pcan_usb_pro_send_cmd(dev, &um);
}

static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev,
				      u32 *device_id)
static int pcan_usb_pro_get_can_channel_id(struct peak_usb_device *dev,
					   u32 *can_ch_id)
{
	struct pcan_usb_pro_devid *pdn;
	struct pcan_usb_pro_msg um;
@@ -439,7 +439,7 @@ static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev,
		return err;

	pdn = (struct pcan_usb_pro_devid *)pc;
	*device_id = le32_to_cpu(pdn->dev_num);
	*can_ch_id = le32_to_cpu(pdn->dev_num);

	return err;
}
@@ -1076,7 +1076,7 @@ const struct peak_usb_adapter pcan_usb_pro = {
	.dev_free = pcan_usb_pro_free,
	.dev_set_bus = pcan_usb_pro_set_bus,
	.dev_set_bittiming = pcan_usb_pro_set_bittiming,
	.dev_get_device_id = pcan_usb_pro_get_device_id,
	.dev_get_can_channel_id = pcan_usb_pro_get_can_channel_id,
	.dev_decode_buf = pcan_usb_pro_decode_buf,
	.dev_encode_msg = pcan_usb_pro_encode_msg,
	.dev_start = pcan_usb_pro_start,