Changeset 46

Show
Ignore:
Timestamp:
12/07/98 23:15:49 (14 years ago)
Author:
frodo
Message:

Module use count fix

This fix will only work for kernels >= 2.1.58.

* lm75, lm78: {INC,DEC}_MOD_USE_COUNT called for {inc,dec}_mod_use hooks
* sensors: For new kernels, fill_inode is called, which in turn calls

{inc,dec}_mod_use for a certain client

Location:
lm-sensors/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/lm75.c

    r40 r46  
    222222void lm75_inc_use (struct i2c_client *client) 
    223223{ 
     224#ifdef MODULE 
     225  MOD_INC_USE_COUNT; 
     226#endif 
    224227} 
    225228 
     
    227230void lm75_dec_use (struct i2c_client *client) 
    228231{ 
     232#ifdef MODULE 
     233  MOD_DEC_USE_COUNT; 
     234#endif 
    229235} 
    230236 
  • lm-sensors/trunk/kernel/chips/lm78.c

    r36 r46  
    584584void lm78_inc_use (struct i2c_client *client) 
    585585{ 
     586#ifdef MODULE 
     587  MOD_INC_USE_COUNT; 
     588#endif 
    586589} 
    587590 
     
    589592void lm78_dec_use (struct i2c_client *client) 
    590593{ 
     594#ifdef MODULE 
     595  MOD_DEC_USE_COUNT; 
     596#endif 
    591597} 
    592598  
  • lm-sensors/trunk/kernel/i2c-proc.c

    r43 r46  
    436436} 
    437437 
    438  
    439438#ifdef MODULE 
    440439 
  • lm-sensors/trunk/kernel/sensors.c

    r39 r46  
    2222#include <linux/ctype.h> 
    2323#include <linux/sysctl.h> 
     24#include <linux/proc_fs.h> 
    2425 
    2526#include "version.h" 
     
    4748#define SENSORS_ENTRY_MAX 20 
    4849static struct ctl_table_header *sensors_entries[SENSORS_ENTRY_MAX]; 
     50 
     51#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     52static struct i2c_client *sensors_clients[SENSORS_ENTRY_MAX]; 
     53static unsigned short sensors_inodes[SENSORS_ENTRY_MAX]; 
     54void sensors_fill_inode(struct inode *inode, int fill); 
     55#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 
    4956 
    5057static ctl_table sysctl_table[] = { 
     
    136143  sensors_entries[id-256] = new_header; 
    137144 
     145#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     146  sensors_clients[id-256] = client; 
     147#ifdef DEBUG 
     148  if (!new_header || !new_header->ctl_table ||  
     149      !new_header->ctl_table->child ||  
     150      !new_header->ctl_table->child->child || 
     151      !new_header->ctl_table->child->child->de) { 
     152    printk("sensors.o: NULL pointer when trying to install fill_inode fix!\n"); 
     153    return id;   
     154  } 
     155#endif /* DEBUG */ 
     156  sensors_inodes[id-256] = new_header->ctl_table->child->child->de->low_ino; 
     157  new_header->ctl_table->child->child->de->fill_inode = &sensors_fill_inode; 
     158#endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     159 
    138160  return id; 
    139161} 
     
    148170    kfree((void *) (table[4].procname)); 
    149171    kfree(table); 
    150     sensors_entries[id] = 0; 
    151   } 
    152 } 
     172    sensors_entries[id] = NULL; 
     173#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     174    sensors_clients[id-256] = NULL; 
     175#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 
     176  } 
     177} 
     178 
     179#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     180void sensors_fill_inode(struct inode *inode, int fill) 
     181{ 
     182  int i; 
     183  struct i2c_client *client; 
     184 
     185#ifdef DEBUG 
     186  if (! inode) { 
     187    printk("sensors.o: Warning: inode NULL in fill_inode()\n"); 
     188    return; 
     189  } 
     190#endif /* def DEBUG */ 
     191   
     192  for (i = 0; i < SENSORS_ENTRY_MAX; i++)  
     193    if (sensors_clients[i] && (sensors_inodes[i] == inode->i_ino)) 
     194      break; 
     195#ifdef DEBUG 
     196  if (i == SENSORS_ENTRY_MAX) { 
     197    printk("sensors.o: Warning: inode (%ld) not found in fill_inode()\n", 
     198           inode->i_ino); 
     199    return; 
     200  } 
     201#endif /* def DEBUG */ 
     202  client = sensors_clients[i]; 
     203  if (fill) 
     204    client->driver->inc_use(client); 
     205  else 
     206    client->driver->dec_use(client); 
     207} 
     208#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 
    153209 
    154210/* This funcion reads or writes a 'real' value (encoded by the combination 
  • lm-sensors/trunk/src/i2c-proc.c

    r43 r46  
    436436} 
    437437 
    438  
    439438#ifdef MODULE 
    440439 
  • lm-sensors/trunk/src/lm75.c

    r40 r46  
    222222void lm75_inc_use (struct i2c_client *client) 
    223223{ 
     224#ifdef MODULE 
     225  MOD_INC_USE_COUNT; 
     226#endif 
    224227} 
    225228 
     
    227230void lm75_dec_use (struct i2c_client *client) 
    228231{ 
     232#ifdef MODULE 
     233  MOD_DEC_USE_COUNT; 
     234#endif 
    229235} 
    230236 
  • lm-sensors/trunk/src/lm78.c

    r36 r46  
    584584void lm78_inc_use (struct i2c_client *client) 
    585585{ 
     586#ifdef MODULE 
     587  MOD_INC_USE_COUNT; 
     588#endif 
    586589} 
    587590 
     
    589592void lm78_dec_use (struct i2c_client *client) 
    590593{ 
     594#ifdef MODULE 
     595  MOD_DEC_USE_COUNT; 
     596#endif 
    591597} 
    592598  
  • lm-sensors/trunk/src/sensors.c

    r39 r46  
    2222#include <linux/ctype.h> 
    2323#include <linux/sysctl.h> 
     24#include <linux/proc_fs.h> 
    2425 
    2526#include "version.h" 
     
    4748#define SENSORS_ENTRY_MAX 20 
    4849static struct ctl_table_header *sensors_entries[SENSORS_ENTRY_MAX]; 
     50 
     51#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     52static struct i2c_client *sensors_clients[SENSORS_ENTRY_MAX]; 
     53static unsigned short sensors_inodes[SENSORS_ENTRY_MAX]; 
     54void sensors_fill_inode(struct inode *inode, int fill); 
     55#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 
    4956 
    5057static ctl_table sysctl_table[] = { 
     
    136143  sensors_entries[id-256] = new_header; 
    137144 
     145#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     146  sensors_clients[id-256] = client; 
     147#ifdef DEBUG 
     148  if (!new_header || !new_header->ctl_table ||  
     149      !new_header->ctl_table->child ||  
     150      !new_header->ctl_table->child->child || 
     151      !new_header->ctl_table->child->child->de) { 
     152    printk("sensors.o: NULL pointer when trying to install fill_inode fix!\n"); 
     153    return id;   
     154  } 
     155#endif /* DEBUG */ 
     156  sensors_inodes[id-256] = new_header->ctl_table->child->child->de->low_ino; 
     157  new_header->ctl_table->child->child->de->fill_inode = &sensors_fill_inode; 
     158#endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     159 
    138160  return id; 
    139161} 
     
    148170    kfree((void *) (table[4].procname)); 
    149171    kfree(table); 
    150     sensors_entries[id] = 0; 
    151   } 
    152 } 
     172    sensors_entries[id] = NULL; 
     173#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     174    sensors_clients[id-256] = NULL; 
     175#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 
     176  } 
     177} 
     178 
     179#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) 
     180void sensors_fill_inode(struct inode *inode, int fill) 
     181{ 
     182  int i; 
     183  struct i2c_client *client; 
     184 
     185#ifdef DEBUG 
     186  if (! inode) { 
     187    printk("sensors.o: Warning: inode NULL in fill_inode()\n"); 
     188    return; 
     189  } 
     190#endif /* def DEBUG */ 
     191   
     192  for (i = 0; i < SENSORS_ENTRY_MAX; i++)  
     193    if (sensors_clients[i] && (sensors_inodes[i] == inode->i_ino)) 
     194      break; 
     195#ifdef DEBUG 
     196  if (i == SENSORS_ENTRY_MAX) { 
     197    printk("sensors.o: Warning: inode (%ld) not found in fill_inode()\n", 
     198           inode->i_ino); 
     199    return; 
     200  } 
     201#endif /* def DEBUG */ 
     202  client = sensors_clients[i]; 
     203  if (fill) 
     204    client->driver->inc_use(client); 
     205  else 
     206    client->driver->dec_use(client); 
     207} 
     208#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 
    153209 
    154210/* This funcion reads or writes a 'real' value (encoded by the combination