Skip to content

Commit

Permalink
Fix offsets.c. The operations are now in a separate net_device_ops st…
Browse files Browse the repository at this point in the history
…ruct
  • Loading branch information
Wei Hu committed Sep 2, 2011
1 parent 949b027 commit 6de3844
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clean:
.PHONY: modules modules_install clean

else
obj-m := netdevs.o dram.o
obj-m := netdevs.o dram.o offsets.o
endif


16 changes: 6 additions & 10 deletions net/offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@
//-------------------------------------------------------------------

#include <linux/module.h> // for init_module()
#include <linux/proc_fs.h> // for create_proc_info_entry()
#include <linux/proc_fs.h>
#include <linux/netdevice.h> // for 'struct net_device'


char modname[] = "offsets";


int my_get_info( char *buf, char **start, off_t off, int count )
int my_get_info( char *buf, char **start, off_t off, int count, int *eof, void *data )
{
int o_name = offsetof( struct net_device, name );
int o_ifindex = offsetof( struct net_device, ifindex );
int o_irq = offsetof( struct net_device, irq );
int o_priv = offsetof( struct net_device, priv );
int o_open = offsetof( struct net_device, open );
int o_stop = offsetof( struct net_device, stop );
int o_priv = netdev_priv(0);
int o_devops = offsetof( struct net_device, netdev_ops );
int o_dev_addr = offsetof( struct net_device, dev_addr );
int o_hwxmit = offsetof( struct net_device, hard_start_xmit );
int len = 0;

len += sprintf( buf+len, "\n" );
Expand All @@ -45,10 +43,8 @@ int my_get_info( char *buf, char **start, off_t off, int count )
len += sprintf( buf+len, " 0x%04X ifindex \n", o_ifindex );
len += sprintf( buf+len, " 0x%04X dev_addr \n", o_dev_addr );
len += sprintf( buf+len, " 0x%04X irq \n", o_irq );
len += sprintf( buf+len, " 0x%04X device_ops \n", o_devops );
len += sprintf( buf+len, " 0x%04X priv \n", o_priv );
len += sprintf( buf+len, " 0x%04X open \n", o_open );
len += sprintf( buf+len, " 0x%04X stop \n", o_stop );
len += sprintf( buf+len, " 0x%04X hard_start_xmit \n", o_hwxmit );
len += sprintf( buf+len, "\n" );

return len;
Expand All @@ -59,7 +55,7 @@ static int __init my_init( void )
{
printk( "<1>\nInstalling \'%s\' module\n", modname );

create_proc_info_entry( modname, 0, NULL, my_get_info );
create_proc_read_entry( modname, 0, NULL, my_get_info, NULL );
return 0; //SUCCESS
}

Expand Down

0 comments on commit 6de3844

Please sign in to comment.