diff mbox

[U-Boot,1/5] net: fec_mxc: remove useless struct nbuf

Message ID 1434716311-26189-2-git-send-email-albert.aribaud@3adev.fr
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Albert ARIBAUD (3ADEV) June 19, 2015, 12:18 p.m. UTC
This locally defined struct is actually only used once
and as an opaque type. Remove it for clarity.

Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---

 drivers/net/fec_mxc.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

Comments

Joe Hershberger June 19, 2015, 3:38 p.m. UTC | #1
Hi Albert,

On Fri, Jun 19, 2015 at 7:18 AM, Albert ARIBAUD (3ADEV)
<albert.aribaud@3adev.fr> wrote:
> This locally defined struct is actually only used once
> and as an opaque type. Remove it for clarity.
>
> Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
> ---
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Stefano Babic July 10, 2015, 8:03 a.m. UTC | #2
On 19/06/2015 14:18, Albert ARIBAUD (3ADEV) wrote:
> This locally defined struct is actually only used once
> and as an opaque type. Remove it for clarity.
> 
> Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
> ---
> 
>  drivers/net/fec_mxc.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 9225d37..c5dcbbb 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -67,13 +67,6 @@ DECLARE_GLOBAL_DATA_PTR;
>  
>  #undef DEBUG
>  
> -struct nbuf {
> -	uint8_t data[1500];	/**< actual data */
> -	int length;		/**< actual length */
> -	int used;		/**< buffer in use or not */
> -	uint8_t head[16];	/**< MAC header(6 + 6 + 2) + 2(aligned) */
> -};
> -
>  #ifdef CONFIG_FEC_MXC_SWAP_PACKET
>  static void swap_packet(uint32_t *packet, int length)
>  {
> @@ -775,7 +768,6 @@ static int fec_recv(struct eth_device *dev)
>  	struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index];
>  	unsigned long ievent;
>  	int frame_length, len = 0;
> -	struct nbuf *frame;
>  	uint16_t bd_status;
>  	uint32_t addr, size, end;
>  	int i;
> @@ -835,12 +827,11 @@ static int fec_recv(struct eth_device *dev)
>  			/*
>  			 * Get buffer address and size
>  			 */
> -			frame = (struct nbuf *)readl(&rbd->data_pointer);
> +			addr = readl(&rbd->data_pointer);
>  			frame_length = readw(&rbd->data_length) - 4;
>  			/*
>  			 * Invalidate data cache over the buffer
>  			 */
> -			addr = (uint32_t)frame;
>  			end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
>  			addr &= ~(ARCH_DMA_MINALIGN - 1);
>  			invalidate_dcache_range(addr, end);
> @@ -849,16 +840,15 @@ static int fec_recv(struct eth_device *dev)
>  			 *  Fill the buffer and pass it to upper layers
>  			 */
>  #ifdef CONFIG_FEC_MXC_SWAP_PACKET
> -			swap_packet((uint32_t *)frame->data, frame_length);
> +			swap_packet((uint32_t *)addr, frame_length);
>  #endif
> -			memcpy(buff, frame->data, frame_length);
> +			memcpy(buff, (char *)addr, frame_length);
>  			net_process_received_packet(buff, frame_length);
>  			len = frame_length;
>  		} else {
>  			if (bd_status & FEC_RBD_ERR)
> -				printf("error frame: 0x%08lx 0x%08x\n",
> -						(ulong)rbd->data_pointer,
> -						bd_status);
> +				printf("error frame: 0x%08x 0x%08x\n",
> +				       addr, bd_status);
>  		}
>  
>  		/*
> 

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 9225d37..c5dcbbb 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -67,13 +67,6 @@  DECLARE_GLOBAL_DATA_PTR;
 
 #undef DEBUG
 
-struct nbuf {
-	uint8_t data[1500];	/**< actual data */
-	int length;		/**< actual length */
-	int used;		/**< buffer in use or not */
-	uint8_t head[16];	/**< MAC header(6 + 6 + 2) + 2(aligned) */
-};
-
 #ifdef CONFIG_FEC_MXC_SWAP_PACKET
 static void swap_packet(uint32_t *packet, int length)
 {
@@ -775,7 +768,6 @@  static int fec_recv(struct eth_device *dev)
 	struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index];
 	unsigned long ievent;
 	int frame_length, len = 0;
-	struct nbuf *frame;
 	uint16_t bd_status;
 	uint32_t addr, size, end;
 	int i;
@@ -835,12 +827,11 @@  static int fec_recv(struct eth_device *dev)
 			/*
 			 * Get buffer address and size
 			 */
-			frame = (struct nbuf *)readl(&rbd->data_pointer);
+			addr = readl(&rbd->data_pointer);
 			frame_length = readw(&rbd->data_length) - 4;
 			/*
 			 * Invalidate data cache over the buffer
 			 */
-			addr = (uint32_t)frame;
 			end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
 			addr &= ~(ARCH_DMA_MINALIGN - 1);
 			invalidate_dcache_range(addr, end);
@@ -849,16 +840,15 @@  static int fec_recv(struct eth_device *dev)
 			 *  Fill the buffer and pass it to upper layers
 			 */
 #ifdef CONFIG_FEC_MXC_SWAP_PACKET
-			swap_packet((uint32_t *)frame->data, frame_length);
+			swap_packet((uint32_t *)addr, frame_length);
 #endif
-			memcpy(buff, frame->data, frame_length);
+			memcpy(buff, (char *)addr, frame_length);
 			net_process_received_packet(buff, frame_length);
 			len = frame_length;
 		} else {
 			if (bd_status & FEC_RBD_ERR)
-				printf("error frame: 0x%08lx 0x%08x\n",
-						(ulong)rbd->data_pointer,
-						bd_status);
+				printf("error frame: 0x%08x 0x%08x\n",
+				       addr, bd_status);
 		}
 
 		/*