Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

WAN: Simplify sca_init_port() in HD64572 driver.

Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>

+31 -36
+31 -36
drivers/net/wan/hd64572.c
··· 131 131 static void sca_init_port(port_t *port) 132 132 { 133 133 card_t *card = port->card; 134 + u16 dmac_rx = get_dmac_rx(port), dmac_tx = get_dmac_tx(port); 134 135 int transmit, i; 135 136 136 137 port->rxin = 0; ··· 139 138 port->txlast = 0; 140 139 141 140 for (transmit = 0; transmit < 2; transmit++) { 142 - u16 dmac = transmit ? get_dmac_tx(port) : get_dmac_rx(port); 143 141 u16 buffs = transmit ? card->tx_ring_buffers 144 142 : card->rx_ring_buffers; 145 143 ··· 152 152 writew(0, &desc->len); 153 153 writeb(0, &desc->stat); 154 154 } 155 - 156 - /* DMA disable - to halt state */ 157 - sca_out(0, transmit ? DSR_TX(port->chan) : 158 - DSR_RX(port->chan), card); 159 - /* software ABORT - to initial state */ 160 - sca_out(DCR_ABORT, transmit ? DCR_TX(port->chan) : 161 - DCR_RX(port->chan), card); 162 - 163 - /* current desc addr */ 164 - sca_outl(desc_offset(port, 0, transmit), dmac + CDAL, card); 165 - if (!transmit) 166 - sca_outl(desc_offset(port, buffs - 1, transmit), 167 - dmac + EDAL, card); 168 - else 169 - sca_outl(desc_offset(port, 0, transmit), dmac + EDAL, 170 - card); 171 - 172 - /* clear frame end interrupt counter */ 173 - sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(port->chan) : 174 - DCR_RX(port->chan), card); 175 - 176 - if (!transmit) { /* Receive */ 177 - /* set buffer length */ 178 - sca_outw(HDLC_MAX_MRU, dmac + BFLL, card); 179 - /* Chain mode, Multi-frame */ 180 - sca_out(0x14, DMR_RX(port->chan), card); 181 - sca_out(DIR_EOME, DIR_RX(port->chan), card); 182 - /* DMA enable */ 183 - sca_out(DSR_DE, DSR_RX(port->chan), card); 184 - } else { /* Transmit */ 185 - /* Chain mode, Multi-frame */ 186 - sca_out(0x14, DMR_TX(port->chan), card); 187 - /* enable underflow interrupts */ 188 - sca_out(DIR_EOME, DIR_TX(port->chan), card); 189 - } 190 155 } 156 + 157 + /* DMA disable - to halt state */ 158 + sca_out(0, DSR_RX(port->chan), card); 159 + sca_out(0, DSR_TX(port->chan), card); 160 + 161 + /* software ABORT - to initial state */ 162 + sca_out(DCR_ABORT, DCR_RX(port->chan), card); 163 + sca_out(DCR_ABORT, DCR_TX(port->chan), card); 164 + 165 + /* current desc addr */ 166 + sca_outl(desc_offset(port, 0, 0), dmac_rx + CDAL, card); 167 + sca_outl(desc_offset(port, card->tx_ring_buffers - 1, 0), 168 + dmac_rx + EDAL, card); 169 + sca_outl(desc_offset(port, 0, 1), dmac_tx + CDAL, card); 170 + sca_outl(desc_offset(port, 0, 1), dmac_tx + EDAL, card); 171 + 172 + /* clear frame end interrupt counter */ 173 + sca_out(DCR_CLEAR_EOF, DCR_RX(port->chan), card); 174 + sca_out(DCR_CLEAR_EOF, DCR_TX(port->chan), card); 175 + 176 + /* Receive */ 177 + sca_outw(HDLC_MAX_MRU, dmac_rx + BFLL, card); /* set buffer length */ 178 + sca_out(0x14, DMR_RX(port->chan), card); /* Chain mode, Multi-frame */ 179 + sca_out(DIR_EOME, DIR_RX(port->chan), card); /* enable interrupts */ 180 + sca_out(DSR_DE, DSR_RX(port->chan), card); /* DMA enable */ 181 + 182 + /* Transmit */ 183 + sca_out(0x14, DMR_TX(port->chan), card); /* Chain mode, Multi-frame */ 184 + sca_out(DIR_EOME, DIR_TX(port->chan), card); /* enable interrupts */ 185 + 191 186 sca_set_carrier(port); 192 187 netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT); 193 188 }