Changeset 22

Show
Ignore:
Timestamp:
12/02/98 18:25:53 (10 years ago)
Author:
frodo
Message:

Fixes to make code compile with 2.1 kernels

Everything now compiles cleanly (except for warnings in kernel header files)
against 2.1.122. As I do not run 2.1 kernels, loading them could not be
tested.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/TODO

    r20 r22  
    11Many, many things. Most notably: 
    22 
    3 * 2.1 kernel tests; at this moment, only 2.0 compiles have been tried. 
     3* Change the i2c modules to keep the namespace clean (EXPORT_SYMBOL does not 
     4  work for us; many static declarations need to be added; better ask Simon 
     5  Vogl first) 
    46* Make it SMP-safe: there are no spinlocks yet. They are needed at many 
    57  places, probably (everywhere where global vars are accessed). 
     
    1113* Make lm78.c detect 'double hits', (same chip connected to both SMBus and 
    1214  ISA). 
     15* Better lm78 detection; insmod-time paramters to set addresses (difficult, 
     16  because of all i2c busses!). 
    1317* Check whether some lm78 functionality is chip-generic and can be moved to 
    1418  sensors.c. 
  • lm-sensors/trunk/i2c/bit-mb.c

    r4 r22  
    2828#include <linux/version.h> 
    2929 
    30 /* When exactly was the new pci interface introduced? */ 
    31 #if LINUX_VERSION_CODE < 0x020100 
     30#if LINUX_VERSION_CODE < 0x020136 /* 2.1.54 */ 
    3231#include <linux/bios32.h> 
    3332#endif 
     
    129128 
    130129/* When exactly was the new pci interface introduced? */ 
    131 #if LINUX_VERSION_CODE >= 0x020100 
     130#if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */ 
    132131 
    133132static u32 find_i2c(void) 
  • lm-sensors/trunk/kernel/busses/i2c-piix4.c

    r15 r22  
    1818*/ 
    1919 
     20/* Note: New PCI (non-BIOS) interface introduced in 2.1.54! */ 
     21 
    2022#include <linux/module.h> 
    2123#include <linux/kernel.h> 
     24#include <linux/stddef.h> 
    2225#include "smbus.h" 
    2326#include "version.h" 
  • lm-sensors/trunk/kernel/compat.h

    r19 r22  
    3838#endif /* def MODULE */ 
    3939 
    40 /* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels; perhaps in 
    41    some early 2.1 kernels too? */ 
     40/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels  
     41   get_user was redefined in 2.1 kernels to use two arguments, and returns 
     42   an error code */ 
    4243#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) 
    4344#define copy_from_user memcpy_fromfs 
    4445#define copy_to_user memcpy_tofs 
    45 #endif 
    46  
    47 /* get_user was redefined in 2.1 kernels to use two arguments, and returns 
    48    an error code */ 
    49 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) 
    5046#define get_user_data(to,from) ((to) = get_user(from),0) 
    5147#else 
     48#include <asm/uaccess.h> 
    5249#define get_user_data(to,from) get_user(to,from) 
    5350#endif 
  • lm-sensors/trunk/kernel/i2c-proc.c

    r18 r22  
    4141static void i2cproc_inc_use(struct i2c_client *client); 
    4242static void i2cproc_dec_use(struct i2c_client *client); 
    43 static int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 
    44                             int count); 
    45  
    46 /* To implement the dynamic /proc/bus/i2c-? files, we need our own  
    47    implementation of the read hook */ 
    48 static struct file_operations i2cproc_operations = { 
    49         NULL, 
    50         i2cproc_bus_read, 
    51 }; 
    52  
    53 static struct inode_operations i2cproc_inode_operations = { 
    54         &i2cproc_operations 
    55 }; 
    56  
    57  
    58 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    59  
    60 static int i2proc_bus_read(char *buf, char **start, off_t offset, int len, 
     43 
     44#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
     45 
     46static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,  
     47                                loff_t *ppos); 
     48static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 
    6149                           int *eof , void *private); 
    62 ssize_t array_read(struct file * file, char * buf,size_t count, loff_t *ppos); 
    63  
    64 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
    65  
    66 int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 
    67                      int count); 
     50 
     51#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
     52 
     53static int i2cproc_bus_read(struct inode * inode, struct file * file, 
     54                            char * buf, int count); 
    6855static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 
    6956                        int unused); 
     
    10087 
    10188#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ 
     89 
     90/* To implement the dynamic /proc/bus/i2c-? files, we need our own  
     91   implementation of the read hook */ 
     92static struct file_operations i2cproc_operations = { 
     93        NULL, 
     94        i2cproc_bus_read, 
     95}; 
     96 
     97static struct inode_operations i2cproc_inode_operations = { 
     98        &i2cproc_operations 
     99}; 
     100 
    102101 
    103102/* Used by init/cleanup */ 
     
    203202  if (i2cproc_initialized >= 1) { 
    204203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    205     if ((res = remove_proc_entry("i2c",proc_bus))) { 
    206       printk("i2c-proc.o: could not delete /proc/bus/i2c, module not removed."); 
    207       return res; 
    208     } 
     204    remove_proc_entry("i2c",proc_bus); 
    209205    i2cproc_initialized -= 2; 
    210206#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
     
    253249/* This function generates the output for /proc/bus/i2c-? */ 
    254250#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    255 ssize_t i2cproc_read(struct file * file, char * buf,size_t count, loff_t *ppos) 
     251ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,  
     252                         loff_t *ppos) 
    256253{ 
    257254  struct inode * inode = file->f_dentry->d_inode; 
     
    291288      if (len < 0)  
    292289        len = 0; 
    293       memcpy_tofs(buf,kbuf+file->f_pos,len); 
     290      copy_to_user (buf,kbuf+file->f_pos,len); 
    294291      file->f_pos += len; 
    295292      kfree(kbuf); 
     
    347344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    348345  proc_entry = create_proc_entry(name,0,proc_bus); 
    349   if (! proc_entry) 
    350   else { 
     346  if (! proc_entry) { 
    351347    printk("i2c-proc.o: Could not create /proc/bus/%s\n",name); 
    352348    kfree(client); 
     
    399395#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    400396      sprintf(name,"i2c-%d",i); 
    401       if ((res = remove_proc_entry(name,proc_bus))) { 
    402         printk("i2c-proc.o: Deregistration of /proc entry failed, " 
    403                "client not detached.\n"); 
    404         return res; 
    405       } 
     397      remove_proc_entry(name,proc_bus); 
    406398#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
    407399      if ((res = proc_unregister(&proc_bus_dir, 
  • lm-sensors/trunk/kernel/include/compat.h

    r19 r22  
    3838#endif /* def MODULE */ 
    3939 
    40 /* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels; perhaps in 
    41    some early 2.1 kernels too? */ 
     40/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels  
     41   get_user was redefined in 2.1 kernels to use two arguments, and returns 
     42   an error code */ 
    4243#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) 
    4344#define copy_from_user memcpy_fromfs 
    4445#define copy_to_user memcpy_tofs 
    45 #endif 
    46  
    47 /* get_user was redefined in 2.1 kernels to use two arguments, and returns 
    48    an error code */ 
    49 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) 
    5046#define get_user_data(to,from) ((to) = get_user(from),0) 
    5147#else 
     48#include <asm/uaccess.h> 
    5249#define get_user_data(to,from) get_user(to,from) 
    5350#endif 
  • lm-sensors/trunk/kernel/smbus.c

    r15 r22  
    2020#include <linux/module.h> 
    2121#include <linux/kernel.h> 
     22#include <linux/stddef.h> 
    2223 
    2324#include "i2c.h" 
  • lm-sensors/trunk/src/compat.h

    r19 r22  
    3838#endif /* def MODULE */ 
    3939 
    40 /* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels; perhaps in 
    41    some early 2.1 kernels too? */ 
     40/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels  
     41   get_user was redefined in 2.1 kernels to use two arguments, and returns 
     42   an error code */ 
    4243#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) 
    4344#define copy_from_user memcpy_fromfs 
    4445#define copy_to_user memcpy_tofs 
    45 #endif 
    46  
    47 /* get_user was redefined in 2.1 kernels to use two arguments, and returns 
    48    an error code */ 
    49 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) 
    5046#define get_user_data(to,from) ((to) = get_user(from),0) 
    5147#else 
     48#include <asm/uaccess.h> 
    5249#define get_user_data(to,from) get_user(to,from) 
    5350#endif 
  • lm-sensors/trunk/src/i2c-proc.c

    r18 r22  
    4141static void i2cproc_inc_use(struct i2c_client *client); 
    4242static void i2cproc_dec_use(struct i2c_client *client); 
    43 static int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 
    44                             int count); 
    45  
    46 /* To implement the dynamic /proc/bus/i2c-? files, we need our own  
    47    implementation of the read hook */ 
    48 static struct file_operations i2cproc_operations = { 
    49         NULL, 
    50         i2cproc_bus_read, 
    51 }; 
    52  
    53 static struct inode_operations i2cproc_inode_operations = { 
    54         &i2cproc_operations 
    55 }; 
    56  
    57  
    58 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    59  
    60 static int i2proc_bus_read(char *buf, char **start, off_t offset, int len, 
     43 
     44#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
     45 
     46static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,  
     47                                loff_t *ppos); 
     48static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 
    6149                           int *eof , void *private); 
    62 ssize_t array_read(struct file * file, char * buf,size_t count, loff_t *ppos); 
    63  
    64 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
    65  
    66 int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 
    67                      int count); 
     50 
     51#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
     52 
     53static int i2cproc_bus_read(struct inode * inode, struct file * file, 
     54                            char * buf, int count); 
    6855static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 
    6956                        int unused); 
     
    10087 
    10188#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ 
     89 
     90/* To implement the dynamic /proc/bus/i2c-? files, we need our own  
     91   implementation of the read hook */ 
     92static struct file_operations i2cproc_operations = { 
     93        NULL, 
     94        i2cproc_bus_read, 
     95}; 
     96 
     97static struct inode_operations i2cproc_inode_operations = { 
     98        &i2cproc_operations 
     99}; 
     100 
    102101 
    103102/* Used by init/cleanup */ 
     
    203202  if (i2cproc_initialized >= 1) { 
    204203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    205     if ((res = remove_proc_entry("i2c",proc_bus))) { 
    206       printk("i2c-proc.o: could not delete /proc/bus/i2c, module not removed."); 
    207       return res; 
    208     } 
     204    remove_proc_entry("i2c",proc_bus); 
    209205    i2cproc_initialized -= 2; 
    210206#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
     
    253249/* This function generates the output for /proc/bus/i2c-? */ 
    254250#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    255 ssize_t i2cproc_read(struct file * file, char * buf,size_t count, loff_t *ppos) 
     251ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,  
     252                         loff_t *ppos) 
    256253{ 
    257254  struct inode * inode = file->f_dentry->d_inode; 
     
    291288      if (len < 0)  
    292289        len = 0; 
    293       memcpy_tofs(buf,kbuf+file->f_pos,len); 
     290      copy_to_user (buf,kbuf+file->f_pos,len); 
    294291      file->f_pos += len; 
    295292      kfree(kbuf); 
     
    347344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    348345  proc_entry = create_proc_entry(name,0,proc_bus); 
    349   if (! proc_entry) 
    350   else { 
     346  if (! proc_entry) { 
    351347    printk("i2c-proc.o: Could not create /proc/bus/%s\n",name); 
    352348    kfree(client); 
     
    399395#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 
    400396      sprintf(name,"i2c-%d",i); 
    401       if ((res = remove_proc_entry(name,proc_bus))) { 
    402         printk("i2c-proc.o: Deregistration of /proc entry failed, " 
    403                "client not detached.\n"); 
    404         return res; 
    405       } 
     397      remove_proc_entry(name,proc_bus); 
    406398#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 
    407399      if ((res = proc_unregister(&proc_bus_dir, 
  • lm-sensors/trunk/src/piix4.c

    r15 r22  
    1818*/ 
    1919 
     20/* Note: New PCI (non-BIOS) interface introduced in 2.1.54! */ 
     21 
    2022#include <linux/module.h> 
    2123#include <linux/kernel.h> 
     24#include <linux/stddef.h> 
    2225#include "smbus.h" 
    2326#include "version.h" 
  • lm-sensors/trunk/src/smbus.c

    r15 r22  
    2020#include <linux/module.h> 
    2121#include <linux/kernel.h> 
     22#include <linux/stddef.h> 
    2223 
    2324#include "i2c.h"