net: dm9000: Turn DM9000_DMP_PACKET() into a function

Rework DM9000_DMP_PACKET() into dm9000_dump_packet() function,
this brings better type checking. No functional change.

Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
This commit is contained in:
Marek Vasut 2022-04-13 04:15:27 +02:00 committed by Ramon Fried
parent d1854794c0
commit c7b7ee52b2

View File

@ -58,25 +58,6 @@ TODO: external MII is not functional, only internal at the moment.
#include "dm9000x.h" #include "dm9000x.h"
/* Board/System/Debug information/definition ---------------- */
/* #define CONFIG_DM9000_DEBUG */
#ifdef CONFIG_DM9000_DEBUG
#define DM9000_DMP_PACKET(func,packet,length) \
do { \
int i; \
printf("%s: length: %d\n", func, length); \
for (i = 0; i < length; i++) { \
if (i % 8 == 0) \
printf("\n%s: %02x: ", func, i); \
printf("%02x ", ((unsigned char *) packet)[i]); \
} printf("\n"); \
} while(0)
#else
#define DM9000_DMP_PACKET(func,packet,length)
#endif
/* Structure/enum declaration ------------------------------- */ /* Structure/enum declaration ------------------------------- */
typedef struct board_info { typedef struct board_info {
u32 runt_length_counter; /* counter: RX length < 64byte */ u32 runt_length_counter; /* counter: RX length < 64byte */
@ -122,6 +103,25 @@ static void dm9000_iow(int reg, u8 value);
#define dm9000_inl(r) __raw_readl(r) #define dm9000_inl(r) __raw_readl(r)
#endif #endif
#ifdef DEBUG
static void dm9000_dump_packet(const char *func, u8 *packet, int length)
{
int i;
printf("%s: length: %d\n", func, length);
for (i = 0; i < length; i++) {
if (i % 8 == 0)
printf("\n%s: %02x: ", func, i);
printf("%02x ", packet[i]);
}
printf("\n");
}
#else
static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
#endif
static void dm9000_outblk_8bit(volatile void *data_ptr, int count) static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
{ {
int i; int i;
@ -387,7 +387,7 @@ static int dm9000_send(struct eth_device *netdev, void *packet, int length)
int tmo; int tmo;
struct board_info *db = &dm9000_info; struct board_info *db = &dm9000_info;
DM9000_DMP_PACKET(__func__ , packet, length); dm9000_dump_packet(__func__ , packet, length);
dm9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */ dm9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
@ -498,7 +498,7 @@ static int dm9000_rx(struct eth_device *netdev)
dm9000_reset(); dm9000_reset();
} }
} else { } else {
DM9000_DMP_PACKET(__func__ , rdptr, rxlen); dm9000_dump_packet(__func__ , rdptr, rxlen);
debug("passing packet to upper layer\n"); debug("passing packet to upper layer\n");
net_process_received_packet(net_rx_packets[0], rxlen); net_process_received_packet(net_rx_packets[0], rxlen);