mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-17 19:30:26 +00:00
ISA changes
* i2c-isa simplified, by using the addr field in the client structure, instead of a new field. This means we do not need `struct isa_*' anymore * All clients changed to reflect the new isa code. Many are much simplified now. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@505 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
abf15cf902
commit
2212822342
10 files changed
+75
-285
No files matched your search
@@ -6,7 +6,8 @@ I2C CODE CHANGES
|
||||
* Test all modules
|
||||
* Add code and supporting files to compile modules into the main kernel
|
||||
* Write a mkpatch script, as in the i2c tree
|
||||
* Check the i2c-isa code, use 16 bit address field in i2c struct.
|
||||
* Check what happens if the ISA bus is selected by a force parameter;
|
||||
I think the _detect procedures are called?!?
|
||||
|
||||
KERNEL MODULES
|
||||
==============
|
||||
|
||||
+30
-79
@@ -27,26 +27,13 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,19)
|
||||
#include <linux/sched.h>
|
||||
#else
|
||||
#include <asm/semaphore.h>
|
||||
#endif
|
||||
|
||||
#include "version.h"
|
||||
#include "i2c-isa.h"
|
||||
|
||||
static int isa_master_xfer (struct isa_adapter *adap,
|
||||
struct i2c_msg msgs[], int num);
|
||||
static int isa_slave_send (struct isa_adapter *adap, char *data, int len);
|
||||
static int isa_slave_recv (struct isa_adapter *adap, char *data, int len);
|
||||
static int isa_algo_control (struct isa_adapter *adap, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
static int isa_client_register (struct isa_client *client);
|
||||
static int isa_client_unregister (struct isa_client *client);
|
||||
static void isa_inc_use (struct i2c_adapter *adapter);
|
||||
static void isa_dec_use (struct i2c_adapter *adapter);
|
||||
|
||||
static int isa_init(void);
|
||||
static int isa_cleanup(void);
|
||||
@@ -57,81 +44,48 @@ extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
/* This is the actual algorithm we define */
|
||||
static struct isa_algorithm isa_algorithm = {
|
||||
/* name */ "ISA bus adapter",
|
||||
/* id */ ALGO_ISA,
|
||||
/* master_xfer */ &isa_master_xfer,
|
||||
/* slave_send */ &isa_slave_send,
|
||||
/* slave_rcv */ &isa_slave_recv,
|
||||
/* algo_control */ &isa_algo_control,
|
||||
/* client_register */ &isa_client_register,
|
||||
/* client_unregister*/&isa_client_unregister
|
||||
static struct i2c_algorithm isa_algorithm = {
|
||||
/* name */ "ISA bus algorithm",
|
||||
/* id */ I2C_ALGO_ISA,
|
||||
/* master_xfer */ NULL,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
};
|
||||
|
||||
/* There can only be one... */
|
||||
static struct isa_adapter isa_adapter;
|
||||
static struct i2c_adapter isa_adapter = {
|
||||
/* name */ "ISA main adapter",
|
||||
/* id */ I2C_ALGO_ISA | I2C_HW_ISA,
|
||||
/* algorithm */ &isa_algorithm,
|
||||
/* algo_data */ NULL,
|
||||
/* inc_use */ &isa_inc_use,
|
||||
/* dec_use */ &isa_dec_use,
|
||||
/* data */ NULL,
|
||||
/* Other fields not initialized */
|
||||
};
|
||||
|
||||
/* Used in isa_init/cleanup */
|
||||
static int isa_initialized;
|
||||
|
||||
/* Algorithm master_xfer call-back implementation. Can't do that... */
|
||||
int isa_master_xfer (struct isa_adapter *adap, struct i2c_msg msgs[],
|
||||
int num)
|
||||
void isa_inc_use (struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printk("i2c-isa.o: isa_master_xfer called for adapter `%s' "
|
||||
"(no i2c level access possible!)\n",
|
||||
adap->name);
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Algorithm slave_send call-back implementation. Can't do that... */
|
||||
int isa_slave_send (struct isa_adapter *adap, char *data, int len)
|
||||
void isa_dec_use (struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printk("i2c-isa.o: isa_slave_send called for adapter `%s' "
|
||||
"(no i2c level access possible!)\n",
|
||||
adap->name);
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Algorithm slave_recv call-back implementation. Can't do that... */
|
||||
int isa_slave_recv (struct isa_adapter *adap, char *data, int len)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printk("i2c-isa.o: isa_slave_recv called for adapter `%s' "
|
||||
"(no i2c level access possible!)\n",
|
||||
adap->name);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Here we can put additional calls to modify the workings of the algorithm.
|
||||
But right now, there is no need for that. */
|
||||
int isa_algo_control (struct isa_adapter *adap, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ehm... This is called when a client is registered to an adapter. We could
|
||||
do all kinds of neat stuff here like, ehm - returning success? */
|
||||
int isa_client_register (struct isa_client *client)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int isa_client_unregister (struct isa_client *client)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int isa_init(void)
|
||||
{
|
||||
int res;
|
||||
printk("isa.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
printk("i2c-isa.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
#ifdef DEBUG
|
||||
if (isa_initialized) {
|
||||
printk("i2c-isa.o: Oops, isa_init called a second time!\n");
|
||||
@@ -139,16 +93,13 @@ int isa_init(void)
|
||||
}
|
||||
#endif
|
||||
isa_initialized = 0;
|
||||
if ((res = isa_add_algorithm(&isa_algorithm))) {
|
||||
if ((res = i2c_add_algorithm(&isa_algorithm))) {
|
||||
printk("i2c-isa.o: Algorithm registration failed, module not inserted.\n");
|
||||
isa_cleanup();
|
||||
return res;
|
||||
}
|
||||
isa_initialized++;
|
||||
strcpy(isa_adapter.name,"ISA main adapter");
|
||||
isa_adapter.id = ALGO_ISA | ISA_MAIN;
|
||||
isa_adapter.algo = &isa_algorithm;
|
||||
if ((res = isa_add_adapter(&isa_adapter))) {
|
||||
if ((res = i2c_add_adapter(&isa_adapter))) {
|
||||
printk("i2c-isa.o: Adapter registration failed, "
|
||||
"module isa.o is not inserted\n.");
|
||||
isa_cleanup();
|
||||
@@ -164,7 +115,7 @@ int isa_cleanup(void)
|
||||
int res;
|
||||
if (isa_initialized >= 2)
|
||||
{
|
||||
if ((res = isa_del_adapter(&isa_adapter))) {
|
||||
if ((res = i2c_del_adapter(&isa_adapter))) {
|
||||
printk("i2c-isa.o: Adapter deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
} else
|
||||
@@ -172,7 +123,7 @@ int isa_cleanup(void)
|
||||
}
|
||||
if (isa_initialized >= 1)
|
||||
{
|
||||
if ((res = isa_del_algorithm(&isa_algorithm))) {
|
||||
if ((res = i2c_del_algorithm(&isa_algorithm))) {
|
||||
printk("i2c-isa.o: Algorithm deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
} else
|
||||
|
||||
@@ -271,8 +271,6 @@ static void adm9240_vid(struct i2c_client *client, int operation, int ctl_name,
|
||||
#define MAX_ADM9240_NR 4
|
||||
static struct i2c_client *adm9240_list[MAX_ADM9240_NR];
|
||||
|
||||
/* The driver. I choose to use type i2c_driver, as at is identical to both
|
||||
smbus_driver and isa_driver, and clients could be of either kind */
|
||||
static struct i2c_driver adm9240_driver = {
|
||||
/* name */ "ADM9240 sensor driver",
|
||||
/* id */ I2C_DRIVERID_ADM9240,
|
||||
|
||||
+9
-16
@@ -231,8 +231,6 @@ static void lm78_fan_div(struct i2c_client *client, int operation, int ctl_name,
|
||||
#define MAX_LM78_NR 8
|
||||
static struct i2c_client *lm78_list[MAX_LM78_NR];
|
||||
|
||||
/* The driver. I choose to use type i2c_driver, as at is identical to both
|
||||
smbus_driver and isa_driver, and clients could be of either kind */
|
||||
static struct i2c_driver lm78_driver = {
|
||||
/* name */ "LM78(-J) and LM79 sensor driver",
|
||||
/* id */ I2C_DRIVERID_LM78,
|
||||
@@ -344,7 +342,7 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access lm78_{read,write}_value. */
|
||||
|
||||
if (! (new_client = kmalloc((is_isa?sizeof(struct isa_client):
|
||||
if (! (new_client = kmalloc((is_isa?sizeof(struct i2c_client):
|
||||
sizeof(struct i2c_client)) +
|
||||
sizeof(struct lm78_data),
|
||||
GFP_KERNEL))) {
|
||||
@@ -352,15 +350,10 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
if (is_isa) {
|
||||
data = (struct lm78_data *) (((struct isa_client *) new_client) + 1);
|
||||
new_client->addr = 0;
|
||||
((struct isa_client *) new_client)->isa_addr = address;
|
||||
data = (struct lm78_data *) (((struct i2c_client *) new_client) + 1);
|
||||
if (is_isa)
|
||||
init_MUTEX(&data->lock);
|
||||
} else {
|
||||
data = (struct lm78_data *) (((struct i2c_client *) new_client) + 1);
|
||||
new_client->addr = address;
|
||||
}
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &lm78_driver;
|
||||
@@ -485,7 +478,7 @@ int lm78_detach_client(struct i2c_client *client)
|
||||
lm78_list[i] = NULL;
|
||||
|
||||
if i2c_is_isa_client(client)
|
||||
release_region(((struct isa_client *)client)->isa_addr,LM78_EXTENT);
|
||||
release_region(client->addr,LM78_EXTENT);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
@@ -526,9 +519,9 @@ int lm78_read_value(struct i2c_client *client, u8 reg)
|
||||
int res;
|
||||
if (i2c_is_isa_client(client)) {
|
||||
down(& (((struct lm78_data *) (client->data)) -> lock));
|
||||
outb_p(reg,(((struct isa_client *) client)->isa_addr) +
|
||||
outb_p(reg,client->addr +
|
||||
LM78_ADDR_REG_OFFSET);
|
||||
res = inb_p((((struct isa_client *) client)->isa_addr) +
|
||||
res = inb_p(client->addr +
|
||||
LM78_DATA_REG_OFFSET);
|
||||
up( & (((struct lm78_data *) (client->data)) -> lock));
|
||||
return res;
|
||||
@@ -547,8 +540,8 @@ int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||
{
|
||||
if (i2c_is_isa_client(client)) {
|
||||
down(&(((struct lm78_data *) (client->data)) -> lock));
|
||||
outb_p(reg,((struct isa_client *) client)->isa_addr + LM78_ADDR_REG_OFFSET);
|
||||
outb_p(value,((struct isa_client *) client)->isa_addr + LM78_DATA_REG_OFFSET);
|
||||
outb_p(reg,client->addr + LM78_ADDR_REG_OFFSET);
|
||||
outb_p(value,client->addr + LM78_DATA_REG_OFFSET);
|
||||
up(&(((struct lm78_data *) (client->data)) -> lock));
|
||||
return 0;
|
||||
} else
|
||||
|
||||
@@ -224,8 +224,6 @@ static void lm80_fan_div(struct i2c_client *client, int operation, int ctl_name,
|
||||
#define MAX_LM80_NR 4
|
||||
static struct i2c_client *lm80_list[MAX_LM80_NR];
|
||||
|
||||
/* The driver. I choose to use type i2c_driver, as at is identical to both
|
||||
smbus_driver and isa_driver, and clients could be of either kind */
|
||||
static struct i2c_driver lm80_driver = {
|
||||
/* name */ "LM80 sensor driver",
|
||||
/* id */ I2C_DRIVERID_LM80,
|
||||
|
||||
+8
-11
@@ -347,16 +347,15 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access sis5595_{read,write}_value. */
|
||||
|
||||
if (! (new_client = kmalloc(sizeof(struct isa_client) +
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct sis5595_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct sis5595_data *) (((struct isa_client *) new_client) + 1);
|
||||
new_client->addr = 0;
|
||||
((struct isa_client *) new_client)->isa_addr = address;
|
||||
data = (struct sis5595_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
init_MUTEX(&data->lock);
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
@@ -457,7 +456,7 @@ int sis5595_detach_client(struct i2c_client *client)
|
||||
}
|
||||
sis5595_list[i] = NULL;
|
||||
|
||||
release_region(((struct isa_client *)client)->isa_addr,SIS5595_EXTENT);
|
||||
release_region(client->addr,SIS5595_EXTENT);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
@@ -495,10 +494,8 @@ int sis5595_read_value(struct i2c_client *client, u8 reg)
|
||||
|
||||
down((struct semaphore *) (client->data));
|
||||
down(& (((struct sis5595_data *) (client->data)) -> lock));
|
||||
outb_p(reg,(((struct isa_client *) client)->isa_addr) +
|
||||
SIS5595_ADDR_REG_OFFSET);
|
||||
res = inb_p((((struct isa_client *) client)->isa_addr) +
|
||||
SIS5595_DATA_REG_OFFSET);
|
||||
outb_p(reg,client->addr + SIS5595_ADDR_REG_OFFSET);
|
||||
res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
|
||||
up( & (((struct sis5595_data *) (client->data)) -> lock));
|
||||
return res;
|
||||
}
|
||||
@@ -509,8 +506,8 @@ int sis5595_read_value(struct i2c_client *client, u8 reg)
|
||||
int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||
{
|
||||
down(& (((struct sis5595_data *) (client->data)) -> lock));
|
||||
outb_p(reg,((struct isa_client *) client)->isa_addr + SIS5595_ADDR_REG_OFFSET);
|
||||
outb_p(value,((struct isa_client *) client)->isa_addr + SIS5595_DATA_REG_OFFSET);
|
||||
outb_p(reg,client->addr + SIS5595_ADDR_REG_OFFSET);
|
||||
outb_p(value,client->addr + SIS5595_DATA_REG_OFFSET);
|
||||
up( & (((struct sis5595_data *) (client->data)) -> lock));
|
||||
return 0;
|
||||
}
|
||||
|
||||
+20
-45
@@ -397,8 +397,6 @@ static void w83781d_rt(struct i2c_client *client, int operation,
|
||||
#define MAX_W83781D_NR 8
|
||||
static struct i2c_client *w83781d_list[MAX_W83781D_NR];
|
||||
|
||||
/* The driver. I choose to use type i2c_driver, as at is identical to both
|
||||
smbus_driver and isa_driver, and clients could be of either kind */
|
||||
static struct i2c_driver w83781d_driver = {
|
||||
/* name */ "W83781D sensor driver",
|
||||
/* id */ I2C_DRIVERID_W83781D,
|
||||
@@ -676,22 +674,15 @@ int w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access w83781d_{read,write}_value. */
|
||||
|
||||
if (! (new_client = kmalloc((is_isa?sizeof(struct isa_client):
|
||||
sizeof(struct i2c_client)) +
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct w83781d_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
if (is_isa) {
|
||||
data = (struct w83781d_data *) (((struct isa_client *) new_client) + 1);
|
||||
new_client->addr = 0;
|
||||
((struct isa_client *) new_client)->isa_addr = address;
|
||||
} else {
|
||||
data = (struct w83781d_data *) (((struct i2c_client *) new_client) + 1);
|
||||
new_client->addr = address;
|
||||
}
|
||||
data = (struct w83781d_data *) (((struct i2c_client *) new_client) + 1);
|
||||
new_client->addr = address;
|
||||
init_MUTEX(&data->lock);
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
@@ -837,7 +828,7 @@ int w83781d_detach_client(struct i2c_client *client)
|
||||
w83781d_list[i] = NULL;
|
||||
|
||||
if i2c_is_isa_client(client)
|
||||
release_region(((struct isa_client *)client)->isa_addr,W83781D_EXTENT);
|
||||
release_region(client->addr,W83781D_EXTENT);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
@@ -880,26 +871,18 @@ int w83781d_read_value(struct i2c_client *client, u16 reg)
|
||||
down(& (((struct w83781d_data *) (client->data)) -> lock));
|
||||
if (i2c_is_isa_client(client)) {
|
||||
if (reg & 0xff00) {
|
||||
outb_p(W83781D_REG_BANK,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(reg >> 8,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p(W83781D_REG_BANK,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(reg >> 8,client->addr + W83781D_DATA_REG_OFFSET);
|
||||
}
|
||||
outb_p(reg & 0xff,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
res = inb_p((((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p(reg & 0xff,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
res = inb_p(client->addr + W83781D_DATA_REG_OFFSET);
|
||||
if (word_sized) {
|
||||
outb_p((reg & 0xff)+1,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
res = (res << 8) + inb_p((((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p((reg & 0xff)+1,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
res = (res << 8) + inb_p(client->addr + W83781D_DATA_REG_OFFSET);
|
||||
}
|
||||
if (reg & 0xff00) {
|
||||
outb_p(W83781D_REG_BANK,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(0,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p(W83781D_REG_BANK,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(0,client->addr + W83781D_DATA_REG_OFFSET);
|
||||
}
|
||||
} else {
|
||||
if (reg & 0xff00)
|
||||
@@ -933,26 +916,18 @@ int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
|
||||
down( & (((struct w83781d_data *) (client->data)) -> lock));
|
||||
if (i2c_is_isa_client(client)) {
|
||||
if (reg & 0xff00) {
|
||||
outb_p(W83781D_REG_BANK,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(reg >> 8,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p(W83781D_REG_BANK,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(reg >> 8,client->addr + W83781D_DATA_REG_OFFSET);
|
||||
}
|
||||
outb_p(reg & 0xff,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(reg & 0xff,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
if (word_sized) {
|
||||
outb_p(value >> 8,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p((reg & 0xff)+1,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(value >> 8,client->addr + W83781D_DATA_REG_OFFSET);
|
||||
outb_p((reg & 0xff)+1,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
}
|
||||
outb_p(value &0xff,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p(value &0xff,client->addr + W83781D_DATA_REG_OFFSET);
|
||||
if (reg & 0xff00) {
|
||||
outb_p(W83781D_REG_BANK,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(0,(((struct isa_client *) client)->isa_addr) +
|
||||
W83781D_DATA_REG_OFFSET);
|
||||
outb_p(W83781D_REG_BANK,client->addr + W83781D_ADDR_REG_OFFSET);
|
||||
outb_p(0,client->addr + W83781D_DATA_REG_OFFSET);
|
||||
}
|
||||
} else {
|
||||
if (reg & 0xff00)
|
||||
|
||||
+5
-126
@@ -19,141 +19,20 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SENSORS_SENSOR_H
|
||||
#define SENSORS_SENSOR_H
|
||||
#ifndef SENSORS_SENSORS_ISA_H
|
||||
#define SENSORS_SENSORS_ISA_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* This file must interface with Simon Vogl's i2c driver. Version 19981006 is
|
||||
OK, earlier versions are not; later versions will probably give problems
|
||||
too.
|
||||
*/
|
||||
#include <asm/types.h>
|
||||
|
||||
/* I2C_SPINLOCK is defined in i2c.h. */
|
||||
#ifdef I2C_SPINLOCK
|
||||
#include <asm/spinlock.h>
|
||||
#else
|
||||
#if LINUX_VERSION_CODE < 0x020019
|
||||
#include <linux/sched.h>
|
||||
#else
|
||||
#include <asm/semaphore.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <linux/i2c.h>
|
||||
|
||||
/* Note that this driver is *not* built upon smbus.c, but is parallel to it.
|
||||
We do not need SMBus facilities if we are on the ISA bus, after all */
|
||||
|
||||
/* Declarations, to keep the compiler happy */
|
||||
struct isa_driver;
|
||||
struct isa_client;
|
||||
struct isa_algorithm;
|
||||
struct isa_adapter;
|
||||
|
||||
/* A driver tells us how we should handle a specific kind of chip.
|
||||
A specific instance of such a chip is called a client.
|
||||
This structure is essentially the same as i2c_driver. */
|
||||
struct isa_driver {
|
||||
char name[32];
|
||||
int id;
|
||||
unsigned int flags;
|
||||
int (* attach_adapter) (struct isa_adapter *);
|
||||
int (* detach_client) (struct isa_client *);
|
||||
int (* command) (struct isa_client *, unsigned int cmd, void *arg);
|
||||
void (* inc_use) (struct isa_client *);
|
||||
void (* dec_use) (struct isa_client *);
|
||||
};
|
||||
|
||||
/* A client is a specifc instance of a chip: for each detected chip, there will
|
||||
be a client. Its operation is controlled by a driver.
|
||||
This structure is an extension of i2c_client. */
|
||||
struct isa_client {
|
||||
char name[32];
|
||||
int id;
|
||||
unsigned int flags;
|
||||
unsigned char addr;
|
||||
struct isa_adapter *adapter;
|
||||
struct isa_driver *driver;
|
||||
void *data;
|
||||
|
||||
/* Here ended i2c_client */
|
||||
unsigned int isa_addr;
|
||||
};
|
||||
|
||||
/* An algorithm describes how a certain class of busses can be accessed.
|
||||
A specific instance of sucj a bus is called an adapter.
|
||||
This structure is essentially the same as i2c_adapter. */
|
||||
struct isa_algorithm {
|
||||
char name[32];
|
||||
unsigned int id;
|
||||
int (* master_xfer) (struct isa_adapter *adap, struct i2c_msg msgs[],
|
||||
int num);
|
||||
int (* slave_send) (struct isa_adapter *,char *, int);
|
||||
int (* slave_recv) (struct isa_adapter *,char *, int);
|
||||
int (* algo_control) (struct isa_adapter *, unsigned int, unsigned long);
|
||||
int (* client_register) (struct isa_client *);
|
||||
int (* client_unregister) (struct isa_client *);
|
||||
};
|
||||
|
||||
/* An adapter is a specifc instance of a bus: for each detected bus, there will
|
||||
be an adapter. Its operation is controlled by an algorithm.
|
||||
I2C_SPINLOCK must be the same as declared in i2c.h.
|
||||
This structure is essentially the same as i2c_algorithm. */
|
||||
struct isa_adapter {
|
||||
char name[32];
|
||||
unsigned int id;
|
||||
struct isa_algorithm *algo;
|
||||
void *data;
|
||||
#ifdef I2C_SPINLOCK
|
||||
spinlock_t lock;
|
||||
unsigned long lockflags;
|
||||
#else
|
||||
struct semaphore lock;
|
||||
#endif
|
||||
unsigned int flags;
|
||||
struct isa_client *clients[I2C_CLIENT_MAX];
|
||||
int client_count;
|
||||
int timeout;
|
||||
int retries;
|
||||
};
|
||||
|
||||
|
||||
/* Detect whether we are on the isa bus. If this returns true, all i2c
|
||||
access will fail! */
|
||||
access will fail! */
|
||||
#define i2c_is_isa_client(clientptr) \
|
||||
((clientptr)->adapter->algo->id == ALGO_ISA)
|
||||
((clientptr)->adapter->algo->id == I2C_ALGO_ISA)
|
||||
#define i2c_is_isa_adapter(adapptr) \
|
||||
((adapptr)->algo->id == ALGO_ISA)
|
||||
|
||||
/* Next: define ISA variants of registering. */
|
||||
#define isa_add_algorithm(algoptr) \
|
||||
i2c_add_algorithm((struct i2c_algorithm *) (algoptr))
|
||||
#define isa_del_algorithm(algoptr) \
|
||||
i2c_del_algorithm((struct i2c_algorithm *) (algoptr))
|
||||
|
||||
#define isa_add_adapter(adapptr) \
|
||||
i2c_add_adapter((struct i2c_adapter *) (adapptr))
|
||||
#define isa_del_adapter(adapptr) \
|
||||
i2c_del_adapter((struct i2c_adapter *) (adapptr))
|
||||
|
||||
#define isa_add_driver(driverptr) \
|
||||
i2c_add_driver((struct i2c_driver *) (driverptr))
|
||||
#define isa_del_driver(driverptr) \
|
||||
i2c_add_driver((struct i2c_driver *) (driverptr))
|
||||
|
||||
#define isa_attach_client(clientptr) \
|
||||
i2c_attach_client((struct i2c_client *) (clientptr))
|
||||
#define isa_detach_client(clientptr) \
|
||||
i2c_detach_client((struct i2c_client *) (clientptr))
|
||||
((adapptr)->algo->id == I2C_ALGO_ISA)
|
||||
|
||||
#endif /* def __KERNEL__ */
|
||||
|
||||
/* We need to mark ISA algorithms in the algorithm structure. */
|
||||
#define ALGO_ISA 0x50000
|
||||
|
||||
/* ISA Adapter ids */
|
||||
#define ISA_MAIN 1
|
||||
|
||||
#endif /* ndef SENSORS_ISA_H */
|
||||
@@ -128,8 +128,6 @@ int sensors_register_entry(struct i2c_client *client ,const char *prefix,
|
||||
struct ctl_table_header *new_header;
|
||||
|
||||
if ((res = sensors_create_name(&name,prefix,client->adapter,
|
||||
i2c_is_isa_client(client)?
|
||||
((struct isa_client *) client)->isa_addr:
|
||||
client->addr)))
|
||||
return res;
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
/* To keep glibc2 happy */
|
||||
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 0
|
||||
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 0
|
||||
#include <sys/perm.h>
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user