Commit ae3554ba authored by David S. Miller's avatar David S. Miller

Merge branch 'hd6470-cleanups'

Peng Li says:

====================
net: hd64570: clean up some code style issues

This patchset clean up some code style issues.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 06d62113 0f1e7a34
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#define SCA_INTR_DMAC_RX(node) (node ? 0x20 : 0x02) #define SCA_INTR_DMAC_RX(node) (node ? 0x20 : 0x02)
#define SCA_INTR_DMAC_TX(node) (node ? 0x40 : 0x04) #define SCA_INTR_DMAC_TX(node) (node ? 0x40 : 0x04)
static inline struct net_device *port_to_dev(port_t *port) static inline struct net_device *port_to_dev(port_t *port)
{ {
return port->dev; return port->dev;
...@@ -59,12 +58,18 @@ static inline int sca_intr_status(card_t *card) ...@@ -59,12 +58,18 @@ static inline int sca_intr_status(card_t *card)
u8 isr0 = sca_in(ISR0, card); u8 isr0 = sca_in(ISR0, card);
u8 isr1 = sca_in(ISR1, card); u8 isr1 = sca_in(ISR1, card);
if (isr1 & 0x03) result |= SCA_INTR_DMAC_RX(0); if (isr1 & 0x03)
if (isr1 & 0x0C) result |= SCA_INTR_DMAC_TX(0); result |= SCA_INTR_DMAC_RX(0);
if (isr1 & 0x30) result |= SCA_INTR_DMAC_RX(1); if (isr1 & 0x0C)
if (isr1 & 0xC0) result |= SCA_INTR_DMAC_TX(1); result |= SCA_INTR_DMAC_TX(0);
if (isr0 & 0x0F) result |= SCA_INTR_MSCI(0); if (isr1 & 0x30)
if (isr0 & 0xF0) result |= SCA_INTR_MSCI(1); result |= SCA_INTR_DMAC_RX(1);
if (isr1 & 0xC0)
result |= SCA_INTR_DMAC_TX(1);
if (isr0 & 0x0F)
result |= SCA_INTR_MSCI(0);
if (isr0 & 0xF0)
result |= SCA_INTR_MSCI(1);
if (!(result & SCA_INTR_DMAC_TX(0))) if (!(result & SCA_INTR_DMAC_TX(0)))
if (sca_in(DSR_TX(0), card) & DSR_EOM) if (sca_in(DSR_TX(0), card) & DSR_EOM)
...@@ -76,7 +81,7 @@ static inline int sca_intr_status(card_t *card) ...@@ -76,7 +81,7 @@ static inline int sca_intr_status(card_t *card)
return result; return result;
} }
static inline port_t* dev_to_port(struct net_device *dev) static inline port_t *dev_to_port(struct net_device *dev)
{ {
return dev_to_hdlc(dev)->priv; return dev_to_hdlc(dev)->priv;
} }
...@@ -87,7 +92,6 @@ static inline u16 next_desc(port_t *port, u16 desc, int transmit) ...@@ -87,7 +92,6 @@ static inline u16 next_desc(port_t *port, u16 desc, int transmit)
: port_to_card(port)->rx_ring_buffers); : port_to_card(port)->rx_ring_buffers);
} }
static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit)
{ {
u16 rx_buffs = port_to_card(port)->rx_ring_buffers; u16 rx_buffs = port_to_card(port)->rx_ring_buffers;
...@@ -98,14 +102,12 @@ static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) ...@@ -98,14 +102,12 @@ static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit)
transmit * rx_buffs + desc; transmit * rx_buffs + desc;
} }
static inline u16 desc_offset(port_t *port, u16 desc, int transmit) static inline u16 desc_offset(port_t *port, u16 desc, int transmit)
{ {
/* Descriptor offset always fits in 16 bits */ /* Descriptor offset always fits in 16 bits */
return desc_abs_number(port, desc, transmit) * sizeof(pkt_desc); return desc_abs_number(port, desc, transmit) * sizeof(pkt_desc);
} }
static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc,
int transmit) int transmit)
{ {
...@@ -118,14 +120,12 @@ static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, ...@@ -118,14 +120,12 @@ static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc,
#endif #endif
} }
static inline u32 buffer_offset(port_t *port, u16 desc, int transmit) static inline u32 buffer_offset(port_t *port, u16 desc, int transmit)
{ {
return port_to_card(port)->buff_offset + return port_to_card(port)->buff_offset +
desc_abs_number(port, desc, transmit) * (u32)HDLC_MAX_MRU; desc_abs_number(port, desc, transmit) * (u32)HDLC_MAX_MRU;
} }
static inline void sca_set_carrier(port_t *port) static inline void sca_set_carrier(port_t *port)
{ {
if (!(sca_in(get_msci(port) + ST3, port_to_card(port)) & ST3_DCD)) { if (!(sca_in(get_msci(port) + ST3, port_to_card(port)) & ST3_DCD)) {
...@@ -143,7 +143,6 @@ static inline void sca_set_carrier(port_t *port) ...@@ -143,7 +143,6 @@ static inline void sca_set_carrier(port_t *port)
} }
} }
static void sca_init_port(port_t *port) static void sca_init_port(port_t *port)
{ {
card_t *card = port_to_card(port); card_t *card = port_to_card(port);
...@@ -213,13 +212,12 @@ static void sca_init_port(port_t *port) ...@@ -213,13 +212,12 @@ static void sca_init_port(port_t *port)
sca_set_carrier(port); sca_set_carrier(port);
} }
#ifdef NEED_SCA_MSCI_INTR #ifdef NEED_SCA_MSCI_INTR
/* MSCI interrupt service */ /* MSCI interrupt service */
static inline void sca_msci_intr(port_t *port) static inline void sca_msci_intr(port_t *port)
{ {
u16 msci = get_msci(port); u16 msci = get_msci(port);
card_t* card = port_to_card(port); card_t *card = port_to_card(port);
u8 stat = sca_in(msci + ST1, card); /* read MSCI ST1 status */ u8 stat = sca_in(msci + ST1, card); /* read MSCI ST1 status */
/* Reset MSCI TX underrun and CDCD status bit */ /* Reset MSCI TX underrun and CDCD status bit */
...@@ -236,7 +234,6 @@ static inline void sca_msci_intr(port_t *port) ...@@ -236,7 +234,6 @@ static inline void sca_msci_intr(port_t *port)
} }
#endif #endif
static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
u16 rxin) u16 rxin)
{ {
...@@ -265,8 +262,9 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, ...@@ -265,8 +262,9 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
memcpy_fromio(skb->data, winbase(card) + buff, maxlen); memcpy_fromio(skb->data, winbase(card) + buff, maxlen);
openwin(card, page + 1); openwin(card, page + 1);
memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen); memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen);
} else } else {
memcpy_fromio(skb->data, winbase(card) + buff, len); memcpy_fromio(skb->data, winbase(card) + buff, len);
}
#ifndef PAGE0_ALWAYS_MAPPED #ifndef PAGE0_ALWAYS_MAPPED
openwin(card, 0); /* select pkt_desc table page back */ openwin(card, 0); /* select pkt_desc table page back */
...@@ -282,7 +280,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, ...@@ -282,7 +280,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
netif_rx(skb); netif_rx(skb);
} }
/* Receive DMA interrupt service */ /* Receive DMA interrupt service */
static inline void sca_rx_intr(port_t *port) static inline void sca_rx_intr(port_t *port)
{ {
...@@ -304,7 +301,7 @@ static inline void sca_rx_intr(port_t *port) ...@@ -304,7 +301,7 @@ static inline void sca_rx_intr(port_t *port)
pkt_desc __iomem *desc; pkt_desc __iomem *desc;
u32 cda = sca_inw(dmac + CDAL, card); u32 cda = sca_inw(dmac + CDAL, card);
if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc))) if (cda >= desc_off && (cda < desc_off + sizeof(pkt_desc)))
break; /* No frame received */ break; /* No frame received */
desc = desc_address(port, port->rxin, 0); desc = desc_address(port, port->rxin, 0);
...@@ -322,8 +319,9 @@ static inline void sca_rx_intr(port_t *port) ...@@ -322,8 +319,9 @@ static inline void sca_rx_intr(port_t *port)
dev->stats.rx_crc_errors++; dev->stats.rx_crc_errors++;
if (stat & ST_RX_EOM) if (stat & ST_RX_EOM)
port->rxpart = 0; /* received last fragment */ port->rxpart = 0; /* received last fragment */
} else } else {
sca_rx(card, port, desc, port->rxin); sca_rx(card, port, desc, port->rxin);
}
/* Set new error descriptor address */ /* Set new error descriptor address */
sca_outw(desc_off, dmac + EDAL, card); sca_outw(desc_off, dmac + EDAL, card);
...@@ -334,13 +332,12 @@ static inline void sca_rx_intr(port_t *port) ...@@ -334,13 +332,12 @@ static inline void sca_rx_intr(port_t *port)
sca_out(DSR_DE, DSR_RX(phy_node(port)), card); sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
} }
/* Transmit DMA interrupt service */ /* Transmit DMA interrupt service */
static inline void sca_tx_intr(port_t *port) static inline void sca_tx_intr(port_t *port)
{ {
struct net_device *dev = port_to_dev(port); struct net_device *dev = port_to_dev(port);
u16 dmac = get_dmac_tx(port); u16 dmac = get_dmac_tx(port);
card_t* card = port_to_card(port); card_t *card = port_to_card(port);
u8 stat; u8 stat;
spin_lock(&port->lock); spin_lock(&port->lock);
...@@ -356,7 +353,8 @@ static inline void sca_tx_intr(port_t *port) ...@@ -356,7 +353,8 @@ static inline void sca_tx_intr(port_t *port)
u32 desc_off = desc_offset(port, port->txlast, 1); u32 desc_off = desc_offset(port, port->txlast, 1);
u32 cda = sca_inw(dmac + CDAL, card); u32 cda = sca_inw(dmac + CDAL, card);
if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc)))
if (cda >= desc_off && (cda < desc_off + sizeof(pkt_desc)))
break; /* Transmitter is/will_be sending this frame */ break; /* Transmitter is/will_be sending this frame */
desc = desc_address(port, port->txlast, 1); desc = desc_address(port, port->txlast, 1);
...@@ -370,8 +368,7 @@ static inline void sca_tx_intr(port_t *port) ...@@ -370,8 +368,7 @@ static inline void sca_tx_intr(port_t *port)
spin_unlock(&port->lock); spin_unlock(&port->lock);
} }
static irqreturn_t sca_intr(int irq, void *dev_id)
static irqreturn_t sca_intr(int irq, void* dev_id)
{ {
card_t *card = dev_id; card_t *card = dev_id;
int i; int i;
...@@ -379,10 +376,11 @@ static irqreturn_t sca_intr(int irq, void* dev_id) ...@@ -379,10 +376,11 @@ static irqreturn_t sca_intr(int irq, void* dev_id)
int handled = 0; int handled = 0;
u8 page = sca_get_page(card); u8 page = sca_get_page(card);
while((stat = sca_intr_status(card)) != 0) { while ((stat = sca_intr_status(card)) != 0) {
handled = 1; handled = 1;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
port_t *port = get_port(card, i); port_t *port = get_port(card, i);
if (port) { if (port) {
if (stat & SCA_INTR_MSCI(i)) if (stat & SCA_INTR_MSCI(i))
sca_msci_intr(port); sca_msci_intr(port);
...@@ -400,15 +398,13 @@ static irqreturn_t sca_intr(int irq, void* dev_id) ...@@ -400,15 +398,13 @@ static irqreturn_t sca_intr(int irq, void* dev_id)
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
static void sca_set_port(port_t *port) static void sca_set_port(port_t *port)
{ {
card_t* card = port_to_card(port); card_t *card = port_to_card(port);
u16 msci = get_msci(port); u16 msci = get_msci(port);
u8 md2 = sca_in(msci + MD2, card); u8 md2 = sca_in(msci + MD2, card);
unsigned int tmc, br = 10, brv = 1024; unsigned int tmc, br = 10, brv = 1024;
if (port->settings.clock_rate > 0) { if (port->settings.clock_rate > 0) {
/* Try lower br for better accuracy*/ /* Try lower br for better accuracy*/
do { do {
...@@ -417,14 +413,15 @@ static void sca_set_port(port_t *port) ...@@ -417,14 +413,15 @@ static void sca_set_port(port_t *port)
/* Baud Rate = CLOCK_BASE / TMC / 2^BR */ /* Baud Rate = CLOCK_BASE / TMC / 2^BR */
tmc = CLOCK_BASE / brv / port->settings.clock_rate; tmc = CLOCK_BASE / brv / port->settings.clock_rate;
}while (br > 1 && tmc <= 128); } while (br > 1 && tmc <= 128);
if (tmc < 1) { if (tmc < 1) {
tmc = 1; tmc = 1;
br = 0; /* For baud=CLOCK_BASE we use tmc=1 br=0 */ br = 0; /* For baud=CLOCK_BASE we use tmc=1 br=0 */
brv = 1; brv = 1;
} else if (tmc > 255) } else if (tmc > 255) {
tmc = 256; /* tmc=0 means 256 - low baud rates */ tmc = 256; /* tmc=0 means 256 - low baud rates */
}
port->settings.clock_rate = CLOCK_BASE / brv / tmc; port->settings.clock_rate = CLOCK_BASE / brv / tmc;
} else { } else {
...@@ -450,34 +447,50 @@ static void sca_set_port(port_t *port) ...@@ -450,34 +447,50 @@ static void sca_set_port(port_t *port)
md2 &= ~MD2_LOOPBACK; md2 &= ~MD2_LOOPBACK;
sca_out(md2, msci + MD2, card); sca_out(md2, msci + MD2, card);
} }
static void sca_open(struct net_device *dev) static void sca_open(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
card_t* card = port_to_card(port); card_t *card = port_to_card(port);
u16 msci = get_msci(port); u16 msci = get_msci(port);
u8 md0, md2; u8 md0, md2;
switch(port->encoding) { switch (port->encoding) {
case ENCODING_NRZ: md2 = MD2_NRZ; break; case ENCODING_NRZ:
case ENCODING_NRZI: md2 = MD2_NRZI; break; md2 = MD2_NRZ;
case ENCODING_FM_MARK: md2 = MD2_FM_MARK; break; break;
case ENCODING_FM_SPACE: md2 = MD2_FM_SPACE; break; case ENCODING_NRZI:
default: md2 = MD2_MANCHESTER; md2 = MD2_NRZI;
break;
case ENCODING_FM_MARK:
md2 = MD2_FM_MARK;
break;
case ENCODING_FM_SPACE:
md2 = MD2_FM_SPACE;
break;
default:
md2 = MD2_MANCHESTER;
} }
if (port->settings.loopback) if (port->settings.loopback)
md2 |= MD2_LOOPBACK; md2 |= MD2_LOOPBACK;
switch(port->parity) { switch (port->parity) {
case PARITY_CRC16_PR0: md0 = MD0_HDLC | MD0_CRC_16_0; break; case PARITY_CRC16_PR0:
case PARITY_CRC16_PR1: md0 = MD0_HDLC | MD0_CRC_16; break; md0 = MD0_HDLC | MD0_CRC_16_0;
case PARITY_CRC16_PR0_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU_0; break; break;
case PARITY_CRC16_PR1_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU; break; case PARITY_CRC16_PR1:
default: md0 = MD0_HDLC | MD0_CRC_NONE; md0 = MD0_HDLC | MD0_CRC_16;
break;
case PARITY_CRC16_PR0_CCITT:
md0 = MD0_HDLC | MD0_CRC_ITU_0;
break;
case PARITY_CRC16_PR1_CCITT:
md0 = MD0_HDLC | MD0_CRC_ITU;
break;
default:
md0 = MD0_HDLC | MD0_CRC_NONE;
} }
sca_out(CMD_RESET, msci + CMD, card); sca_out(CMD_RESET, msci + CMD, card);
...@@ -494,9 +507,9 @@ static void sca_open(struct net_device *dev) ...@@ -494,9 +507,9 @@ static void sca_open(struct net_device *dev)
sca_out(0x14, msci + TRC1, card); /* +1=TXRDY/DMA deactiv condition */ sca_out(0x14, msci + TRC1, card); /* +1=TXRDY/DMA deactiv condition */
/* We're using the following interrupts: /* We're using the following interrupts:
- TXINT (DMAC completed all transmisions, underrun or DCD change) * - TXINT (DMAC completed all transmisions, underrun or DCD change)
- all DMA interrupts * - all DMA interrupts
*/ */
sca_set_carrier(port); sca_set_carrier(port);
/* MSCI TX INT and RX INT A IRQ enable */ /* MSCI TX INT and RX INT A IRQ enable */
...@@ -517,11 +530,10 @@ static void sca_open(struct net_device *dev) ...@@ -517,11 +530,10 @@ static void sca_open(struct net_device *dev)
netif_start_queue(dev); netif_start_queue(dev);
} }
static void sca_close(struct net_device *dev) static void sca_close(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
card_t* card = port_to_card(port); card_t *card = port_to_card(port);
/* reset channel */ /* reset channel */
sca_out(CMD_RESET, get_msci(port) + CMD, port_to_card(port)); sca_out(CMD_RESET, get_msci(port) + CMD, port_to_card(port));
...@@ -535,7 +547,6 @@ static void sca_close(struct net_device *dev) ...@@ -535,7 +547,6 @@ static void sca_close(struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
} }
static int sca_attach(struct net_device *dev, unsigned short encoding, static int sca_attach(struct net_device *dev, unsigned short encoding,
unsigned short parity) unsigned short parity)
{ {
...@@ -558,7 +569,6 @@ static int sca_attach(struct net_device *dev, unsigned short encoding, ...@@ -558,7 +569,6 @@ static int sca_attach(struct net_device *dev, unsigned short encoding,
return 0; return 0;
} }
#ifdef DEBUG_RINGS #ifdef DEBUG_RINGS
static void sca_dump_rings(struct net_device *dev) static void sca_dump_rings(struct net_device *dev)
{ {
...@@ -613,7 +623,6 @@ static void sca_dump_rings(struct net_device *dev) ...@@ -613,7 +623,6 @@ static void sca_dump_rings(struct net_device *dev)
} }
#endif /* DEBUG_RINGS */ #endif /* DEBUG_RINGS */
static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev) static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
...@@ -645,8 +654,9 @@ static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -645,8 +654,9 @@ static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev)
memcpy_toio(winbase(card) + buff, skb->data, maxlen); memcpy_toio(winbase(card) + buff, skb->data, maxlen);
openwin(card, page + 1); openwin(card, page + 1);
memcpy_toio(winbase(card), skb->data + maxlen, len - maxlen); memcpy_toio(winbase(card), skb->data + maxlen, len - maxlen);
} else } else {
memcpy_toio(winbase(card) + buff, skb->data, len); memcpy_toio(winbase(card) + buff, skb->data, len);
}
#ifndef PAGE0_ALWAYS_MAPPED #ifndef PAGE0_ALWAYS_MAPPED
openwin(card, 0); /* select pkt_desc table page back */ openwin(card, 0); /* select pkt_desc table page back */
...@@ -670,7 +680,6 @@ static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -670,7 +680,6 @@ static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
#ifdef NEED_DETECT_RAM #ifdef NEED_DETECT_RAM
static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize) static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize)
{ {
...@@ -699,7 +708,6 @@ static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize) ...@@ -699,7 +708,6 @@ static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize)
} }
#endif /* NEED_DETECT_RAM */ #endif /* NEED_DETECT_RAM */
static void sca_init(card_t *card, int wait_states) static void sca_init(card_t *card, int wait_states)
{ {
sca_out(wait_states, WCRL, card); /* Wait Control */ sca_out(wait_states, WCRL, card); /* Wait Control */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment