Commit 106fcb76 authored by Federico Vaga's avatar Federico Vaga

kernel:wr-nic: checkpatch cleanup

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 7499f529
......@@ -59,6 +59,7 @@ static int wrn_remove(struct platform_device *pdev)
/* Unregister all interrupts that were registered */
for (i = 0; wrn->irq_registered; i++) {
static int irqs[] = WRN_IRQ_NUMBERS;
if (wrn->irq_registered & (1 << i))
free_irq(irqs[i], wrn);
wrn->irq_registered &= ~(1 << i);
......@@ -119,13 +120,14 @@ static int wrn_probe(struct platform_device *pdev)
if (++wrn->use_count != 1) {
--wrn->use_count;
spin_unlock(&wrn->lock);
printk("use count %i\n", wrn->use_count);
dev_err(&pdev->dev, "use count %i\n", wrn->use_count);
return -EBUSY;
}
spin_unlock(&wrn->lock);
#endif
/* Map our resource list and instantiate the shortcut pointers */
if ( (err = __wrn_map_resources(pdev)) )
err = __wrn_map_resources(pdev);
if (err)
goto out;
wrn->regs = wrn->bases[WRN_FB_NIC];
wrn->txtsu_regs = wrn->bases[WRN_FB_TS];
......@@ -135,15 +137,16 @@ static int wrn_probe(struct platform_device *pdev)
wrn->databuf = (void *)wrn->regs + offsetof(struct NIC_WB, MEM);
tasklet_init(&wrn->rx_tlet, wrn_rx_interrupt, (unsigned long)wrn);
if (0)
printk("regs %p, txd %p, rxd %p, buffer %p\n",
wrn->regs, wrn->txd, wrn->rxd, wrn->databuf);
dev_info(&pdev->dev, "regs %p, txd %p, rxd %p, buffer %p\n",
wrn->regs, wrn->txd, wrn->rxd, wrn->databuf);
#if 0
/* Register the interrupt handlers (not shared) */
for (i = 0; i < ARRAY_SIZE(irq_names); i++) {
err = request_irq(irqs[i], irq_handlers[i],
IRQF_TRIGGER_LOW, irq_names[i], wrn);
if (err) goto out;
if (err)
goto out;
wrn->irq_registered |= 1 << i;
}
#endif
......@@ -181,14 +184,15 @@ static int wrn_probe(struct platform_device *pdev)
wrn->dev[i] = netdev;
err = wrn_mezzanine_init(netdev);
if (err)
dev_err(&pdev->dev, "Init mezzanine code: "
"error %i\n", err);
dev_err(&pdev->dev,
"Init mezzanine code: error %i\n", err);
}
if (i == 0)
return -ENODEV; /* no endpoints */
for (i = 0; i < WRN_NR_TXDESC; i++) { /* Clear all tx descriptors */
struct wrn_txd *tx;
tx = wrn->txd + i;
writel(0, &tx->tx1);
}
......@@ -200,7 +204,7 @@ static int wrn_probe(struct platform_device *pdev)
rx = wrn->rxd + i;
offset = __wrn_desc_offset(wrn, WRN_DDIR_RX, i);
writel( (2000 << 16) | offset, &rx->rx3);
writel((2000 << 16) | offset, &rx->rx3);
writel(NIC_RX1_D1_EMPTY, &rx->rx1);
}
......
......@@ -38,7 +38,7 @@ int wrn_phy_read(struct net_device *dev, int phy_id, int location)
}
wrn_ep_write(ep, MDIO_CR, EP_MDIO_CR_ADDR_W(location));
while( (wrn_ep_read(ep, MDIO_ASR) & EP_MDIO_ASR_READY) == 0)
while ((wrn_ep_read(ep, MDIO_ASR) & EP_MDIO_ASR_READY) == 0)
;
val = wrn_ep_read(ep, MDIO_ASR);
/* mask from wbgen macros */
......@@ -64,7 +64,7 @@ void wrn_phy_write(struct net_device *dev, int phy_id, int location,
EP_MDIO_CR_ADDR_W(location)
| EP_MDIO_CR_DATA_W(value)
| EP_MDIO_CR_RW);
while( (wrn_ep_read(ep, MDIO_ASR) & EP_MDIO_ASR_READY) == 0)
while ((wrn_ep_read(ep, MDIO_ASR) & EP_MDIO_ASR_READY) == 0)
;
}
......@@ -81,18 +81,18 @@ static void wrn_update_link_status(struct net_device *dev)
// printk("%s: read %x %x %x\n", __func__, bmsr, bmcr);
/* Link wnt down? */
if (!mii_link_ok(&ep->mii)) {
if(netif_carrier_ok(dev)) {
if (!mii_link_ok(&ep->mii)) {
if (netif_carrier_ok(dev)) {
netif_carrier_off(dev);
clear_bit(WRN_EP_UP, &ep->ep_flags);
printk(KERN_INFO "%s: Link down.\n", dev->name);
netdev_info(dev, "Link down.\n");
return;
}
return;
}
/* Currently the link is active */
if(netif_carrier_ok(dev)) {
if (netif_carrier_ok(dev)) {
/* Software already knows it's up */
return;
}
......@@ -109,16 +109,15 @@ static void wrn_update_link_status(struct net_device *dev)
if (0) { /* was commented in minic */
wrn_ep_write(ep, FCR,
EP_FCR_TXPAUSE |EP_FCR_RXPAUSE
EP_FCR_TXPAUSE | EP_FCR_RXPAUSE
| EP_FCR_TX_THR_W(128)
| EP_FCR_TX_QUANTA_W(200));
}
printk(KERN_INFO "%s: Link up, lpa 0x%04x.\n",
dev->name, lpa);
netdev_info(dev, "Link up, lpa 0x%04x.\n", lpa);
} else {
/* No autonegotiation. It's up immediately */
printk(KERN_INFO "%s: Link up.\n", dev->name);
netdev_info(dev, "Link up.\n");
}
netif_carrier_on(dev);
set_bit(WRN_EP_UP, &ep->ep_flags);
......@@ -126,7 +125,7 @@ static void wrn_update_link_status(struct net_device *dev)
/* reset RMON counters */
ecr = wrn_ep_read(ep, ECR);
wrn_ep_write(ep, ECR, ecr | EP_ECR_RST_CNT);
wrn_ep_write(ep, ECR, ecr );
wrn_ep_write(ep, ECR, ecr);
}
/* Actual timer function. Takes the lock and calls above function */
......@@ -165,7 +164,7 @@ int wrn_ep_open(struct net_device *dev)
* and we need the RX OOB block to identify orginating endpoints
* for RXed packets -- Tom
*/
writel(EP_TSCR_EN_TXTS| EP_TSCR_EN_RXTS, &ep->ep_regs->TSCR);
writel(EP_TSCR_EN_TXTS | EP_TSCR_EN_RXTS, &ep->ep_regs->TSCR);
writel(0
| EP_ECR_PORTID_W(ep->ep_number)
......@@ -253,8 +252,7 @@ int wrn_endpoint_probe(struct net_device *dev)
/* Finally, register and succeed, or fail and undo */
err = register_netdev(dev);
if (err) {
printk(KERN_ERR KBUILD_MODNAME ": Can't register dev %s\n",
dev->name);
netdev_err(dev, "Can't register device\n");
__wrn_endpoint_shutdown(ep);
/* ENODEV means "no more" for the caller, so avoid it */
return err == -ENODEV ? -EIO : err;
......
......@@ -29,7 +29,7 @@ static int wrn_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
ret = mii_ethtool_gset(&ep->mii, cmd);
spin_unlock_irq(&ep->lock);
cmd->supported=
cmd->supported =
SUPPORTED_FIBRE | /* FIXME: copper sfp? */
SUPPORTED_Autoneg |
SUPPORTED_1000baseKX_Full;
......
......@@ -44,11 +44,10 @@ static int wrn_open(struct net_device *dev)
wrn_ep_open(dev);
/* Software-only management is in this file*/
if (netif_queue_stopped(dev)) {
if (netif_queue_stopped(dev))
netif_wake_queue(dev);
} else {
else
netif_start_queue(dev);
}
/*
* Set the MRU bit enough, to avoid issues. We used dev-mtu,
......@@ -57,7 +56,7 @@ static int wrn_open(struct net_device *dev)
* malformed packets
*/
val = readl(&ep->ep_regs->RFCR) & ~EP_RFCR_MRU_MASK;
writel (val | EP_RFCR_MRU_W(2048), &ep->ep_regs->RFCR);
writel(val | EP_RFCR_MRU_W(2048), &ep->ep_regs->RFCR);
/* Most drivers call platform_set_drvdata() but we don't need it */
return 0;
......@@ -68,7 +67,8 @@ static int wrn_close(struct net_device *dev)
struct wrn_ep *ep = netdev_priv(dev);
int ret;
if ( (ret = wrn_ep_close(dev)) )
ret = wrn_ep_close(dev);
if (ret)
return ret;
/* FIXME: software-only fixing at close time */
......@@ -78,7 +78,7 @@ static int wrn_close(struct net_device *dev)
return 0;
}
static int wrn_set_mac_address(struct net_device *dev, void* vaddr)
static int wrn_set_mac_address(struct net_device *dev, void *vaddr)
{
struct wrn_ep *ep = netdev_priv(dev);
struct sockaddr *addr = vaddr;
......@@ -165,7 +165,7 @@ static int wrn_start_xmit(struct sk_buff *skb, struct net_device *dev)
int id;
int do_stamp = 0;
void *data; /* FIXME: move data and len to __wrn_tx_desc */
unsigned len;
unsigned int len;
if (unlikely(skb->len > WRN_MTU)) {
/* FIXME: check this WRN_MTU is needed and used properly */
......@@ -210,7 +210,7 @@ static int wrn_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* We are done, this is trivial maiintainance*/
ep->stats.tx_packets++;
ep->stats.tx_bytes += len;
#if KERNEL_VERSION(4,7,0) > LINUX_VERSION_CODE
#if KERNEL_VERSION(4, 7, 0) > LINUX_VERSION_CODE
dev->trans_start = jiffies;
#else
netif_trans_update(dev);
......@@ -245,7 +245,6 @@ int __weak wrn_mezzanine_init(struct net_device *dev)
void __weak wrn_mezzanine_exit(struct net_device *dev)
{
return;
}
......@@ -378,7 +377,7 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
__wrn_copy_in(skb_put(skb, len), wrn->databuf + off, len);
/* Rewrite lenght (modified during rx) and mark it free ASAP */
writel( (2000 << 16) | offset, &rx->rx3);
writel((2000 << 16) | offset, &rx->rx3);
writel(NIC_RX1_D1_EMPTY, &rx->rx1);
/* RX timestamping part */
......@@ -391,14 +390,14 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
ts.tv_sec = (s32)utc & 0x7fffffff;
cntr_diff = (ts_r & 0xf) - ts_f;
/* the bit says the rising edge cnter is 1tick ahead */
if(cntr_diff == 1 || cntr_diff == (-0xf))
if (cntr_diff == 1 || cntr_diff == (-0xf))
ts.tv_sec |= 0x80000000;
ts.tv_nsec = ts_r * NSEC_PER_TICK;
pr_debug("Timestamp: %li:%li, ahead = %d\n",
ts.tv_sec & 0x7fffffff,
ts.tv_nsec & 0x7fffffff,
ts.tv_sec & 0x80000000 ? 1 :0);
ts.tv_sec & 0x7fffffff,
ts.tv_nsec & 0x7fffffff,
ts.tv_sec & 0x80000000 ? 1 : 0);
if (1) {
/* SPEC: don't do the strange stuff for wr-ptp */
......@@ -406,7 +405,7 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
ts.tv_nsec &= 0x7fffffff;
}
if (! (r1 & NIC_RX1_D1_TS_INCORRECT)) {
if (!(r1 & NIC_RX1_D1_TS_INCORRECT)) {
hwts = skb_hwtstamps(skb);
hwts->hwtstamp = timespec_to_ktime(ts);
}
......@@ -420,7 +419,7 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
return;
err_out: /* Mark it free anyways -- with its full length */
writel( (2000 << 16) | offset, &rx->rx3);
writel((2000 << 16) | offset, &rx->rx3);
writel(NIC_RX1_D1_EMPTY, &rx->rx1);
/* account the error to endpoint 0 -- we don't know who it is */
......@@ -461,7 +460,7 @@ static void wrn_tx_interrupt(struct wrn_dev *wrn)
int i;
/* Loop using our tail until one is not sent */
while ( (i = wrn->next_tx_tail) != wrn->next_tx_head) {
while ((i = wrn->next_tx_tail) != wrn->next_tx_head) {
/* Check if this is txdone */
tx = wrn->txd + i;
reg = readl(&tx->tx1);
......
......@@ -32,12 +32,12 @@ void wrn_tx_tstamp_skb(struct wrn_dev *wrn, int desc)
wrn_ppsg_read_time(wrn, &counter_ppsg, &utc);
/* We may be at the beginning og the next second */
if(counter_ppsg < d->cycles)
if (counter_ppsg < d->cycles)
utc--;
ts.tv_sec = (s32)utc & 0x7fffffff;
ts.tv_nsec = d->cycles * NSEC_PER_TICK;
if (! (d->valid & TS_INVALID)) {
if (!(d->valid & TS_INVALID)) {
hwts = skb_hwtstamps(skb);
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
......@@ -75,7 +75,7 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg, u32 r2)
wrn_ppsg_read_time(wrn, &counter_ppsg, &utc);
if(counter_ppsg < (tsval & 0xfffffff))
if (counter_ppsg < (tsval & 0xfffffff))
utc--;
ts.tv_sec = (s32)utc & 0x7fffffff;
......@@ -119,8 +119,9 @@ int wrn_tstamp_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
if (copy_from_user(&config, rq->ifr_data, sizeof(config)))
return -EFAULT;
if (0) netdev_dbg(dev, "%s: tx type %i, rx filter %i\n", __func__,
config.tx_type, config.rx_filter);
if (0)
netdev_dbg(dev, "%s: tx type %i, rx filter %i\n",
__func__, config.tx_type, config.rx_filter);
switch (config.tx_type) {
/* Set up time stamping on transmission */
......
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