Commit 5f505b2b authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr pcmcia] convert several drivers to ethtool_ops

Drivers updated: fmvj18x_cs, ibmtr_cs, nmclan_cs, pcnet_cs,
xirc2ps_cs.
parent 5cb6eed7
......@@ -113,7 +113,7 @@ static void fjn_reset(struct net_device *dev);
static struct net_device_stats *fjn_get_stats(struct net_device *dev);
static void set_rx_mode(struct net_device *dev);
static void fjn_tx_timeout(struct net_device *dev);
static int fjn_ioctl(struct net_device *, struct ifreq *, int);
static struct ethtool_ops netdev_ethtool_ops;
static dev_info_t dev_info = "fmvj18x_cs";
static dev_link_t *dev_list;
......@@ -312,7 +312,7 @@ static dev_link_t *fmvj18x_attach(void)
dev->tx_timeout = fjn_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#endif
dev->do_ioctl = fjn_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
/* Register with Card Services */
link->next = dev_list;
......@@ -1186,64 +1186,33 @@ static void fjn_rx(struct net_device *dev)
/*====================================================================*/
static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
u32 ethcmd;
/* dev_ioctl() in ../../net/core/dev.c has already checked
capable(CAP_NET_ADMIN), so don't bother with that here. */
if (get_user(ethcmd, (u32 *)useraddr))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
strcpy (info.driver, DRV_NAME);
strcpy (info.version, DRV_VERSION);
sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
if (copy_to_user (useraddr, &info, sizeof (info)))
return -EFAULT;
return 0;
}
strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
}
#ifdef PCMCIA_DEBUG
/* get message-level */
case ETHTOOL_GMSGLVL: {
struct ethtool_value edata = {ETHTOOL_GMSGLVL};
edata.data = pc_debug;
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
}
/* set message-level */
case ETHTOOL_SMSGLVL: {
struct ethtool_value edata;
if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;
pc_debug = edata.data;
return 0;
}
#endif
default:
break;
}
return -EOPNOTSUPP;
static u32 netdev_get_msglevel(struct net_device *dev)
{
return pc_debug;
}
static int fjn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
static void netdev_set_msglevel(struct net_device *dev, u32 level)
{
switch (cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
default:
return -EOPNOTSUPP;
}
pc_debug = level;
}
#endif /* PCMCIA_DEBUG */
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
#ifdef PCMCIA_DEBUG
.get_msglevel = netdev_get_msglevel,
.set_msglevel = netdev_set_msglevel,
#endif /* PCMCIA_DEBUG */
};
static int fjn_config(struct net_device *dev, struct ifmap *map){
return 0;
......
......@@ -157,36 +157,15 @@ static void flush_stale_links(void)
}
}
static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
u32 ethcmd;
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, "ibmtr_cs", sizeof(info.driver)-1);
if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT;
return 0;
}
}
return -EOPNOTSUPP;
strcpy(info->driver, "ibmtr_cs");
}
static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
switch(cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
default:
return -EOPNOTSUPP;
}
}
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
};
/*======================================================================
......@@ -235,7 +214,7 @@ static dev_link_t *ibmtr_attach(void)
link->irq.Instance = info->dev = dev;
dev->init = &ibmtr_probe;
dev->do_ioctl = &private_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
/* Register with Card Services */
link->next = dev_list;
......
......@@ -442,7 +442,8 @@ static struct net_device_stats *mace_get_stats(struct net_device *dev);
static int mace_rx(struct net_device *dev, unsigned char RxCnt);
static void restore_multicast_list(struct net_device *dev);
static void set_multicast_list(struct net_device *dev);
static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static struct ethtool_ops netdev_ethtool_ops;
static dev_link_t *nmclan_attach(void);
static void nmclan_detach(dev_link_t *);
......@@ -515,7 +516,7 @@ static dev_link_t *nmclan_attach(void)
dev->set_config = &mace_config;
dev->get_stats = &mace_get_stats;
dev->set_multicast_list = &set_multicast_list;
dev->do_ioctl = &mace_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
dev->open = &mace_open;
dev->stop = &mace_close;
#ifdef HAVE_TX_TIMEOUT
......@@ -1014,65 +1015,33 @@ static int mace_close(struct net_device *dev)
return 0;
} /* mace_close */
static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
u32 ethcmd;
/* dev_ioctl() in ../../net/core/dev.c has already checked
capable(CAP_NET_ADMIN), so don't bother with that here. */
if (get_user(ethcmd, (u32 *)useraddr))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
strcpy (info.driver, DRV_NAME);
strcpy (info.version, DRV_VERSION);
sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
if (copy_to_user (useraddr, &info, sizeof (info)))
return -EFAULT;
return 0;
}
strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
}
#ifdef PCMCIA_DEBUG
/* get message-level */
case ETHTOOL_GMSGLVL: {
struct ethtool_value edata = {ETHTOOL_GMSGLVL};
edata.data = pc_debug;
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
}
/* set message-level */
case ETHTOOL_SMSGLVL: {
struct ethtool_value edata;
if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;
pc_debug = edata.data;
return 0;
}
#endif
default:
break;
}
return -EOPNOTSUPP;
static u32 netdev_get_msglevel(struct net_device *dev)
{
return pc_debug;
}
static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
static void netdev_set_msglevel(struct net_device *dev, u32 level)
{
switch (cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
default:
return -EOPNOTSUPP;
}
return 0;
pc_debug = level;
}
#endif /* PCMCIA_DEBUG */
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
#ifdef PCMCIA_DEBUG
.get_msglevel = netdev_get_msglevel,
.set_msglevel = netdev_set_msglevel,
#endif /* PCMCIA_DEBUG */
};
/* ----------------------------------------------------------------------------
mace_start_xmit
......
......@@ -116,7 +116,7 @@ static int pcnet_event(event_t event, int priority,
static int pcnet_open(struct net_device *dev);
static int pcnet_close(struct net_device *dev);
static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd);
static struct ethtool_ops netdev_ethtool_ops;
static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
static void ei_watchdog(u_long arg);
static void pcnet_reset_8390(struct net_device *dev);
......@@ -756,6 +756,7 @@ static void pcnet_config(dev_link_t *link)
strcpy(info->node.dev_name, dev->name);
link->dev = &info->node;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
if (info->flags & (IS_DL10019|IS_DL10022)) {
u_char id = inb(dev->base_addr + 0x1a);
......@@ -769,7 +770,6 @@ static void pcnet_config(dev_link_t *link)
printk("PNA, ");
} else {
printk(KERN_INFO "%s: NE2000 Compatible: ", dev->name);
dev->do_ioctl = &do_ioctl_light;
}
printk("io %#3lx, irq %d,", dev->base_addr, dev->irq);
if (info->flags & USE_SHMEM)
......@@ -1205,26 +1205,16 @@ static void ei_watchdog(u_long arg)
/*====================================================================*/
static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
u32 ethcmd;
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, "pcnet_cs", sizeof(info.driver)-1);
if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT;
return 0;
}
}
return -EOPNOTSUPP;
strcpy(info->driver, "pcnet_cs");
}
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
};
/*====================================================================*/
......@@ -1234,8 +1224,6 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
u16 *data = (u16 *)&rq->ifr_data;
ioaddr_t mii_addr = dev->base_addr + DLINK_GPIO;
switch (cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
case SIOCDEVPRIVATE:
data[0] = info->phy_id;
case SIOCDEVPRIVATE+1:
......@@ -1252,17 +1240,6 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
/*====================================================================*/
static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd)
{
switch (cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
}
return -EOPNOTSUPP;
}
/*====================================================================*/
static void dma_get_8390_hdr(struct net_device *dev,
struct e8390_pkt_hdr *hdr,
int ring_page)
......
......@@ -382,6 +382,7 @@ static int set_card_type(dev_link_t *link, const void *s);
static int do_config(struct net_device *dev, struct ifmap *map);
static int do_open(struct net_device *dev);
static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static struct ethtool_ops netdev_ethtool_ops;
static void hardreset(struct net_device *dev);
static void do_reset(struct net_device *dev, int full);
static int init_mii(struct net_device *dev);
......@@ -626,6 +627,7 @@ xirc2ps_attach(void)
dev->set_config = &do_config;
dev->get_stats = &do_get_stats;
dev->do_ioctl = &do_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
dev->set_multicast_list = &set_multicast_list;
dev->open = &do_open;
dev->stop = &do_stop;
......@@ -1699,26 +1701,16 @@ do_open(struct net_device *dev)
return 0;
}
static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
u32 ethcmd;
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, "xirc2ps_cs", sizeof(info.driver)-1);
if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT;
return 0;
}
}
return -EOPNOTSUPP;
strcpy(info->driver, "xirc2ps_cs");
}
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
};
static int
do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
......@@ -1734,8 +1726,6 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return -EOPNOTSUPP;
switch(cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */
data[0] = 0; /* we have only this address */
/* fall trough */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment