[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090513153112.0822809b@bike.lwn.net>
Date: Wed, 13 May 2009 15:31:12 -0600
From: Jonathan Corbet <corbet@....net>
To: Wolfgang Grandegger <wg@...ndegger.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Wolfgang Grandegger <wg@...ndegger.com>,
Oliver Hartkopp <oliver.hartkopp@...kswagen.de>
Subject: Re: [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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists