Re: [PATCH 3/3] can: peak_usb: Includes support for a new MCU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19.07.2022 14:06:32, Stephane Grosjean wrote:
> The CANFD-USB PCAN-USB FD interface undergoes an internal component change
> that requires a slight modification of its drivers, which leads them to
> dynamically use endpoint numbers provided by the interface itself.
> In addition to a change in the calls to the USB functions exported by the
> kernel, the detection of the USB interface dedicated to CAN must also be
> modified, as some PEAK-System devices support other interfaces than CAN.
> 
> Signed-off-by: Stephane Grosjean <s.grosjean@xxxxxxxxxxxxxxx>
> ---
>  drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 70 ++++++++++++++++++----
>  1 file changed, 60 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> index 65487ec33566..267a70d3a5d1 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
[...]
> @@ -910,6 +941,14 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev)
>  			dev->can.ctrlmode |= CAN_CTRLMODE_FD_NON_ISO;
>  		}
>  
> +		/* if vendor rsp is of type 2, then it contains EP numbers to
> +		 * use for cmds pipes. If not, then default EP should be used.
> +		 */
> +		if (fw_info->type != PCAN_USBFD_TYPE_EXT) {

This and the other type comparison throws the following warning:

  CHECK   /srv/work/frogger/socketcan/linux/drivers/net/can/usb/peak_usb/pcan_usb_fd.c                                                                                                          
drivers/net/can/usb/peak_usb/pcan_usb_fd.c:945:28: warning: restricted __le16 degrades to integer                                                             
drivers/net/can/usb/peak_usb/pcan_usb_fd.c:982:20: warning: restricted __le16 degrades to integer 

I've fixed them with this incremental patch:

-               if (fw_info->type != PCAN_USBFD_TYPE_EXT) {
+               if (fw_info->type != cpu_to_le16(PCAN_USBFD_TYPE_EXT)) {

> +			fw_info->cmd_out_ep = PCAN_USBPRO_EP_CMDOUT;
> +			fw_info->cmd_in_ep = PCAN_USBPRO_EP_CMDIN;
> +		}
> +
>  		/* tell the hardware the can driver is running */
>  		err = pcan_usb_fd_drv_loaded(dev, 1);
>  		if (err) {
> @@ -930,12 +969,23 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev)
>  		/* do a copy of the ctrlmode[_supported] too */
>  		dev->can.ctrlmode = ppdev->dev.can.ctrlmode;
>  		dev->can.ctrlmode_supported = ppdev->dev.can.ctrlmode_supported;
> +
> +		fw_info = &pdev->usb_if->fw_info;
>  	}
>  
>  	pdev->usb_if->dev[dev->ctrl_idx] = dev;
>  	dev->device_number =
>  		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
> +	 * use for data pipes. If not, then statically defined EP are used
> +	 * (see peak_usb_create_dev()).
> +	 */
> +	if (fw_info->type == PCAN_USBFD_TYPE_EXT) {
> +		dev->ep_msg_in = fw_info->data_in_ep;
> +		dev->ep_msg_out = fw_info->data_out_ep[dev->ctrl_idx];
> +	}

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux