mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-20 11:29:31 +00:00
Example lm_sensors-2 driver
Though it is called the LM78 driver, there is not too much LM78 specific code in it; it can better be seen as an example code skeleton for other drivers. Right now, it creats a file /proc/sensors-test, which contains a list of busses it registered itself on. Stupid, but very useful for testing purposes! You need a 2.0 kernel for lm78.o to insert (or hack the /proc system specific parts; see lm78.c of lm_sensors version 1 how to do this). Other parts of lm_sensors-2 are not tested for 2.1 kernels either, but I am certain it won't work in this case :-). See the TODO list to get some idea what is left to do, choose something and implement it. Or not :-). But please, send a note to the mailing list when you start on something, to avoid duplicate work... Other notable changes: the smbus_access routines now use (the more logical) i2c_adapter structure, instead of smbus_adapter. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@13 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
4d29df9f32
commit
45d6e40e75
12 files changed
+75
-46
No files matched your search
@@ -77,7 +77,7 @@ struct isa_client {
|
||||
void *data;
|
||||
|
||||
/* Here ended i2c_client */
|
||||
unsigned int full_address;
|
||||
unsigned int isa_addr;
|
||||
};
|
||||
|
||||
/* An algorithm describes how a certain class of busses can be accessed.
|
||||
@@ -127,6 +127,8 @@ struct isa_adapter {
|
||||
access will fail! */
|
||||
#define i2c_is_isa_client(clientptr) \
|
||||
((clientptr)->adapter->algo->id == ALGO_ISA)
|
||||
#define i2c_is_isa_adapter(adapptr) \
|
||||
((adapptr)->algo->id == ALGO_ISA)
|
||||
|
||||
/* Next: define ISA variants of registering. */
|
||||
#define isa_add_algorithm(algoptr) \
|
||||
|
||||
@@ -77,7 +77,7 @@ struct isa_client {
|
||||
void *data;
|
||||
|
||||
/* Here ended i2c_client */
|
||||
unsigned int full_address;
|
||||
unsigned int isa_addr;
|
||||
};
|
||||
|
||||
/* An algorithm describes how a certain class of busses can be accessed.
|
||||
@@ -127,6 +127,8 @@ struct isa_adapter {
|
||||
access will fail! */
|
||||
#define i2c_is_isa_client(clientptr) \
|
||||
((clientptr)->adapter->algo->id == ALGO_ISA)
|
||||
#define i2c_is_isa_adapter(adapptr) \
|
||||
((adapptr)->algo->id == ALGO_ISA)
|
||||
|
||||
/* Next: define ISA variants of registering. */
|
||||
#define isa_add_algorithm(algoptr) \
|
||||
|
||||
+16
-12
@@ -130,6 +130,8 @@ struct smbus_adapter {
|
||||
course. */
|
||||
#define i2c_is_smbus_client(clientptr) \
|
||||
((clientptr)->adapter->algo->id == ALGO_SMBUS)
|
||||
#define i2c_is_smbus_adapter(adapptr) \
|
||||
((adapptr)->algo->id == ALGO_SMBUS)
|
||||
|
||||
/* This union is used within smbus_access routines */
|
||||
union smbus_data {
|
||||
@@ -157,21 +159,23 @@ extern struct smbus_algorithm smbus_algorithm;
|
||||
|
||||
/* This is the very generalized SMBus access routine. You probably do not
|
||||
want to use this, though; one of the functions below may be much easier,
|
||||
and probably just as fast. */
|
||||
extern s32 smbus_access (struct smbus_adapter * adapter, u8 addr,
|
||||
and probably just as fast.
|
||||
Note that we use i2c_adapter here, because you do not need a specific
|
||||
smbus adapter to call this function. */
|
||||
extern s32 smbus_access (struct i2c_adapter * adapter, u8 addr,
|
||||
char read_write, u8 command, int size,
|
||||
union smbus_data * data);
|
||||
|
||||
/* Now follow the 'nice' access routines. These also document the calling
|
||||
conventions of smbus_access. */
|
||||
|
||||
extern inline s32 smbus_write_quick(struct smbus_adapter * adapter, u8 addr,
|
||||
extern inline s32 smbus_write_quick(struct i2c_adapter * adapter, u8 addr,
|
||||
u8 value)
|
||||
{
|
||||
return smbus_access(adapter,addr,value,0,SMBUS_QUICK,NULL);
|
||||
}
|
||||
|
||||
extern inline s32 smbus_read_byte(struct smbus_adapter * adapter,u8 addr)
|
||||
extern inline s32 smbus_read_byte(struct i2c_adapter * adapter,u8 addr)
|
||||
{
|
||||
union smbus_data data;
|
||||
if (smbus_access(adapter,addr,SMBUS_READ,0,SMBUS_BYTE,&data))
|
||||
@@ -180,13 +184,13 @@ extern inline s32 smbus_read_byte(struct smbus_adapter * adapter,u8 addr)
|
||||
return data.byte;
|
||||
}
|
||||
|
||||
extern inline s32 smbus_write_byte(struct smbus_adapter * adapter, u8 addr,
|
||||
extern inline s32 smbus_write_byte(struct i2c_adapter * adapter, u8 addr,
|
||||
u8 value)
|
||||
{
|
||||
return smbus_access(adapter,addr,SMBUS_WRITE,value, SMBUS_BYTE,NULL);
|
||||
}
|
||||
|
||||
extern inline s32 smbus_read_byte_data(struct smbus_adapter * adapter,
|
||||
extern inline s32 smbus_read_byte_data(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command)
|
||||
{
|
||||
union smbus_data data;
|
||||
@@ -196,7 +200,7 @@ extern inline s32 smbus_read_byte_data(struct smbus_adapter * adapter,
|
||||
return data.byte;
|
||||
}
|
||||
|
||||
extern inline s32 smbus_write_byte_data(struct smbus_adapter * adapter,
|
||||
extern inline s32 smbus_write_byte_data(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command, u8 value)
|
||||
{
|
||||
union smbus_data data;
|
||||
@@ -204,7 +208,7 @@ extern inline s32 smbus_write_byte_data(struct smbus_adapter * adapter,
|
||||
return smbus_access(adapter,addr,SMBUS_WRITE,command,SMBUS_BYTE_DATA,&data);
|
||||
}
|
||||
|
||||
extern inline s32 smbus_read_word_data(struct smbus_adapter * adapter,
|
||||
extern inline s32 smbus_read_word_data(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command)
|
||||
{
|
||||
union smbus_data data;
|
||||
@@ -214,7 +218,7 @@ extern inline s32 smbus_read_word_data(struct smbus_adapter * adapter,
|
||||
return data.word;
|
||||
}
|
||||
|
||||
extern inline s32 smbus_write_word_data(struct smbus_adapter * adapter,
|
||||
extern inline s32 smbus_write_word_data(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command, u16 value)
|
||||
{
|
||||
union smbus_data data;
|
||||
@@ -222,7 +226,7 @@ extern inline s32 smbus_write_word_data(struct smbus_adapter * adapter,
|
||||
return smbus_access(adapter,addr,SMBUS_WRITE,command,SMBUS_WORD_DATA,&data);
|
||||
}
|
||||
|
||||
extern inline s32 smbus_process_call(struct smbus_adapter * adapter,
|
||||
extern inline s32 smbus_process_call(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command, u16 value)
|
||||
{
|
||||
union smbus_data data;
|
||||
@@ -234,7 +238,7 @@ extern inline s32 smbus_process_call(struct smbus_adapter * adapter,
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
extern inline s32 smbus_read_block_data(struct smbus_adapter * adapter,
|
||||
extern inline s32 smbus_read_block_data(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command, u8 *values)
|
||||
{
|
||||
union smbus_data data;
|
||||
@@ -248,7 +252,7 @@ extern inline s32 smbus_read_block_data(struct smbus_adapter * adapter,
|
||||
}
|
||||
}
|
||||
|
||||
extern inline int smbus_write_block_data(struct smbus_adapter * adapter,
|
||||
extern inline int smbus_write_block_data(struct i2c_adapter * adapter,
|
||||
u8 addr, u8 command, u8 length,
|
||||
u8 *values)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user