2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

Module use count trick expanded to all files and directories

Also fixed a minor Makefile typo.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@55 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Frodo Looijaard
1998-12-09 15:11:32 +00:00
parent 15fd94984f
commit 0e8799ff27
6 changed files with 85 additions and 7 deletions

2
TODO
View File

@@ -14,8 +14,6 @@ Many, many things. Most notably:
* Make it SMP-safe: there are no spinlocks yet. They are needed at many
places, probably (everywhere where global vars are accessed). This must be
done for the i2c modules, too.
* Extend the mod_inc_use/mod_dec_use through the fill_inode trick, for all
new /proc files.
* Make lm78.c detect 'double hits', (same chip connected to both SMBus and
ISA).
* Better lm78/lm75 detection; insmod-time paramters to set addresses

View File

@@ -35,6 +35,6 @@ all :: all-i2c-eeprom
# No install rule
clean-i2c-eeprom:
$(RM) $(I2CEEPROMSOURCES:.c=.d) $(I2CEEPROMSOURCES:.c=.o) \
$(RM) $(I2CEEPROMSOURCES:.c=.rd) $(I2CEEPROMSOURCES:.c=.ro) \
$(I2CEEPROMTARGETS)
clean :: clean-i2c-eeprom

View File

@@ -41,6 +41,10 @@ static int i2cproc_command(struct i2c_client *client, unsigned int cmd,
static void i2cproc_inc_use(struct i2c_client *client);
static void i2cproc_dec_use(struct i2c_client *client);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
static void monitor_bus_i2c(struct inode *inode, int fill);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
@@ -80,6 +84,9 @@ static struct proc_dir_entry proc_bus_i2c_dir =
/* size */ 0,
/* ops */ NULL,
/* get_info */ &read_bus_i2c
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
/* fill_inode */ &monitor_bus_i2c
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
};
/* List of registered entries in /proc/bus */
@@ -223,6 +230,19 @@ int i2cproc_cleanup(void)
return 0;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
/* Monitor access to /proc/bus/i2c*; make unloading i2c-proc.o impossible
if some process still uses it or some file in it */
void monitor_bus_i2c(struct inode *inode, int fill)
{
if (fill)
MOD_INC_USE_COUNT;
else
MOD_DEC_USE_COUNT;
}
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
/* This function generates the output for /proc/bus/i2c */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
int read_bus_i2c(char *buf, char **start, off_t offset, int len, int *eof,
@@ -349,6 +369,9 @@ int i2cproc_attach_adapter(struct i2c_adapter *adapter)
return -ENOENT;
}
proc_entry->ops = &i2cproc_inode_operations;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
proc_entry->fill_inode = &monitor_bus_i2c;
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
if (!(proc_entry = kmalloc(sizeof(struct proc_dir_entry)+strlen(name)+1,
GFP_KERNEL))) {

View File

@@ -56,7 +56,8 @@ 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];
void sensors_fill_inode(struct inode *inode, int fill);
static void sensors_fill_inode(struct inode *inode, int fill);
static void sensors_dir_fill_inode(struct inode *inode, int fill);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
static ctl_table sysctl_table[] = {
@@ -180,7 +181,7 @@ 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;
new_header->ctl_table->child->child->de->fill_inode = &sensors_fill_inode;
new_header->ctl_table->child->child->de->fill_inode = &sensors_dir_fill_inode;
#endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
return id;
@@ -203,7 +204,20 @@ void sensors_deregister_entry(int id)
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
/* Monitor access for /proc/sys/dev/sensors; make unloading sensors.o
impossible if some process still uses it or some file in it */
void sensors_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 sensors_dir_fill_inode(struct inode *inode, int fill)
{
int i;
struct i2c_client *client;
@@ -567,6 +581,9 @@ int 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))
sensors_proc_header->ctl_table->child->de->fill_inode = &sensors_fill_inode;
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
sensors_initialized ++;
return 0;
}

View File

@@ -41,6 +41,10 @@ static int i2cproc_command(struct i2c_client *client, unsigned int cmd,
static void i2cproc_inc_use(struct i2c_client *client);
static void i2cproc_dec_use(struct i2c_client *client);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
static void monitor_bus_i2c(struct inode *inode, int fill);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
@@ -80,6 +84,9 @@ static struct proc_dir_entry proc_bus_i2c_dir =
/* size */ 0,
/* ops */ NULL,
/* get_info */ &read_bus_i2c
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
/* fill_inode */ &monitor_bus_i2c
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
};
/* List of registered entries in /proc/bus */
@@ -223,6 +230,19 @@ int i2cproc_cleanup(void)
return 0;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
/* Monitor access to /proc/bus/i2c*; make unloading i2c-proc.o impossible
if some process still uses it or some file in it */
void monitor_bus_i2c(struct inode *inode, int fill)
{
if (fill)
MOD_INC_USE_COUNT;
else
MOD_DEC_USE_COUNT;
}
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
/* This function generates the output for /proc/bus/i2c */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
int read_bus_i2c(char *buf, char **start, off_t offset, int len, int *eof,
@@ -349,6 +369,9 @@ int i2cproc_attach_adapter(struct i2c_adapter *adapter)
return -ENOENT;
}
proc_entry->ops = &i2cproc_inode_operations;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
proc_entry->fill_inode = &monitor_bus_i2c;
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
if (!(proc_entry = kmalloc(sizeof(struct proc_dir_entry)+strlen(name)+1,
GFP_KERNEL))) {

View File

@@ -56,7 +56,8 @@ 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];
void sensors_fill_inode(struct inode *inode, int fill);
static void sensors_fill_inode(struct inode *inode, int fill);
static void sensors_dir_fill_inode(struct inode *inode, int fill);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
static ctl_table sysctl_table[] = {
@@ -180,7 +181,7 @@ 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;
new_header->ctl_table->child->child->de->fill_inode = &sensors_fill_inode;
new_header->ctl_table->child->child->de->fill_inode = &sensors_dir_fill_inode;
#endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
return id;
@@ -203,7 +204,20 @@ void sensors_deregister_entry(int id)
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58))
/* Monitor access for /proc/sys/dev/sensors; make unloading sensors.o
impossible if some process still uses it or some file in it */
void sensors_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 sensors_dir_fill_inode(struct inode *inode, int fill)
{
int i;
struct i2c_client *client;
@@ -567,6 +581,9 @@ int 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))
sensors_proc_header->ctl_table->child->de->fill_inode = &sensors_fill_inode;
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */
sensors_initialized ++;
return 0;
}