Use netdev_priv in YAM driver
Subsystems (2)
PATCH 2/9 Use netdev_priv in YAM driver
o Convert the YAM driver to use netdev_priv().
o If dev is valid there is no point in checking netdev_priv()'s return value for being NULL.
o Fix build warning.
yam.c | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-)
drivers/net/hamradio/yam.c +19 -19
@@ -442,7 +442,7 @@static void yam_set_uart (struct net_device *dev) { -struct yam_port *yp = (struct yam_port *) dev->priv; +struct yam_port *yp =netdev_priv (dev);int divisor =115200 / yp->baudrate;outb (0 ,IER (dev->base_addr));
@@ -565,7 +565,7 @@static int yam_send_packet (struct sk_buff *skb,struct net_device *dev) { -struct yam_port *yp = dev->priv; +struct yam_port *yp =netdev_priv (dev);skb_queue_tail (&yp->send_queue, skb); dev->trans_start = jiffies;
@@ -592,12 +592,11 @@static void yam_arbitrate (struct net_device *dev) { -struct yam_port *yp = dev->priv; +struct yam_port *yp =netdev_priv (dev); -if (!yp || yp->magic !=YAM_MAGIC - || yp->tx_state !=TX_OFF ||skb_queue_empty (&yp->send_queue)) { +if (yp->magic !=YAM_MAGIC || yp->tx_state !=TX_OFF || +skb_queue_empty (&yp->send_queue))return ; - }/* tx_state is TX_OFF and there is data to send */ if (yp->dupmode) {
@@ -725,7 +724,7 @@for (i =0 ; i <NR_PORTS ; i++) { dev = yam_devs[i]; - yp = dev->priv; + yp =netdev_priv (dev);if (!netif_running (dev))continue ;
@@ -784,8 +783,8 @@static int yam_seq_show (struct seq_file *seq,void *v) { -const struct net_device *dev = v; -const struct yam_port *yp = dev->priv; +struct net_device *dev = v; +const struct yam_port *yp =netdev_priv (dev);seq_printf (seq,"Device %s\n" , dev->name);seq_printf (seq," Up %d\n" ,netif_running (dev));
@@ -838,10 +837,10 @@ {struct yam_port *yp; -if (!dev || !dev->priv) +if (!dev)return NULL ; - yp = (struct yam_port *) dev->priv; + yp =netdev_priv (dev);if (yp->magic !=YAM_MAGIC )return NULL ;
@@ -856,14 +855,14 @@static int yam_open (struct net_device *dev) { -struct yam_port *yp = (struct yam_port *) dev->priv; +struct yam_port *yp =netdev_priv (dev);enum uart u;int i;int ret=0 ;printk (KERN_INFO "Trying %s at iobase 0x%lx irq %u\n" , dev->name, dev->base_addr, dev->irq); -if (!dev || !yp || !yp->bitrate) +if (!dev || !yp->bitrate)return -ENXIO ;if (!dev->base_addr || dev->base_addr >0x1000 -YAM_EXTENT || dev->irq <2 || dev->irq >15 ) {
@@ -900,7 +899,7 @@/* Reset overruns for all ports - FPGA programming makes overruns */ for (i =0 ; i <NR_PORTS ; i++) {struct net_device *dev = yam_devs[i]; -struct yam_port *yp = dev->priv; +struct yam_port *yp =netdev_priv (dev);inb (LSR (dev->base_addr)); yp->stats.rx_fifo_errors =0 ; }
@@ -919,10 +918,11 @@static int yam_close (struct net_device *dev) {struct sk_buff *skb; -struct yam_port *yp = (struct yam_port *) dev->priv; +struct yam_port *yp =netdev_priv (dev); -if (!dev || !yp) +if (!dev)return -EINVAL ; +/* * disable interrupts */
@@ -944,7 +944,7 @@static int yam_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd) { -struct yam_port *yp = (struct yam_port *) dev->priv; +struct yam_port *yp =netdev_priv (dev);struct yamdrv_ioctl_cfg yi;struct yamdrv_ioctl_mcs *ym;int ioctl_cmd;
@@ -952,7 +952,7 @@if (copy_from_user (&ioctl_cmd, ifr->ifr_data,sizeof (int )))return -EFAULT ; -if (yp ==NULL || yp->magic !=YAM_MAGIC ) +if (yp->magic !=YAM_MAGIC )return -EINVAL ;if (!capable (CAP_NET_ADMIN ))
@@ -1091,7 +1091,7 @@static void yam_setup (struct net_device *dev) { -struct yam_port *yp = dev->priv; +struct yam_port *yp =netdev_priv (dev); yp->magic =YAM_MAGIC ; yp->bitrate =DEFAULT_BITRATE ;
Jeff Garzik
Appliedapplied patches 2-9 to netdev-2.6 queue (thus -mm, etc.).
Not sure where patch #1 went, I don't see it (unless #1 is the reformat patch)
Quoted 4 lines · Jeff Garzik
applied patches 2-9 to netdev-2.6 queue (thus -mm, etc.).
Not sure where patch #1 went, I don't see it (unless #1 is the reformat patch)
#1 did touch only the encapsulation pseudo devices provided by the NETROM and ROSE network protocols in net/netrom and net/rose so I did cc only to netdev. Thought you'd not care. In case you do, it's attached below.
Ralf
netrom/nr_dev.c | 8 ++++---- rose/rose_dev.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
net/netrom/nr_dev.c +4 -4
@@ -46,7 +46,7 @@int nr_rx_ip (struct sk_buff *skb,struct net_device *dev) { -struct net_device_stats *stats = (struct net_device_stats *)dev->priv; +struct net_device_stats *stats =netdev_priv (dev);if (!netif_running (dev)) { stats->rx_errors++;
@@ -73,7 +73,7 @@static int nr_rebuild_header (struct sk_buff *skb) {struct net_device *dev = skb->dev; -struct net_device_stats *stats = (struct net_device_stats *)dev->priv; +struct net_device_stats *stats =netdev_priv (dev);struct sk_buff *skbn;unsigned char *bp = skb->data;int len;
@@ -186,7 +186,7 @@static int nr_xmit (struct sk_buff *skb,struct net_device *dev) { -struct net_device_stats *stats = (struct net_device_stats *)dev->priv; +struct net_device_stats *stats =netdev_priv (dev);dev_kfree_skb (skb); stats->tx_errors++;return 0 ;
@@ -194,7 +194,7 @@static struct net_device_stats *nr_get_stats (struct net_device *dev) { -return (struct net_device_stats *)dev->priv; +return netdev_priv (dev); }void nr_setup (struct net_device *dev)
net/rose/rose_dev.c +3 -3
@@ -57,7 +57,7 @@static int rose_rebuild_header (struct sk_buff *skb) {struct net_device *dev = skb->dev; -struct net_device_stats *stats = (struct net_device_stats *)dev->priv; +struct net_device_stats *stats =netdev_priv (dev);unsigned char *bp = (unsigned char *)skb->data;struct sk_buff *skbn;
@@ -117,7 +117,7 @@static int rose_xmit (struct sk_buff *skb,struct net_device *dev) { -struct net_device_stats *stats = (struct net_device_stats *)dev->priv; +struct net_device_stats *stats =netdev_priv (dev);if (!netif_running (dev)) {printk (KERN_ERR "ROSE: rose_xmit - called when iface is down\n" );
@@ -130,7 +130,7 @@static struct net_device_stats *rose_get_stats (struct net_device *dev) { -return (struct net_device_stats *)dev->priv; +return netdev_priv (dev); }void rose_setup (struct net_device *dev)
Quoted 5 lines · Jeff Garzik
Quoted 3 lines
#1 did touch only the encapsulation pseudo devices provided by the NETROM and ROSE network protocols in net/netrom and net/rose so I did cc only to netdev. Thought you'd not care. In case you do, it's attached below.
Nah, that's all DaveM. Thanks for letting me know.
Thought so.
Ralf
Quoted 11 lines · Ralf Baechle DL5RB wrote:
Quoted 3 lines · Jeff Garzik
applied patches 2-9 to netdev-2.6 queue (thus -mm, etc.).
Not sure where patch #1 went, I don't see it (unless #1 is the reformat patch)
#1 did touch only the encapsulation pseudo devices provided by the NETROM and ROSE network protocols in net/netrom and net/rose so I did cc only to netdev. Thought you'd not care. In case you do, it's attached below.
Nah, that's all DaveM. Thanks for letting me know.
Jeff