diff options
Diffstat (limited to 'drivers/net/xilinx_emaclite.c')
-rw-r--r-- | drivers/net/xilinx_emaclite.c | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index ecbbb688eba0..372572c0adc6 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
25 | #include <linux/of_platform.h> | 25 | #include <linux/of_platform.h> |
26 | #include <linux/of_mdio.h> | 26 | #include <linux/of_mdio.h> |
27 | #include <linux/of_net.h> | ||
27 | #include <linux/phy.h> | 28 | #include <linux/phy.h> |
28 | 29 | ||
29 | #define DRIVER_NAME "xilinx_emaclite" | 30 | #define DRIVER_NAME "xilinx_emaclite" |
@@ -430,8 +431,8 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data) | |||
430 | } | 431 | } |
431 | 432 | ||
432 | /* Get the protocol type of the ethernet frame that arrived */ | 433 | /* Get the protocol type of the ethernet frame that arrived */ |
433 | proto_type = ((in_be32(addr + XEL_HEADER_OFFSET + | 434 | proto_type = ((ntohl(in_be32(addr + XEL_HEADER_OFFSET + |
434 | XEL_RXBUFF_OFFSET) >> XEL_HEADER_SHIFT) & | 435 | XEL_RXBUFF_OFFSET)) >> XEL_HEADER_SHIFT) & |
435 | XEL_RPLR_LENGTH_MASK); | 436 | XEL_RPLR_LENGTH_MASK); |
436 | 437 | ||
437 | /* Check if received ethernet frame is a raw ethernet frame | 438 | /* Check if received ethernet frame is a raw ethernet frame |
@@ -439,9 +440,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data) | |||
439 | if (proto_type > (ETH_FRAME_LEN + ETH_FCS_LEN)) { | 440 | if (proto_type > (ETH_FRAME_LEN + ETH_FCS_LEN)) { |
440 | 441 | ||
441 | if (proto_type == ETH_P_IP) { | 442 | if (proto_type == ETH_P_IP) { |
442 | length = ((in_be32(addr + | 443 | length = ((ntohl(in_be32(addr + |
443 | XEL_HEADER_IP_LENGTH_OFFSET + | 444 | XEL_HEADER_IP_LENGTH_OFFSET + |
444 | XEL_RXBUFF_OFFSET) >> | 445 | XEL_RXBUFF_OFFSET)) >> |
445 | XEL_HEADER_SHIFT) & | 446 | XEL_HEADER_SHIFT) & |
446 | XEL_RPLR_LENGTH_MASK); | 447 | XEL_RPLR_LENGTH_MASK); |
447 | length += ETH_HLEN + ETH_FCS_LEN; | 448 | length += ETH_HLEN + ETH_FCS_LEN; |
@@ -515,7 +516,7 @@ static void xemaclite_update_address(struct net_local *drvdata, | |||
515 | */ | 516 | */ |
516 | static int xemaclite_set_mac_address(struct net_device *dev, void *address) | 517 | static int xemaclite_set_mac_address(struct net_device *dev, void *address) |
517 | { | 518 | { |
518 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 519 | struct net_local *lp = netdev_priv(dev); |
519 | struct sockaddr *addr = address; | 520 | struct sockaddr *addr = address; |
520 | 521 | ||
521 | if (netif_running(dev)) | 522 | if (netif_running(dev)) |
@@ -534,7 +535,7 @@ static int xemaclite_set_mac_address(struct net_device *dev, void *address) | |||
534 | */ | 535 | */ |
535 | static void xemaclite_tx_timeout(struct net_device *dev) | 536 | static void xemaclite_tx_timeout(struct net_device *dev) |
536 | { | 537 | { |
537 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 538 | struct net_local *lp = netdev_priv(dev); |
538 | unsigned long flags; | 539 | unsigned long flags; |
539 | 540 | ||
540 | dev_err(&lp->ndev->dev, "Exceeded transmit timeout of %lu ms\n", | 541 | dev_err(&lp->ndev->dev, "Exceeded transmit timeout of %lu ms\n", |
@@ -578,7 +579,7 @@ static void xemaclite_tx_timeout(struct net_device *dev) | |||
578 | */ | 579 | */ |
579 | static void xemaclite_tx_handler(struct net_device *dev) | 580 | static void xemaclite_tx_handler(struct net_device *dev) |
580 | { | 581 | { |
581 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 582 | struct net_local *lp = netdev_priv(dev); |
582 | 583 | ||
583 | dev->stats.tx_packets++; | 584 | dev->stats.tx_packets++; |
584 | if (lp->deferred_skb) { | 585 | if (lp->deferred_skb) { |
@@ -605,7 +606,7 @@ static void xemaclite_tx_handler(struct net_device *dev) | |||
605 | */ | 606 | */ |
606 | static void xemaclite_rx_handler(struct net_device *dev) | 607 | static void xemaclite_rx_handler(struct net_device *dev) |
607 | { | 608 | { |
608 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 609 | struct net_local *lp = netdev_priv(dev); |
609 | struct sk_buff *skb; | 610 | struct sk_buff *skb; |
610 | unsigned int align; | 611 | unsigned int align; |
611 | u32 len; | 612 | u32 len; |
@@ -641,7 +642,7 @@ static void xemaclite_rx_handler(struct net_device *dev) | |||
641 | skb_put(skb, len); /* Tell the skb how much data we got */ | 642 | skb_put(skb, len); /* Tell the skb how much data we got */ |
642 | 643 | ||
643 | skb->protocol = eth_type_trans(skb, dev); | 644 | skb->protocol = eth_type_trans(skb, dev); |
644 | skb->ip_summed = CHECKSUM_NONE; | 645 | skb_checksum_none_assert(skb); |
645 | 646 | ||
646 | dev->stats.rx_packets++; | 647 | dev->stats.rx_packets++; |
647 | dev->stats.rx_bytes += len; | 648 | dev->stats.rx_bytes += len; |
@@ -661,7 +662,7 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id) | |||
661 | { | 662 | { |
662 | bool tx_complete = 0; | 663 | bool tx_complete = 0; |
663 | struct net_device *dev = dev_id; | 664 | struct net_device *dev = dev_id; |
664 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 665 | struct net_local *lp = netdev_priv(dev); |
665 | void __iomem *base_addr = lp->base_addr; | 666 | void __iomem *base_addr = lp->base_addr; |
666 | u32 tx_status; | 667 | u32 tx_status; |
667 | 668 | ||
@@ -785,7 +786,7 @@ static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int reg) | |||
785 | * @reg: register number to write to | 786 | * @reg: register number to write to |
786 | * @val: value to write to the register number specified by reg | 787 | * @val: value to write to the register number specified by reg |
787 | * | 788 | * |
788 | * This fucntion waits till the device is ready to accept a new MDIO | 789 | * This function waits till the device is ready to accept a new MDIO |
789 | * request and then writes the val to the MDIO Write Data register. | 790 | * request and then writes the val to the MDIO Write Data register. |
790 | */ | 791 | */ |
791 | static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg, | 792 | static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg, |
@@ -918,7 +919,7 @@ void xemaclite_adjust_link(struct net_device *ndev) | |||
918 | */ | 919 | */ |
919 | static int xemaclite_open(struct net_device *dev) | 920 | static int xemaclite_open(struct net_device *dev) |
920 | { | 921 | { |
921 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 922 | struct net_local *lp = netdev_priv(dev); |
922 | int retval; | 923 | int retval; |
923 | 924 | ||
924 | /* Just to be safe, stop the device first */ | 925 | /* Just to be safe, stop the device first */ |
@@ -987,7 +988,7 @@ static int xemaclite_open(struct net_device *dev) | |||
987 | */ | 988 | */ |
988 | static int xemaclite_close(struct net_device *dev) | 989 | static int xemaclite_close(struct net_device *dev) |
989 | { | 990 | { |
990 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 991 | struct net_local *lp = netdev_priv(dev); |
991 | 992 | ||
992 | netif_stop_queue(dev); | 993 | netif_stop_queue(dev); |
993 | xemaclite_disable_interrupts(lp); | 994 | xemaclite_disable_interrupts(lp); |
@@ -1001,21 +1002,6 @@ static int xemaclite_close(struct net_device *dev) | |||
1001 | } | 1002 | } |
1002 | 1003 | ||
1003 | /** | 1004 | /** |
1004 | * xemaclite_get_stats - Get the stats for the net_device | ||
1005 | * @dev: Pointer to the network device | ||
1006 | * | ||
1007 | * This function returns the address of the 'net_device_stats' structure for the | ||
1008 | * given network device. This structure holds usage statistics for the network | ||
1009 | * device. | ||
1010 | * | ||
1011 | * Return: Pointer to the net_device_stats structure. | ||
1012 | */ | ||
1013 | static struct net_device_stats *xemaclite_get_stats(struct net_device *dev) | ||
1014 | { | ||
1015 | return &dev->stats; | ||
1016 | } | ||
1017 | |||
1018 | /** | ||
1019 | * xemaclite_send - Transmit a frame | 1005 | * xemaclite_send - Transmit a frame |
1020 | * @orig_skb: Pointer to the socket buffer to be transmitted | 1006 | * @orig_skb: Pointer to the socket buffer to be transmitted |
1021 | * @dev: Pointer to the network device | 1007 | * @dev: Pointer to the network device |
@@ -1031,7 +1017,7 @@ static struct net_device_stats *xemaclite_get_stats(struct net_device *dev) | |||
1031 | */ | 1017 | */ |
1032 | static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev) | 1018 | static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev) |
1033 | { | 1019 | { |
1034 | struct net_local *lp = (struct net_local *) netdev_priv(dev); | 1020 | struct net_local *lp = netdev_priv(dev); |
1035 | struct sk_buff *new_skb; | 1021 | struct sk_buff *new_skb; |
1036 | unsigned int len; | 1022 | unsigned int len; |
1037 | unsigned long flags; | 1023 | unsigned long flags; |
@@ -1068,7 +1054,7 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev) | |||
1068 | static void xemaclite_remove_ndev(struct net_device *ndev) | 1054 | static void xemaclite_remove_ndev(struct net_device *ndev) |
1069 | { | 1055 | { |
1070 | if (ndev) { | 1056 | if (ndev) { |
1071 | struct net_local *lp = (struct net_local *) netdev_priv(ndev); | 1057 | struct net_local *lp = netdev_priv(ndev); |
1072 | 1058 | ||
1073 | if (lp->base_addr) | 1059 | if (lp->base_addr) |
1074 | iounmap((void __iomem __force *) (lp->base_addr)); | 1060 | iounmap((void __iomem __force *) (lp->base_addr)); |
@@ -1115,8 +1101,7 @@ static struct net_device_ops xemaclite_netdev_ops; | |||
1115 | * Return: 0, if the driver is bound to the Emaclite device, or | 1101 | * Return: 0, if the driver is bound to the Emaclite device, or |
1116 | * a negative error if there is failure. | 1102 | * a negative error if there is failure. |
1117 | */ | 1103 | */ |
1118 | static int __devinit xemaclite_of_probe(struct platform_device *ofdev, | 1104 | static int __devinit xemaclite_of_probe(struct platform_device *ofdev) |
1119 | const struct of_device_id *match) | ||
1120 | { | 1105 | { |
1121 | struct resource r_irq; /* Interrupt resources */ | 1106 | struct resource r_irq; /* Interrupt resources */ |
1122 | struct resource r_mem; /* IO mem resources */ | 1107 | struct resource r_mem; /* IO mem resources */ |
@@ -1245,7 +1230,7 @@ static int __devexit xemaclite_of_remove(struct platform_device *of_dev) | |||
1245 | struct device *dev = &of_dev->dev; | 1230 | struct device *dev = &of_dev->dev; |
1246 | struct net_device *ndev = dev_get_drvdata(dev); | 1231 | struct net_device *ndev = dev_get_drvdata(dev); |
1247 | 1232 | ||
1248 | struct net_local *lp = (struct net_local *) netdev_priv(ndev); | 1233 | struct net_local *lp = netdev_priv(ndev); |
1249 | 1234 | ||
1250 | /* Un-register the mii_bus, if configured */ | 1235 | /* Un-register the mii_bus, if configured */ |
1251 | if (lp->has_mdio) { | 1236 | if (lp->has_mdio) { |
@@ -1269,13 +1254,25 @@ static int __devexit xemaclite_of_remove(struct platform_device *of_dev) | |||
1269 | return 0; | 1254 | return 0; |
1270 | } | 1255 | } |
1271 | 1256 | ||
1257 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1258 | static void | ||
1259 | xemaclite_poll_controller(struct net_device *ndev) | ||
1260 | { | ||
1261 | disable_irq(ndev->irq); | ||
1262 | xemaclite_interrupt(ndev->irq, ndev); | ||
1263 | enable_irq(ndev->irq); | ||
1264 | } | ||
1265 | #endif | ||
1266 | |||
1272 | static struct net_device_ops xemaclite_netdev_ops = { | 1267 | static struct net_device_ops xemaclite_netdev_ops = { |
1273 | .ndo_open = xemaclite_open, | 1268 | .ndo_open = xemaclite_open, |
1274 | .ndo_stop = xemaclite_close, | 1269 | .ndo_stop = xemaclite_close, |
1275 | .ndo_start_xmit = xemaclite_send, | 1270 | .ndo_start_xmit = xemaclite_send, |
1276 | .ndo_set_mac_address = xemaclite_set_mac_address, | 1271 | .ndo_set_mac_address = xemaclite_set_mac_address, |
1277 | .ndo_tx_timeout = xemaclite_tx_timeout, | 1272 | .ndo_tx_timeout = xemaclite_tx_timeout, |
1278 | .ndo_get_stats = xemaclite_get_stats, | 1273 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1274 | .ndo_poll_controller = xemaclite_poll_controller, | ||
1275 | #endif | ||
1279 | }; | 1276 | }; |
1280 | 1277 | ||
1281 | /* Match table for OF platform binding */ | 1278 | /* Match table for OF platform binding */ |
@@ -1290,7 +1287,7 @@ static struct of_device_id xemaclite_of_match[] __devinitdata = { | |||
1290 | }; | 1287 | }; |
1291 | MODULE_DEVICE_TABLE(of, xemaclite_of_match); | 1288 | MODULE_DEVICE_TABLE(of, xemaclite_of_match); |
1292 | 1289 | ||
1293 | static struct of_platform_driver xemaclite_of_driver = { | 1290 | static struct platform_driver xemaclite_of_driver = { |
1294 | .driver = { | 1291 | .driver = { |
1295 | .name = DRIVER_NAME, | 1292 | .name = DRIVER_NAME, |
1296 | .owner = THIS_MODULE, | 1293 | .owner = THIS_MODULE, |
@@ -1308,7 +1305,7 @@ static struct of_platform_driver xemaclite_of_driver = { | |||
1308 | static int __init xemaclite_init(void) | 1305 | static int __init xemaclite_init(void) |
1309 | { | 1306 | { |
1310 | /* No kernel boot options used, we just need to register the driver */ | 1307 | /* No kernel boot options used, we just need to register the driver */ |
1311 | return of_register_platform_driver(&xemaclite_of_driver); | 1308 | return platform_driver_register(&xemaclite_of_driver); |
1312 | } | 1309 | } |
1313 | 1310 | ||
1314 | /** | 1311 | /** |
@@ -1316,7 +1313,7 @@ static int __init xemaclite_init(void) | |||
1316 | */ | 1313 | */ |
1317 | static void __exit xemaclite_cleanup(void) | 1314 | static void __exit xemaclite_cleanup(void) |
1318 | { | 1315 | { |
1319 | of_unregister_platform_driver(&xemaclite_of_driver); | 1316 | platform_driver_unregister(&xemaclite_of_driver); |
1320 | } | 1317 | } |
1321 | 1318 | ||
1322 | module_init(xemaclite_init); | 1319 | module_init(xemaclite_init); |