Hi,
I have updated the 0001-Fix-compilatin-issues-on-kernel-above-3.10.patch, which
has fixed the compilation issues but introduce several bugs that have broken a
kernel modules when RTnet proc files have been read. This updated patch remove
issues with accessing proc subsystem. It should be applied to origin/master
branch.
Best,
Mariusz Janiak
From 3d53a3c09ae54938bc79dcf0794c5e22e9e8ae6b Mon Sep 17 00:00:00 2001
From: Mariusz Janiak <mariusz.jan...@pwr.edu.pl>
Date: Mon, 15 Dec 2014 11:53:14 +0100
Subject: [PATCH] Fix compilatin issues on kernel above 3.10
Fix kernel panic when access proc
Fix proc handling for kernel above 3.10
Signed-off-by: Mariusz Janiak <mariusz.jan...@pwr.edu.pl>
Rebase to Fix proc handling for kernel above 3.10
---
drivers/e1000e/netdev.c | 8 +-
stack/include/rtcfg/rtcfg_conn_event.h | 1 +
stack/include/rtcfg/rtcfg_event.h | 1 +
stack/include/rtmac/rtmac_disc.h | 6 +-
stack/include/rtmac/rtmac_vnic.h | 7 +-
stack/include/rtnet_internal.h | 3 +-
stack/ipv4/af_inet.c | 2 +-
stack/ipv4/route.c | 105 +++++++-------
stack/ipv4/tcp/tcp.c | 46 +++---
stack/ipv4/udp/udp.c | 3 +-
stack/rtcfg/rtcfg_client_event.c | 2 +
stack/rtcfg/rtcfg_event.c | 3 +-
stack/rtcfg/rtcfg_proc.c | 250 ++++++++++++++++----------------
stack/rtmac/nomac/nomac_module.c | 18 +--
stack/rtmac/rtmac_disc.c | 18 +--
stack/rtmac/rtmac_proc.c | 68 +++++++--
stack/rtmac/rtmac_vnic.c | 18 +--
stack/rtmac/tdma/tdma_module.c | 74 ++++------
stack/rtnet_module.c | 179 ++++++++++++-----------
19 files changed, 424 insertions(+), 388 deletions(-)
diff --git a/drivers/e1000e/netdev.c b/drivers/e1000e/netdev.c
index 5634a9b..cc9d537 100644
--- a/drivers/e1000e/netdev.c
+++ b/drivers/e1000e/netdev.c
@@ -2204,7 +2204,7 @@ static void e1000_set_multi(struct rtnet_device *netdev)
e1000_update_mc_addr_list(hw, NULL, 0);
- if (netdev->features & NETIF_F_HW_VLAN_RX)
+ if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
e1000e_vlan_strip_enable(adapter);
else
e1000e_vlan_strip_disable(adapter);
@@ -4102,15 +4102,15 @@ static int e1000_probe(struct pci_dev *pdev,
/* Set initial default active device features */
netdev->features = (NETIF_F_SG |
- NETIF_F_HW_VLAN_RX |
- NETIF_F_HW_VLAN_TX |
+ NETIF_F_HW_VLAN_CTAG_RX |
+ NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6 |
NETIF_F_RXCSUM |
NETIF_F_HW_CSUM);
if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
- netdev->features |= NETIF_F_HW_VLAN_FILTER;
+ netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
if (pci_using_dac) {
netdev->features |= NETIF_F_HIGHDMA;
diff --git a/stack/include/rtcfg/rtcfg_conn_event.h b/stack/include/rtcfg/rtcfg_conn_event.h
index a89dcd1..0083ae4 100644
--- a/stack/include/rtcfg/rtcfg_conn_event.h
+++ b/stack/include/rtcfg/rtcfg_conn_event.h
@@ -61,6 +61,7 @@ struct rtcfg_connection {
u64 cfg_timeout;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_entry;
+ char proc_entry_name[64];
#endif
};
diff --git a/stack/include/rtcfg/rtcfg_event.h b/stack/include/rtcfg/rtcfg_event.h
index 5a6fb9d..98a1a85 100644
--- a/stack/include/rtcfg/rtcfg_event.h
+++ b/stack/include/rtcfg/rtcfg_event.h
@@ -68,6 +68,7 @@ struct rtcfg_device {
unsigned int burstrate;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_entry;
+ char proc_entry_name[64];
#endif
union {
diff --git a/stack/include/rtmac/rtmac_disc.h b/stack/include/rtmac/rtmac_disc.h
index 58663ce..b120959 100644
--- a/stack/include/rtmac/rtmac_disc.h
+++ b/stack/include/rtmac/rtmac_disc.h
@@ -49,8 +49,7 @@ struct rtmac_priv {
struct rtmac_proc_entry {
const char *name;
- int (*handler)(char *buf, char **start, off_t offset, int count, int *eof,
- void *data);
+ int (*handler)(struct seq_file *p, void *data);
};
struct rtmac_disc {
@@ -87,8 +86,7 @@ int rtmac_disc_register(struct rtmac_disc *disc);
void rtmac_disc_deregister(struct rtmac_disc *disc);
#ifdef CONFIG_PROC_FS
-int rtmac_proc_read_disc(char *buf, char **start, off_t offset,
- int count, int *eof, void *data);
+int rtnet_rtmac_disciplines_show(struct seq_file *p, void *data);
#endif /* CONFIG_PROC_FS */
diff --git a/stack/include/rtmac/rtmac_vnic.h b/stack/include/rtmac/rtmac_vnic.h
index 1adf295..634bd72 100644
--- a/stack/include/rtmac/rtmac_vnic.h
+++ b/stack/include/rtmac/rtmac_vnic.h
@@ -48,10 +48,9 @@ static inline void rtmac_vnic_cleanup(struct rtnet_device *rtdev)
rtskb_pool_release(&mac_priv->vnic_skb_pool);
}
-
-int rtmac_proc_read_vnic(char *buf, char **start, off_t offset,
- int count, int *eof, void *data);
-
+#ifdef CONFIG_PROC_FS
+int rtnet_rtmac_vnics_show(struct seq_file *p, void *data);
+#endif /* CONFIG_PROC_FS */
int __init rtmac_vnic_module_init(void);
void rtmac_vnic_module_cleanup(void);
diff --git a/stack/include/rtnet_internal.h b/stack/include/rtnet_internal.h
index 81b291a..008e92d 100644
--- a/stack/include/rtnet_internal.h
+++ b/stack/include/rtnet_internal.h
@@ -76,8 +76,9 @@ extern const char rtnet_rtdm_provider_name[];
#include <linux/proc_fs.h>
+#ifdef CONFIG_PROC_FS
extern struct proc_dir_entry *rtnet_proc_root;
-
+#endif
/* Derived from Erwin Rol's rtai_proc_fs.h.
Standard version assumes that output fits into the provided buffer,
diff --git a/stack/ipv4/af_inet.c b/stack/ipv4/af_inet.c
index 8b394be..d3fe5e0 100644
--- a/stack/ipv4/af_inet.c
+++ b/stack/ipv4/af_inet.c
@@ -305,7 +305,7 @@ static int __init rt_ipv4_proto_init(void)
rt_icmp_init();
#ifdef CONFIG_PROC_FS
- ipv4_proc_root = create_proc_entry("ipv4", S_IFDIR, rtnet_proc_root);
+ ipv4_proc_root = proc_mkdir("ipv4", rtnet_proc_root);
if (!ipv4_proc_root) {
/*ERRMSG*/printk("RTnet: unable to initialize /proc entry (ipv4)\n");
return -1;
diff --git a/stack/ipv4/route.c b/stack/ipv4/route.c
index c3c4a9b..b976d9b 100644
--- a/stack/ipv4/route.c
+++ b/stack/ipv4/route.c
@@ -98,47 +98,50 @@ MODULE_PARM_DESC(net_hash_key_shift, "destination right shift for "
* proc filesystem section
*/
#ifdef CONFIG_PROC_FS
-static int rt_route_read_proc(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+static int rtnet_ipv4_route_show(struct seq_file *p, void *data)
{
#ifdef CONFIG_RTNET_RTIPV4_NETROUTING
u32 mask;
#endif /* CONFIG_RTNET_RTIPV4_NETROUTING */
- RTNET_PROC_PRINT_VARS(256);
-
- if (!RTNET_PROC_PRINT("Host routes allocated/total:\t%d/%d\n"
- "Host hash table size:\t\t%d\n",
- allocated_host_routes,
- CONFIG_RTNET_RTIPV4_HOST_ROUTES,
- HOST_HASH_TBL_SIZE))
- goto done;
+ seq_printf(p, "Host routes allocated/total:\t%d/%d\n"
+ "Host hash table size:\t\t%d\n",
+ allocated_host_routes,
+ CONFIG_RTNET_RTIPV4_HOST_ROUTES,
+ HOST_HASH_TBL_SIZE);
#ifdef CONFIG_RTNET_RTIPV4_NETROUTING
mask = NET_HASH_KEY_MASK << net_hash_key_shift;
- if (!RTNET_PROC_PRINT("Network routes allocated/total:\t%d/%d\n"
- "Network hash table size:\t%d\n"
- "Network hash key shift/mask:\t%d/%08X\n",
- allocated_net_routes,
- CONFIG_RTNET_RTIPV4_NET_ROUTES, NET_HASH_TBL_SIZE,
- net_hash_key_shift, mask))
- goto done;
+ seq_printf(p, "Network routes allocated/total:\t%d/%d\n"
+ "Network hash table size:\t%d\n"
+ "Network hash key shift/mask:\t%d/%08X\n",
+ allocated_net_routes,
+ CONFIG_RTNET_RTIPV4_NET_ROUTES, NET_HASH_TBL_SIZE,
+ net_hash_key_shift, mask);
#endif /* CONFIG_RTNET_RTIPV4_NETROUTING */
#ifdef CONFIG_RTNET_RTIPV4_ROUTER
- RTNET_PROC_PRINT("IP Router:\t\t\tyes\n");
+ seq_printf(p, "IP Router:\t\t\tyes\n");
#else
- RTNET_PROC_PRINT("IP Router:\t\t\tno\n");
+ seq_printf(p, "IP Router:\t\t\tno\n");
#endif
- done:
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
+static int rtnet_ipv4_route_open(struct inode *inode, struct file *file) {
+ return single_open(file, rtnet_ipv4_route_show, PDE_DATA(inode));
+}
+
+static const struct file_operations rtnet_ipv4_route_fops = {
+ .open = rtnet_ipv4_route_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
-static int rt_host_route_read_proc(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+static int rtnet_ipv4_host__route_show(struct seq_file *p, void *data)
{
struct host_route *entry_ptr;
struct dest_route dest_host;
@@ -146,13 +149,8 @@ static int rt_host_route_read_proc(char *buf, char **start, off_t offset,
unsigned int index;
unsigned int i;
rtdm_lockctx_t context;
- int res;
- RTNET_PROC_PRINT_VARS_EX(80);
-
-
- if (!RTNET_PROC_PRINT_EX("Hash\tDestination\tHW Address\t\tDevice\n"))
- goto done;
+ seq_printf(p, "Hash\tDestination\tHW Address\t\tDevice\n");
for (key = 0; key < HOST_HASH_TBL_SIZE; key++) {
index = 0;
while (1) {
@@ -174,25 +172,32 @@ static int rt_host_route_read_proc(char *buf, char **start, off_t offset,
rtdm_lock_put_irqrestore(&host_table_lock, context);
- res = RTNET_PROC_PRINT_EX("%02X\t%u.%u.%u.%-3u\t"
- "%02X:%02X:%02X:%02X:%02X:%02X\t%s\n",
- key, NIPQUAD(dest_host.ip),
- dest_host.dev_addr[0], dest_host.dev_addr[1],
- dest_host.dev_addr[2], dest_host.dev_addr[3],
- dest_host.dev_addr[4], dest_host.dev_addr[5],
- dest_host.rtdev->name);
+ seq_printf(p, "%02X\t%u.%u.%u.%-3u\t"
+ "%02X:%02X:%02X:%02X:%02X:%02X\t%s\n",
+ key, NIPQUAD(dest_host.ip),
+ dest_host.dev_addr[0], dest_host.dev_addr[1],
+ dest_host.dev_addr[2], dest_host.dev_addr[3],
+ dest_host.dev_addr[4], dest_host.dev_addr[5],
+ dest_host.rtdev->name);
rtdev_dereference(dest_host.rtdev);
- if (!res)
- goto done;
index++;
}
}
+ return 0;
+}
- done:
- RTNET_PROC_PRINT_DONE_EX;
+static int rtnet_ipv4_host__route_open(struct inode *inode,
+ struct file *file) {
+ return single_open(file, rtnet_ipv4_host__route_show, PDE_DATA(inode));
}
+static const struct file_operations rtnet_ipv4_host__route_fops = {
+ .open = rtnet_ipv4_host__route_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
#ifdef CONFIG_RTNET_RTIPV4_NETROUTING
@@ -266,31 +271,27 @@ static int __init rt_route_proc_register(void)
struct proc_dir_entry *proc_entry;
- proc_entry = create_proc_entry("route", S_IFREG | S_IRUGO | S_IWUSR,
- ipv4_proc_root);
+ proc_entry = proc_create("route", S_IFREG | S_IRUGO | S_IWUSR,
+ ipv4_proc_root, &rtnet_ipv4_route_fops);
if (!proc_entry)
goto err1;
- proc_entry->read_proc = rt_route_read_proc;
- proc_entry = create_proc_entry("host_route", S_IFREG | S_IRUGO | S_IWUSR,
- ipv4_proc_root);
+ proc_entry = proc_create("host_route", S_IFREG | S_IRUGO | S_IWUSR,
+ ipv4_proc_root, &rtnet_ipv4_host__route_fops);
if (!proc_entry)
goto err2;
- proc_entry->read_proc = rt_host_route_read_proc;
/* create "arp" as an alias for "host_route" */
- proc_entry = create_proc_entry("arp", S_IFREG | S_IRUGO | S_IWUSR,
- ipv4_proc_root);
+ proc_entry = proc_create("arp", S_IFREG | S_IRUGO | S_IWUSR,
+ ipv4_proc_root, &rtnet_ipv4_host__route_fops);
if (!proc_entry)
goto err3;
- proc_entry->read_proc = rt_host_route_read_proc;
#ifdef CONFIG_RTNET_RTIPV4_NETROUTING
- proc_entry = create_proc_entry("net_route", S_IFREG | S_IRUGO | S_IWUSR,
- ipv4_proc_root);
+ proc_entry = proc_create("net_route", S_IFREG | S_IRUGO | S_IWUSR,
+ ipv4_proc_root, &rtnet_ipv4_net__route_fops);
if (!proc_entry)
goto err4;
- proc_entry->read_proc = rt_net_route_read_proc;
#endif /* CONFIG_RTNET_RTIPV4_NETROUTING */
return 0;
diff --git a/stack/ipv4/tcp/tcp.c b/stack/ipv4/tcp/tcp.c
index b49f8de..379474c 100644
--- a/stack/ipv4/tcp/tcp.c
+++ b/stack/ipv4/tcp/tcp.c
@@ -201,9 +201,8 @@ static inline struct tcp_socket *port_hash_search(u32 saddr, u16 sport)
{
u32 bucket = sport & port_hash_mask;
struct tcp_socket *ts;
- struct hlist_node *n;
- hlist_for_each_entry(ts, n, &port_hash[bucket], link)
+ hlist_for_each_entry(ts, &port_hash[bucket], link)
if (ts->sport == sport &&
(saddr == INADDR_ANY
|| ts->saddr == saddr
@@ -2175,8 +2174,7 @@ static inline char* rt_tcp_string_of_state(u8 state)
}
}
-static int rt_tcp_proc_read(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+static int rtnet_ipv4_tcp_show(struct seq_file *p, void *data)
{
rtdm_lockctx_t context;
struct tcp_socket *ts;
@@ -2186,13 +2184,9 @@ static int rt_tcp_proc_read(char *buf, char **start, off_t offset,
char dbuffer[24];
int state;
int index;
- int ret;
-
- RTNET_PROC_PRINT_VARS_EX(80);
- if (!RTNET_PROC_PRINT_EX("Hash Local Address "
- "Foreign Address State\n"))
- goto done;
+ seq_printf(p, "Hash Local Address "
+ "Foreign Address State\n");
for (index = 0; index < RT_TCP_SOCKETS; index++) {
rtdm_lock_get_irqsave(&tcp_socket_base_lock, context);
@@ -2215,34 +2209,42 @@ static int rt_tcp_proc_read(char *buf, char **start, off_t offset,
snprintf(dbuffer, sizeof(dbuffer), "%u.%u.%u.%u:%u",
NIPQUAD(daddr), ntohs(dport));
- ret = RTNET_PROC_PRINT_EX("%04X %-23s %-23s %s\n",
- sport & port_hash_mask, sbuffer, dbuffer,
- rt_tcp_string_of_state(state));
- if (!ret)
- break;
+ seq_printf(p, "%04X %-23s %-23s %s\n",
+ sport & port_hash_mask, sbuffer, dbuffer,
+ rt_tcp_string_of_state(state));
}
}
-
- done:
- RTNET_PROC_PRINT_DONE_EX;
+ return 0;
}
/***
* rt_tcp_proc_register
*/
+
+static int rtnet_ipv4_tcp_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rtnet_ipv4_tcp_show, PDE_DATA(inode));
+}
+
+static const struct file_operations rtnet_ipv4_tcp_fops = {
+ .open = rtnet_ipv4_tcp_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+
static int __init rt_tcp_proc_register(void)
{
struct proc_dir_entry *proc_entry;
- proc_entry = create_proc_entry("tcp", S_IFREG | S_IRUGO | S_IWUSR,
- ipv4_proc_root);
+ proc_entry = proc_create("tcp", S_IFREG | S_IRUGO | S_IWUSR,
+ ipv4_proc_root, &rtnet_ipv4_tcp_fops);
if (!proc_entry) {
return -EPERM;
}
- proc_entry->read_proc = rt_tcp_proc_read;
-
return 0;
}
diff --git a/stack/ipv4/udp/udp.c b/stack/ipv4/udp/udp.c
index 87be2a4..32b716a 100644
--- a/stack/ipv4/udp/udp.c
+++ b/stack/ipv4/udp/udp.c
@@ -94,9 +94,8 @@ static inline struct udp_socket *port_hash_search(u32 saddr, u16 sport)
{
unsigned bucket = sport & port_hash_mask;
struct udp_socket *sock;
- struct hlist_node *n;
- hlist_for_each_entry(sock, n, &port_hash[bucket], link)
+ hlist_for_each_entry(sock, &port_hash[bucket], link)
if (sock->sport == sport &&
(saddr == INADDR_ANY
|| sock->saddr == saddr
diff --git a/stack/rtcfg/rtcfg_client_event.c b/stack/rtcfg/rtcfg_client_event.c
index 0ad0cc4..5eef8ba 100644
--- a/stack/rtcfg/rtcfg_client_event.c
+++ b/stack/rtcfg/rtcfg_client_event.c
@@ -744,7 +744,9 @@ static int rtcfg_client_recv_announce(int ifindex, struct rtskb *rtskb)
struct rtcfg_frm_announce *announce_frm;
struct rtcfg_device *rtcfg_dev = &device[ifindex];
u32 i;
+#ifdef CONFIG_RTNET_RTIPV4
u32 announce_frm_addr;
+#endif
int result;
diff --git a/stack/rtcfg/rtcfg_event.c b/stack/rtcfg/rtcfg_event.c
index e3005d3..5e70372 100644
--- a/stack/rtcfg/rtcfg_event.c
+++ b/stack/rtcfg/rtcfg_event.c
@@ -507,8 +507,9 @@ static int rtcfg_server_recv_announce(int ifindex, RTCFG_EVENT event_id,
struct list_head *entry;
struct rtcfg_frm_announce *announce;
struct rtcfg_connection *conn;
+#ifdef CONFIG_RTNET_RTIPV4
u32 announce_addr;
-
+#endif
if (rtskb->len < sizeof(struct rtcfg_frm_announce)) {
rtdm_mutex_unlock(&rtcfg_dev->dev_mutex);
diff --git a/stack/rtcfg/rtcfg_proc.c b/stack/rtcfg/rtcfg_proc.c
index 93aafd8..3c65519 100644
--- a/stack/rtcfg/rtcfg_proc.c
+++ b/stack/rtcfg/rtcfg_proc.c
@@ -31,69 +31,71 @@
#ifdef CONFIG_PROC_FS
+
DEFINE_MUTEX(nrt_proc_lock);
static struct proc_dir_entry *rtcfg_proc_root;
-
-
-int rtcfg_proc_read_dev_state(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+static int rtnet_rtcfg_dev_state_show(struct seq_file *p, void *data)
{
- struct rtcfg_device *rtcfg_dev = data;
+ struct rtcfg_device *rtcfg_dev = p->private;
char *state_name[] = { "OFF", "SERVER_RUNNING", "CLIENT_0", "CLIENT_1",
"CLIENT_ANNOUNCED", "CLIENT_ALL_KNOWN",
"CLIENT_ALL_FRAMES", "CLIENT_2", "CLIENT_READY" };
- RTNET_PROC_PRINT_VARS(256);
-
- if (!RTNET_PROC_PRINT("state:\t\t\t%d (%s)\n"
- "flags:\t\t\t%08X\n"
- "other stations:\t\t%d\n"
- "stations found:\t\t%d\n"
- "stations ready:\t\t%d\n",
- rtcfg_dev->state, state_name[rtcfg_dev->state],
- rtcfg_dev->flags, rtcfg_dev->other_stations,
- rtcfg_dev->stations_found,
- rtcfg_dev->stations_ready))
- goto done;
+ seq_printf(p, "state:\t\t\t%d (%s)\n"
+ "flags:\t\t\t%08X\n"
+ "other stations:\t\t%d\n"
+ "stations found:\t\t%d\n"
+ "stations ready:\t\t%d\n",
+ rtcfg_dev->state, state_name[rtcfg_dev->state],
+ rtcfg_dev->flags, rtcfg_dev->other_stations,
+ rtcfg_dev->stations_found,
+ rtcfg_dev->stations_ready);
if (rtcfg_dev->state == RTCFG_MAIN_SERVER_RUNNING) {
- RTNET_PROC_PRINT("configured clients:\t%d\n"
- "burstrate:\t\t%d\n"
- "heartbeat period:\t%d ms\n",
- rtcfg_dev->spec.srv.clients_configured,
- rtcfg_dev->burstrate, rtcfg_dev->spec.srv.heartbeat);
+ seq_printf(p, "configured clients:\t%d\n"
+ "burstrate:\t\t%d\n"
+ "heartbeat period:\t%d ms\n",
+ rtcfg_dev->spec.srv.clients_configured,
+ rtcfg_dev->burstrate, rtcfg_dev->spec.srv.heartbeat);
} else if (rtcfg_dev->state != RTCFG_MAIN_OFF) {
- RTNET_PROC_PRINT("address type:\t\t%d\n"
- "server address:\t\t%02X:%02X:%02X:%02X:%02X:%02X\n"
- "stage 2 config:\t\t%d/%d\n",
- rtcfg_dev->spec.clt.addr_type,
- rtcfg_dev->spec.clt.srv_mac_addr[0],
- rtcfg_dev->spec.clt.srv_mac_addr[1],
- rtcfg_dev->spec.clt.srv_mac_addr[2],
- rtcfg_dev->spec.clt.srv_mac_addr[3],
- rtcfg_dev->spec.clt.srv_mac_addr[4],
- rtcfg_dev->spec.clt.srv_mac_addr[5],
- rtcfg_dev->spec.clt.cfg_offs,
- rtcfg_dev->spec.clt.cfg_len);
+ seq_printf(p, "address type:\t\t%d\n"
+ "server address:\t\t%02X:%02X:%02X:%02X:%02X:%02X\n"
+ "stage 2 config:\t\t%d/%d\n",
+ rtcfg_dev->spec.clt.addr_type,
+ rtcfg_dev->spec.clt.srv_mac_addr[0],
+ rtcfg_dev->spec.clt.srv_mac_addr[1],
+ rtcfg_dev->spec.clt.srv_mac_addr[2],
+ rtcfg_dev->spec.clt.srv_mac_addr[3],
+ rtcfg_dev->spec.clt.srv_mac_addr[4],
+ rtcfg_dev->spec.clt.srv_mac_addr[5],
+ rtcfg_dev->spec.clt.cfg_offs,
+ rtcfg_dev->spec.clt.cfg_len);
}
- done:
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
+static int rtnet_rtcfg_dev_state_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rtnet_rtcfg_dev_state_show, PDE_DATA(inode));
+}
+static const struct file_operations rtnet_rtcfg_dev_state_fops = {
+ .owner = THIS_MODULE,
+ .open = rtnet_rtcfg_dev_state_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
-int rtcfg_proc_read_stations(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+int rtnet_rtcfg_dev_station_list_show(struct seq_file *p, void *data)
{
- struct rtcfg_device *rtcfg_dev = data;
+ struct rtcfg_device *rtcfg_dev = p->private;
struct list_head *entry;
struct rtcfg_connection *conn;
struct rtcfg_station *station;
int i;
- RTNET_PROC_PRINT_VARS_EX(80);
-
if (mutex_lock_interruptible(&nrt_proc_lock))
return -ERESTARTSYS;
@@ -103,78 +105,94 @@ int rtcfg_proc_read_stations(char *buf, char **start, off_t offset, int count,
conn = list_entry(entry, struct rtcfg_connection, entry);
if ((conn->state != RTCFG_CONN_SEARCHING) &&
- (conn->state != RTCFG_CONN_DEAD) &&
- !RTNET_PROC_PRINT_EX("%02X:%02X:%02X:%02X:%02X:%02X\t%02X\n",
- conn->mac_addr[0], conn->mac_addr[1],
- conn->mac_addr[2], conn->mac_addr[3],
- conn->mac_addr[4], conn->mac_addr[5],
- conn->flags))
- break;
+ (conn->state != RTCFG_CONN_DEAD)) {
+ seq_printf(p, "%02X:%02X:%02X:%02X:%02X:%02X\t%02X\n",
+ conn->mac_addr[0], conn->mac_addr[1],
+ conn->mac_addr[2], conn->mac_addr[3],
+ conn->mac_addr[4], conn->mac_addr[5],
+ conn->flags);
+ break;
+ }
}
} else if (rtcfg_dev->spec.clt.station_addr_list) {
for (i = 0; i < rtcfg_dev->stations_found; i++) {
station = &rtcfg_dev->spec.clt.station_addr_list[i];
- if (!RTNET_PROC_PRINT_EX("%02X:%02X:%02X:%02X:%02X:%02X\t%02X\n",
- station->mac_addr[0], station->mac_addr[1],
- station->mac_addr[2], station->mac_addr[3],
- station->mac_addr[4], station->mac_addr[5],
- station->flags))
- break;
- }
+ seq_printf(p, "%02X:%02X:%02X:%02X:%02X:%02X\t%02X\n",
+ station->mac_addr[0], station->mac_addr[1],
+ station->mac_addr[2], station->mac_addr[3],
+ station->mac_addr[4], station->mac_addr[5],
+ station->flags);
+ }
}
mutex_unlock(&nrt_proc_lock);
- RTNET_PROC_PRINT_DONE_EX;
+
+ return 0;
}
+static int rtnet_rtcfg_dev_station_list_open(struct inode *inode,
+ struct file *file)
+{
+ return single_open(file, rtnet_rtcfg_dev_station_list_show, PDE_DATA(inode));
+}
+static const struct file_operations rtnet_rtcfg_dev_station_list_fops = {
+ .open = rtnet_rtcfg_dev_station_list_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
-int rtcfg_proc_read_conn_state(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+int rtnet_rtcfg_dev_conn_show(struct seq_file *p, void *data)
{
- struct rtcfg_connection *conn = data;
+ struct rtcfg_connection *conn = p->private;
char *state_name[] =
{ "SEARCHING", "STAGE_1", "STAGE_2", "READY", "DEAD" };
- RTNET_PROC_PRINT_VARS(512);
-
-
- if (!RTNET_PROC_PRINT("state:\t\t\t%d (%s)\n"
- "flags:\t\t\t%02X\n"
- "stage 1 size:\t\t%zd\n"
- "stage 2 filename:\t%s\n"
- "stage 2 size:\t\t%zd\n"
- "stage 2 offset:\t\t%d\n"
- "burstrate:\t\t%d\n"
- "mac address:\t\t%02X:%02X:%02X:%02X:%02X:%02X\n",
- conn->state, state_name[conn->state], conn->flags,
- conn->stage1_size,
- (conn->stage2_file)? conn->stage2_file->name: "-",
- (conn->stage2_file)? conn->stage2_file->size: 0,
- conn->cfg_offs, conn->burstrate,
- conn->mac_addr[0], conn->mac_addr[1],
- conn->mac_addr[2], conn->mac_addr[3],
- conn->mac_addr[4], conn->mac_addr[5]))
- goto done;
+
+ seq_printf(p, "state:\t\t\t%d (%s)\n"
+ "flags:\t\t\t%02X\n"
+ "stage 1 size:\t\t%zd\n"
+ "stage 2 filename:\t%s\n"
+ "stage 2 size:\t\t%zd\n"
+ "stage 2 offset:\t\t%d\n"
+ "burstrate:\t\t%d\n"
+ "mac address:\t\t%02X:%02X:%02X:%02X:%02X:%02X\n",
+ conn->state, state_name[conn->state], conn->flags,
+ conn->stage1_size,
+ (conn->stage2_file)? conn->stage2_file->name: "-",
+ (conn->stage2_file)? conn->stage2_file->size: 0,
+ conn->cfg_offs, conn->burstrate,
+ conn->mac_addr[0], conn->mac_addr[1],
+ conn->mac_addr[2], conn->mac_addr[3],
+ conn->mac_addr[4], conn->mac_addr[5]);
#ifdef CONFIG_RTNET_RTIPV4
if ((conn->addr_type & RTCFG_ADDR_MASK) == RTCFG_ADDR_IP)
- RTNET_PROC_PRINT("ip:\t\t\t%u.%u.%u.%u\n",
- NIPQUAD(conn->addr.ip_addr));
+ seq_printf(p, "ip:\t\t\t%u.%u.%u.%u\n",
+ NIPQUAD(conn->addr.ip_addr));
#endif /* CONFIG_RTNET_RTIPV4 */
- done:
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
+static int rtnet_rtcfg_dev_conn_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rtnet_rtcfg_dev_conn_show, PDE_DATA(inode));
+}
+static const struct file_operations rtnet_rtcfg_dev_conn_fops = {
+ .open = rtnet_rtcfg_dev_conn_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
void rtcfg_update_conn_proc_entries(int ifindex)
{
struct rtcfg_device *dev = &device[ifindex];
struct list_head *entry;
struct rtcfg_connection *conn;
- char name_buf[64];
if (dev->state != RTCFG_MAIN_SERVER_RUNNING)
@@ -186,31 +204,30 @@ void rtcfg_update_conn_proc_entries(int ifindex)
switch (conn->addr_type & RTCFG_ADDR_MASK) {
#ifdef CONFIG_RTNET_RTIPV4
case RTCFG_ADDR_IP:
- snprintf(name_buf, 64, "CLIENT_%u.%u.%u.%u",
+ snprintf(conn->proc_entry_name, sizeof(conn->proc_entry_name),
+ "CLIENT_%u.%u.%u.%u",
NIPQUAD(conn->addr.ip_addr));
break;
#endif /* CONFIG_RTNET_RTIPV4 */
default: /* RTCFG_ADDR_MAC */
- snprintf(name_buf, 64,
+ snprintf(conn->proc_entry_name, sizeof(conn->proc_entry_name),
"CLIENT_%02X%02X%02X%02X%02X%02X",
conn->mac_addr[0], conn->mac_addr[1],
conn->mac_addr[2], conn->mac_addr[3],
conn->mac_addr[4], conn->mac_addr[5]);
break;
}
- conn->proc_entry = create_proc_entry(name_buf,
- S_IFREG | S_IRUGO | S_IWUSR, dev->proc_entry);
+ conn->proc_entry = proc_create_data(conn->proc_entry_name,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ dev->proc_entry,
+ &rtnet_rtcfg_dev_conn_fops,
+ conn);
if (!conn->proc_entry)
continue;
-
- conn->proc_entry->read_proc = rtcfg_proc_read_conn_state;
- conn->proc_entry->data = conn;
}
}
-
-
void rtcfg_remove_conn_proc_entries(int ifindex)
{
struct rtcfg_device *dev = &device[ifindex];
@@ -224,44 +241,41 @@ void rtcfg_remove_conn_proc_entries(int ifindex)
list_for_each(entry, &dev->spec.srv.conn_list) {
conn = list_entry(entry, struct rtcfg_connection, entry);
- remove_proc_entry(conn->proc_entry->name, dev->proc_entry);
+ remove_proc_entry(conn->proc_entry_name, dev->proc_entry);
}
}
-
-
void rtcfg_new_rtdev(struct rtnet_device *rtdev)
{
- struct rtcfg_device *dev = &device[rtdev->ifindex];
- struct proc_dir_entry *proc_entry;
+ struct rtcfg_device *dev = &device[rtdev->ifindex];
+ struct proc_dir_entry *proc_entry;
mutex_lock(&nrt_proc_lock);
- dev->proc_entry = create_proc_entry(rtdev->name, S_IFDIR, rtcfg_proc_root);
+ strncpy(dev->proc_entry_name, rtdev->name, sizeof(dev->proc_entry_name));
+ dev->proc_entry = proc_mkdir(dev->proc_entry_name, rtcfg_proc_root);
if (!dev->proc_entry)
goto exit;
- proc_entry = create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
- dev->proc_entry);
+ proc_entry = proc_create_data("state", S_IFREG | S_IRUGO | S_IWUSR,
+ dev->proc_entry,
+ &rtnet_rtcfg_dev_state_fops,
+ dev);
if (!proc_entry)
goto exit;
- proc_entry->read_proc = rtcfg_proc_read_dev_state;
- proc_entry->data = dev;
- proc_entry = create_proc_entry("station_list", S_IFREG | S_IRUGO | S_IWUSR,
- dev->proc_entry);
+ proc_entry = proc_create_data("station_list", S_IFREG | S_IRUGO | S_IWUSR,
+ dev->proc_entry,
+ &rtnet_rtcfg_dev_station_list_fops,
+ dev);
if (!proc_entry)
goto exit;
- proc_entry->read_proc = rtcfg_proc_read_stations;
- proc_entry->data = dev;
exit:
mutex_unlock(&nrt_proc_lock);
}
-
-
void rtcfg_remove_rtdev(struct rtnet_device *rtdev)
{
struct rtcfg_device *dev = &device[rtdev->ifindex];
@@ -276,31 +290,27 @@ void rtcfg_remove_rtdev(struct rtnet_device *rtdev)
remove_proc_entry("station_list", dev->proc_entry);
remove_proc_entry("state", dev->proc_entry);
- remove_proc_entry(dev->proc_entry->name, rtcfg_proc_root);
+ remove_proc_entry(dev->proc_entry_name, rtcfg_proc_root);
dev->proc_entry = NULL;
}
mutex_unlock(&nrt_proc_lock);
}
-
-
static struct rtdev_event_hook rtdev_hook = {
- .register_device = rtcfg_new_rtdev,
- .unregister_device =rtcfg_remove_rtdev,
- .ifup = NULL,
- .ifdown = NULL
+ .register_device = rtcfg_new_rtdev,
+ .unregister_device = rtcfg_remove_rtdev,
+ .ifup = NULL,
+ .ifdown = NULL
};
-
-
int rtcfg_init_proc(void)
{
struct rtnet_device *rtdev;
int i;
- rtcfg_proc_root = create_proc_entry("rtcfg", S_IFDIR, rtnet_proc_root);
+ rtcfg_proc_root = proc_mkdir("rtcfg", rtnet_proc_root);
if (!rtcfg_proc_root)
goto err1;
@@ -320,8 +330,6 @@ int rtcfg_init_proc(void)
return -1;
}
-
-
void rtcfg_cleanup_proc(void)
{
struct rtnet_device *rtdev;
diff --git a/stack/rtmac/nomac/nomac_module.c b/stack/rtmac/nomac/nomac_module.c
index b874bbe..06ca905 100644
--- a/stack/rtmac/nomac/nomac_module.c
+++ b/stack/rtmac/nomac/nomac_module.c
@@ -38,28 +38,24 @@ LIST_HEAD(nomac_devices);
DEFINE_MUTEX(nomac_nrt_lock);
-int nomac_proc_read(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+int nomac_proc_read(struct seq_file *p, void *data)
{
struct nomac_priv *entry;
- RTNET_PROC_PRINT_VARS(80);
-
mutex_lock(&nomac_nrt_lock);
- if (!RTNET_PROC_PRINT("Interface API Device State\n"))
- goto done;
+ seq_printf(p, "Interface API Device State\n");
list_for_each_entry(entry, &nomac_devices, list_entry) {
- if (!RTNET_PROC_PRINT("%-15s %-15s Attached\n", entry->rtdev->name,
- entry->api_device.device_name))
- break;
+ seq_printf(p,
+ "%-15s %-15s Attached\n",
+ entry->rtdev->name,
+ entry->api_device.device_name);
}
- done:
mutex_unlock(&nomac_nrt_lock);
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
#endif /* CONFIG_PROC_FS */
diff --git a/stack/rtmac/rtmac_disc.c b/stack/rtmac/rtmac_disc.c
index 8143de0..daa0c23 100644
--- a/stack/rtmac/rtmac_disc.c
+++ b/stack/rtmac/rtmac_disc.c
@@ -247,28 +247,22 @@ void rtmac_disc_deregister(struct rtmac_disc *disc)
#ifdef CONFIG_PROC_FS
-int rtmac_proc_read_disc(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+int rtnet_rtmac_disciplines_show(struct seq_file *p, void *data)
{
struct list_head *disc;
- RTNET_PROC_PRINT_VARS(80);
-
mutex_lock(&disc_list_lock);
- if (!RTNET_PROC_PRINT("Name\t\tID\n"))
- goto done;
+ seq_printf(p, "Name\t\tID\n");
list_for_each(disc, &disc_list) {
- if (!RTNET_PROC_PRINT("%-15s %04X\n",
- ((struct rtmac_disc *)disc)->name,
- ntohs(((struct rtmac_disc *)disc)->disc_type)))
- break;
+ seq_printf(p, "%-15s %04X\n",
+ ((struct rtmac_disc *)disc)->name,
+ ntohs(((struct rtmac_disc *)disc)->disc_type));
}
- done:
mutex_unlock(&disc_list_lock);
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
#endif /* CONFIG_PROC_FS */
diff --git a/stack/rtmac/rtmac_proc.c b/stack/rtmac/rtmac_proc.c
index f155ea3..bb6901d 100644
--- a/stack/rtmac/rtmac_proc.c
+++ b/stack/rtmac/rtmac_proc.c
@@ -34,6 +34,25 @@
struct proc_dir_entry *rtmac_proc_root;
+static int rtnet_rtmac_disc_show(struct seq_file *p, void *data)
+{
+ int (*handler)(struct seq_file *p, void *data) = p->private;
+
+ return handler(p, NULL);
+}
+
+static int rtnet_rtmac_disc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rtnet_rtmac_disc_show, PDE_DATA(inode));
+}
+
+static const struct file_operations rtnet_rtmac_disc_fops = {
+ .open = rtnet_rtmac_disc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
int rtmac_disc_proc_register(struct rtmac_disc *disc)
{
int i;
@@ -42,9 +61,11 @@ int rtmac_disc_proc_register(struct rtmac_disc *disc)
i = 0;
while (disc->proc_entries[i].name != NULL) {
- proc_entry = create_proc_entry(disc->proc_entries[i].name,
- S_IFREG | S_IRUGO | S_IWUSR,
- rtmac_proc_root);
+ proc_entry = proc_create_data(disc->proc_entries[i].name,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ rtmac_proc_root,
+ &rtnet_rtmac_disc_fops,
+ disc->proc_entries[i].handler);
if (!proc_entry) {
while (--i > 0) {
remove_proc_entry(disc->proc_entries[i].name, rtmac_proc_root);
@@ -52,8 +73,6 @@ int rtmac_disc_proc_register(struct rtmac_disc *disc)
}
return -1;
}
-
- proc_entry->read_proc = disc->proc_entries[i].handler;
i++;
}
@@ -66,7 +85,6 @@ void rtmac_disc_proc_unregister(struct rtmac_disc *disc)
{
int i;
-
i = 0;
while (disc->proc_entries[i].name != NULL) {
remove_proc_entry(disc->proc_entries[i].name, rtmac_proc_root);
@@ -74,6 +92,32 @@ void rtmac_disc_proc_unregister(struct rtmac_disc *disc)
}
}
+static int rtnet_rtmac_disciplines_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rtnet_rtmac_disciplines_show, PDE_DATA(inode));
+}
+
+static const struct file_operations rtnet_rtmac_disciplines_fops = {
+ .open = rtnet_rtmac_disciplines_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+
+
+static int rtnet_rtmac_vnics_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rtnet_rtmac_vnics_show, PDE_DATA(inode));
+}
+
+static const struct file_operations rtnet_rtmac_vnics_fops = {
+ .open = rtnet_rtmac_vnics_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
int rtmac_proc_register(void)
@@ -81,21 +125,19 @@ int rtmac_proc_register(void)
struct proc_dir_entry *proc_entry;
- rtmac_proc_root = create_proc_entry("rtmac", S_IFDIR, rtnet_proc_root);
+ rtmac_proc_root = proc_mkdir("rtmac", rtnet_proc_root);
if (!rtmac_proc_root)
goto err1;
- proc_entry = create_proc_entry("disciplines", S_IFREG | S_IRUGO | S_IWUSR,
- rtmac_proc_root);
+ proc_entry = proc_create("disciplines", S_IFREG | S_IRUGO | S_IWUSR,
+ rtmac_proc_root, &rtnet_rtmac_disciplines_fops);
if (!proc_entry)
goto err2;
- proc_entry->read_proc = rtmac_proc_read_disc;
- proc_entry = create_proc_entry("vnics", S_IFREG | S_IRUGO | S_IWUSR,
- rtmac_proc_root);
+ proc_entry = proc_create("vnics", S_IFREG | S_IRUGO | S_IWUSR,
+ rtmac_proc_root, &rtnet_rtmac_vnics_fops);
if (!proc_entry)
goto err3;
- proc_entry->read_proc = rtmac_proc_read_vnic;
return 0;
diff --git a/stack/rtmac/rtmac_vnic.c b/stack/rtmac/rtmac_vnic.c
index 68798f9..7460401 100644
--- a/stack/rtmac/rtmac_vnic.c
+++ b/stack/rtmac/rtmac_vnic.c
@@ -333,17 +333,13 @@ void rtmac_vnic_unregister(struct rtnet_device *rtdev)
#ifdef CONFIG_PROC_FS
-int rtmac_proc_read_vnic(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+int rtnet_rtmac_vnics_show(struct seq_file *p, void *data)
{
struct rtnet_device *rtdev;
int i;
- int res = 0;
- RTNET_PROC_PRINT_VARS(80);
- if (!RTNET_PROC_PRINT("RT-NIC name\tVNIC name\n"))
- goto done;
+ seq_printf(p, "RT-NIC name\tVNIC name\n");
for (i = 1; i <= MAX_RT_DEVICES; i++) {
rtdev = rtdev_get_by_index(i);
@@ -359,19 +355,15 @@ int rtmac_proc_read_vnic(char *buf, char **start, off_t offset, int count,
struct rtmac_priv *rtmac;
rtmac = (struct rtmac_priv *)rtdev->mac_priv;
- res = RTNET_PROC_PRINT("%-15s %s\n",
- rtdev->name, rtmac->vnic->name);
+ seq_printf(p, "%-15s %s\n",
+ rtdev->name, rtmac->vnic->name);
}
mutex_unlock(&rtdev->nrt_lock);
rtdev_dereference(rtdev);
-
- if (!res)
- break;
}
- done:
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
#endif /* CONFIG_PROC_FS */
diff --git a/stack/rtmac/tdma/tdma_module.c b/stack/rtmac/tdma/tdma_module.c
index 18dbc5d..d5045ba 100644
--- a/stack/rtmac/tdma/tdma_module.c
+++ b/stack/rtmac/tdma/tdma_module.c
@@ -46,8 +46,7 @@ MODULE_PARM_DESC(start_timer, "set to non-zero to start RTAI timer");
#endif
#ifdef CONFIG_PROC_FS
-int tdma_proc_read(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+int tdma_proc_read(struct seq_file *p, void *data)
{
struct rtnet_device *rtdev = NULL;
struct tdma_priv *tdma;
@@ -56,12 +55,9 @@ int tdma_proc_read(char *buf, char **start, off_t offset, int count,
#ifdef CONFIG_RTNET_TDMA_MASTER
u64 cycle;
#endif
- RTNET_PROC_PRINT_VARS(80);
-
- if (!RTNET_PROC_PRINT("Interface API Device Operation Mode "
- "Cycle State\n"))
- goto done;
+ seq_printf(p, "Interface API Device Operation Mode "
+ "Cycle State\n");
for (d = 1; d <= MAX_RT_DEVICES; d++) {
rtdev = rtdev_get_by_index(d);
@@ -78,9 +74,11 @@ int tdma_proc_read(char *buf, char **start, off_t offset, int count,
goto unlock_dev;
tdma = (struct tdma_priv *)rtdev->mac_priv->disc_priv;
- if (!RTNET_PROC_PRINT("%-15s %-15s ", rtdev->name,
- tdma->api_device.device_name))
- break;
+ seq_printf(p,
+ "%-15s %-15s ",
+ rtdev->name,
+ tdma->api_device.device_name);
+
if (test_bit(TDMA_FLAG_CALIBRATED, &tdma->flags)) {
#ifdef CONFIG_RTNET_TDMA_MASTER
if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags) &&
@@ -96,36 +94,35 @@ int tdma_proc_read(char *buf, char **start, off_t offset, int count,
cycle = tdma->cycle_period + 500;
do_div(cycle, 1000);
if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags)) {
- if (!RTNET_PROC_PRINT("Backup Master %-7ld %s\n",
- (unsigned long)cycle, state))
- break;
+ seq_printf(p,
+ "Backup Master %-7ld %s\n",
+ (unsigned long)cycle,
+ state);
} else {
- if (!RTNET_PROC_PRINT("Master %-7ld %s\n",
- (unsigned long)cycle, state))
- break;
+ seq_printf(p,
+ "Master %-7ld %s\n",
+ (unsigned long)cycle,
+ state);
}
} else
#endif /* CONFIG_RTNET_TDMA_MASTER */
- if (!RTNET_PROC_PRINT("Slave - %s\n", state))
- break;
+ seq_printf(p, "Slave - %s\n", state);
unlock_dev:
mutex_unlock(&rtdev->nrt_lock);
rtdev_dereference(rtdev);
rtdev = NULL;
}
-
-done:
if (rtdev) {
mutex_unlock(&rtdev->nrt_lock);
rtdev_dereference(rtdev);
}
- RTNET_PROC_PRINT_DONE;
+
+ return 0;
}
-int tdma_slots_proc_read(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+int tdma_slots_proc_read(struct seq_file *p, void *data)
{
struct rtnet_device *rtdev = NULL;
struct tdma_priv *tdma;
@@ -133,12 +130,10 @@ int tdma_slots_proc_read(char *buf, char **start, off_t offset, int count,
int d, i;
int jnt_id;
u64 slot_offset;
- RTNET_PROC_PRINT_VARS(80);
-
- if (!RTNET_PROC_PRINT("Interface "
- "Slots (id[->joint]:offset:phasing/period:size)\n"))
- goto done;
+ seq_printf(p,
+ "Interface "
+ "Slots (id[->joint]:offset:phasing/period:size)\n");
for (d = 1; d <= MAX_RT_DEVICES; d++) {
rtdev = rtdev_get_by_index(d);
@@ -155,15 +150,13 @@ int tdma_slots_proc_read(char *buf, char **start, off_t offset, int count,
goto unlock_dev;
tdma = (struct tdma_priv *)rtdev->mac_priv->disc_priv;
- if (!RTNET_PROC_PRINT("%-15s ", rtdev->name))
- break;
+ seq_printf(p, "%-15s ", rtdev->name);
#ifdef CONFIG_RTNET_TDMA_MASTER
if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags)) {
slot_offset = tdma->backup_sync_inc - tdma->cycle_period + 500;
do_div(slot_offset, 1000);
- if (!RTNET_PROC_PRINT("bak:%ld ", (unsigned long)slot_offset))
- break;
+ seq_printf(p, "bak:%ld ", (unsigned long)slot_offset);
}
#endif /* CONFIG_RTNET_TDMA_MASTER */
@@ -176,27 +169,23 @@ int tdma_slots_proc_read(char *buf, char **start, off_t offset, int count,
continue;
if (slot->queue == &slot->local_queue) {
- if (!RTNET_PROC_PRINT("%d", i))
- goto done;
+ seq_printf(p, "%d", i);
} else
for (jnt_id = 0; jnt_id <= tdma->max_slot_id; jnt_id++)
if (&tdma->slot_table[jnt_id]->local_queue ==
slot->queue) {
- if (!RTNET_PROC_PRINT("%d->%d", i, jnt_id))
- goto done;
+ seq_printf(p, "%d->%d", i, jnt_id);
break;
}
slot_offset = slot->offset + 500;
do_div(slot_offset, 1000);
- if (!RTNET_PROC_PRINT(":%ld:%d/%d:%d ",
+ seq_printf(p, ":%ld:%d/%d:%d ",
(unsigned long)slot_offset, slot->phasing + 1,
- slot->period, slot->mtu))
- goto done;
+ slot->period, slot->mtu);
}
- if (!RTNET_PROC_PRINT("\n"))
- break;
+ seq_printf(p, "\n");
unlock_dev:
mutex_unlock(&rtdev->nrt_lock);
@@ -204,12 +193,11 @@ unlock_dev:
rtdev = NULL;
}
-done:
if (rtdev) {
mutex_unlock(&rtdev->nrt_lock);
rtdev_dereference(rtdev);
}
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
#endif /* CONFIG_PROC_FS */
diff --git a/stack/rtnet_module.c b/stack/rtnet_module.c
index d36f37d..e9f2b7e 100644
--- a/stack/rtnet_module.c
+++ b/stack/rtnet_module.c
@@ -50,7 +50,6 @@ const char rtnet_rtdm_provider_name[] =
EXPORT_SYMBOL(rtnet_rtdm_provider_name);
-
#ifdef CONFIG_PROC_FS
/***
* proc filesystem section
@@ -59,64 +58,71 @@ struct proc_dir_entry *rtnet_proc_root;
EXPORT_SYMBOL(rtnet_proc_root);
-
-static int rtnet_read_proc_devices(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+static int proc_rtnet_devices_show(struct seq_file *p, void *data)
{
int i;
- int res;
struct rtnet_device *rtdev;
- RTNET_PROC_PRINT_VARS(80);
-
- if (!RTNET_PROC_PRINT("Index\tName\t\tFlags\n"))
- goto done;
+ seq_printf(p, "Index\tName\t\tFlags\n");
mutex_lock(&rtnet_devices_nrt_lock);
for (i = 1; i <= MAX_RT_DEVICES; i++) {
rtdev = __rtdev_get_by_index(i);
if (rtdev != NULL) {
- res = RTNET_PROC_PRINT("%d\t%-15s %s%s%s%s\n",
- rtdev->ifindex, rtdev->name,
- (rtdev->flags & IFF_UP) ? "UP" : "DOWN",
- (rtdev->flags & IFF_BROADCAST) ? " BROADCAST" : "",
- (rtdev->flags & IFF_LOOPBACK) ? " LOOPBACK" : "",
- (rtdev->flags & IFF_PROMISC) ? " PROMISC" : "");
- if (!res)
- break;
+ seq_printf(p, "%d\t%-15s %s%s%s%s\n",
+ rtdev->ifindex, rtdev->name,
+ (rtdev->flags & IFF_UP) ? "UP" : "DOWN",
+ (rtdev->flags & IFF_BROADCAST) ? " BROADCAST" : "",
+ (rtdev->flags & IFF_LOOPBACK) ? " LOOPBACK" : "",
+ (rtdev->flags & IFF_PROMISC) ? " PROMISC" : "");
}
}
mutex_unlock(&rtnet_devices_nrt_lock);
- done:
- RTNET_PROC_PRINT_DONE;
+ return 0;
}
+static int proc_rtnet_devices_open(struct inode *inode, struct file *file) {
+ return single_open(file, proc_rtnet_devices_show, PDE_DATA(inode));
+}
+static const struct file_operations proc_rtnet_devices_fops = {
+ .open = proc_rtnet_devices_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
-static int rtnet_read_proc_rtskb(char *buf, char **start, off_t offset, int count,
- int *eof, void *data)
+
+static int proc_rtnet_rtskb_show(struct seq_file *p, void *data)
{
unsigned int rtskb_len;
- RTNET_PROC_PRINT_VARS(256);
-
rtskb_len = ALIGN_RTSKB_STRUCT_LEN + SKB_DATA_ALIGN(RTSKB_SIZE);
- RTNET_PROC_PRINT("Statistics\t\tCurrent\tMaximum\n"
- "rtskb pools\t\t%d\t%d\n"
- "rtskbs\t\t\t%d\t%d\n"
- "rtskb memory need\t%d\t%d\n",
- rtskb_pools, rtskb_pools_max,
- rtskb_amount, rtskb_amount_max,
- rtskb_amount * rtskb_len, rtskb_amount_max * rtskb_len);
-
- RTNET_PROC_PRINT_DONE;
+ seq_printf(p, "Statistics\t\tCurrent\tMaximum\n"
+ "rtskb pools\t\t%d\t%d\n"
+ "rtskbs\t\t\t%d\t%d\n"
+ "rtskb memory need\t%d\t%d\n",
+ rtskb_pools, rtskb_pools_max,
+ rtskb_amount, rtskb_amount_max,
+ rtskb_amount * rtskb_len, rtskb_amount_max * rtskb_len);
+
+ return 0;
}
+static int proc_rtnet_rtskb_open(struct inode *inode, struct file *file) {
+ return single_open(file, proc_rtnet_rtskb_show, PDE_DATA(inode));
+}
+
+static const struct file_operations proc_rtnet_rtskb_fops = {
+ .open = proc_rtnet_rtskb_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
-static int rtnet_read_proc_version(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+static int proc_rtnet_version_show(struct seq_file *p, void *data)
{
const char verstr[] =
"RTnet " RTNET_PACKAGE_VERSION " - built on " __DATE__ " " __TIME__ "\n"
@@ -138,31 +144,34 @@ static int rtnet_read_proc_version(char *buf, char **start, off_t offset,
#else
"no\n";
#endif
- RTNET_PROC_PRINT_VARS(256);
+ seq_printf(p, "%s", verstr);
- RTNET_PROC_PRINT(verstr);
+ return 0;
+}
- RTNET_PROC_PRINT_DONE;
+static int proc_rtnet_version_open(struct inode *inode, struct file *file) {
+ return single_open(file, proc_rtnet_version_show, PDE_DATA(inode));
}
+static const struct file_operations proc_rtnet_version_fops = {
+ .open = proc_rtnet_version_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
-static int rtnet_read_proc_stats(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+static int proc_rtnet_stats_show(struct seq_file *p, void *data)
{
int i;
- int res;
struct rtnet_device *rtdev;
- RTNET_PROC_PRINT_VARS(130);
-
- if (!RTNET_PROC_PRINT("Inter-| Receive "
- " | Transmit\n") ||
- !RTNET_PROC_PRINT(" face |bytes packets errs drop fifo frame "
- "compressed multicast|bytes packets errs "
- "drop fifo colls carrier compressed\n"))
- goto done;
+ seq_printf(p, "Inter-| Receive "
+ " | Transmit\n");
+ seq_printf(p, " face |bytes packets errs drop fifo frame "
+ "compressed multicast|bytes packets errs "
+ "drop fifo colls carrier compressed\n");
mutex_lock(&rtnet_devices_nrt_lock);
for (i = 1; i <= MAX_RT_DEVICES; i++) {
@@ -172,69 +181,71 @@ static int rtnet_read_proc_stats(char *buf, char **start, off_t offset,
if (rtdev->get_stats) {
struct net_device_stats *stats = rtdev->get_stats(rtdev);
- res = RTNET_PROC_PRINT(
- "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
- "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
- rtdev->name, stats->rx_bytes, stats->rx_packets,
- stats->rx_errors,
- stats->rx_dropped + stats->rx_missed_errors,
- stats->rx_fifo_errors,
- stats->rx_length_errors + stats->rx_over_errors +
- stats->rx_crc_errors + stats->rx_frame_errors,
- stats->rx_compressed, stats->multicast,
- stats->tx_bytes, stats->tx_packets,
- stats->tx_errors, stats->tx_dropped,
- stats->tx_fifo_errors, stats->collisions,
- stats->tx_carrier_errors +
- stats->tx_aborted_errors +
- stats->tx_window_errors +
- stats->tx_heartbeat_errors,
- stats->tx_compressed);
+ seq_printf(p, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
+ "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
+ rtdev->name, stats->rx_bytes, stats->rx_packets,
+ stats->rx_errors,
+ stats->rx_dropped + stats->rx_missed_errors,
+ stats->rx_fifo_errors,
+ stats->rx_length_errors + stats->rx_over_errors +
+ stats->rx_crc_errors + stats->rx_frame_errors,
+ stats->rx_compressed, stats->multicast,
+ stats->tx_bytes, stats->tx_packets,
+ stats->tx_errors, stats->tx_dropped,
+ stats->tx_fifo_errors, stats->collisions,
+ stats->tx_carrier_errors +
+ stats->tx_aborted_errors +
+ stats->tx_window_errors +
+ stats->tx_heartbeat_errors,
+ stats->tx_compressed);
} else {
- res = RTNET_PROC_PRINT("%6s: No statistics available.\n",
- rtdev->name);
+ seq_printf(p, "%6s: No statistics available.\n", rtdev->name);
}
- if (!res)
- break;
}
mutex_unlock(&rtnet_devices_nrt_lock);
- done:
- RTNET_PROC_PRINT_DONE;
+ return 0;
+}
+
+static int proc_rtnet_stats_open(struct inode *inode, struct file *file) {
+ return single_open(file, proc_rtnet_stats_show, PDE_DATA(inode));
}
+static const struct file_operations proc_rtnet_stats_fops = {
+ .open = proc_rtnet_stats_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
static int rtnet_proc_register(void)
{
struct proc_dir_entry *proc_entry;
- rtnet_proc_root = create_proc_entry("rtnet", S_IFDIR, 0);
+ rtnet_proc_root = proc_mkdir("rtnet", 0);
if (!rtnet_proc_root)
goto error1;
- proc_entry = create_proc_entry("devices", S_IFREG | S_IRUGO | S_IWUSR,
- rtnet_proc_root);
+ proc_entry = proc_create("devices", S_IFREG | S_IRUGO | S_IWUSR,
+ rtnet_proc_root, &proc_rtnet_devices_fops);
if (!proc_entry)
goto error2;
- proc_entry->read_proc = rtnet_read_proc_devices;
- proc_entry = create_proc_entry("rtskb", S_IFREG | S_IRUGO | S_IWUSR,
- rtnet_proc_root);
+ proc_entry = proc_create("rtskb", S_IFREG | S_IRUGO | S_IWUSR,
+ rtnet_proc_root, &proc_rtnet_rtskb_fops);
if (!proc_entry)
goto error3;
- proc_entry->read_proc = rtnet_read_proc_rtskb;
- proc_entry = create_proc_entry("version", S_IFREG | S_IRUGO | S_IWUSR,
- rtnet_proc_root);
+ proc_entry = proc_create("version", S_IFREG | S_IRUGO | S_IWUSR,
+ rtnet_proc_root, &proc_rtnet_version_fops);
if (!proc_entry)
goto error4;
- proc_entry->read_proc = rtnet_read_proc_version;
- proc_entry = create_proc_entry("stats", S_IRUGO, rtnet_proc_root);
+ proc_entry = proc_create("stats", S_IRUGO,
+ rtnet_proc_root, &proc_rtnet_stats_fops);
if (!proc_entry)
goto error5;
- proc_entry->read_proc = rtnet_read_proc_stats;
return 0;
--
1.7.9.5
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users