Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] cris v10 eth: use ethtool_ops

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>

authored by

Christoph Hellwig and committed by
Jeff Garzik
76f2b4d9 eac1dfcb

+71 -78
+71 -78
drivers/net/cris/eth_v10.c
··· 409 409 static void e100_rx(struct net_device *dev); 410 410 static int e100_close(struct net_device *dev); 411 411 static int e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); 412 - static int e100_ethtool_ioctl(struct net_device* dev, struct ifreq *ifr); 413 412 static int e100_set_config(struct net_device* dev, struct ifmap* map); 414 413 static void e100_tx_timeout(struct net_device *dev); 415 414 static struct net_device_stats *e100_get_stats(struct net_device *dev); ··· 434 435 435 436 static void e100_clear_network_leds(unsigned long dummy); 436 437 static void e100_set_network_leds(int active); 438 + 439 + static struct ethtool_ops e100_ethtool_ops; 437 440 438 441 static void broadcom_check_speed(struct net_device* dev); 439 442 static void broadcom_check_duplex(struct net_device* dev); ··· 496 495 dev->get_stats = e100_get_stats; 497 496 dev->set_multicast_list = set_multicast_list; 498 497 dev->set_mac_address = e100_set_mac_address; 498 + dev->ethtool_ops = &e100_ethtool_ops; 499 499 dev->do_ioctl = e100_ioctl; 500 500 dev->set_config = e100_set_config; 501 501 dev->tx_timeout = e100_tx_timeout; ··· 1450 1448 1451 1449 spin_lock(&np->lock); /* Preempt protection */ 1452 1450 switch (cmd) { 1453 - case SIOCETHTOOL: 1454 - return e100_ethtool_ioctl(dev,ifr); 1455 1451 case SIOCGMIIPHY: /* Get PHY address */ 1456 1452 data->phy_id = mdio_phy_addr; 1457 1453 break; ··· 1486 1486 return 0; 1487 1487 } 1488 1488 1489 - static int 1490 - e100_ethtool_ioctl(struct net_device *dev, struct ifreq *ifr) 1489 + static int e100_set_settings(struct net_device *dev, 1490 + struct ethtool_cmd *ecmd) 1491 1491 { 1492 - struct ethtool_cmd ecmd; 1493 - 1494 - if (copy_from_user(&ecmd, ifr->ifr_data, sizeof (ecmd))) 1495 - return -EFAULT; 1496 - 1497 - switch (ecmd.cmd) { 1498 - case ETHTOOL_GSET: 1499 - { 1500 - memset((void *) &ecmd, 0, sizeof (ecmd)); 1501 - ecmd.supported = 1502 - SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII | 1492 + ecmd->supported = SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII | 1503 1493 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 1504 1494 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full; 1505 - ecmd.port = PORT_TP; 1506 - ecmd.transceiver = XCVR_EXTERNAL; 1507 - ecmd.phy_address = mdio_phy_addr; 1508 - ecmd.speed = current_speed; 1509 - ecmd.duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF; 1510 - ecmd.advertising = ADVERTISED_TP; 1511 - if (current_duplex == autoneg && current_speed_selection == 0) 1512 - ecmd.advertising |= ADVERTISED_Autoneg; 1513 - else { 1514 - ecmd.advertising |= 1515 - ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | 1516 - ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full; 1517 - if (current_speed_selection == 10) 1518 - ecmd.advertising &= ~(ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full); 1519 - else if (current_speed_selection == 100) 1520 - ecmd.advertising &= ~(ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full); 1521 - if (current_duplex == half) 1522 - ecmd.advertising &= ~(ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Full); 1523 - else if (current_duplex == full) 1524 - ecmd.advertising &= ~(ADVERTISED_10baseT_Half | ADVERTISED_100baseT_Half); 1525 - } 1526 - ecmd.autoneg = AUTONEG_ENABLE; 1527 - if (copy_to_user(ifr->ifr_data, &ecmd, sizeof (ecmd))) 1528 - return -EFAULT; 1529 - } 1530 - break; 1531 - case ETHTOOL_SSET: 1532 - { 1533 - if (!capable(CAP_NET_ADMIN)) { 1534 - return -EPERM; 1535 - } 1536 - if (ecmd.autoneg == AUTONEG_ENABLE) { 1537 - e100_set_duplex(dev, autoneg); 1538 - e100_set_speed(dev, 0); 1539 - } else { 1540 - e100_set_duplex(dev, ecmd.duplex == DUPLEX_HALF ? half : full); 1541 - e100_set_speed(dev, ecmd.speed == SPEED_10 ? 10: 100); 1542 - } 1543 - } 1544 - break; 1545 - case ETHTOOL_GDRVINFO: 1546 - { 1547 - struct ethtool_drvinfo info; 1548 - memset((void *) &info, 0, sizeof (info)); 1549 - strncpy(info.driver, "ETRAX 100LX", sizeof(info.driver) - 1); 1550 - strncpy(info.version, "$Revision: 1.31 $", sizeof(info.version) - 1); 1551 - strncpy(info.fw_version, "N/A", sizeof(info.fw_version) - 1); 1552 - strncpy(info.bus_info, "N/A", sizeof(info.bus_info) - 1); 1553 - info.regdump_len = 0; 1554 - info.eedump_len = 0; 1555 - info.testinfo_len = 0; 1556 - if (copy_to_user(ifr->ifr_data, &info, sizeof (info))) 1557 - return -EFAULT; 1558 - } 1559 - break; 1560 - case ETHTOOL_NWAY_RST: 1561 - if (current_duplex == autoneg && current_speed_selection == 0) 1562 - e100_negotiate(dev); 1563 - break; 1564 - default: 1565 - return -EOPNOTSUPP; 1566 - break; 1495 + ecmd->port = PORT_TP; 1496 + ecmd->transceiver = XCVR_EXTERNAL; 1497 + ecmd->phy_address = mdio_phy_addr; 1498 + ecmd->speed = current_speed; 1499 + ecmd->duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF; 1500 + ecmd->advertising = ADVERTISED_TP; 1501 + 1502 + if (current_duplex == autoneg && current_speed_selection == 0) 1503 + ecmd->advertising |= ADVERTISED_Autoneg; 1504 + else { 1505 + ecmd->advertising |= 1506 + ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | 1507 + ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full; 1508 + if (current_speed_selection == 10) 1509 + ecmd->advertising &= ~(ADVERTISED_100baseT_Half | 1510 + ADVERTISED_100baseT_Full); 1511 + else if (current_speed_selection == 100) 1512 + ecmd->advertising &= ~(ADVERTISED_10baseT_Half | 1513 + ADVERTISED_10baseT_Full); 1514 + if (current_duplex == half) 1515 + ecmd->advertising &= ~(ADVERTISED_10baseT_Full | 1516 + ADVERTISED_100baseT_Full); 1517 + else if (current_duplex == full) 1518 + ecmd->advertising &= ~(ADVERTISED_10baseT_Half | 1519 + ADVERTISED_100baseT_Half); 1567 1520 } 1521 + 1522 + ecmd->autoneg = AUTONEG_ENABLE; 1568 1523 return 0; 1569 1524 } 1525 + 1526 + static int e100_set_settings(struct net_device *dev, 1527 + struct ethtool_cmd *ecmd) 1528 + { 1529 + if (ecmd->autoneg == AUTONEG_ENABLE) { 1530 + e100_set_duplex(dev, autoneg); 1531 + e100_set_speed(dev, 0); 1532 + } else { 1533 + e100_set_duplex(dev, ecmd->duplex == DUPLEX_HALF ? half : full); 1534 + e100_set_speed(dev, ecmd->speed == SPEED_10 ? 10: 100); 1535 + } 1536 + 1537 + return 0; 1538 + } 1539 + 1540 + static void e100_get_drvinfo(struct net_device *dev, 1541 + struct ethtool_drvinfo *info) 1542 + { 1543 + strncpy(info->driver, "ETRAX 100LX", sizeof(info->driver) - 1); 1544 + strncpy(info->version, "$Revision: 1.31 $", sizeof(info->version) - 1); 1545 + strncpy(info->fw_version, "N/A", sizeof(info->fw_version) - 1); 1546 + strncpy(info->bus_info, "N/A", sizeof(info->bus_info) - 1); 1547 + } 1548 + 1549 + static int e100_nway_reset(struct net_device *dev) 1550 + { 1551 + if (current_duplex == autoneg && current_speed_selection == 0) 1552 + e100_negotiate(dev); 1553 + return 0; 1554 + } 1555 + 1556 + static struct ethtool_ops e100_ethtool_ops = { 1557 + .get_settings = e100_get_settings, 1558 + .set_settings = e100_set_settings, 1559 + .get_drvinfo = e100_get_drvinfo, 1560 + .nway_reset = e100_nway_reset, 1561 + .get_link = ethtool_op_get_link, 1562 + }; 1570 1563 1571 1564 static int 1572 1565 e100_set_config(struct net_device *dev, struct ifmap *map)