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

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.netSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent e9ac502c
...@@ -381,19 +381,19 @@ static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number) ...@@ -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]; u8 args[PCAN_USB_CMD_ARGS_LEN];
int err; int err;
err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_DEVID, PCAN_USB_GET, args); err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_DEVID, PCAN_USB_GET, args);
if (err) 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 else
*device_id = args[0]; *can_ch_id = args[0];
return err; return err;
} }
...@@ -1017,7 +1017,7 @@ const struct peak_usb_adapter pcan_usb = { ...@@ -1017,7 +1017,7 @@ const struct peak_usb_adapter pcan_usb = {
.dev_init = pcan_usb_init, .dev_init = pcan_usb_init,
.dev_set_bus = pcan_usb_write_mode, .dev_set_bus = pcan_usb_write_mode,
.dev_set_bittiming = pcan_usb_set_bittiming, .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_decode_buf = pcan_usb_decode_buf,
.dev_encode_msg = pcan_usb_encode_msg, .dev_encode_msg = pcan_usb_encode_msg,
.dev_start = pcan_usb_start, .dev_start = pcan_usb_start,
......
...@@ -921,12 +921,12 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter, ...@@ -921,12 +921,12 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter,
goto adap_dev_free; goto adap_dev_free;
} }
/* get device number early */ /* get CAN channel id early */
if (dev->adapter->dev_get_device_id) if (dev->adapter->dev_get_can_channel_id)
dev->adapter->dev_get_device_id(dev, &dev->device_number); dev->adapter->dev_get_can_channel_id(dev, &dev->can_channel_id);
netdev_info(netdev, "attached to %s channel %u (device %u)\n", 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; return 0;
......
...@@ -60,7 +60,7 @@ struct peak_usb_adapter { ...@@ -60,7 +60,7 @@ struct peak_usb_adapter {
int (*dev_set_data_bittiming)(struct peak_usb_device *dev, int (*dev_set_data_bittiming)(struct peak_usb_device *dev,
struct can_bittiming *bt); struct can_bittiming *bt);
int (*dev_set_bus)(struct peak_usb_device *dev, u8 onoff); 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_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
int (*dev_encode_msg)(struct peak_usb_device *dev, struct sk_buff *skb, int (*dev_encode_msg)(struct peak_usb_device *dev, struct sk_buff *skb,
u8 *obuf, size_t *size); u8 *obuf, size_t *size);
...@@ -122,7 +122,8 @@ struct peak_usb_device { ...@@ -122,7 +122,8 @@ struct peak_usb_device {
u8 *cmd_buf; u8 *cmd_buf;
struct usb_anchor rx_submitted; 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 device_rev;
u8 ep_msg_in; u8 ep_msg_in;
......
...@@ -972,7 +972,7 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev) ...@@ -972,7 +972,7 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev)
} }
pdev->usb_if->dev[dev->ctrl_idx] = 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]); 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 /* if vendor rsp is of type 2, then it contains EP numbers to
......
...@@ -419,8 +419,8 @@ static int pcan_usb_pro_set_led(struct peak_usb_device *dev, u8 mode, ...@@ -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); return pcan_usb_pro_send_cmd(dev, &um);
} }
static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev, static int pcan_usb_pro_get_can_channel_id(struct peak_usb_device *dev,
u32 *device_id) u32 *can_ch_id)
{ {
struct pcan_usb_pro_devid *pdn; struct pcan_usb_pro_devid *pdn;
struct pcan_usb_pro_msg um; struct pcan_usb_pro_msg um;
...@@ -439,7 +439,7 @@ static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev, ...@@ -439,7 +439,7 @@ static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev,
return err; return err;
pdn = (struct pcan_usb_pro_devid *)pc; 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; return err;
} }
...@@ -1076,7 +1076,7 @@ const struct peak_usb_adapter pcan_usb_pro = { ...@@ -1076,7 +1076,7 @@ const struct peak_usb_adapter pcan_usb_pro = {
.dev_free = pcan_usb_pro_free, .dev_free = pcan_usb_pro_free,
.dev_set_bus = pcan_usb_pro_set_bus, .dev_set_bus = pcan_usb_pro_set_bus,
.dev_set_bittiming = pcan_usb_pro_set_bittiming, .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_decode_buf = pcan_usb_pro_decode_buf,
.dev_encode_msg = pcan_usb_pro_encode_msg, .dev_encode_msg = pcan_usb_pro_encode_msg,
.dev_start = pcan_usb_pro_start, .dev_start = pcan_usb_pro_start,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment