On 28.01.2022 16:01:55, Stephane Grosjean wrote: > This series of patches adds a callback that allows the user to flash a > self-defined value to all USB - CAN/CANFD interfaces of PEAK-System managed > by this driver, namely: > - PCAN-USB > - PCAN-USB FD > - PCAN-USB Pro FD > - PCAN-USB X6 > - PCAN-Chip USB > - PCAN-USB Pro > > Signed-off-by: Stephane Grosjean <s.grosjean@xxxxxxxxxxxxxxx> > --- > drivers/net/can/usb/peak_usb/pcan_usb.c | 20 +++++++++++++++ > drivers/net/can/usb/peak_usb/pcan_usb_core.h | 1 + > drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 26 ++++++++++++++++++++ > drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 15 +++++++++++ > drivers/net/can/usb/peak_usb/pcan_usb_pro.h | 1 + > 5 files changed, 63 insertions(+) > > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c > index 954abf43d552..b29daaab2e6e 100644 > --- a/drivers/net/can/usb/peak_usb/pcan_usb.c > +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c > @@ -398,6 +398,25 @@ static int pcan_usb_get_user_devid(struct peak_usb_device *dev, u32 *device_id) > return err; > } > > +/* set a new user device id in the flash memory of the device */ > +static int pcan_usb_set_user_devid(struct peak_usb_device *dev, u32 devid) > +{ > + u8 args[PCAN_USB_CMD_ARGS_LEN]; > + > + /* this kind of device supports 8-bit values only */ > + if (devid > 255) > + return -EINVAL; please use U8_MAX. > + > + /* during the flash process the device disconnects during ~1.25 s.: > + * prohibit access when interface is UP > + */ > + if (dev->netdev->flags & IFF_UP) > + return -EBUSY; > + > + args[0] = (u8)devid; cast not needed. 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