mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-21 19:51:45 +00:00
(Kyösti) some cleanups for 2.4+
Module refcounting using .owner, removing of inc/dec_use.
These require (yet unreleased) i2c 2.8.0+.
Named initializers everywhere. Unified namespace.
Cleanup for 2.5, remove EXPORT_NO_SYMBOLS, declare everything
static. Apply initcalls.
PCI device registration changes for busses started, replicating
from i2c-amd*. While everything does compile, nothing really
works. Well, maybe i2c-amd* ported back from 2.5 tree.
After updating your work directory, run
> cvs diff -u -r LAST-PRE-2-8-I2C > lm-2.8-patches-1
BEWARE: I have not even insmoded any of these yet.
To compile, you need i2c from cvs too.
For 2.4 kernel :
> cvs co -r lk2-4 i2c
For 2.5 kernel :
> cvs co i2c
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1698 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
2a462eaae3
commit
39391ba6ea
59 files changed
+1596
-5391
No files matched your search
+21
-97
@@ -30,19 +30,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)) || \
|
||||
(LINUX_VERSION_CODE == KERNEL_VERSION(2,3,0))
|
||||
#define init_MUTEX(s) do { *(s) = MUTEX; } while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef THIS_MODULE
|
||||
#define THIS_MODULE NULL
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = { 0x2E, SENSORS_I2C_END };
|
||||
@@ -66,18 +54,6 @@ struct matorb_data {
|
||||
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_matorb_init(void);
|
||||
static int __init matorb_cleanup(void);
|
||||
static int matorb_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int matorb_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
@@ -85,8 +61,7 @@ static void matorb_init_client(struct i2c_client *client);
|
||||
static int matorb_detach_client(struct i2c_client *client);
|
||||
static int matorb_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void matorb_inc_use(struct i2c_client *client);
|
||||
static void matorb_dec_use(struct i2c_client *client);
|
||||
|
||||
static int matorb_write_value(struct i2c_client *client, u8 reg,
|
||||
u16 value);
|
||||
static void matorb_disp(struct i2c_client *client, int operation,
|
||||
@@ -96,14 +71,13 @@ static void matorb_update_client(struct i2c_client *client);
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver matorb_driver = {
|
||||
/* name */ "Matrix Orbital LCD driver",
|
||||
/* id */ I2C_DRIVERID_MATORB,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &matorb_attach_adapter,
|
||||
/* detach_client */ &matorb_detach_client,
|
||||
/* command */ &matorb_command,
|
||||
/* inc_use */ &matorb_inc_use,
|
||||
/* dec_use */ &matorb_dec_use
|
||||
.owner = THIS_MODULE,
|
||||
.name = "Matrix Orbital LCD driver",
|
||||
.id = I2C_DRIVERID_MATORB,
|
||||
.flags = I2C_DF_NOTIFY,
|
||||
.attach_adapter = matorb_attach_adapter,
|
||||
.detach_client = matorb_detach_client,
|
||||
.command = matorb_command,
|
||||
};
|
||||
|
||||
/* These files are created for each detected MATORB. This is just a template;
|
||||
@@ -117,12 +91,9 @@ static ctl_table matorb_dir_table_template[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
static int __initdata matorb_initialized = 0;
|
||||
|
||||
static int matorb_id = 0;
|
||||
|
||||
int matorb_attach_adapter(struct i2c_adapter *adapter)
|
||||
static int matorb_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return i2c_detect(adapter, &addr_data, matorb_detect);
|
||||
}
|
||||
@@ -209,7 +180,7 @@ int matorb_detect(struct i2c_adapter *adapter, int address,
|
||||
return err;
|
||||
}
|
||||
|
||||
int matorb_detach_client(struct i2c_client *client)
|
||||
static int matorb_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
|
||||
@@ -229,32 +200,17 @@ int matorb_detach_client(struct i2c_client *client)
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int matorb_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
static int matorb_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void matorb_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void matorb_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* All registers are word-sized, except for the configuration register.
|
||||
MATORB uses a high-byte first convention, which is exactly opposite to
|
||||
the usual practice. */
|
||||
int matorb_read_value(struct i2c_client *client, u8 reg)
|
||||
static int matorb_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return -1; /* Doesn't support reads */
|
||||
}
|
||||
@@ -263,7 +219,7 @@ int matorb_read_value(struct i2c_client *client, u8 reg)
|
||||
/* All registers are word-sized, except for the configuration register.
|
||||
MATORB uses a high-byte first convention, which is exactly opposite to
|
||||
the usual practice. */
|
||||
int matorb_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
static int matorb_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
if (reg == 0) {
|
||||
return i2c_smbus_write_byte(client, value);
|
||||
@@ -272,12 +228,12 @@ int matorb_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
}
|
||||
}
|
||||
|
||||
void matorb_init_client(struct i2c_client *client)
|
||||
static void matorb_init_client(struct i2c_client *client)
|
||||
{
|
||||
/* Initialize the MATORB chip */
|
||||
}
|
||||
|
||||
void matorb_update_client(struct i2c_client *client)
|
||||
static void matorb_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct matorb_data *data = client->data;
|
||||
|
||||
@@ -317,54 +273,22 @@ void matorb_disp(struct i2c_client *client, int operation, int ctl_name,
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_matorb_init(void)
|
||||
static int __init sm_matorb_init(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
printk("matorb.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
matorb_initialized = 0;
|
||||
if ((res = i2c_add_driver(&matorb_driver))) {
|
||||
printk
|
||||
("matorb.o: Driver registration failed, module not inserted.\n");
|
||||
matorb_cleanup();
|
||||
return res;
|
||||
}
|
||||
matorb_initialized++;
|
||||
return 0;
|
||||
return i2c_add_driver(&matorb_driver);
|
||||
}
|
||||
|
||||
int __init matorb_cleanup(void)
|
||||
static void __exit sm_matorb_exit(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (matorb_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&matorb_driver))) {
|
||||
printk
|
||||
("matorb.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
matorb_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
i2c_del_driver(&matorb_driver);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("MATORB driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_matorb_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return matorb_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(sm_matorb_init);
|
||||
module_exit(sm_matorb_exit);
|
||||
Reference in new issue
Block a user