Patches to make it compatible with kernel 2.3.27 and newer

* Improved monitoring of /proc directories
  Instead of doing:
         proc_bus_i2c->fill_inode = &monitor_bus_i2c;
         void monitor_bus_i2c(struct inode *inode, int fill)
         {
           if (fill)
             MOD_INC_USE_COUNT;
           else
             MOD_DEC_USE_COUNT;
         }
  you can now simply set:
         proc_bus_i2c->owner = THIS_MODULE;
  and this is just as good!
* An old 2.3 problem seemingly never was resolved yet: instead of using
  a *wait_queue directly, you have to use a wait_queue_head_t and
  initialize it properly:
         #if (LINUX_VERSION_CODE < 0x020301)
         static struct wait_queue *pcf_wait = NULL;
         #else
         static wait_queue_head_t pcf_wait;
         #endif

         #if (LINUX_VERSION_CODE >= 0x020301)
            init_waitqueue_head(&pcf_wait);
         #endif
  except for this, semantics remain the same (but using a plain
  wait_queue_head_t instead of a pointer to a wait_queue)
* I had to change the semantics of sensors_register_entry slightly,
  to make the monitoring of /proc/sys/dev/* files possible for kernels
  2.3.27 and newer. It now takes an additional parameter, which you
  can specify as THIS_MODULE.
* THIS_MODULE is only defined in kernels 2.3.13 and later; added
  it to compat.h and the compatibility section of mkpatch.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@640 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Frodo Looijaard committed 1999-11-30 20:48:43 +00:00
1 parent e3ff8f1660
commit 52b2ce8f52
18 files changed
+67 -24

No files matched your search

+17 -4
View File
@@ -63,8 +63,10 @@ static struct ctl_table_header *sensors_entries[SENSORS_ENTRY_MAX];
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
static struct i2c_client *sensors_clients[SENSORS_ENTRY_MAX];
static unsigned short sensors_inodes[SENSORS_ENTRY_MAX];
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
static void sensors_fill_inode(struct inode *inode, int fill);
static void sensors_dir_fill_inode(struct inode *inode, int fill);
#endif
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
static ctl_table sysctl_table[] = {
@@ -124,9 +126,14 @@ int sensors_create_name(char **name, const char *prefix,
ctl_template should be a template of the newly created directory. It is
copied in memory. The extra2 field of each file is set to point to client.
If any driver wants subdirectories within the newly created directory,
this function must be updated! */
this function must be updated!
controlling_mod is the controlling module. It should usually be
THIS_MODULE when calling. Note that this symbol is not defined in
kernels before 2.3.13; define it to NULL in that case. We will not use it
for anything older than 2.3.27 anyway. */
int sensors_register_entry(struct i2c_client *client ,const char *prefix,
ctl_table *ctl_template)
ctl_table *ctl_template,
struct module *controlling_mod)
{
int i,res,len,id;
ctl_table *new_table;
@@ -186,7 +193,11 @@ int sensors_register_entry(struct i2c_client *client ,const char *prefix,
}
#endif /* DEBUG */
sensors_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 = &sensors_dir_fill_inode;
#endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27))
#endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
return id;
@@ -759,9 +770,11 @@ int __init sensors_init(void)
sensors_initialized = 0;
if (! (sensors_proc_header = register_sysctl_table(sensors_proc,0)))
return -ENOMEM;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1))
sensors_proc_header->ctl_table->child->de->owner = THIS_MODULE;
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
sensors_proc_header->ctl_table->child->de->fill_inode = &sensors_fill_inode;
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1)) */
sensors_initialized ++;
return 0;
}