`indent -kr -i8' on all kernel sources

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@707 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Frodo Looijaard committed 2000-01-24 20:37:01 +00:00
1 parent 83d5845df5
commit 6a2c82b491
29 files changed
+10217 -9155

No files matched your search

+177 -165
View File
@@ -53,56 +53,57 @@
/* Each client has this additional data */
struct icspll_data {
int sysctl_id;
int sysctl_id;
struct semaphore update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
struct semaphore update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
u8 data[ICSPLL_SIZE]; /* Register values */
int memtype;
u8 data[ICSPLL_SIZE]; /* Register values */
int memtype;
};
#ifdef MODULE
extern int init_module(void);
extern int cleanup_module(void);
#endif /* MODULE */
#endif /* MODULE */
#ifdef MODULE
static
#else
extern
#endif
int __init sensors_icspll_init(void);
int __init sensors_icspll_init(void);
static int __init icspll_cleanup(void);
static int icspll_attach_adapter(struct i2c_adapter *adapter);
static int icspll_detach_client(struct i2c_client *client);
static int icspll_command(struct i2c_client *client, unsigned int cmd,
void *arg);
static void icspll_inc_use (struct i2c_client *client);
static void icspll_dec_use (struct i2c_client *client);
void *arg);
static void icspll_inc_use(struct i2c_client *client);
static void icspll_dec_use(struct i2c_client *client);
#if 0
static int icspll_write_value(struct i2c_client *client, u8 reg, u16 value);
static int icspll_write_value(struct i2c_client *client, u8 reg,
u16 value);
#endif
static void icspll_contents(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results);
static void icspll_contents(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void icspll_update_client(struct i2c_client *client);
/* This is the driver that will be inserted */
static struct i2c_driver icspll_driver = {
/* name */ "ICS/PLL clock reader",
/* id */ I2C_DRIVERID_ICSPLL,
/* flags */ I2C_DF_NOTIFY,
/* attach_adapter */ &icspll_attach_adapter,
/* detach_client */ &icspll_detach_client,
/* command */ &icspll_command,
/* inc_use */ &icspll_inc_use,
/* dec_use */ &icspll_dec_use
/* name */ "ICS/PLL clock reader",
/* id */ I2C_DRIVERID_ICSPLL,
/* flags */ I2C_DF_NOTIFY,
/* attach_adapter */ &icspll_attach_adapter,
/* detach_client */ &icspll_detach_client,
/* command */ &icspll_command,
/* inc_use */ &icspll_inc_use,
/* dec_use */ &icspll_dec_use
};
/* These files are created for each detected ICSPLL. This is just a template;
@@ -111,9 +112,9 @@ static struct i2c_driver icspll_driver = {
is done through one of the 'extra' fields which are initialized
when a new copy is allocated. */
static ctl_table icspll_dir_table_template[] = {
{ ICSPLL_SYSCTL1, "reg0-6", NULL, 0, 0444, NULL, &sensors_proc_real,
&sensors_sysctl_real, NULL, &icspll_contents },
{ 0 }
{ICSPLL_SYSCTL1, "reg0-6", NULL, 0, 0444, NULL, &sensors_proc_real,
&sensors_sysctl_real, NULL, &icspll_contents},
{0}
};
/* holding place for data - block read could be as much as 32 */
@@ -125,119 +126,124 @@ static int __initdata icspll_initialized = 0;
static int icspll_id = 0;
int icspll_attach_adapter(struct i2c_adapter *adapter)
{
int address,err,i;
struct i2c_client *new_client;
struct icspll_data *data;
int address, err, i;
struct i2c_client *new_client;
struct icspll_data *data;
err = 0;
/* Make sure we aren't probing the ISA bus!! */
if (i2c_is_isa_adapter(adapter)) return 0;
/* OK, this is no detection. I know. It will do for now, though. */
err = 0;
/* Make sure we aren't probing the ISA bus!! */
if (i2c_is_isa_adapter(adapter))
return 0;
/* Set err only if a global error would make registering other clients
impossible too (like out-of-memory). */
/* ICS and PLL clock chips seem to all be at 0x69.
Don't know what is out there at 0x6A, don't scan that yet. */
/* OK, this is no detection. I know. It will do for now, though. */
for (address = 0x69; (! err) && (address <= 0x69); address ++) {
/* Set err only if a global error would make registering other clients
impossible too (like out-of-memory). */
/* Later on, we will keep a list of registered addresses for each
adapter, and check whether they are used here */
/* these chips only support block transfers so use that for detection */
if(i2c_smbus_read_block_data(adapter, address, 0x00, tempdata) < 0) {
/* ICS and PLL clock chips seem to all be at 0x69.
Don't know what is out there at 0x6A, don't scan that yet. */
for (address = 0x69; (!err) && (address <= 0x69); address++) {
/* Later on, we will keep a list of registered addresses for each
adapter, and check whether they are used here */
/* these chips only support block transfers so use that for detection */
if (i2c_smbus_read_block_data
(adapter, address, 0x00, tempdata) < 0) {
#ifdef DEBUG
printk("icspll.o: No icspll found at: 0x%X\n",address);
printk("icspll.o: No icspll found at: 0x%X\n",
address);
#endif
continue;
}
continue;
}
/* Real detection code goes here */
/* Real detection code goes here */
/* Allocate space for a new client structure */
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct icspll_data),
GFP_KERNEL))) {
err = -ENOMEM;
continue;
}
/* Allocate space for a new client structure */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct icspll_data),
GFP_KERNEL))) {
err = -ENOMEM;
continue;
}
/* Fill the new client structure with data */
data = (struct icspll_data *) (new_client + 1);
new_client->data = data;
new_client->id = icspll_id++;
new_client->addr = address;
new_client->adapter = adapter;
new_client->driver = &icspll_driver;
new_client->flags = 0;
strcpy(new_client->name,"ICSPLL chip");
data->valid = 0;
init_MUTEX(&data->update_lock);
/* Fill the new client structure with data */
data = (struct icspll_data *) (new_client + 1);
new_client->data = data;
new_client->id = icspll_id++;
new_client->addr = address;
new_client->adapter = adapter;
new_client->driver = &icspll_driver;
new_client->flags = 0;
strcpy(new_client->name, "ICSPLL chip");
data->valid = 0;
init_MUTEX(&data->update_lock);
/* fill data structure so unknown registers are 0xFF */
data->data[0] = ICSPLL_SIZE;
for(i = 1; i <= ICSPLL_SIZE; i++)
data->data[i] = 0xFF;
/* Tell i2c-core a new client has arrived */
if ((err = i2c_attach_client(new_client)))
goto ERROR2;
/* Register a new directory entry with module sensors */
if ((err = sensors_register_entry(new_client,"icspll",
icspll_dir_table_template
THIS_MODULE)) < 0)
goto ERROR3;
data->sysctl_id = err;
err = 0;
data->data[0] = ICSPLL_SIZE;
for (i = 1; i <= ICSPLL_SIZE; i++)
data->data[i] = 0xFF;
continue;
/* Tell i2c-core a new client has arrived */
if ((err = i2c_attach_client(new_client)))
goto ERROR2;
/* Register a new directory entry with module sensors */
if ((err = sensors_register_entry(new_client, "icspll",
icspll_dir_table_template
THIS_MODULE)) < 0)
goto ERROR3;
data->sysctl_id = err;
err = 0;
continue;
/* OK, this is not exactly good programming practice, usually. But it is
very code-efficient in this case. */
ERROR3:
i2c_detach_client(new_client);
ERROR2:
ERROR1:
kfree(new_client);
}
return err;
ERROR3:
i2c_detach_client(new_client);
ERROR2:
ERROR1:
kfree(new_client);
}
return err;
}
int icspll_detach_client(struct i2c_client *client)
{
int err,i;
int err, i;
sensors_deregister_entry(((struct icspll_data *)(client->data))->sysctl_id);
sensors_deregister_entry(((struct icspll_data *) (client->data))->
sysctl_id);
if ((err = i2c_detach_client(client))) {
printk("icspll.o: Client deregistration failed, client not detached.\n");
return err;
}
if ((err = i2c_detach_client(client))) {
printk
("icspll.o: Client deregistration failed, client not detached.\n");
return err;
}
kfree(client);
return 0;
kfree(client);
return 0;
}
/* No commands defined yet */
int icspll_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
return 0;
return 0;
}
void icspll_inc_use (struct i2c_client *client)
void icspll_inc_use(struct i2c_client *client)
{
#ifdef MODULE
MOD_INC_USE_COUNT;
MOD_INC_USE_COUNT;
#endif
}
void icspll_dec_use (struct i2c_client *client)
void icspll_dec_use(struct i2c_client *client)
{
#ifdef MODULE
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
#endif
}
@@ -245,111 +251,117 @@ void icspll_dec_use (struct i2c_client *client)
/* No writes yet (PAE) */
int icspll_write_value(struct i2c_client *client, u8 reg, u16 value)
{
return i2c_smbus_write_block_data(client->adapter,client->addr,reg,value);
return i2c_smbus_write_block_data(client->adapter, client->addr,
reg, value);
}
#endif
void icspll_update_client(struct i2c_client *client)
{
struct icspll_data *data = client->data;
int i, len;
struct icspll_data *data = client->data;
int i, len;
down(&data->update_lock);
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
(jiffies < data->last_updated) || ! data->valid) {
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
len = i2c_smbus_read_block_data(client->adapter, client->addr, 0x00, tempdata);
len =
i2c_smbus_read_block_data(client->adapter,
client->addr, 0x00,
tempdata);
#ifdef DEBUG
printk("icspll.o: read returned %d values\n", len);
printk("icspll.o: read returned %d values\n", len);
#endif
if(len > ICSPLL_SIZE)
len = ICSPLL_SIZE;
for(i = 0; i < len; i++)
data->data[i] = tempdata[i];
data->last_updated = jiffies;
data->valid = 1;
}
if (len > ICSPLL_SIZE)
len = ICSPLL_SIZE;
for (i = 0; i < len; i++)
data->data[i] = tempdata[i];
up(&data->update_lock);
data->last_updated = jiffies;
data->valid = 1;
}
up(&data->update_lock);
}
void icspll_contents(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
void icspll_contents(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results)
{
int i;
struct icspll_data *data = client->data;
if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0;
else if (operation == SENSORS_PROC_REAL_READ) {
icspll_update_client(client);
for (i=0; i< ICSPLL_SIZE; i++) {
results[i]=data->data[i];
}
int i;
struct icspll_data *data = client->data;
if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0;
else if (operation == SENSORS_PROC_REAL_READ) {
icspll_update_client(client);
for (i = 0; i < ICSPLL_SIZE; i++) {
results[i] = data->data[i];
}
#ifdef DEBUG
printk("icspll.o: 0x%X ICSPLL Contents: ",client->addr);
for (i=0; i< ICSPLL_SIZE; i++) {
printk(" 0x%X",data->data[i]);
}
printk(" .\n");
printk("icspll.o: 0x%X ICSPLL Contents: ", client->addr);
for (i = 0; i < ICSPLL_SIZE; i++) {
printk(" 0x%X", data->data[i]);
}
printk(" .\n");
#endif
*nrels_mag = ICSPLL_SIZE;
} else if (operation == SENSORS_PROC_REAL_WRITE) {
*nrels_mag = ICSPLL_SIZE;
} else if (operation == SENSORS_PROC_REAL_WRITE) {
/* No writes to the ICSPLL (yet, anyway) (PAE) */
printk("icspll.o: No writes to ICSPLLs supported!\n");
}
printk("icspll.o: No writes to ICSPLLs supported!\n");
}
}
int __init sensors_icspll_init(void)
{
int res;
int res;
printk("icspll.o version %s (%s)\n",LM_VERSION,LM_DATE);
icspll_initialized = 0;
if ((res = i2c_add_driver(&icspll_driver))) {
printk("icspll.o: Driver registration failed, module not inserted.\n");
icspll_cleanup();
return res;
}
icspll_initialized ++;
return 0;
printk("icspll.o version %s (%s)\n", LM_VERSION, LM_DATE);
icspll_initialized = 0;
if ((res = i2c_add_driver(&icspll_driver))) {
printk
("icspll.o: Driver registration failed, module not inserted.\n");
icspll_cleanup();
return res;
}
icspll_initialized++;
return 0;
}
int __init icspll_cleanup(void)
{
int res;
int res;
if (icspll_initialized >= 1) {
if ((res = i2c_del_driver(&icspll_driver))) {
printk("icspll.o: Driver deregistration failed, module not removed.\n");
return res;
}
} else
icspll_initialized --;
if (icspll_initialized >= 1) {
if ((res = i2c_del_driver(&icspll_driver))) {
printk
("icspll.o: Driver deregistration failed, module not removed.\n");
return res;
}
} else
icspll_initialized--;
return 0;
return 0;
}
EXPORT_NO_SYMBOLS;
#ifdef MODULE
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark Studebaker <mdsxyz123@yahoo.com>");
MODULE_AUTHOR
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark Studebaker <mdsxyz123@yahoo.com>");
MODULE_DESCRIPTION("ICSPLL driver");
int init_module(void)
{
return sensors_icspll_init();
return sensors_icspll_init();
}
int cleanup_module(void)
{
return icspll_cleanup();
return icspll_cleanup();
}
#endif /* MODULE */
#endif /* MODULE */