static struct proc_dir_entry
*debug_create_proc_dir_entry(struct proc_dir_entry *root,
const char *name, mode_t mode,
- struct inode_operations *iops,
struct file_operations *fops);
static void debug_delete_proc_dir_entry(struct proc_dir_entry *root,
struct proc_dir_entry *entry);
static debug_info_t *debug_area_first = NULL;
static debug_info_t *debug_area_last = NULL;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-static struct semaphore debug_lock = MUTEX;
-#else
DECLARE_MUTEX(debug_lock);
-#endif
static int initialized = 0;
static struct file_operations debug_file_ops = {
+ owner: THIS_MODULE,
read: debug_output,
write: debug_input,
open: debug_open,
release: debug_close,
};
-static struct inode_operations debug_inode_ops = {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
- default_file_ops: &debug_file_ops, /* file ops */
-#endif
-};
-
-
static struct proc_dir_entry *debug_proc_root_entry;
/* functions */
/* create proc rood directory */
- rc->proc_root_entry =
- debug_create_proc_dir_entry(debug_proc_root_entry, rc->name,
- S_IFDIR | S_IRUGO | S_IXUGO |
- S_IWUSR | S_IWGRP, NULL, NULL);
+ rc->proc_root_entry = proc_mkdir(rc->name, debug_proc_root_entry);
/* append new element to linked list */
- if(debug_area_first == NULL){
+ if (debug_area_first == NULL) {
/* first element in list */
debug_area_first = rc;
rc->prev = NULL;
- }
- else{
+ } else {
/* append element to end of list */
debug_area_last->next = rc;
rc->prev = debug_area_last;
#ifdef DEBUG
printk("debug_open\n");
#endif
- MOD_INC_USE_COUNT;
down(&debug_lock);
/* find debug log and view */
for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
if (debug_info->views[i] == NULL)
continue;
- else if (debug_info->proc_entries[i]->low_ino ==
- file->f_dentry->d_inode->i_ino) {
+ else if (debug_info->proc_entries[i] ==
+ PDE(file->f_dentry->d_inode)) {
goto found; /* found view ! */
}
}
out:
up(&debug_lock);
- if (rc != 0)
- MOD_DEC_USE_COUNT;
return rc;
}
debug_info_free(p_info->debug_info_snap);
debug_info_put(p_info->debug_info_org);
kfree(file->private_data);
- MOD_DEC_USE_COUNT;
return 0; /* success */
}
static struct proc_dir_entry *debug_create_proc_dir_entry
(struct proc_dir_entry *root, const char *name, mode_t mode,
- struct inode_operations *iops, struct file_operations *fops)
+ struct file_operations *fops)
{
- struct proc_dir_entry *rc = NULL;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
- const char *fn = name;
- int len;
- len = strlen(fn);
-
- rc = (struct proc_dir_entry *) kmalloc(sizeof(struct proc_dir_entry)
- + len + 1, GFP_ATOMIC);
- if (!rc)
- goto out;
-
- memset(rc, 0, sizeof(struct proc_dir_entry));
- memcpy(((char *) rc) + sizeof(*rc), fn, len + 1);
- rc->name = ((char *) rc) + sizeof(*rc);
- rc->namelen = len;
- rc->low_ino = 0, rc->mode = mode;
- rc->nlink = 1;
- rc->uid = 0;
- rc->gid = 0;
- rc->size = 0;
- rc->get_info = NULL;
- rc->ops = iops;
-
- proc_register(root, rc);
-#else
- rc = create_proc_entry(name, mode, root);
- if (!rc)
- goto out;
- if (fops)
+ struct proc_dir_entry *rc = create_proc_entry(name, mode, root);
+ if (rc && fops)
rc->proc_fops = fops;
-#endif
-
- out:
return rc;
}
static void debug_delete_proc_dir_entry
(struct proc_dir_entry *root, struct proc_dir_entry *proc_entry)
{
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
- proc_unregister(root, proc_entry->low_ino);
- kfree(proc_entry);
-#else
remove_proc_entry(proc_entry->name, root);
-#endif
}
/*
down(&debug_lock);
if (!initialized) {
- debug_proc_root_entry =
- debug_create_proc_dir_entry(&proc_root, DEBUG_DIR_ROOT,
- S_IFDIR | S_IRUGO | S_IXUGO
- | S_IWUSR | S_IWGRP, NULL,
- NULL);
+ debug_proc_root_entry = proc_mkdir(DEBUG_DIR_ROOT, NULL);
printk(KERN_INFO "debug: Initialization complete\n");
initialized = 1;
}
id->proc_entries[i] =
debug_create_proc_dir_entry(id->proc_root_entry,
view->name, mode,
- &debug_inode_ops,
&debug_file_ops);
rc = 0;
}
#ifdef DEBUG
printk("debug_cleanup_module: \n");
#endif
- debug_delete_proc_dir_entry(&proc_root, debug_proc_root_entry);
+ debug_delete_proc_dir_entry(NULL, debug_proc_root_entry);
return;
}
static struct proc_dir_entry
*debug_create_proc_dir_entry(struct proc_dir_entry *root,
const char *name, mode_t mode,
- struct inode_operations *iops,
struct file_operations *fops);
static void debug_delete_proc_dir_entry(struct proc_dir_entry *root,
struct proc_dir_entry *entry);
release: debug_close,
};
-static struct inode_operations debug_inode_ops = {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
- default_file_ops: &debug_file_ops, /* file ops */
-#endif
-};
-
-
static struct proc_dir_entry *debug_proc_root_entry;
/* functions */
/* create proc rood directory */
- rc->proc_root_entry =
- debug_create_proc_dir_entry(debug_proc_root_entry, rc->name,
- S_IFDIR | S_IRUGO | S_IXUGO |
- S_IWUSR | S_IWGRP, NULL, NULL);
-
+ rc->proc_root_entry = proc_mkdir(rc->name, debug_proc_root_entry);
/* append new element to linked list */
if(debug_area_first == NULL){
for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
if (debug_info->views[i] == NULL)
continue;
- else if (debug_info->proc_entries[i]->low_ino ==
- file->f_dentry->d_inode->i_ino) {
+ else if (debug_info->proc_entries[i] ==
+ PDE(file->f_dentry->d_inode)) {
goto found; /* found view ! */
}
}
static struct proc_dir_entry *debug_create_proc_dir_entry
(struct proc_dir_entry *root, const char *name, mode_t mode,
- struct inode_operations *iops, struct file_operations *fops)
+ struct file_operations *fops)
{
- struct proc_dir_entry *rc = NULL;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
- const char *fn = name;
- int len;
- len = strlen(fn);
-
- rc = (struct proc_dir_entry *) kmalloc(sizeof(struct proc_dir_entry)
- + len + 1, GFP_ATOMIC);
- if (!rc)
- goto out;
-
- memset(rc, 0, sizeof(struct proc_dir_entry));
- memcpy(((char *) rc) + sizeof(*rc), fn, len + 1);
- rc->name = ((char *) rc) + sizeof(*rc);
- rc->namelen = len;
- rc->low_ino = 0, rc->mode = mode;
- rc->nlink = 1;
- rc->uid = 0;
- rc->gid = 0;
- rc->size = 0;
- rc->get_info = NULL;
- rc->ops = iops;
-
- proc_register(root, rc);
-#else
- rc = create_proc_entry(name, mode, root);
- if (!rc)
- goto out;
- if (fops)
+ struct proc_dir_entry *rc = create_proc_entry(name, mode, root);
+ if (rc && fops)
rc->proc_fops = fops;
-#endif
-
- out:
return rc;
}
static void debug_delete_proc_dir_entry
(struct proc_dir_entry *root, struct proc_dir_entry *proc_entry)
{
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
- proc_unregister(root, proc_entry->low_ino);
- kfree(proc_entry);
-#else
remove_proc_entry(proc_entry->name, root);
-#endif
}
/*
down(&debug_lock);
if (!initialized) {
- debug_proc_root_entry =
- debug_create_proc_dir_entry(&proc_root, DEBUG_DIR_ROOT,
- S_IFDIR | S_IRUGO | S_IXUGO
- | S_IWUSR | S_IWGRP, NULL,
- NULL);
+ debug_proc_root_entry = proc_mkdir(DEBUG_DIR_ROOT, NULL);
printk(KERN_INFO "debug: Initialization complete\n");
initialized = 1;
}
id->proc_entries[i] =
debug_create_proc_dir_entry(id->proc_root_entry,
view->name, mode,
- &debug_inode_ops,
&debug_file_ops);
rc = 0;
}
static struct ctl_table_header *i2c_entries[SENSORS_ENTRY_MAX];
static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX];
-static unsigned short i2c_inodes[SENSORS_ENTRY_MAX];
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
-static void i2c_fill_inode(struct inode *inode, int fill);
-static void i2c_dir_fill_inode(struct inode *inode, int fill);
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1) */
static ctl_table sysctl_table[] = {
{CTL_DEV, "dev", NULL, 0, 0555},
return id;
}
#endif /* DEBUG */
- i2c_inodes[id - 256] =
- new_header->ctl_table->child->child->de->low_ino;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27))
new_header->ctl_table->child->child->de->owner = controlling_mod;
-#else
- new_header->ctl_table->child->child->de->fill_inode =
- &i2c_dir_fill_inode;
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) */
return id;
}
}
}
-/* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o
- impossible if some process still uses it or some file in it */
-void i2c_fill_inode(struct inode *inode, int fill)
-{
- if (fill)
- MOD_INC_USE_COUNT;
- else
- MOD_DEC_USE_COUNT;
-}
-
-/* Monitor access for /proc/sys/dev/sensors/ directories; make unloading
- the corresponding module impossible if some process still uses it or
- some file in it */
-void i2c_dir_fill_inode(struct inode *inode, int fill)
-{
- int i;
- struct i2c_client *client;
-
-#ifdef DEBUG
- if (!inode) {
- printk("i2c-proc.o: Warning: inode NULL in fill_inode()\n");
- return;
- }
-#endif /* def DEBUG */
-
- for (i = 0; i < SENSORS_ENTRY_MAX; i++)
- if (i2c_clients[i]
- && (i2c_inodes[i] == inode->i_ino)) break;
-#ifdef DEBUG
- if (i == SENSORS_ENTRY_MAX) {
- printk
- ("i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n",
- inode->i_ino);
- return;
- }
-#endif /* def DEBUG */
- client = i2c_clients[i];
- if (fill)
- client->driver->inc_use(client);
- else
- client->driver->dec_use(client);
-}
-
int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp,
void *buffer, size_t * lenp)
{
if (!
(i2c_proc_header =
register_sysctl_table(i2c_proc, 0))) return -ENOMEM;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1))
i2c_proc_header->ctl_table->child->de->owner = THIS_MODULE;
-#else
- i2c_proc_header->ctl_table->child->de->fill_inode =
- &i2c_fill_inode;
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1)) */
i2c_initialized++;
return 0;
}
card = card_root;
while (card) {
pd = card->procconf;
- if (pd->low_ino == (ino->i_ino & 0xFFFF))
+ if (pd == PDE(ino))
break;
card = card->next; /* search next entry */
}
card = card_root;
while (card) {
pd = card->procconf;
- if (pd->low_ino == (ino->i_ino & 0xFFFF))
+ if (pd == PDE(ino))
break;
card = card->next; /* search next entry */
}
{
struct log_data *inf;
int len;
- word ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
struct procdata *pd = NULL;
hysdn_card *card;
return (-EAGAIN);
/* sorry, but we need to search the card */
- ino = file->f_dentry->d_inode->i_ino & 0xFFFF; /* low-ino */
card = card_root;
while (card) {
pd = card->proclog;
- if (pd->log->low_ino == ino)
+ if (pd->log == pde)
break;
card = card->next; /* search next entry */
}
card = card_root;
while (card) {
pd = card->proclog;
- if (pd->log->low_ino == (ino->i_ino & 0xFFFF))
+ if (pd->log == PDE(ino))
break;
card = card->next; /* search next entry */
}
card = card_root;
while (card) {
pd = card->proclog;
- if (pd->log->low_ino == (ino->i_ino & 0xFFFF))
+ if (pd->log == PDE(ino))
break;
card = card->next; /* search next entry */
}
hysdn_log_poll(struct file *file, poll_table * wait)
{
unsigned int mask = 0;
- word ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
hysdn_card *card;
struct procdata *pd = NULL;
return (mask); /* no polling for write supported */
/* we need to search the card */
- ino = file->f_dentry->d_inode->i_ino & 0xFFFF; /* low-ino */
card = card_root;
while (card) {
pd = card->proclog;
- if (pd->log->low_ino == ino)
+ if (pd->log == pde)
break;
card = card->next; /* search next entry */
}
/* Paranoia checking: */
- if (file->f_dentry->d_inode->i_ino != entry->low_ino)
+ if (PDE(file->f_dentry->d_inode) != entry)
{
printk(KERN_ERR "munich_write_proc: file <-> data internal error\n");
return -EIO;
lock_kernel();
if ((de = PDE(dir)) != NULL) {
for (de = de->subdir ; de ; de = de->next) {
- if ((de && de->low_ino) &&
- (de->namelen == dentry->d_name.len) &&
+ if ((de->namelen == dentry->d_name.len) &&
(memcmp(dentry->d_name.name, de->name,
de->namelen) == 0)) {
if ((inode = proc_get_inode(dir->i_sb,
release:tape_devices_release, /* close */
};
-static struct inode_operations tape_devices_inode_ops =
-{
-#if !(LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
- default_file_ops:&tape_devices_file_ops /* file ops */
-#endif /* LINUX_IS_24 */
-};
#endif /* CONFIG_PROC_FS */
/* SECTION: Parameters for tape */
return 1;
}
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,2,16))
__setup("tape=", tape_parm_call_setup);
-#endif /* kernel <2.2.19 */
#endif /* not defined MODULE */
static inline int
/* Allocate local buffer for the ccwcache */
tape_init_emergency_req ();
#ifdef CONFIG_PROC_FS
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
tape_devices_entry = create_proc_entry ("tapedevices",
S_IFREG | S_IRUGO | S_IWUSR,
&proc_root);
tape_devices_entry->proc_fops = &tape_devices_file_ops;
- tape_devices_entry->proc_iops = &tape_devices_inode_ops;
-#else
- tape_devices_entry = (struct proc_dir_entry *) kmalloc
- (sizeof (struct proc_dir_entry), GFP_ATOMIC);
- if (tape_devices_entry) {
- memset (tape_devices_entry, 0, sizeof (struct proc_dir_entry));
- tape_devices_entry->name = "tapedevices";
- tape_devices_entry->namelen = strlen ("tapedevices");
- tape_devices_entry->low_ino = 0;
- tape_devices_entry->mode = (S_IFREG | S_IRUGO | S_IWUSR);
- tape_devices_entry->nlink = 1;
- tape_devices_entry->uid = 0;
- tape_devices_entry->gid = 0;
- tape_devices_entry->size = 0;
- tape_devices_entry->get_info = NULL;
- tape_devices_entry->ops = &tape_devices_inode_ops;
- proc_register (&proc_root, tape_devices_entry);
- }
-#endif
#endif /* CONFIG_PROC_FS */
return 0;
devfs_unregister (tape_devfs_root_entry);
#endif CONFIG_DEVFS_FS
#ifdef CONFIG_PROC_FS
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
remove_proc_entry ("tapedevices", &proc_root);
-#else
- proc_unregister (&proc_root, tape_devices_entry->low_ino);
- kfree (tape_devices_entry);
-#endif /* LINUX_IS_24 */
#endif
#ifdef CONFIG_S390_TAPE_CHAR
tapechar_uninit();
#define FREE_IRQ free_irq
#endif
-#if LINUX_VERSION_CODE >= 0x020213
-# include <asm/idals.h>
-#else
-# define set_normalized_cda(ccw, addr) ((ccw)->cda = (addr),0)
-# define clear_normalized_cda(ccw)
-#endif
-#if LINUX_VERSION_CODE < 0x020400
-# define s390_dev_info_t dev_info_t
-# define dev_kfree_skb_irq(a) dev_kfree_skb(a)
-#endif
+#include <asm/idals.h>
#include <asm/irq.h>
typedef struct ctc_priv_t {
struct net_device_stats stats;
-#if LINUX_VERSION_CODE >= 0x02032D
unsigned long tbusy;
-#endif
/**
* The finite state machine of this interface.
*/
* Compatibility macros for busy handling
* of network devices.
*/
-#if LINUX_VERSION_CODE < 0x02032D
-static __inline__ void ctc_clear_busy(net_device *dev)
-{
- clear_bit(0 ,(void *)&dev->tbusy);
- mark_bh(NET_BH);
-}
-
-static __inline__ int ctc_test_and_set_busy(net_device *dev)
-{
- return(test_and_set_bit(0, (void *)&dev->tbusy));
-}
-
-#define SET_DEVICE_START(device, value) dev->start = value
-#else
static __inline__ void ctc_clear_busy(net_device *dev)
{
clear_bit(0, &(((ctc_priv *)dev->priv)->tbusy));
}
#define SET_DEVICE_START(device, value)
-#endif
/**
* Print Banner.
dev->name,
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
-#if LINUX_VERSION_CODE >= 0x020400
INIT_LIST_HEAD(&ch->tq.list);
-#else
- ch->tq.next = NULL;
-#endif
ch->tq.sync = 0;
ch->tq.routine = (void *)(void *)ctc_bh;
ch->tq.data = ch;
* procfs related structures and routines
*****************************************************************************/
-static net_device *find_netdev_by_ino(unsigned long ino)
+static net_device *find_netdev_by_ino(struct proc_dir_entry *pde)
{
channel *ch = channels;
net_device *dev = NULL;
dev = ch->netdev;
privptr = (ctc_priv *)dev->priv;
- if ((privptr->proc_ctrl_entry->low_ino == ino) ||
- (privptr->proc_stat_entry->low_ino == ino))
+ if ((privptr->proc_ctrl_entry == pde) ||
+ (privptr->proc_stat_entry == pde))
return dev;
}
ch = ch->next;
return NULL;
}
-#if LINUX_VERSION_CODE < 0x020363
-/**
- * Lock the module, if someone changes into
- * our proc directory.
- */
-static void ctc_fill_inode(struct inode *inode, int fill)
-{
- if (fill) {
- MOD_INC_USE_COUNT;
- } else
- MOD_DEC_USE_COUNT;
-}
-#endif
-
#define CTRL_BUFSIZE 40
static int ctc_ctrl_open(struct inode *inode, struct file *file)
static ssize_t ctc_ctrl_write(struct file *file, const char *buf, size_t count,
loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
net_device *dev;
ctc_priv *privptr;
char *e;
int bs1;
char tmp[40];
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
static ssize_t ctc_ctrl_read(struct file *file, char *buf, size_t count,
loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
char *sbuf = (char *)file->private_data;
net_device *dev;
ctc_priv *privptr;
char *p = sbuf;
int l;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
static ssize_t ctc_stat_write(struct file *file, const char *buf, size_t count,
loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
net_device *dev;
ctc_priv *privptr;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
privptr = (ctc_priv *)dev->priv;
privptr->channel[WRITE]->prof.maxmulti = 0;
static ssize_t ctc_stat_read(struct file *file, char *buf, size_t count,
loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
char *sbuf = (char *)file->private_data;
net_device *dev;
ctc_priv *privptr;
char *p = sbuf;
int l;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
release: ctc_ctrl_close,
};
-static struct inode_operations ctc_stat_iops = {
-#if LINUX_VERSION_CODE < 0x020363
- default_file_ops: &ctc_stat_fops
-#endif
-};
-static struct inode_operations ctc_ctrl_iops = {
-#if LINUX_VERSION_CODE < 0x020363
- default_file_ops: &ctc_ctrl_fops
-#endif
-};
-
-static struct proc_dir_entry stat_entry = {
- 0, /* low_ino */
- 10, /* namelen */
- "statistics", /* name */
- S_IFREG | S_IRUGO | S_IWUSR, /* mode */
- 1, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- &ctc_stat_iops /* ops */
-};
-
-static struct proc_dir_entry ctrl_entry = {
- 0, /* low_ino */
- 10, /* namelen */
- "buffersize", /* name */
- S_IFREG | S_IRUSR | S_IWUSR, /* mode */
- 1, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- &ctc_ctrl_iops /* ops */
-};
-
-#if LINUX_VERSION_CODE < 0x020363
-static struct proc_dir_entry ctc_dir = {
- 0, /* low_ino */
- 3, /* namelen */
- "ctc", /* name */
- S_IFDIR | S_IRUGO | S_IXUGO, /* mode */
- 2, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- 0, /* ops */
- 0, /* get_info */
- ctc_fill_inode /* fill_ino (for locking) */
-};
-
-static struct proc_dir_entry ctc_template =
-{
- 0, /* low_ino */
- 0, /* namelen */
- "", /* name */
- S_IFDIR | S_IRUGO | S_IXUGO, /* mode */
- 2, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- 0, /* ops */
- 0, /* get_info */
- ctc_fill_inode /* fill_ino (for locking) */
-};
-#else
static struct proc_dir_entry *ctc_dir = NULL;
-static struct proc_dir_entry *ctc_template = NULL;
-#endif
/**
* Create the driver's main directory /proc/net/ctc
/**
* If not registered, register main proc dir-entry now
*/
-#if LINUX_VERSION_CODE > 0x020362
if (!ctc_dir)
ctc_dir = proc_mkdir("ctc", proc_net);
-#else
- if (ctc_dir.low_ino == 0)
- proc_net_register(&ctc_dir);
-#endif
}
#ifdef MODULE
* Destroy /proc/net/ctc
*/
static void ctc_proc_destroy_main(void) {
-#if LINUX_VERSION_CODE > 0x020362
remove_proc_entry("ctc", proc_net);
-#else
- proc_net_unregister(ctc_dir.low_ino);
-#endif
}
#endif MODULE
static void ctc_proc_create_sub(net_device *dev) {
ctc_priv *privptr = dev->priv;
-#if LINUX_VERSION_CODE > 0x020362
privptr->proc_dentry = proc_mkdir(dev->name, ctc_dir);
privptr->proc_stat_entry =
create_proc_entry("statistics",
S_IFREG | S_IRUSR | S_IWUSR,
privptr->proc_dentry);
privptr->proc_stat_entry->proc_fops = &ctc_stat_fops;
- privptr->proc_stat_entry->proc_iops = &ctc_stat_iops;
privptr->proc_ctrl_entry =
create_proc_entry("buffersize",
S_IFREG | S_IRUSR | S_IWUSR,
privptr->proc_dentry);
privptr->proc_ctrl_entry->proc_fops = &ctc_ctrl_fops;
- privptr->proc_ctrl_entry->proc_iops = &ctc_ctrl_iops;
-#else
- privptr->proc_dentry->name = dev->name;
- privptr->proc_dentry->namelen = strlen(dev->name);
- proc_register(&ctc_dir, privptr->proc_dentry);
- proc_register(privptr->proc_dentry, privptr->proc_stat_entry);
- proc_register(privptr->proc_dentry, privptr->proc_ctrl_entry);
-#endif
privptr->proc_registered = 1;
}
static void ctc_proc_destroy_sub(ctc_priv *privptr) {
if (!privptr->proc_registered)
return;
-#if LINUX_VERSION_CODE > 0x020362
remove_proc_entry("statistics", privptr->proc_dentry);
remove_proc_entry("buffersize", privptr->proc_dentry);
remove_proc_entry(privptr->proc_dentry->name, ctc_dir);
-#else
- proc_unregister(privptr->proc_dentry,
- privptr->proc_stat_entry->low_ino);
- proc_unregister(privptr->proc_dentry,
- privptr->proc_ctrl_entry->low_ino);
- proc_unregister(&ctc_dir,
- privptr->proc_dentry->low_ino);
-#endif
privptr->proc_registered = 0;
}
static void ctc_setup(char *setup)
# define ctc_setup_return return
#else MODULE
-# if LINUX_VERSION_CODE < 0x020300
- __initfunc(void ctc_setup(char *setup, int *ints))
-# define ctc_setup_return return
-# define ints local_ints
-# else
static int __init ctc_setup(char *setup)
# define ctc_setup_return return(1)
-# endif
#endif MODULE
{
int write_dev;
ctc_setup_return;
}
-#if LINUX_VERSION_CODE >= 0x020300
__setup("ctc=", ctc_setup);
-#endif
#endif /* !CTC_CHANDEV */
\f
ctc_priv *privptr;
int priv_size;
if (alloc_device) {
- dev = kmalloc(sizeof(net_device)
-#if LINUX_VERSION_CODE < 0x020300
- + 11 /* name + zero */
-#endif
- , GFP_KERNEL);
+ dev = kmalloc(sizeof(net_device), GFP_KERNEL);
if (!dev)
return NULL;
memset(dev, 0, sizeof(net_device));
}
- priv_size = sizeof(ctc_priv) + sizeof(ctc_template) +
- sizeof(stat_entry) + sizeof(ctrl_entry);
+ priv_size = sizeof(ctc_priv);
dev->priv = kmalloc(priv_size, GFP_KERNEL);
if (dev->priv == NULL) {
if (alloc_device)
}
memset(dev->priv, 0, priv_size);
privptr = (ctc_priv *)dev->priv;
- privptr->proc_dentry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(ctc_priv));
- privptr->proc_stat_entry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(ctc_priv) +
- sizeof(ctc_template));
- privptr->proc_ctrl_entry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(ctc_priv) +
- sizeof(ctc_template) + sizeof(stat_entry));
- memcpy(privptr->proc_dentry, &ctc_template, sizeof(ctc_template));
- memcpy(privptr->proc_stat_entry, &stat_entry, sizeof(stat_entry));
- memcpy(privptr->proc_ctrl_entry, &ctrl_entry, sizeof(ctrl_entry));
privptr->fsm = init_fsm("ctcdev", dev_state_names,
dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
ret = -ENOMEM;
break;
}
-#if LINUX_VERSION_CODE < 0x020300
- dev->name = (unsigned char *)dev + sizeof(net_device);
-#endif
if (par && par->name) {
char *p;
int n;
}
#ifndef MODULE
-#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,3,0))
__initcall(ctc_init);
-#endif /* LINUX_VERSION_CODE */
#endif /* MODULE */
/* --- This is the END my friend --- */
static char *iucv = "";
-/**
- * compatibility stuff
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
typedef struct net_device net_device;
-#else
-typedef struct device net_device;
-#endif
\f
/**
*/
typedef struct netiucv_priv_t {
struct net_device_stats stats;
-#if LINUX_VERSION_CODE >= 0x02032D
unsigned long tbusy;
-#endif
fsm_instance *fsm;
iucv_connection *conn;
struct proc_dir_entry *proc_dentry;
* Compatibility macros for busy handling
* of network devices.
*/
-#if LINUX_VERSION_CODE < 0x02032D
-static __inline__ void netiucv_clear_busy(net_device *dev)
-{
- clear_bit(0 ,(void *)&dev->tbusy);
- mark_bh(NET_BH);
-}
-
-static __inline__ int netiucv_test_and_set_busy(net_device *dev)
-{
- return(test_and_set_bit(0, (void *)&dev->tbusy));
-}
-
-#define SET_DEVICE_START(device, value) dev->start = value
-#else
static __inline__ void netiucv_clear_busy(net_device *dev)
{
clear_bit(0, &(((netiucv_priv *)dev->priv)->tbusy));
}
#define SET_DEVICE_START(device, value)
-#endif
-
-#if LINUX_VERSION_CODE < 0x020400
-# define dev_kfree_skb_irq(a) dev_kfree_skb(a)
-#endif
__u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
__u8 iucvMagic[16] = {
*****************************************************************************/
static net_device *
-find_netdev_by_ino(unsigned long ino)
+find_netdev_by_ino(struct proc_dir_entry *pde)
{
iucv_connection *conn = connections;
net_device *dev = NULL;
dev = conn->netdev;
privptr = (netiucv_priv *)dev->priv;
- if ((privptr->proc_buffer_entry->low_ino == ino) ||
- (privptr->proc_user_entry->low_ino == ino) ||
- (privptr->proc_stat_entry->low_ino == ino) )
+ if ((privptr->proc_buffer_entry == pde) ||
+ (privptr->proc_user_entry == pde) ||
+ (privptr->proc_stat_entry == pde) )
return dev;
}
conn = conn->next;
return NULL;
}
-#if LINUX_VERSION_CODE < 0x020363
-/**
- * Lock the module, if someone changes into
- * our proc directory.
- */
-static void
-netiucv_fill_inode(struct inode *inode, int fill)
-{
- if (fill) {
- MOD_INC_USE_COUNT;
- } else
- MOD_DEC_USE_COUNT;
-}
-#endif
-
#define CTRL_BUFSIZE 40
static int
netiucv_buffer_write(struct file *file, const char *buf, size_t count,
loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
net_device *dev;
netiucv_priv *privptr;
char *e;
int bs1;
char tmp[CTRL_BUFSIZE];
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
static ssize_t
netiucv_buffer_read(struct file *file, char *buf, size_t count, loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
char *sbuf = (char *)file->private_data;
net_device *dev;
netiucv_priv *privptr;
char *p = sbuf;
int l;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
netiucv_user_write(struct file *file, const char *buf, size_t count,
loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
net_device *dev;
netiucv_priv *privptr;
int i;
char tmp[CTRL_BUFSIZE];
char user[9];
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
static ssize_t
netiucv_user_read(struct file *file, char *buf, size_t count, loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
char *sbuf = (char *)file->private_data;
net_device *dev;
netiucv_priv *privptr;
char *p = sbuf;
int l;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
static ssize_t
netiucv_stat_write(struct file *file, const char *buf, size_t count, loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
net_device *dev;
netiucv_priv *privptr;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
privptr = (netiucv_priv *)dev->priv;
privptr->conn->prof.maxmulti = 0;
static ssize_t
netiucv_stat_read(struct file *file, char *buf, size_t count, loff_t *off)
{
- unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+ struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
char *sbuf = (char *)file->private_data;
net_device *dev;
netiucv_priv *privptr;
char *p = sbuf;
int l;
- if (!(dev = find_netdev_by_ino(ino)))
+ if (!(dev = find_netdev_by_ino(pde)))
return -ENODEV;
if (off != &file->f_pos)
return -ESPIPE;
release: netiucv_user_close,
};
-static struct inode_operations netiucv_stat_iops = {
-#if LINUX_VERSION_CODE < 0x020363
- default_file_ops: &netiucv_stat_fops
-#endif
-};
-static struct inode_operations netiucv_buffer_iops = {
-#if LINUX_VERSION_CODE < 0x020363
- default_file_ops: &netiucv_buffer_fops
-#endif
-};
-
-static struct inode_operations netiucv_user_iops = {
-#if LINUX_VERSION_CODE < 0x020363
- default_file_ops: &netiucv_user_fops
-#endif
-};
-
-static struct proc_dir_entry stat_entry = {
- 0, /* low_ino */
- 10, /* namelen */
- "statistics", /* name */
- S_IFREG | S_IRUGO | S_IWUSR, /* mode */
- 1, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- &netiucv_stat_iops /* ops */
-};
-
-static struct proc_dir_entry buffer_entry = {
- 0, /* low_ino */
- 10, /* namelen */
- "buffersize", /* name */
- S_IFREG | S_IRUSR | S_IWUSR, /* mode */
- 1, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- &netiucv_buffer_iops /* ops */
-};
-
-static struct proc_dir_entry user_entry = {
- 0, /* low_ino */
- 8, /* namelen */
- "username", /* name */
- S_IFREG | S_IRUSR | S_IWUSR, /* mode */
- 1, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- &netiucv_user_iops /* ops */
-};
-
-#if LINUX_VERSION_CODE < 0x020363
-static struct proc_dir_entry netiucv_dir = {
- 0, /* low_ino */
- 4, /* namelen */
- "iucv", /* name */
- S_IFDIR | S_IRUGO | S_IXUGO, /* mode */
- 2, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- 0, /* ops */
- 0, /* get_info */
- netiucv_fill_inode /* fill_ino (for locking) */
-};
-
-static struct proc_dir_entry netiucv_template =
-{
- 0, /* low_ino */
- 0, /* namelen */
- "", /* name */
- S_IFDIR | S_IRUGO | S_IXUGO, /* mode */
- 2, /* nlink */
- 0, /* uid */
- 0, /* gid */
- 0, /* size */
- 0, /* ops */
- 0, /* get_info */
- netiucv_fill_inode /* fill_ino (for locking) */
-};
-#else
static struct proc_dir_entry *netiucv_dir = NULL;
static struct proc_dir_entry *netiucv_template = NULL;
-#endif
/**
* Create the driver's main directory /proc/net/iucv
/**
* If not registered, register main proc dir-entry now
*/
-#if LINUX_VERSION_CODE > 0x020362
if (!netiucv_dir)
netiucv_dir = proc_mkdir("iucv", proc_net);
-#else
- if (netiucv_dir.low_ino == 0)
- proc_net_register(&netiucv_dir);
-#endif
}
#ifdef MODULE
static void
netiucv_proc_destroy_main(void)
{
-#if LINUX_VERSION_CODE > 0x020362
remove_proc_entry("iucv", proc_net);
-#else
- proc_net_unregister(netiucv_dir.low_ino);
-#endif
}
#endif MODULE
netiucv_proc_create_sub(net_device *dev) {
netiucv_priv *privptr = dev->priv;
-#if LINUX_VERSION_CODE > 0x020362
privptr->proc_dentry = proc_mkdir(dev->name, netiucv_dir);
privptr->proc_stat_entry =
create_proc_entry("statistics",
S_IFREG | S_IRUSR | S_IWUSR,
privptr->proc_dentry);
privptr->proc_stat_entry->proc_fops = &netiucv_stat_fops;
- privptr->proc_stat_entry->proc_iops = &netiucv_stat_iops;
privptr->proc_buffer_entry =
create_proc_entry("buffersize",
S_IFREG | S_IRUSR | S_IWUSR,
privptr->proc_dentry);
privptr->proc_buffer_entry->proc_fops = &netiucv_buffer_fops;
- privptr->proc_buffer_entry->proc_iops = &netiucv_buffer_iops;
privptr->proc_user_entry =
create_proc_entry("username",
S_IFREG | S_IRUSR | S_IWUSR,
privptr->proc_dentry);
privptr->proc_user_entry->proc_fops = &netiucv_user_fops;
- privptr->proc_user_entry->proc_iops = &netiucv_user_iops;
-#else
- privptr->proc_dentry->name = dev->name;
- privptr->proc_dentry->namelen = strlen(dev->name);
- proc_register(&netiucv_dir, privptr->proc_dentry);
- proc_register(privptr->proc_dentry, privptr->proc_stat_entry);
- proc_register(privptr->proc_dentry, privptr->proc_buffer_entry);
- proc_register(privptr->proc_dentry, privptr->proc_user_entry);
-#endif
privptr->proc_registered = 1;
}
netiucv_proc_destroy_sub(netiucv_priv *privptr) {
if (!privptr->proc_registered)
return;
-#if LINUX_VERSION_CODE > 0x020362
remove_proc_entry("statistics", privptr->proc_dentry);
remove_proc_entry("buffersize", privptr->proc_dentry);
remove_proc_entry("username", privptr->proc_dentry);
remove_proc_entry(privptr->proc_dentry->name, netiucv_dir);
-#else
- proc_unregister(privptr->proc_dentry,
- privptr->proc_stat_entry->low_ino);
- proc_unregister(privptr->proc_dentry,
- privptr->proc_buffer_entry->low_ino);
- proc_unregister(privptr->proc_dentry,
- privptr->proc_user_entry->low_ino);
- proc_unregister(&netiucv_dir,
- privptr->proc_dentry->low_ino);
-#endif
privptr->proc_registered = 0;
}
\f
netiucv_priv *privptr;
int priv_size;
- net_device *dev = kmalloc(sizeof(net_device)
-#if LINUX_VERSION_CODE < 0x020300
- + 11 /* name + zero */
-#endif
- , GFP_KERNEL);
+ net_device *dev = kmalloc(sizeof(net_device), GFP_KERNEL);
if (!dev)
return NULL;
memset(dev, 0, sizeof(net_device));
-#if LINUX_VERSION_CODE < 0x020300
- dev->name = (char *)dev + sizeof(net_device);
-#endif
sprintf(dev->name, "iucv%d", ifno);
- priv_size = sizeof(netiucv_priv) + sizeof(netiucv_template) +
- sizeof(stat_entry) + sizeof(buffer_entry) + sizeof(user_entry);
+ priv_size = sizeof(netiucv_priv);
dev->priv = kmalloc(priv_size, GFP_KERNEL);
if (dev->priv == NULL) {
kfree(dev);
}
memset(dev->priv, 0, priv_size);
privptr = (netiucv_priv *)dev->priv;
- privptr->proc_dentry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(netiucv_priv));
- privptr->proc_stat_entry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(netiucv_priv) +
- sizeof(netiucv_template));
- privptr->proc_buffer_entry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(netiucv_priv) +
- sizeof(netiucv_template) + sizeof(stat_entry));
- privptr->proc_user_entry = (struct proc_dir_entry *)
- (((char *)privptr) + sizeof(netiucv_priv) +
- sizeof(netiucv_template) + sizeof(stat_entry) +
- sizeof(buffer_entry));
- memcpy(privptr->proc_dentry, &netiucv_template,
- sizeof(netiucv_template));
- memcpy(privptr->proc_stat_entry, &stat_entry, sizeof(stat_entry));
- memcpy(privptr->proc_buffer_entry, &buffer_entry, sizeof(buffer_entry));
- memcpy(privptr->proc_user_entry, &user_entry, sizeof(user_entry));
privptr->fsm = init_fsm("netiucvdev", dev_state_names,
dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
}
#ifndef MODULE
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
# define init_return(a) return a
static int __init
iucv_setup(char *param)
-# else
-# define init_return(a) return
-__initfunc (void iucv_setup(char *param, int *ints))
-# endif
{
/**
* We do not parse parameters here because at the time of
init_return(1);
}
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
__setup ("iucv=", iucv_setup);
-# endif
#else
static void
netiucv_exit(void)
int proc_match(int len, const char *name,struct proc_dir_entry * de)
{
- if (!de || !de->low_ino)
- return 0;
if (de->namelen != len)
return 0;
return !memcmp(name, de->name, len);
de = PDE(dir);
if (de) {
for (de = de->subdir; de ; de = de->next) {
- if (!de || !de->low_ino)
- continue;
if (de->namelen != dentry->d_name.len)
continue;
if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {