forked from mirrors/linux
		
	can: bittiming: add CAN_KBPS, CAN_MBPS and CAN_MHZ macros
Add three macro to simplify the readability of big bit timing numbers:
  - CAN_KBPS: kilobits per second (one thousand)
  - CAN_MBPS: megabits per second (one million)
  - CAN_MHZ: megahertz per second (one million)
Example:
	u32 bitrate_max = 8 * CAN_MBPS;
	struct can_clock clock = {.freq = 80 * CAN_MHZ};
instead of:
	u32 bitrate_max = 8000000;
	struct can_clock clock = {.freq = 80000000};
Apply the new macro to driver/net/can/dev/bittiming.c.
Link: https://lore.kernel.org/r/20210306054040.76483-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
			
			
This commit is contained in:
		
							parent
							
								
									c25cc79932
								
							
						
					
					
						commit
						1d7750760b
					
				
					 2 changed files with 10 additions and 2 deletions
				
			
		| 
						 | 
					@ -81,9 +81,9 @@ int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
 | 
				
			||||||
	if (bt->sample_point) {
 | 
						if (bt->sample_point) {
 | 
				
			||||||
		sample_point_nominal = bt->sample_point;
 | 
							sample_point_nominal = bt->sample_point;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (bt->bitrate > 800000)
 | 
							if (bt->bitrate > 800 * CAN_KBPS)
 | 
				
			||||||
			sample_point_nominal = 750;
 | 
								sample_point_nominal = 750;
 | 
				
			||||||
		else if (bt->bitrate > 500000)
 | 
							else if (bt->bitrate > 500 * CAN_KBPS)
 | 
				
			||||||
			sample_point_nominal = 800;
 | 
								sample_point_nominal = 800;
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			sample_point_nominal = 875;
 | 
								sample_point_nominal = 875;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CAN_SYNC_SEG 1
 | 
					#define CAN_SYNC_SEG 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Kilobits and Megabits per second */
 | 
				
			||||||
 | 
					#define CAN_KBPS 1000UL
 | 
				
			||||||
 | 
					#define CAN_MBPS 1000000UL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Megahertz */
 | 
				
			||||||
 | 
					#define CAN_MHZ 1000000UL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * struct can_tdc - CAN FD Transmission Delay Compensation parameters
 | 
					 * struct can_tdc - CAN FD Transmission Delay Compensation parameters
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue