gianfar: various coding style and whitespace cleanups

Signed-off-by: Jan Ceuleers <jan.ceuleers@computer.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jan Ceuleers
2012-06-05 03:42:13 +00:00
committed by David S. Miller
parent 0977f817df
commit bc4598bc07

View File

@@ -283,7 +283,8 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
for (i = 0; i < priv->num_tx_queues; i++) { for (i = 0; i < priv->num_tx_queues; i++) {
tx_queue = priv->tx_queue[i]; tx_queue = priv->tx_queue[i];
tx_queue->tx_skbuff = kmalloc(sizeof(*tx_queue->tx_skbuff) * tx_queue->tx_skbuff = kmalloc(sizeof(*tx_queue->tx_skbuff) *
tx_queue->tx_ring_size, GFP_KERNEL); tx_queue->tx_ring_size,
GFP_KERNEL);
if (!tx_queue->tx_skbuff) { if (!tx_queue->tx_skbuff) {
netif_err(priv, ifup, ndev, netif_err(priv, ifup, ndev,
"Could not allocate tx_skbuff\n"); "Could not allocate tx_skbuff\n");
@@ -297,7 +298,8 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
for (i = 0; i < priv->num_rx_queues; i++) { for (i = 0; i < priv->num_rx_queues; i++) {
rx_queue = priv->rx_queue[i]; rx_queue = priv->rx_queue[i];
rx_queue->rx_skbuff = kmalloc(sizeof(*rx_queue->rx_skbuff) * rx_queue->rx_skbuff = kmalloc(sizeof(*rx_queue->rx_skbuff) *
rx_queue->rx_ring_size, GFP_KERNEL); rx_queue->rx_ring_size,
GFP_KERNEL);
if (!rx_queue->rx_skbuff) { if (!rx_queue->rx_skbuff) {
netif_err(priv, ifup, ndev, netif_err(priv, ifup, ndev,
@@ -581,14 +583,12 @@ static int gfar_parse_group(struct device_node *np,
priv->gfargrp[priv->num_grps].priv = priv; priv->gfargrp[priv->num_grps].priv = priv;
spin_lock_init(&priv->gfargrp[priv->num_grps].grplock); spin_lock_init(&priv->gfargrp[priv->num_grps].grplock);
if (priv->mode == MQ_MG_MODE) { if (priv->mode == MQ_MG_MODE) {
queue_mask = (u32 *)of_get_property(np, queue_mask = (u32 *)of_get_property(np, "fsl,rx-bit-map", NULL);
"fsl,rx-bit-map", NULL); priv->gfargrp[priv->num_grps].rx_bit_map = queue_mask ?
priv->gfargrp[priv->num_grps].rx_bit_map = *queue_mask : (DEFAULT_MAPPING >> priv->num_grps);
queue_mask ? *queue_mask :(DEFAULT_MAPPING >> priv->num_grps); queue_mask = (u32 *)of_get_property(np, "fsl,tx-bit-map", NULL);
queue_mask = (u32 *)of_get_property(np, priv->gfargrp[priv->num_grps].tx_bit_map = queue_mask ?
"fsl,tx-bit-map", NULL); *queue_mask : (DEFAULT_MAPPING >> priv->num_grps);
priv->gfargrp[priv->num_grps].tx_bit_map =
queue_mask ? *queue_mask : (DEFAULT_MAPPING >> priv->num_grps);
} else { } else {
priv->gfargrp[priv->num_grps].rx_bit_map = 0xFF; priv->gfargrp[priv->num_grps].rx_bit_map = 0xFF;
priv->gfargrp[priv->num_grps].tx_bit_map = 0xFF; priv->gfargrp[priv->num_grps].tx_bit_map = 0xFF;
@@ -730,18 +730,18 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING; priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
mac_addr = of_get_mac_address(np); mac_addr = of_get_mac_address(np);
if (mac_addr) if (mac_addr)
memcpy(dev->dev_addr, mac_addr, ETH_ALEN); memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
if (model && !strcasecmp(model, "TSEC")) if (model && !strcasecmp(model, "TSEC"))
priv->device_flags = priv->device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
FSL_GIANFAR_DEV_HAS_GIGABIT |
FSL_GIANFAR_DEV_HAS_COALESCE | FSL_GIANFAR_DEV_HAS_COALESCE |
FSL_GIANFAR_DEV_HAS_RMON | FSL_GIANFAR_DEV_HAS_RMON |
FSL_GIANFAR_DEV_HAS_MULTI_INTR; FSL_GIANFAR_DEV_HAS_MULTI_INTR;
if (model && !strcasecmp(model, "eTSEC")) if (model && !strcasecmp(model, "eTSEC"))
priv->device_flags = priv->device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
FSL_GIANFAR_DEV_HAS_GIGABIT |
FSL_GIANFAR_DEV_HAS_COALESCE | FSL_GIANFAR_DEV_HAS_COALESCE |
FSL_GIANFAR_DEV_HAS_RMON | FSL_GIANFAR_DEV_HAS_RMON |
FSL_GIANFAR_DEV_HAS_MULTI_INTR | FSL_GIANFAR_DEV_HAS_MULTI_INTR |
@@ -851,6 +851,7 @@ static unsigned int reverse_bitmap(unsigned int bit_map, unsigned int max_qs)
{ {
unsigned int new_bit_map = 0x0; unsigned int new_bit_map = 0x0;
int mask = 0x1 << (max_qs - 1), i; int mask = 0x1 << (max_qs - 1), i;
for (i = 0; i < max_qs; i++) { for (i = 0; i < max_qs; i++) {
if (bit_map & mask) if (bit_map & mask)
new_bit_map = new_bit_map + (1 << i); new_bit_map = new_bit_map + (1 << i);
@@ -1028,7 +1029,8 @@ static int gfar_probe(struct platform_device *ofdev)
/* Register for napi ...We are registering NAPI for each grp */ /* Register for napi ...We are registering NAPI for each grp */
for (i = 0; i < priv->num_grps; i++) for (i = 0; i < priv->num_grps; i++)
netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT); netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll,
GFAR_DEV_WEIGHT);
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
@@ -1103,10 +1105,10 @@ static int gfar_probe(struct platform_device *ofdev)
* basically reverses the queue numbers * basically reverses the queue numbers
*/ */
for (i = 0; i< priv->num_grps; i++) { for (i = 0; i< priv->num_grps; i++) {
priv->gfargrp[i].tx_bit_map = reverse_bitmap( priv->gfargrp[i].tx_bit_map =
priv->gfargrp[i].tx_bit_map, MAX_TX_QS); reverse_bitmap(priv->gfargrp[i].tx_bit_map, MAX_TX_QS);
priv->gfargrp[i].rx_bit_map = reverse_bitmap( priv->gfargrp[i].rx_bit_map =
priv->gfargrp[i].rx_bit_map, MAX_RX_QS); reverse_bitmap(priv->gfargrp[i].rx_bit_map, MAX_RX_QS);
} }
/* Calculate RSTAT, TSTAT, RQUEUE and TQUEUE values, /* Calculate RSTAT, TSTAT, RQUEUE and TQUEUE values,
@@ -1114,6 +1116,7 @@ static int gfar_probe(struct platform_device *ofdev)
*/ */
for (grp_idx = 0; grp_idx < priv->num_grps; grp_idx++) { for (grp_idx = 0; grp_idx < priv->num_grps; grp_idx++) {
priv->gfargrp[grp_idx].num_rx_queues = 0x0; priv->gfargrp[grp_idx].num_rx_queues = 0x0;
for_each_set_bit(i, &priv->gfargrp[grp_idx].rx_bit_map, for_each_set_bit(i, &priv->gfargrp[grp_idx].rx_bit_map,
priv->num_rx_queues) { priv->num_rx_queues) {
priv->gfargrp[grp_idx].num_rx_queues++; priv->gfargrp[grp_idx].num_rx_queues++;
@@ -1122,6 +1125,7 @@ static int gfar_probe(struct platform_device *ofdev)
rqueue = rqueue | ((RQUEUE_EN0 | RQUEUE_EX0) >> i); rqueue = rqueue | ((RQUEUE_EN0 | RQUEUE_EX0) >> i);
} }
priv->gfargrp[grp_idx].num_tx_queues = 0x0; priv->gfargrp[grp_idx].num_tx_queues = 0x0;
for_each_set_bit(i, &priv->gfargrp[grp_idx].tx_bit_map, for_each_set_bit(i, &priv->gfargrp[grp_idx].tx_bit_map,
priv->num_tx_queues) { priv->num_tx_queues) {
priv->gfargrp[grp_idx].num_tx_queues++; priv->gfargrp[grp_idx].num_tx_queues++;
@@ -1169,7 +1173,8 @@ static int gfar_probe(struct platform_device *ofdev)
} }
device_init_wakeup(&dev->dev, device_init_wakeup(&dev->dev,
priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); priv->device_flags &
FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
/* fill out IRQ number and name fields */ /* fill out IRQ number and name fields */
for (i = 0; i < priv->num_grps; i++) { for (i = 0; i < priv->num_grps; i++) {
@@ -1247,7 +1252,8 @@ static int gfar_suspend(struct device *dev)
u32 tempval; u32 tempval;
int magic_packet = priv->wol_en && int magic_packet = priv->wol_en &&
(priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); (priv->device_flags &
FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
netif_device_detach(ndev); netif_device_detach(ndev);
@@ -1299,7 +1305,8 @@ static int gfar_resume(struct device *dev)
unsigned long flags; unsigned long flags;
u32 tempval; u32 tempval;
int magic_packet = priv->wol_en && int magic_packet = priv->wol_en &&
(priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); (priv->device_flags &
FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
if (!netif_running(ndev)) { if (!netif_running(ndev)) {
netif_device_attach(ndev); netif_device_attach(ndev);
@@ -1398,8 +1405,9 @@ static phy_interface_t gfar_get_interface(struct net_device *dev)
} }
if (ecntrl & ECNTRL_REDUCED_MODE) { if (ecntrl & ECNTRL_REDUCED_MODE) {
if (ecntrl & ECNTRL_REDUCED_MII_MODE) if (ecntrl & ECNTRL_REDUCED_MII_MODE) {
return PHY_INTERFACE_MODE_RMII; return PHY_INTERFACE_MODE_RMII;
}
else { else {
phy_interface_t interface = priv->interface; phy_interface_t interface = priv->interface;
@@ -1497,8 +1505,9 @@ static void gfar_configure_serdes(struct net_device *dev)
ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE | ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
ADVERTISE_1000XPSE_ASYM); ADVERTISE_1000XPSE_ASYM);
phy_write(tbiphy, MII_BMCR, BMCR_ANENABLE | phy_write(tbiphy, MII_BMCR,
BMCR_ANRESTART | BMCR_FULLDPLX | BMCR_SPEED1000); BMCR_ANENABLE | BMCR_ANRESTART | BMCR_FULLDPLX |
BMCR_SPEED1000);
} }
static void init_registers(struct net_device *dev) static void init_registers(struct net_device *dev)
@@ -1594,8 +1603,8 @@ static void gfar_halt_nodisable(struct net_device *dev)
regs = priv->gfargrp[0].regs; regs = priv->gfargrp[0].regs;
/* Stop the DMA, and wait for it to stop */ /* Stop the DMA, and wait for it to stop */
tempval = gfar_read(&regs->dmactrl); tempval = gfar_read(&regs->dmactrl);
if ((tempval & (DMACTRL_GRS | DMACTRL_GTS)) if ((tempval & (DMACTRL_GRS | DMACTRL_GTS)) !=
!= (DMACTRL_GRS | DMACTRL_GTS)) { (DMACTRL_GRS | DMACTRL_GTS)) {
int ret; int ret;
tempval |= (DMACTRL_GRS | DMACTRL_GTS); tempval |= (DMACTRL_GRS | DMACTRL_GTS);
@@ -1729,6 +1738,7 @@ static void free_skb_resources(struct gfar_private *priv)
/* Go through all the buffer descriptors and free their data buffers */ /* Go through all the buffer descriptors and free their data buffers */
for (i = 0; i < priv->num_tx_queues; i++) { for (i = 0; i < priv->num_tx_queues; i++) {
struct netdev_queue *txq; struct netdev_queue *txq;
tx_queue = priv->tx_queue[i]; tx_queue = priv->tx_queue[i];
txq = netdev_get_tx_queue(tx_queue->dev, tx_queue->qindex); txq = netdev_get_tx_queue(tx_queue->dev, tx_queue->qindex);
if (tx_queue->tx_skbuff) if (tx_queue->tx_skbuff)
@@ -1834,8 +1844,8 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
/* Install our interrupt handlers for Error, /* Install our interrupt handlers for Error,
* Transmit, and Receive * Transmit, and Receive
*/ */
if ((err = request_irq(grp->interruptError, gfar_error, 0, if ((err = request_irq(grp->interruptError, gfar_error,
grp->int_name_er,grp)) < 0) { 0, grp->int_name_er, grp)) < 0) {
netif_err(priv, intr, dev, "Can't get IRQ %d\n", netif_err(priv, intr, dev, "Can't get IRQ %d\n",
grp->interruptError); grp->interruptError);
@@ -1849,15 +1859,15 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
goto tx_irq_fail; goto tx_irq_fail;
} }
if ((err = request_irq(grp->interruptReceive, gfar_receive, 0, if ((err = request_irq(grp->interruptReceive, gfar_receive,
grp->int_name_rx, grp)) < 0) { 0, grp->int_name_rx, grp)) < 0) {
netif_err(priv, intr, dev, "Can't get IRQ %d\n", netif_err(priv, intr, dev, "Can't get IRQ %d\n",
grp->interruptReceive); grp->interruptReceive);
goto rx_irq_fail; goto rx_irq_fail;
} }
} else { } else {
if ((err = request_irq(grp->interruptTransmit, gfar_interrupt, 0, if ((err = request_irq(grp->interruptTransmit, gfar_interrupt,
grp->int_name_tx, grp)) < 0) { 0, grp->int_name_tx, grp)) < 0) {
netif_err(priv, intr, dev, "Can't get IRQ %d\n", netif_err(priv, intr, dev, "Can't get IRQ %d\n",
grp->interruptTransmit); grp->interruptTransmit);
goto err_irq_fail; goto err_irq_fail;
@@ -2152,8 +2162,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (CHECKSUM_PARTIAL == skb->ip_summed) { if (CHECKSUM_PARTIAL == skb->ip_summed) {
fcb = gfar_add_fcb(skb); fcb = gfar_add_fcb(skb);
/* as specified by errata */ /* as specified by errata */
if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) &&
&& ((unsigned long)fcb % 0x20) > 0x18)) { ((unsigned long)fcb % 0x20) > 0x18)) {
__skb_pull(skb, GMAC_FCB_LEN); __skb_pull(skb, GMAC_FCB_LEN);
skb_checksum_help(skb); skb_checksum_help(skb);
} else { } else {
@@ -2365,8 +2375,7 @@ static int gfar_change_mtu(struct net_device *dev, int new_mtu)
frame_size += priv->padding; frame_size += priv->padding;
tempsize = tempsize = (frame_size & ~(INCREMENTAL_BUFFER_SIZE - 1)) +
(frame_size & ~(INCREMENTAL_BUFFER_SIZE - 1)) +
INCREMENTAL_BUFFER_SIZE; INCREMENTAL_BUFFER_SIZE;
/* Only stop and start the controller if it isn't already /* Only stop and start the controller if it isn't already
@@ -2500,6 +2509,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
struct skb_shared_hwtstamps shhwtstamps; struct skb_shared_hwtstamps shhwtstamps;
u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7); u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7);
memset(&shhwtstamps, 0, sizeof(shhwtstamps)); memset(&shhwtstamps, 0, sizeof(shhwtstamps));
shhwtstamps.hwtstamp = ns_to_ktime(*ns); shhwtstamps.hwtstamp = ns_to_ktime(*ns);
skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN); skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN);
@@ -2512,10 +2522,8 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
bdp = next_txbd(bdp, base, tx_ring_size); bdp = next_txbd(bdp, base, tx_ring_size);
for (i = 0; i < frags; i++) { for (i = 0; i < frags; i++) {
dma_unmap_page(&priv->ofdev->dev, dma_unmap_page(&priv->ofdev->dev, bdp->bufPtr,
bdp->bufPtr, bdp->length, DMA_TO_DEVICE);
bdp->length,
DMA_TO_DEVICE);
bdp->lstatus &= BD_LFLAG(TXBD_WRAP); bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
bdp = next_txbd(bdp, base, tx_ring_size); bdp = next_txbd(bdp, base, tx_ring_size);
} }
@@ -2700,6 +2708,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
if (priv->hwts_rx_en) { if (priv->hwts_rx_en) {
struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
u64 *ns = (u64 *) skb->data; u64 *ns = (u64 *) skb->data;
memset(shhwtstamps, 0, sizeof(*shhwtstamps)); memset(shhwtstamps, 0, sizeof(*shhwtstamps));
shhwtstamps->hwtstamp = ns_to_ktime(*ns); shhwtstamps->hwtstamp = ns_to_ktime(*ns);
} }
@@ -2752,6 +2761,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) { while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) {
struct sk_buff *newskb; struct sk_buff *newskb;
rmb(); rmb();
/* Add another skb for the future */ /* Add another skb for the future */
@@ -2806,8 +2816,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
bdp = next_bd(bdp, base, rx_queue->rx_ring_size); bdp = next_bd(bdp, base, rx_queue->rx_ring_size);
/* update to point at the next skb */ /* update to point at the next skb */
rx_queue->skb_currx = rx_queue->skb_currx = (rx_queue->skb_currx + 1) &
(rx_queue->skb_currx + 1) &
RX_RING_MOD_MASK(rx_queue->rx_ring_size); RX_RING_MOD_MASK(rx_queue->rx_ring_size);
} }
@@ -2819,8 +2828,8 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
static int gfar_poll(struct napi_struct *napi, int budget) static int gfar_poll(struct napi_struct *napi, int budget)
{ {
struct gfar_priv_grp *gfargrp = container_of(napi, struct gfar_priv_grp *gfargrp =
struct gfar_priv_grp, napi); container_of(napi, struct gfar_priv_grp, napi);
struct gfar_private *priv = gfargrp->priv; struct gfar_private *priv = gfargrp->priv;
struct gfar __iomem *regs = gfargrp->regs; struct gfar __iomem *regs = gfargrp->regs;
struct gfar_priv_tx_q *tx_queue = NULL; struct gfar_priv_tx_q *tx_queue = NULL;
@@ -2839,7 +2848,6 @@ static int gfar_poll(struct napi_struct *napi, int budget)
gfar_write(&regs->ievent, IEVENT_RTX_MASK); gfar_write(&regs->ievent, IEVENT_RTX_MASK);
while (num_queues && left_over_budget) { while (num_queues && left_over_budget) {
budget_per_queue = left_over_budget/num_queues; budget_per_queue = left_over_budget/num_queues;
left_over_budget = 0; left_over_budget = 0;
@@ -2850,12 +2858,13 @@ static int gfar_poll(struct napi_struct *napi, int budget)
tx_queue = priv->tx_queue[rx_queue->qindex]; tx_queue = priv->tx_queue[rx_queue->qindex];
tx_cleaned += gfar_clean_tx_ring(tx_queue); tx_cleaned += gfar_clean_tx_ring(tx_queue);
rx_cleaned_per_queue = gfar_clean_rx_ring(rx_queue, rx_cleaned_per_queue =
budget_per_queue); gfar_clean_rx_ring(rx_queue, budget_per_queue);
rx_cleaned += rx_cleaned_per_queue; rx_cleaned += rx_cleaned_per_queue;
if (rx_cleaned_per_queue < budget_per_queue) { if (rx_cleaned_per_queue < budget_per_queue) {
left_over_budget = left_over_budget + left_over_budget = left_over_budget +
(budget_per_queue - rx_cleaned_per_queue); (budget_per_queue -
rx_cleaned_per_queue);
set_bit(i, &serviced_queues); set_bit(i, &serviced_queues);
num_queues--; num_queues--;
} }
@@ -2876,8 +2885,8 @@ static int gfar_poll(struct napi_struct *napi, int budget)
/* If we are coalescing interrupts, update the timer /* If we are coalescing interrupts, update the timer
* Otherwise, clear it * Otherwise, clear it
*/ */
gfar_configure_coalescing(priv, gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
gfargrp->rx_bit_map, gfargrp->tx_bit_map); gfargrp->tx_bit_map);
} }
return rx_cleaned; return rx_cleaned;
@@ -3208,7 +3217,8 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
/* Hmm... */ /* Hmm... */
if (netif_msg_rx_err(priv) || netif_msg_tx_err(priv)) if (netif_msg_rx_err(priv) || netif_msg_tx_err(priv))
netdev_dbg(dev, "error interrupt (ievent=0x%08x imask=0x%08x)\n", netdev_dbg(dev,
"error interrupt (ievent=0x%08x imask=0x%08x)\n",
events, gfar_read(&regs->imask)); events, gfar_read(&regs->imask));
/* Update the error counters */ /* Update the error counters */