lkml.org 
[lkml]   [2009]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/7] [PATCH 3/8] can: CAN Network device driver and Netlink interface
[Quick review ...]

> +/*
> + * CAN device restart for bus-off recovery
> + */
> +int can_restart_now(struct net_device *dev)
> +{
> + struct can_priv *priv = netdev_priv(dev);
> + struct net_device_stats *stats = &dev->stats;
> + struct sk_buff *skb;
> + struct can_frame *cf;
> + int err;
> +
> + /* Synchronize with dev->hard_start_xmit() */
> + netif_tx_lock(dev);
> +
> + /* Ensure that no more messages can go out */
> + if (netif_carrier_ok(dev))
> + netif_carrier_off(dev);
> +
> + /* Ensure that no more messages can come in */
> + err = priv->do_set_mode(dev, CAN_MODE_STOP);
> + if (err)
> + return err;

This leaves _xmit_lock held and carrier off. Is that really what you want
to do?

> +
> + /* Now it's save to clean up */
> + del_timer_sync(&priv->restart_timer);
> + can_flush_echo_skb(dev);
> +
> + dev_dbg(dev->dev.parent, "restarted\n");
> + priv->can_stats.restarts++;
> +
> + /* send restart message upstream */
> + skb = dev_alloc_skb(sizeof(struct can_frame));
> + if (skb == NULL)
> + return -ENOMEM;

...here too...

> + skb->dev = dev;
> + skb->protocol = htons(ETH_P_CAN);
> + cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
> + memset(cf, 0, sizeof(struct can_frame));
> + cf->can_id = CAN_ERR_FLAG | CAN_ERR_RESTARTED;
> + cf->can_dlc = CAN_ERR_DLC;
> +
> + netif_rx(skb);
> +
> + dev->last_rx = jiffies;
> + stats->rx_packets++;
> + stats->rx_bytes += cf->can_dlc;
> +
> + /* Now restart the device */
> + err = priv->do_set_mode(dev, CAN_MODE_START);
> + if (err)
> + return err;

...and here too. Do you maybe want to get rid of the middle-of-function
returns and switch to the "goto out" convention?

> + netif_carrier_on(dev);
> +
> + netif_tx_unlock(dev);
> +
> + return 0;
> +}
> +
> +static void can_restart_after(unsigned long data)
> +{
> + struct net_device *dev = (struct net_device *)data;
> +
> + can_restart_now(dev);
> +}

can_restart_after what? I find myself confused by this function and
wondering why it exists.

jon


\
 
 \ /
  Last update: 2009-05-13 23:35    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean