[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-can
Subject: Re: [PATCH 2/6] can: peak_usb: add callback to read user value of CANFD devices
From: Marc Kleine-Budde <mkl () pengutronix ! de>
Date: 2022-01-29 13:48:32
Message-ID: 20220129134832.ig44ibvgcokj6g77 () pengutronix ! de
[Download RAW message or body]
On 28.01.2022 16:01:53, Stephane Grosjean wrote:
> This patch adds the specific function that allows to read a user defined
> value from the non volatile memory of the USB CANFD interfaces of
> PEAK-System.
>
> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
> ---
> drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> 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..ab1a8b797ece 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> @@ -420,6 +420,24 @@ static int pcan_usb_fd_set_bittiming_fast(struct peak_usb_device *dev,
> return pcan_usb_fd_send_cmd(dev, ++cmd);
> }
>
> +/* read user device id from device */
> +static int pcan_usb_fd_get_user_devid(struct peak_usb_device *dev,
> + u32 *device_id)
> +{
> + struct pcan_usb_fd_device *pdev =
> + container_of(dev, struct pcan_usb_fd_device, dev);
> + struct pcan_ufd_fw_info *fw_info = &pdev->usb_if->fw_info;
> + int err;
> +
> + err = pcan_usb_pro_send_req(dev, PCAN_USBPRO_REQ_INFO,
> + PCAN_USBPRO_INFO_FW,
> + fw_info, sizeof(*fw_info));
> + if (!err)
> + *device_id = le32_to_cpu(fw_info->dev_id[dev->ctrl_idx]);
Nitpick: please use the more common return on error:
if (err)
return err;
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 |
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic