Commit 27b3d11b authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] more i2c cruft removal

* version code checks for pre-2.4 version
* !__KERNEL__ stuff in headers.
parent 3c363821
......@@ -61,11 +61,7 @@ static int own = 0;
static int i2c_debug=0;
static struct iic_ite gpi;
#if (LINUX_VERSION_CODE < 0x020301)
static struct wait_queue *iic_wait = NULL;
#else
static wait_queue_head_t iic_wait;
#endif
static int iic_pending;
/* ----- global defines ----------------------------------------------- */
......@@ -236,9 +232,7 @@ static int __init iic_ite_init(void)
piic->iic_own = own;
iic_ite_data.data = (void *)piic;
#if (LINUX_VERSION_CODE >= 0x020301)
init_waitqueue_head(&iic_wait);
#endif
if (iic_hw_resrc_init() == 0) {
if (i2c_iic_add_bus(&iic_ite_ops) < 0)
return -ENODEV;
......
......@@ -228,41 +228,25 @@ static void i2c_parport_detach (struct parport *port)
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4)
static struct parport_driver i2c_driver = {
"i2c-philips-par",
i2c_parport_attach,
i2c_parport_detach,
NULL
};
#endif
int __init i2c_bitlp_init(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,4)
struct parport *port;
#endif
printk(KERN_INFO "i2c-philips-par.o: i2c Philips parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4)
parport_register_driver(&i2c_driver);
#else
for (port = parport_enumerate(); port; port=port->next)
i2c_parport_attach(port);
#endif
return 0;
}
void __exit i2c_bitlp_exit(void)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4)
parport_unregister_driver(&i2c_driver);
#else
struct parport *port;
for (port = parport_enumerate(); port; port=port->next)
i2c_parport_detach(port);
#endif
}
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
......
......@@ -23,7 +23,6 @@
This driver puts entries in /proc/sys/dev/sensors for each I2C device
*/
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
......@@ -31,14 +30,10 @@
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/ioport.h>
#include <asm/uaccess.h>
#include <linux/i2c.h>
#include <linux/i2c-proc.h>
#include <linux/init.h>
#ifndef THIS_MODULE
#define THIS_MODULE NULL
#endif
#include <asm/uaccess.h>
static int i2c_create_name(char **name, const char *prefix,
struct i2c_adapter *adapter, int addr);
......@@ -56,7 +51,6 @@ static int i2c_sysctl_chips(ctl_table * table, int *name, int nlen,
#define SENSORS_ENTRY_MAX 20
static struct ctl_table_header *i2c_entries[SENSORS_ENTRY_MAX];
static unsigned short i2c_inodes[SENSORS_ENTRY_MAX];
static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX];
......@@ -197,8 +191,6 @@ int i2c_register_entry(struct i2c_client *client, const char *prefix,
return id;
}
#endif /* DEBUG */
i2c_inodes[id - 256] =
new_header->ctl_table->child->child->de->low_ino;
new_header->ctl_table->child->child->de->owner = controlling_mod;
return id;
......
......@@ -21,9 +21,8 @@
/* $Id: i2c-dev.h,v 1.11 2002/07/07 15:42:47 mds Exp $ */
#ifndef I2C_DEV_H
#define I2C_DEV_H
#ifndef _LINUX_I2C_DEV_H
#define _LINUX_I2C_DEV_H
#include <linux/types.h>
#include <linux/i2c.h>
......@@ -45,174 +44,4 @@ struct i2c_rdwr_ioctl_data {
int nmsgs; /* number of i2c_msgs */
};
#ifndef __KERNEL__
#include <sys/ioctl.h>
static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
int size, union i2c_smbus_data *data)
{
struct i2c_smbus_ioctl_data args;
args.read_write = read_write;
args.command = command;
args.size = size;
args.data = data;
return ioctl(file,I2C_SMBUS,&args);
}
static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
{
return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
}
static inline __s32 i2c_smbus_read_byte(int file)
{
union i2c_smbus_data data;
if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
return -1;
else
return 0x0FF & data.byte;
}
static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
{
return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
I2C_SMBUS_BYTE,NULL);
}
static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
{
union i2c_smbus_data data;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_BYTE_DATA,&data))
return -1;
else
return 0x0FF & data.byte;
}
static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
__u8 value)
{
union i2c_smbus_data data;
data.byte = value;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BYTE_DATA, &data);
}
static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
{
union i2c_smbus_data data;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_WORD_DATA,&data))
return -1;
else
return 0x0FFFF & data.word;
}
static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
__u16 value)
{
union i2c_smbus_data data;
data.word = value;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_WORD_DATA, &data);
}
static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
{
union i2c_smbus_data data;
data.word = value;
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_PROC_CALL,&data))
return -1;
else
return 0x0FFFF & data.word;
}
/* Returns the number of read bytes */
static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
__u8 *values)
{
union i2c_smbus_data data;
int i;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_BLOCK_DATA,&data))
return -1;
else {
for (i = 1; i <= data.block[0]; i++)
values[i-1] = data.block[i];
return data.block[0];
}
}
static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
__u8 length, __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BLOCK_DATA, &data);
}
/* Returns the number of read bytes */
static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
__u8 *values)
{
union i2c_smbus_data data;
int i;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_I2C_BLOCK_DATA,&data))
return -1;
else {
for (i = 1; i <= data.block[0]; i++)
values[i-1] = data.block[i];
return data.block[0];
}
}
static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
__u8 length, __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_I2C_BLOCK_DATA, &data);
}
/* Returns the number of read bytes */
static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
__u8 length, __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BLOCK_PROC_CALL,&data))
return -1;
else {
for (i = 1; i <= data.block[0]; i++)
values[i-1] = data.block[i];
return data.block[0];
}
}
#endif /* ndef __KERNEL__ */
#endif
#endif /* _LINUX_I2C_DEV_H */
......@@ -25,31 +25,17 @@
/* $Id: i2c.h,v 1.59 2002/07/19 20:53:45 phil Exp $ */
#ifndef I2C_H
#define I2C_H
#ifndef _LINUX_I2C_H
#define _LINUX_I2C_H
#define I2C_DATE "20020719"
#define I2C_VERSION "2.6.4"
#include <linux/i2c-id.h> /* id values of adapters et. al. */
#include <linux/types.h>
struct i2c_msg;
#ifdef __KERNEL__
/* --- Includes and compatibility declarations ------------------------ */
#include <linux/version.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c))
#endif
#include <asm/page.h> /* for 2.2.xx */
#include <asm/semaphore.h>
#include <linux/config.h>
#include <asm/semaphore.h>
/* --- General options ------------------------------------------------ */
......@@ -59,6 +45,7 @@ struct i2c_msg;
#define I2C_CLIENT_MAX 32
#define I2C_DUMMY_MAX 4
struct i2c_msg;
struct i2c_algorithm;
struct i2c_adapter;
struct i2c_client;
......@@ -212,10 +199,6 @@ struct i2c_algorithm {
u32 (*functionality) (struct i2c_adapter *);
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)
struct proc_dir_entry;
#endif
/*
* i2c_adapter is the structure used to identify a physical i2c bus along
* with the access algorithms necessary to access it.
......@@ -250,9 +233,6 @@ struct i2c_adapter {
#ifdef CONFIG_PROC_FS
/* No need to set this when you initialize the adapter */
int inode;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)
struct proc_dir_entry *proc_entry;
#endif
#endif /* def CONFIG_PROC_FS */
};
......@@ -355,8 +335,6 @@ extern u32 i2c_get_functionality (struct i2c_adapter *adap);
/* Return 1 if adapter supports everything we need, 0 if not. */
extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func);
#endif /* __KERNEL__ */
/*
* I2C Message - used for pure i2c transaction, also from /dev interface
*/
......@@ -506,8 +484,6 @@ union i2c_smbus_data {
#define I2C_MAJOR 89 /* Device major number */
#ifdef __KERNEL__
# ifndef NULL
# define NULL ( (void *) 0 )
# endif
......@@ -577,5 +553,4 @@ union i2c_smbus_data {
#define i2c_is_isa_adapter(adapptr) \
((adapptr)->algo->id == I2C_ALGO_ISA)
#endif /* def __KERNEL__ */
#endif /* I2C_H */
#endif /* _LINUX_I2C_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment