aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fs_enet/fs_enet-main.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-10-17 13:42:43 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-17 20:11:28 -0400
commitf860f49ee2e59d1a665416c9155cad7661ee0552 (patch)
tree1f154123248bf511d84742578a94567667f68099 /drivers/net/fs_enet/fs_enet-main.c
parent6880e7cb35bfde5c8ef65cc846e0df54808f982f (diff)
fs_enet: Update for API changes
This driver was recently broken by several changes for which this driver was not (or was improperly) updated: 1. SET_MODULE_OWNER() was removed. 2. netif_napi_add() was only being called when building with the old CPM binding. 3. The received/budget test was backwards. 4. to_net_dev() was wrong -- the device struct embedded in the net_device struct is not the same as the of_platform device in the private struct. 5. napi_disable/napi_enable was being called even when napi was not being used. These changes have been fixed, and napi is now on by default. Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/fs_enet/fs_enet-main.c')
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 04c6faec88d2..f2a4d399a6e5 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -88,7 +88,7 @@ static void skb_align(struct sk_buff *skb, int align)
88static int fs_enet_rx_napi(struct napi_struct *napi, int budget) 88static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
89{ 89{
90 struct fs_enet_private *fep = container_of(napi, struct fs_enet_private, napi); 90 struct fs_enet_private *fep = container_of(napi, struct fs_enet_private, napi);
91 struct net_device *dev = to_net_dev(fep->dev); 91 struct net_device *dev = fep->ndev;
92 const struct fs_platform_info *fpi = fep->fpi; 92 const struct fs_platform_info *fpi = fep->fpi;
93 cbd_t __iomem *bdp; 93 cbd_t __iomem *bdp;
94 struct sk_buff *skb, *skbn, *skbt; 94 struct sk_buff *skb, *skbn, *skbt;
@@ -217,7 +217,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
217 217
218 fep->cur_rx = bdp; 218 fep->cur_rx = bdp;
219 219
220 if (received >= budget) { 220 if (received < budget) {
221 /* done */ 221 /* done */
222 netif_rx_complete(dev, napi); 222 netif_rx_complete(dev, napi);
223 (*fep->ops->napi_enable_rx)(dev); 223 (*fep->ops->napi_enable_rx)(dev);
@@ -807,20 +807,23 @@ static int fs_enet_open(struct net_device *dev)
807 int r; 807 int r;
808 int err; 808 int err;
809 809
810 napi_enable(&fep->napi); 810 if (fep->fpi->use_napi)
811 napi_enable(&fep->napi);
811 812
812 /* Install our interrupt handler. */ 813 /* Install our interrupt handler. */
813 r = fs_request_irq(dev, fep->interrupt, "fs_enet-mac", fs_enet_interrupt); 814 r = fs_request_irq(dev, fep->interrupt, "fs_enet-mac", fs_enet_interrupt);
814 if (r != 0) { 815 if (r != 0) {
815 printk(KERN_ERR DRV_MODULE_NAME 816 printk(KERN_ERR DRV_MODULE_NAME
816 ": %s Could not allocate FS_ENET IRQ!", dev->name); 817 ": %s Could not allocate FS_ENET IRQ!", dev->name);
817 napi_disable(&fep->napi); 818 if (fep->fpi->use_napi)
819 napi_disable(&fep->napi);
818 return -EINVAL; 820 return -EINVAL;
819 } 821 }
820 822
821 err = fs_init_phy(dev); 823 err = fs_init_phy(dev);
822 if(err) { 824 if (err) {
823 napi_disable(&fep->napi); 825 if (fep->fpi->use_napi)
826 napi_disable(&fep->napi);
824 return err; 827 return err;
825 } 828 }
826 phy_start(fep->phydev); 829 phy_start(fep->phydev);
@@ -1232,7 +1235,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1232 fpi->rx_ring = 32; 1235 fpi->rx_ring = 32;
1233 fpi->tx_ring = 32; 1236 fpi->tx_ring = 32;
1234 fpi->rx_copybreak = 240; 1237 fpi->rx_copybreak = 240;
1235 fpi->use_napi = 0; 1238 fpi->use_napi = 1;
1236 fpi->napi_weight = 17; 1239 fpi->napi_weight = 17;
1237 1240
1238 ret = find_phy(ofdev->node, fpi); 1241 ret = find_phy(ofdev->node, fpi);
@@ -1249,11 +1252,11 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1249 goto out_free_fpi; 1252 goto out_free_fpi;
1250 } 1253 }
1251 1254
1252 SET_MODULE_OWNER(ndev);
1253 dev_set_drvdata(&ofdev->dev, ndev); 1255 dev_set_drvdata(&ofdev->dev, ndev);
1254 1256
1255 fep = netdev_priv(ndev); 1257 fep = netdev_priv(ndev);
1256 fep->dev = &ofdev->dev; 1258 fep->dev = &ofdev->dev;
1259 fep->ndev = ndev;
1257 fep->fpi = fpi; 1260 fep->fpi = fpi;
1258 fep->ops = match->data; 1261 fep->ops = match->data;
1259 1262
@@ -1288,10 +1291,11 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1288 ndev->stop = fs_enet_close; 1291 ndev->stop = fs_enet_close;
1289 ndev->get_stats = fs_enet_get_stats; 1292 ndev->get_stats = fs_enet_get_stats;
1290 ndev->set_multicast_list = fs_set_multicast_list; 1293 ndev->set_multicast_list = fs_set_multicast_list;
1291 if (fpi->use_napi) { 1294
1292 ndev->poll = fs_enet_rx_napi; 1295 if (fpi->use_napi)
1293 ndev->weight = fpi->napi_weight; 1296 netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi,
1294 } 1297 fpi->napi_weight);
1298
1295 ndev->ethtool_ops = &fs_ethtool_ops; 1299 ndev->ethtool_ops = &fs_ethtool_ops;
1296 ndev->do_ioctl = fs_ioctl; 1300 ndev->do_ioctl = fs_ioctl;
1297 1301