Re: [PATCH 04/17] can: ems_usb: Added struct used for CAN FD initialization

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

 



On 11/6/20 6:01 PM, Gerhard Uttenthaler wrote:
> Signed-off-by: Gerhard Uttenthaler <uttenthaler@xxxxxxxxxxxxxxxx>
> ---
>  drivers/net/can/usb/ems_usb.c | 33 +++++++++++++++++++++++++++++++--
>  1 file changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
> index fa96217c7d72..4ed0d681a68c 100644
> --- a/drivers/net/can/usb/ems_usb.c
> +++ b/drivers/net/can/usb/ems_usb.c
> @@ -142,7 +142,7 @@ struct __packed cpc_canfd_msg {
>  #define CPC_FDFLAG_XTD          0x80
>  
>  /* Representation of the CAN parameters for the SJA1000 controller */
> -struct cpc_sja1000_params {
> +struct __packed cpc_sja1000_params {

please make that a separate patch

>  	u8 mode;
>  	u8 acc_code0;
>  	u8 acc_code1;
> @@ -157,12 +157,41 @@ struct cpc_sja1000_params {
>  	u8 outp_contr;
>  };
>  
> +#define CPC_GENERICCONF_FD          0x00000001
> +#define CPC_GENERICCONF_FD_BOSCH    0x00000002
> +#define CPC_GENERICCONF_LISTEN_ONLY 0x00000004
> +#define CPC_GENERICCONF_SINGLE_SHOT 0x00000008
> +#define CPC_GENERICCONF_RESET_MODE  0x00000010

use BIT()

> +
> +#define CPC_USB_RESET_MODE 0x00
> +#define CPC_USB_RUN_MODE   0x01
> +
> +struct __packed cpc_generic_can_params {
> +	/* config sets CAN initialization parameters like LOM */
> +	__le32 config;
> +	__le32 can_clk;
> +	struct {
> +		__le16 tseg1;  // Time segment 1 (before sample point)
> +		__le16 tseg2;  // Time segment 2 (after sample point)
> +		__le16 brp;    // Baud rate rate prescaler
> +		__le16 sjw;    // (Re)synchronization jump width
> +	} n;  // nominal baud rate
no C++ comments

why not call the variable nominal_bitrate?

> +	struct {
> +		__le16 tseg1;  // Time segment 1 (before sample point)
> +		__le16 tseg2;  // Time segment 2 (after sample point)
> +		__le16 brp;    // Baud rate prescaler
> +		__le16 sjw;    // (Re)synchronization jump width
> +	} d;  // data baud rate

data_bitrate

> +	__le32 reserved[5];    // Set to 0. Reserved for future use
> +};
> +
>  /* CAN params message representation */
> -struct cpc_can_params {
> +struct __packed cpc_can_params {
>  	u8 cc_type;
>  
>  	union {
>  		struct cpc_sja1000_params sja1000;
> +		struct cpc_generic_can_params generic;
>  	} cc_params;
>  };
>  
> 


-- 
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: OpenPGP digital 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