diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2011-05-13 16:50:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-13 16:50:49 -0400 |
commit | 48e20467227fe540e6bbf3d98df98c2c0fca10f3 (patch) | |
tree | b9957daba74e0b24e9a1b322ba44ec3c6cc6f257 /drivers/net/tokenring | |
parent | 0696c3a8acd3b7c3186dd231d65d97e05a75189f (diff) |
olympic: convert to seq_file
->read_proc interface is going away, switch to seq_file.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tokenring')
-rw-r--r-- | drivers/net/tokenring/olympic.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c index 2684003b8ab6..e3855aeb13d4 100644 --- a/drivers/net/tokenring/olympic.c +++ b/drivers/net/tokenring/olympic.c | |||
@@ -86,6 +86,7 @@ | |||
86 | #include <linux/timer.h> | 86 | #include <linux/timer.h> |
87 | #include <linux/in.h> | 87 | #include <linux/in.h> |
88 | #include <linux/ioport.h> | 88 | #include <linux/ioport.h> |
89 | #include <linux/seq_file.h> | ||
89 | #include <linux/string.h> | 90 | #include <linux/string.h> |
90 | #include <linux/proc_fs.h> | 91 | #include <linux/proc_fs.h> |
91 | #include <linux/ptrace.h> | 92 | #include <linux/ptrace.h> |
@@ -193,7 +194,7 @@ static void olympic_arb_cmd(struct net_device *dev); | |||
193 | static int olympic_change_mtu(struct net_device *dev, int mtu); | 194 | static int olympic_change_mtu(struct net_device *dev, int mtu); |
194 | static void olympic_srb_bh(struct net_device *dev) ; | 195 | static void olympic_srb_bh(struct net_device *dev) ; |
195 | static void olympic_asb_bh(struct net_device *dev) ; | 196 | static void olympic_asb_bh(struct net_device *dev) ; |
196 | static int olympic_proc_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) ; | 197 | static const struct file_operations olympic_proc_ops; |
197 | 198 | ||
198 | static const struct net_device_ops olympic_netdev_ops = { | 199 | static const struct net_device_ops olympic_netdev_ops = { |
199 | .ndo_open = olympic_open, | 200 | .ndo_open = olympic_open, |
@@ -272,7 +273,7 @@ static int __devinit olympic_probe(struct pci_dev *pdev, const struct pci_device | |||
272 | char proc_name[20] ; | 273 | char proc_name[20] ; |
273 | strcpy(proc_name,"olympic_") ; | 274 | strcpy(proc_name,"olympic_") ; |
274 | strcat(proc_name,dev->name) ; | 275 | strcat(proc_name,dev->name) ; |
275 | create_proc_read_entry(proc_name,0,init_net.proc_net,olympic_proc_info,(void *)dev) ; | 276 | proc_create_data(proc_name, 0, init_net.proc_net, &olympic_proc_ops, dev); |
276 | printk("Olympic: Network Monitor information: /proc/%s\n",proc_name); | 277 | printk("Olympic: Network Monitor information: /proc/%s\n",proc_name); |
277 | } | 278 | } |
278 | return 0 ; | 279 | return 0 ; |
@@ -1615,29 +1616,25 @@ static int olympic_change_mtu(struct net_device *dev, int mtu) | |||
1615 | return 0 ; | 1616 | return 0 ; |
1616 | } | 1617 | } |
1617 | 1618 | ||
1618 | static int olympic_proc_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) | 1619 | static int olympic_proc_show(struct seq_file *m, void *v) |
1619 | { | 1620 | { |
1620 | struct net_device *dev = (struct net_device *)data ; | 1621 | struct net_device *dev = m->private; |
1621 | struct olympic_private *olympic_priv=netdev_priv(dev); | 1622 | struct olympic_private *olympic_priv=netdev_priv(dev); |
1622 | u8 __iomem *oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr) ; | 1623 | u8 __iomem *oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr) ; |
1623 | u8 __iomem *opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr) ; | 1624 | u8 __iomem *opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr) ; |
1624 | int size = 0 ; | ||
1625 | int len=0; | ||
1626 | off_t begin=0; | ||
1627 | off_t pos=0; | ||
1628 | u8 addr[6]; | 1625 | u8 addr[6]; |
1629 | u8 addr2[6]; | 1626 | u8 addr2[6]; |
1630 | int i; | 1627 | int i; |
1631 | 1628 | ||
1632 | size = sprintf(buffer, | 1629 | seq_printf(m, |
1633 | "IBM Pit/Pit-Phy/Olympic Chipset Token Ring Adapter %s\n",dev->name); | 1630 | "IBM Pit/Pit-Phy/Olympic Chipset Token Ring Adapter %s\n",dev->name); |
1634 | size += sprintf(buffer+size, "\n%6s: Adapter Address : Node Address : Functional Addr\n", | 1631 | seq_printf(m, "\n%6s: Adapter Address : Node Address : Functional Addr\n", |
1635 | dev->name); | 1632 | dev->name); |
1636 | 1633 | ||
1637 | for (i = 0 ; i < 6 ; i++) | 1634 | for (i = 0 ; i < 6 ; i++) |
1638 | addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr) + i); | 1635 | addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr) + i); |
1639 | 1636 | ||
1640 | size += sprintf(buffer+size, "%6s: %pM : %pM : %02x:%02x:%02x:%02x\n", | 1637 | seq_printf(m, "%6s: %pM : %pM : %02x:%02x:%02x:%02x\n", |
1641 | dev->name, | 1638 | dev->name, |
1642 | dev->dev_addr, addr, | 1639 | dev->dev_addr, addr, |
1643 | readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)), | 1640 | readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)), |
@@ -1645,9 +1642,9 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt | |||
1645 | readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2), | 1642 | readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2), |
1646 | readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+3)); | 1643 | readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+3)); |
1647 | 1644 | ||
1648 | size += sprintf(buffer+size, "\n%6s: Token Ring Parameters Table:\n", dev->name); | 1645 | seq_printf(m, "\n%6s: Token Ring Parameters Table:\n", dev->name); |
1649 | 1646 | ||
1650 | size += sprintf(buffer+size, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", | 1647 | seq_printf(m, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", |
1651 | dev->name) ; | 1648 | dev->name) ; |
1652 | 1649 | ||
1653 | for (i = 0 ; i < 6 ; i++) | 1650 | for (i = 0 ; i < 6 ; i++) |
@@ -1655,7 +1652,7 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt | |||
1655 | for (i = 0 ; i < 6 ; i++) | 1652 | for (i = 0 ; i < 6 ; i++) |
1656 | addr2[i] = readb(opt+offsetof(struct olympic_parameters_table, poll_addr) + i); | 1653 | addr2[i] = readb(opt+offsetof(struct olympic_parameters_table, poll_addr) + i); |
1657 | 1654 | ||
1658 | size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x : %pM : %pM : %04x : %04x : %04x :\n", | 1655 | seq_printf(m, "%6s: %02x:%02x:%02x:%02x : %pM : %pM : %04x : %04x : %04x :\n", |
1659 | dev->name, | 1656 | dev->name, |
1660 | readb(opt+offsetof(struct olympic_parameters_table, phys_addr)), | 1657 | readb(opt+offsetof(struct olympic_parameters_table, phys_addr)), |
1661 | readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+1), | 1658 | readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+1), |
@@ -1666,12 +1663,12 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt | |||
1666 | swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))), | 1663 | swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))), |
1667 | swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code)))); | 1664 | swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code)))); |
1668 | 1665 | ||
1669 | size += sprintf(buffer+size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", | 1666 | seq_printf(m, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", |
1670 | dev->name) ; | 1667 | dev->name) ; |
1671 | 1668 | ||
1672 | for (i = 0 ; i < 6 ; i++) | 1669 | for (i = 0 ; i < 6 ; i++) |
1673 | addr[i] = readb(opt+offsetof(struct olympic_parameters_table, source_addr) + i); | 1670 | addr[i] = readb(opt+offsetof(struct olympic_parameters_table, source_addr) + i); |
1674 | size += sprintf(buffer+size, "%6s: %pM : %04x : %04x : %04x : %04x : %04x : %04x : \n", | 1671 | seq_printf(m, "%6s: %pM : %04x : %04x : %04x : %04x : %04x : %04x : \n", |
1675 | dev->name, addr, | 1672 | dev->name, addr, |
1676 | swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))), | 1673 | swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))), |
1677 | swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))), | 1674 | swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))), |
@@ -1680,12 +1677,12 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt | |||
1680 | swab16(readw(opt+offsetof(struct olympic_parameters_table, mon_error))), | 1677 | swab16(readw(opt+offsetof(struct olympic_parameters_table, mon_error))), |
1681 | swab16(readw(opt+offsetof(struct olympic_parameters_table, frame_correl)))); | 1678 | swab16(readw(opt+offsetof(struct olympic_parameters_table, frame_correl)))); |
1682 | 1679 | ||
1683 | size += sprintf(buffer+size, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n", | 1680 | seq_printf(m, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n", |
1684 | dev->name) ; | 1681 | dev->name) ; |
1685 | 1682 | ||
1686 | for (i = 0 ; i < 6 ; i++) | 1683 | for (i = 0 ; i < 6 ; i++) |
1687 | addr[i] = readb(opt+offsetof(struct olympic_parameters_table, beacon_naun) + i); | 1684 | addr[i] = readb(opt+offsetof(struct olympic_parameters_table, beacon_naun) + i); |
1688 | size += sprintf(buffer+size, "%6s: : %02x : %02x : %pM : %02x:%02x:%02x:%02x : \n", | 1685 | seq_printf(m, "%6s: : %02x : %02x : %pM : %02x:%02x:%02x:%02x : \n", |
1689 | dev->name, | 1686 | dev->name, |
1690 | swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))), | 1687 | swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))), |
1691 | swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))), | 1688 | swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))), |
@@ -1695,19 +1692,21 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt | |||
1695 | readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+2), | 1692 | readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+2), |
1696 | readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+3)); | 1693 | readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+3)); |
1697 | 1694 | ||
1698 | len=size; | 1695 | return 0; |
1699 | pos=begin+size; | ||
1700 | if (pos<offset) { | ||
1701 | len=0; | ||
1702 | begin=pos; | ||
1703 | } | ||
1704 | *start=buffer+(offset-begin); /* Start of wanted data */ | ||
1705 | len-=(offset-begin); /* Start slop */ | ||
1706 | if(len>length) | ||
1707 | len=length; /* Ending slop */ | ||
1708 | return len; | ||
1709 | } | 1696 | } |
1710 | 1697 | ||
1698 | static int olympic_proc_open(struct inode *inode, struct file *file) | ||
1699 | { | ||
1700 | return single_open(file, olympic_proc_show, PDE(inode)->data); | ||
1701 | } | ||
1702 | |||
1703 | static const struct file_operations olympic_proc_ops = { | ||
1704 | .open = olympic_proc_open, | ||
1705 | .read = seq_read, | ||
1706 | .llseek = seq_lseek, | ||
1707 | .release = single_release, | ||
1708 | }; | ||
1709 | |||
1711 | static void __devexit olympic_remove_one(struct pci_dev *pdev) | 1710 | static void __devexit olympic_remove_one(struct pci_dev *pdev) |
1712 | { | 1711 | { |
1713 | struct net_device *dev = pci_get_drvdata(pdev) ; | 1712 | struct net_device *dev = pci_get_drvdata(pdev) ; |