diff mbox series

[15/20] ethernet: ucc_geth: use UCC_GETH_{RX,TX}_BD_RING_ALIGNMENT macros directly

Message ID 20201205191744.7847-16-rasmus.villemoes@prevas.dk
State New
Headers show
Series [01/20] ethernet: ucc_geth: set dev->max_mtu to 1518 | expand

Commit Message

Rasmus Villemoes Dec. 5, 2020, 7:17 p.m. UTC
These macros both have the value 32, there's no point first
initializing align to a lower value.

If anything, one could throw in a
BUILD_BUG_ON(UCC_GETH_TX_BD_RING_ALIGNMENT < 4), but it's not worth it
- lots of code depends on named constants having sensible values.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/net/ethernet/freescale/ucc_geth.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Christophe Leroy Dec. 8, 2020, 3:14 p.m. UTC | #1
Le 05/12/2020 à 20:17, Rasmus Villemoes a écrit :
> These macros both have the value 32, there's no point first

> initializing align to a lower value.

> 

> If anything, one could throw in a

> BUILD_BUG_ON(UCC_GETH_TX_BD_RING_ALIGNMENT < 4), but it's not worth it

> - lots of code depends on named constants having sensible values.

> 

> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

> ---

>   drivers/net/ethernet/freescale/ucc_geth.c | 8 ++------

>   1 file changed, 2 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c

> index 273342233bba..ccde42f547b8 100644

> --- a/drivers/net/ethernet/freescale/ucc_geth.c

> +++ b/drivers/net/ethernet/freescale/ucc_geth.c

> @@ -2196,9 +2196,7 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)

>   		    UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)

>   			length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;

>   		if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {

> -			u32 align = 4;

> -			if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4)

> -				align = UCC_GETH_TX_BD_RING_ALIGNMENT;

> +			u32 align = UCC_GETH_TX_BD_RING_ALIGNMENT;


I think checkpatch.pl will expect an empty line here in addition.

>   			ugeth->tx_bd_ring_offset[j] =

>   				(u32) kmalloc((u32) (length + align), GFP_KERNEL);

>   

> @@ -2274,9 +2272,7 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)

>   	for (j = 0; j < ug_info->numQueuesRx; j++) {

>   		length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd);

>   		if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {

> -			u32 align = 4;

> -			if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)

> -				align = UCC_GETH_RX_BD_RING_ALIGNMENT;

> +			u32 align = UCC_GETH_RX_BD_RING_ALIGNMENT;


Same

>   			ugeth->rx_bd_ring_offset[j] =

>   				(u32) kmalloc((u32) (length + align), GFP_KERNEL);

>   			if (ugeth->rx_bd_ring_offset[j] != 0)

>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 273342233bba..ccde42f547b8 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -2196,9 +2196,7 @@  static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
 		    UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
 			length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
 		if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
-			u32 align = 4;
-			if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4)
-				align = UCC_GETH_TX_BD_RING_ALIGNMENT;
+			u32 align = UCC_GETH_TX_BD_RING_ALIGNMENT;
 			ugeth->tx_bd_ring_offset[j] =
 				(u32) kmalloc((u32) (length + align), GFP_KERNEL);
 
@@ -2274,9 +2272,7 @@  static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
 	for (j = 0; j < ug_info->numQueuesRx; j++) {
 		length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd);
 		if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
-			u32 align = 4;
-			if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
-				align = UCC_GETH_RX_BD_RING_ALIGNMENT;
+			u32 align = UCC_GETH_RX_BD_RING_ALIGNMENT;
 			ugeth->rx_bd_ring_offset[j] =
 				(u32) kmalloc((u32) (length + align), GFP_KERNEL);
 			if (ugeth->rx_bd_ring_offset[j] != 0)