mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-21 19:51:45 +00:00
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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@22 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
01bb2de024
commit
cbf518d36e
11 files changed
+73
-87
No files matched your search
@@ -1,6 +1,8 @@
|
||||
Many, many things. Most notably:
|
||||
|
||||
* 2.1 kernel tests; at this moment, only 2.0 compiles have been tried.
|
||||
* Change the i2c modules to keep the namespace clean (EXPORT_SYMBOL does not
|
||||
work for us; many static declarations need to be added; better ask Simon
|
||||
Vogl first)
|
||||
* Make it SMP-safe: there are no spinlocks yet. They are needed at many
|
||||
places, probably (everywhere where global vars are accessed).
|
||||
* Extend sensors.c with a file /proc/sys/dev/sensors/chips, which lists
|
||||
@@ -10,6 +12,8 @@ Many, many things. Most notably:
|
||||
* Write piix4_* in piix4.c
|
||||
* Make lm78.c detect 'double hits', (same chip connected to both SMBus and
|
||||
ISA).
|
||||
* Better lm78 detection; insmod-time paramters to set addresses (difficult,
|
||||
because of all i2c busses!).
|
||||
* Check whether some lm78 functionality is chip-generic and can be moved to
|
||||
sensors.c.
|
||||
* Rename i2c-proc.c to i2c-user.c, and extend it with /dev entries;
|
||||
|
||||
+2
-3
@@ -27,8 +27,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
/* When exactly was the new pci interface introduced? */
|
||||
#if LINUX_VERSION_CODE < 0x020100
|
||||
#if LINUX_VERSION_CODE < 0x020136 /* 2.1.54 */
|
||||
#include <linux/bios32.h>
|
||||
#endif
|
||||
|
||||
@@ -128,7 +127,7 @@ static void bit_mb_exit(void)
|
||||
}
|
||||
|
||||
/* When exactly was the new pci interface introduced? */
|
||||
#if LINUX_VERSION_CODE >= 0x020100
|
||||
#if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */
|
||||
|
||||
static u32 find_i2c(void)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* Note: New PCI (non-BIOS) interface introduced in 2.1.54! */
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/stddef.h>
|
||||
#include "smbus.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
+4
-7
@@ -37,18 +37,15 @@
|
||||
#endif
|
||||
#endif /* def MODULE */
|
||||
|
||||
/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels; perhaps in
|
||||
some early 2.1 kernels too? */
|
||||
/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels
|
||||
get_user was redefined in 2.1 kernels to use two arguments, and returns
|
||||
an error code */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4))
|
||||
#define copy_from_user memcpy_fromfs
|
||||
#define copy_to_user memcpy_tofs
|
||||
#endif
|
||||
|
||||
/* get_user was redefined in 2.1 kernels to use two arguments, and returns
|
||||
an error code */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4))
|
||||
#define get_user_data(to,from) ((to) = get_user(from),0)
|
||||
#else
|
||||
#include <asm/uaccess.h>
|
||||
#define get_user_data(to,from) get_user(to,from)
|
||||
#endif
|
||||
|
||||
|
||||
+23
-31
@@ -40,31 +40,18 @@ static int i2cproc_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void i2cproc_inc_use(struct i2c_client *client);
|
||||
static void i2cproc_dec_use(struct i2c_client *client);
|
||||
static int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf,
|
||||
int count);
|
||||
|
||||
/* To implement the dynamic /proc/bus/i2c-? files, we need our own
|
||||
implementation of the read hook */
|
||||
static struct file_operations i2cproc_operations = {
|
||||
NULL,
|
||||
i2cproc_bus_read,
|
||||
};
|
||||
|
||||
static struct inode_operations i2cproc_inode_operations = {
|
||||
&i2cproc_operations
|
||||
};
|
||||
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
|
||||
static int i2proc_bus_read(char *buf, char **start, off_t offset, int len,
|
||||
static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
|
||||
loff_t *ppos);
|
||||
static int read_bus_i2c(char *buf, char **start, off_t offset, int len,
|
||||
int *eof , void *private);
|
||||
ssize_t array_read(struct file * file, char * buf,size_t count, loff_t *ppos);
|
||||
|
||||
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
|
||||
|
||||
int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf,
|
||||
int count);
|
||||
static int i2cproc_bus_read(struct inode * inode, struct file * file,
|
||||
char * buf, int count);
|
||||
static int read_bus_i2c(char *buf, char **start, off_t offset, int len,
|
||||
int unused);
|
||||
|
||||
@@ -100,6 +87,18 @@ static struct proc_dir_entry *i2cproc_proc_entries[I2C_ADAP_MAX];
|
||||
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */
|
||||
|
||||
/* To implement the dynamic /proc/bus/i2c-? files, we need our own
|
||||
implementation of the read hook */
|
||||
static struct file_operations i2cproc_operations = {
|
||||
NULL,
|
||||
i2cproc_bus_read,
|
||||
};
|
||||
|
||||
static struct inode_operations i2cproc_inode_operations = {
|
||||
&i2cproc_operations
|
||||
};
|
||||
|
||||
|
||||
/* Used by init/cleanup */
|
||||
static int i2cproc_initialized;
|
||||
|
||||
@@ -202,10 +201,7 @@ int i2cproc_cleanup(void)
|
||||
}
|
||||
if (i2cproc_initialized >= 1) {
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
if ((res = remove_proc_entry("i2c",proc_bus))) {
|
||||
printk("i2c-proc.o: could not delete /proc/bus/i2c, module not removed.");
|
||||
return res;
|
||||
}
|
||||
remove_proc_entry("i2c",proc_bus);
|
||||
i2cproc_initialized -= 2;
|
||||
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
|
||||
if (i2cproc_initialized >= 2) {
|
||||
@@ -252,7 +248,8 @@ int read_bus_i2c(char *buf, char **start, off_t offset, int len, int unused)
|
||||
|
||||
/* This function generates the output for /proc/bus/i2c-? */
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
ssize_t i2cproc_read(struct file * file, char * buf,size_t count, loff_t *ppos)
|
||||
ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct inode * inode = file->f_dentry->d_inode;
|
||||
#else (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29))
|
||||
@@ -290,7 +287,7 @@ int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf,
|
||||
len = len - file->f_pos;
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
memcpy_tofs(buf,kbuf+file->f_pos,len);
|
||||
copy_to_user (buf,kbuf+file->f_pos,len);
|
||||
file->f_pos += len;
|
||||
kfree(kbuf);
|
||||
return len;
|
||||
@@ -346,8 +343,7 @@ int i2cproc_attach_adapter(struct i2c_adapter *adapter)
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
proc_entry = create_proc_entry(name,0,proc_bus);
|
||||
if (! proc_entry)
|
||||
else {
|
||||
if (! proc_entry) {
|
||||
printk("i2c-proc.o: Could not create /proc/bus/%s\n",name);
|
||||
kfree(client);
|
||||
return -ENOENT;
|
||||
@@ -398,11 +394,7 @@ int i2cproc_detach_client(struct i2c_client *client)
|
||||
if (client->adapter == i2cproc_adapters[i]) {
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
sprintf(name,"i2c-%d",i);
|
||||
if ((res = remove_proc_entry(name,proc_bus))) {
|
||||
printk("i2c-proc.o: Deregistration of /proc entry failed, "
|
||||
"client not detached.\n");
|
||||
return res;
|
||||
}
|
||||
remove_proc_entry(name,proc_bus);
|
||||
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
|
||||
if ((res = proc_unregister(&proc_bus_dir,
|
||||
i2cproc_proc_entries[i]->low_ino))) {
|
||||
|
||||
@@ -37,18 +37,15 @@
|
||||
#endif
|
||||
#endif /* def MODULE */
|
||||
|
||||
/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels; perhaps in
|
||||
some early 2.1 kernels too? */
|
||||
/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels
|
||||
get_user was redefined in 2.1 kernels to use two arguments, and returns
|
||||
an error code */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4))
|
||||
#define copy_from_user memcpy_fromfs
|
||||
#define copy_to_user memcpy_tofs
|
||||
#endif
|
||||
|
||||
/* get_user was redefined in 2.1 kernels to use two arguments, and returns
|
||||
an error code */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4))
|
||||
#define get_user_data(to,from) ((to) = get_user(from),0)
|
||||
#else
|
||||
#include <asm/uaccess.h>
|
||||
#define get_user_data(to,from) get_user(to,from)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "i2c.h"
|
||||
#ifdef SPINLOCK
|
||||
|
||||
+4
-7
@@ -37,18 +37,15 @@
|
||||
#endif
|
||||
#endif /* def MODULE */
|
||||
|
||||
/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels; perhaps in
|
||||
some early 2.1 kernels too? */
|
||||
/* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels
|
||||
get_user was redefined in 2.1 kernels to use two arguments, and returns
|
||||
an error code */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4))
|
||||
#define copy_from_user memcpy_fromfs
|
||||
#define copy_to_user memcpy_tofs
|
||||
#endif
|
||||
|
||||
/* get_user was redefined in 2.1 kernels to use two arguments, and returns
|
||||
an error code */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4))
|
||||
#define get_user_data(to,from) ((to) = get_user(from),0)
|
||||
#else
|
||||
#include <asm/uaccess.h>
|
||||
#define get_user_data(to,from) get_user(to,from)
|
||||
#endif
|
||||
|
||||
|
||||
+23
-31
@@ -40,31 +40,18 @@ static int i2cproc_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void i2cproc_inc_use(struct i2c_client *client);
|
||||
static void i2cproc_dec_use(struct i2c_client *client);
|
||||
static int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf,
|
||||
int count);
|
||||
|
||||
/* To implement the dynamic /proc/bus/i2c-? files, we need our own
|
||||
implementation of the read hook */
|
||||
static struct file_operations i2cproc_operations = {
|
||||
NULL,
|
||||
i2cproc_bus_read,
|
||||
};
|
||||
|
||||
static struct inode_operations i2cproc_inode_operations = {
|
||||
&i2cproc_operations
|
||||
};
|
||||
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
|
||||
static int i2proc_bus_read(char *buf, char **start, off_t offset, int len,
|
||||
static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
|
||||
loff_t *ppos);
|
||||
static int read_bus_i2c(char *buf, char **start, off_t offset, int len,
|
||||
int *eof , void *private);
|
||||
ssize_t array_read(struct file * file, char * buf,size_t count, loff_t *ppos);
|
||||
|
||||
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
|
||||
|
||||
int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf,
|
||||
int count);
|
||||
static int i2cproc_bus_read(struct inode * inode, struct file * file,
|
||||
char * buf, int count);
|
||||
static int read_bus_i2c(char *buf, char **start, off_t offset, int len,
|
||||
int unused);
|
||||
|
||||
@@ -100,6 +87,18 @@ static struct proc_dir_entry *i2cproc_proc_entries[I2C_ADAP_MAX];
|
||||
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */
|
||||
|
||||
/* To implement the dynamic /proc/bus/i2c-? files, we need our own
|
||||
implementation of the read hook */
|
||||
static struct file_operations i2cproc_operations = {
|
||||
NULL,
|
||||
i2cproc_bus_read,
|
||||
};
|
||||
|
||||
static struct inode_operations i2cproc_inode_operations = {
|
||||
&i2cproc_operations
|
||||
};
|
||||
|
||||
|
||||
/* Used by init/cleanup */
|
||||
static int i2cproc_initialized;
|
||||
|
||||
@@ -202,10 +201,7 @@ int i2cproc_cleanup(void)
|
||||
}
|
||||
if (i2cproc_initialized >= 1) {
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
if ((res = remove_proc_entry("i2c",proc_bus))) {
|
||||
printk("i2c-proc.o: could not delete /proc/bus/i2c, module not removed.");
|
||||
return res;
|
||||
}
|
||||
remove_proc_entry("i2c",proc_bus);
|
||||
i2cproc_initialized -= 2;
|
||||
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
|
||||
if (i2cproc_initialized >= 2) {
|
||||
@@ -252,7 +248,8 @@ int read_bus_i2c(char *buf, char **start, off_t offset, int len, int unused)
|
||||
|
||||
/* This function generates the output for /proc/bus/i2c-? */
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
ssize_t i2cproc_read(struct file * file, char * buf,size_t count, loff_t *ppos)
|
||||
ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct inode * inode = file->f_dentry->d_inode;
|
||||
#else (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29))
|
||||
@@ -290,7 +287,7 @@ int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf,
|
||||
len = len - file->f_pos;
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
memcpy_tofs(buf,kbuf+file->f_pos,len);
|
||||
copy_to_user (buf,kbuf+file->f_pos,len);
|
||||
file->f_pos += len;
|
||||
kfree(kbuf);
|
||||
return len;
|
||||
@@ -346,8 +343,7 @@ int i2cproc_attach_adapter(struct i2c_adapter *adapter)
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
proc_entry = create_proc_entry(name,0,proc_bus);
|
||||
if (! proc_entry)
|
||||
else {
|
||||
if (! proc_entry) {
|
||||
printk("i2c-proc.o: Could not create /proc/bus/%s\n",name);
|
||||
kfree(client);
|
||||
return -ENOENT;
|
||||
@@ -398,11 +394,7 @@ int i2cproc_detach_client(struct i2c_client *client)
|
||||
if (client->adapter == i2cproc_adapters[i]) {
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29))
|
||||
sprintf(name,"i2c-%d",i);
|
||||
if ((res = remove_proc_entry(name,proc_bus))) {
|
||||
printk("i2c-proc.o: Deregistration of /proc entry failed, "
|
||||
"client not detached.\n");
|
||||
return res;
|
||||
}
|
||||
remove_proc_entry(name,proc_bus);
|
||||
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */
|
||||
if ((res = proc_unregister(&proc_bus_dir,
|
||||
i2cproc_proc_entries[i]->low_ino))) {
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* Note: New PCI (non-BIOS) interface introduced in 2.1.54! */
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/stddef.h>
|
||||
#include "smbus.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "i2c.h"
|
||||
#ifdef SPINLOCK
|
||||
|
||||
Reference in new issue
Block a user