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

Merge branch 'wan-cleanups'

Guangbin Huang says:

====================
net: wan: 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 44be5c42 70fe4523
...@@ -41,20 +41,20 @@ ...@@ -41,20 +41,20 @@
#define NAPI_WEIGHT 16 #define NAPI_WEIGHT 16
#define get_msci(port) (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) #define get_msci(port) ((port)->chan ? MSCI1_OFFSET : MSCI0_OFFSET)
#define get_dmac_rx(port) (port->chan ? DMAC1RX_OFFSET : DMAC0RX_OFFSET) #define get_dmac_rx(port) ((port)->chan ? DMAC1RX_OFFSET : DMAC0RX_OFFSET)
#define get_dmac_tx(port) (port->chan ? DMAC1TX_OFFSET : DMAC0TX_OFFSET) #define get_dmac_tx(port) ((port)->chan ? DMAC1TX_OFFSET : DMAC0TX_OFFSET)
#define sca_in(reg, card) readb(card->scabase + (reg)) #define sca_in(reg, card) readb((card)->scabase + (reg))
#define sca_out(value, reg, card) writeb(value, card->scabase + (reg)) #define sca_out(value, reg, card) writeb(value, (card)->scabase + (reg))
#define sca_inw(reg, card) readw(card->scabase + (reg)) #define sca_inw(reg, card) readw((card)->scabase + (reg))
#define sca_outw(value, reg, card) writew(value, card->scabase + (reg)) #define sca_outw(value, reg, card) writew(value, (card)->scabase + (reg))
#define sca_inl(reg, card) readl(card->scabase + (reg)) #define sca_inl(reg, card) readl((card)->scabase + (reg))
#define sca_outl(value, reg, card) writel(value, card->scabase + (reg)) #define sca_outl(value, reg, card) writel(value, (card)->scabase + (reg))
static int sca_poll(struct napi_struct *napi, int budget); static int sca_poll(struct napi_struct *napi, int budget);
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;
} }
...@@ -81,14 +81,12 @@ static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) ...@@ -81,14 +81,12 @@ static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit)
return port->chan * (rx_buffs + tx_buffs) + transmit * rx_buffs + desc; return port->chan * (rx_buffs + tx_buffs) + 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)
{ {
...@@ -96,14 +94,12 @@ static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, ...@@ -96,14 +94,12 @@ static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc,
desc_offset(port, desc, transmit)); desc_offset(port, desc, transmit));
} }
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->card->buff_offset + return port->card->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->card) & ST3_DCD)) { if (!(sca_in(get_msci(port) + ST3, port->card) & ST3_DCD)) {
...@@ -121,7 +117,6 @@ static inline void sca_set_carrier(port_t *port) ...@@ -121,7 +117,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->card; card_t *card = port->card;
...@@ -181,12 +176,11 @@ static void sca_init_port(port_t *port) ...@@ -181,12 +176,11 @@ static void sca_init_port(port_t *port)
netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT); netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT);
} }
/* 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->card; card_t *card = port->card;
if (sca_in(msci + ST1, card) & ST1_CDCD) { if (sca_in(msci + ST1, card) & ST1_CDCD) {
/* Reset MSCI CDCD status bit */ /* Reset MSCI CDCD status bit */
...@@ -195,7 +189,6 @@ static inline void sca_msci_intr(port_t *port) ...@@ -195,7 +189,6 @@ static inline void sca_msci_intr(port_t *port)
} }
} }
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)
{ {
...@@ -225,7 +218,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, ...@@ -225,7 +218,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
netif_receive_skb(skb); netif_receive_skb(skb);
} }
/* Receive DMA service */ /* Receive DMA service */
static inline int sca_rx_done(port_t *port, int budget) static inline int sca_rx_done(port_t *port, int budget)
{ {
...@@ -281,12 +273,11 @@ static inline int sca_rx_done(port_t *port, int budget) ...@@ -281,12 +273,11 @@ static inline int sca_rx_done(port_t *port, int budget)
return received; return received;
} }
/* Transmit DMA service */ /* Transmit DMA service */
static inline void sca_tx_done(port_t *port) static inline void sca_tx_done(port_t *port)
{ {
struct net_device *dev = port->netdev; struct net_device *dev = port->netdev;
card_t* card = port->card; card_t *card = port->card;
u8 stat; u8 stat;
unsigned count = 0; unsigned count = 0;
...@@ -321,7 +312,6 @@ static inline void sca_tx_done(port_t *port) ...@@ -321,7 +312,6 @@ static inline void sca_tx_done(port_t *port)
spin_unlock(&port->lock); spin_unlock(&port->lock);
} }
static int sca_poll(struct napi_struct *napi, int budget) static int sca_poll(struct napi_struct *napi, int budget)
{ {
port_t *port = container_of(napi, port_t, napi); port_t *port = container_of(napi, port_t, napi);
...@@ -363,15 +353,13 @@ static irqreturn_t sca_intr(int irq, void *dev_id) ...@@ -363,15 +353,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->card; card_t *card = port->card;
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 {
...@@ -380,14 +368,15 @@ static void sca_set_port(port_t *port) ...@@ -380,14 +368,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 {
...@@ -414,34 +403,50 @@ static void sca_set_port(port_t *port) ...@@ -414,34 +403,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->card; card_t *card = port->card;
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_CRC32_PR1_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU32; 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_CRC32_PR1_CCITT:
md0 = MD0_HDLC | MD0_CRC_ITU32;
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);
...@@ -476,7 +481,6 @@ static void sca_open(struct net_device *dev) ...@@ -476,7 +481,6 @@ 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);
...@@ -488,7 +492,6 @@ static void sca_close(struct net_device *dev) ...@@ -488,7 +492,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)
{ {
...@@ -511,7 +514,6 @@ static int sca_attach(struct net_device *dev, unsigned short encoding, ...@@ -511,7 +514,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)
{ {
...@@ -558,7 +560,6 @@ static void sca_dump_rings(struct net_device *dev) ...@@ -558,7 +560,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);
...@@ -600,7 +601,6 @@ static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -600,7 +601,6 @@ static netdev_tx_t sca_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
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)
{ {
/* Round RAM size to 32 bits, fill from end to start */ /* Round RAM size to 32 bits, fill from end to start */
...@@ -619,7 +619,6 @@ static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize) ...@@ -619,7 +619,6 @@ static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize)
return i; return i;
} }
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