[PATCH v5 05/16] can: grcan: Replace bit timing macros with literal values

Arun Muthusamy posted 16 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v5 05/16] can: grcan: Replace bit timing macros with literal values
Posted by Arun Muthusamy 1 month, 2 weeks ago
Refactor the bit timing constants in grcan_bittiming_const by replacing
macros with literal values.

Signed-off-by: Arun Muthusamy <arun.muthusamy@gaisler.com>
Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
---
 drivers/net/can/grcan.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
index f3821e224f4f..12fd4911add2 100644
--- a/drivers/net/can/grcan.c
+++ b/drivers/net/can/grcan.c
@@ -36,6 +36,7 @@
 #include <linux/of_irq.h>
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
+#include <linux/bitfield.h>
 
 #define DRV_NAME	"grcan"
 
@@ -93,16 +94,6 @@ struct grcan_registers {
 	(GRCAN_CONF_BPR | GRCAN_CONF_RSJ | GRCAN_CONF_PS1		\
 	 | GRCAN_CONF_PS2 | GRCAN_CONF_SCALER)
 
-#define GRCAN_CONF_RSJ_MIN	1
-#define GRCAN_CONF_RSJ_MAX	4
-#define GRCAN_CONF_PS1_MIN	1
-#define GRCAN_CONF_PS1_MAX	15
-#define GRCAN_CONF_PS2_MIN	2
-#define GRCAN_CONF_PS2_MAX	8
-#define GRCAN_CONF_SCALER_MIN	0
-#define GRCAN_CONF_SCALER_MAX	255
-#define GRCAN_CONF_SCALER_INC	1
-
 #define GRCAN_CONF_BPR_BIT	8
 #define GRCAN_CONF_RSJ_BIT	12
 #define GRCAN_CONF_PS1_BIT	20
@@ -392,14 +383,14 @@ static struct grcan_device_config grcan_module_config =
 
 static const struct can_bittiming_const grcan_bittiming_const = {
 	.name		= DRV_NAME,
-	.tseg1_min	= GRCAN_CONF_PS1_MIN + 1,
-	.tseg1_max	= GRCAN_CONF_PS1_MAX + 1,
-	.tseg2_min	= GRCAN_CONF_PS2_MIN,
-	.tseg2_max	= GRCAN_CONF_PS2_MAX,
-	.sjw_max	= GRCAN_CONF_RSJ_MAX,
-	.brp_min	= GRCAN_CONF_SCALER_MIN + 1,
-	.brp_max	= GRCAN_CONF_SCALER_MAX + 1,
-	.brp_inc	= GRCAN_CONF_SCALER_INC,
+	.tseg1_min	= 2,
+	.tseg1_max	= 16,
+	.tseg2_min	= 2,
+	.tseg2_max	= 8,
+	.sjw_max	= 4,
+	.brp_min	= 1,
+	.brp_max	= 256,
+	.brp_inc	= 1,
 };
 
 static int grcan_set_bittiming(struct net_device *dev)
-- 
2.51.0
Re: [PATCH v5 05/16] can: grcan: Replace bit timing macros with literal values
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On 16/02/2026 14:53, Arun Muthusamy wrote:
> Refactor the bit timing constants in grcan_bittiming_const by replacing
> macros with literal values.
> 
> Signed-off-by: Arun Muthusamy <arun.muthusamy@gaisler.com>
> Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>

It's random DCO all over. One patch has this order, other patch has a
reversed one.

Please read submitting patches document to understand what you certify
and THEN certify that in a way submitting patches asks you. Not other way.

Best regards,
Krzysztof
Re: [PATCH v5 05/16] can: grcan: Replace bit timing macros with literal values
Posted by Arun Muthusamy 4 weeks ago
On 2/16/26 16:01, Krzysztof Kozlowski wrote:
> On 16/02/2026 14:53, Arun Muthusamy wrote:
>> Refactor the bit timing constants in grcan_bittiming_const by replacing
>> macros with literal values.
>>
>> Signed-off-by: Arun Muthusamy <arun.muthusamy@gaisler.com>
>> Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
> It's random DCO all over. One patch has this order, other patch has a
> reversed one.
>
> Please read submitting patches document to understand what you certify
> and THEN certify that in a way submitting patches asks you. Not other way.
>
Thank you for pointing this out. I apologize for the mistake.
I've corrected the DCO order issue, and it will be addressed in the upcoming patch series.

-- 
-- 
BR,

Arun Muthusamy
Software Engineer
Frontgrade Gaisler
T : +46 (0) 700 558 528
arun.muthusamy@gaisler.com

Frontgrade Gaisler AB, Kungsgatan 12, SE-411 19 GÖTEBORG, Sweden.
+46 (0) 31 775 8650, www.gaisler.com