From af46934e2fdc8301e3a4c5ae3ab420191738ed8f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 25 Feb 2003 01:51:48 -0800 Subject: [PATCH] [PATCH] remove unused last argument to i2c_register_entry (from lm_sensors CVS) --- drivers/i2c/chips/adm1021.c | 16 +++++------- drivers/i2c/chips/lm75.c | 5 ++-- drivers/i2c/i2c-proc.c | 52 +++++++++++++++++++------------------ include/linux/i2c-proc.h | 3 +-- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index 44bd127e5efe3..5c15c7b4be1fe 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -311,18 +311,14 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, goto error3; /* Register a new directory entry with module sensors */ - if ((i = i2c_register_entry(new_client, - type_name, - data->type == - adm1021 ? - adm1021_dir_table_template : - adm1021_max_dir_table_template, - THIS_MODULE)) < 0) { - err = i; + err = i2c_register_entry(new_client, type_name, + (data->type == adm1021) ? + adm1021_dir_table_template : + adm1021_max_dir_table_template); + if (err < 0) goto error4; - } - data->sysctl_id = i; + data->sysctl_id = err; /* Initialize the ADM1021 chip */ adm1021_init_client(new_client); return 0; diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index 0ab250105a5a4..e625528e7b3a9 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -191,9 +191,8 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, goto error3; /* Register a new directory entry with module sensors */ - if ((i = i2c_register_entry(new_client, type_name, - lm75_dir_table_template, - THIS_MODULE)) < 0) { + i = i2c_register_entry(new_client, type_name, lm75_dir_table_template); + if (i < 0) { err = i; goto error4; } diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index a109bf62fdcd0..2b2e752e07696 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -125,17 +125,12 @@ static int i2c_create_name(char **name, const char *prefix, ctl_template should be a template of the newly created directory. It is copied in memory. The extra2 field of each file is set to point to client. If any driver wants subdirectories within the newly created directory, - this function must be updated! - controlling_mod is the controlling module. It should usually be - THIS_MODULE when calling. Note that this symbol is not defined in - kernels before 2.3.13; define it to NULL in that case. We will not use it - for anything older than 2.3.27 anyway. */ + this function must be updated! */ int i2c_register_entry(struct i2c_client *client, const char *prefix, - ctl_table * ctl_template, - struct module *controlling_mod) + ctl_table * ctl_template) { int i, res, len, id; - ctl_table *new_table; + ctl_table *new_table, *client_tbl, *tbl; char *name; struct ctl_table_header *new_header; @@ -150,26 +145,33 @@ int i2c_register_entry(struct i2c_client *client, const char *prefix, kfree(name); return -ENOMEM; } - id += 256; + id += 256; + len = 0; while (ctl_template[len].procname) len++; - len += 7; - if (!(new_table = kmalloc(sizeof(ctl_table) * len, GFP_KERNEL))) { + if (!(new_table = kmalloc(sizeof(sysctl_table) + sizeof(ctl_table) * (len + 1), + GFP_KERNEL))) { kfree(name); return -ENOMEM; } - memcpy(new_table, sysctl_table, 6 * sizeof(ctl_table)); - new_table[0].child = &new_table[2]; - new_table[2].child = &new_table[4]; - new_table[4].child = &new_table[6]; - new_table[4].procname = name; - new_table[4].ctl_name = id; - memcpy(new_table + 6, ctl_template, (len - 6) * sizeof(ctl_table)); - for (i = 6; i < len; i++) - new_table[i].extra2 = client; + memcpy(new_table, sysctl_table, sizeof(sysctl_table)); + tbl = new_table; /* sys/ */ + tbl = tbl->child = tbl + 2; /* dev/ */ + tbl = tbl->child = tbl + 2; /* sensors/ */ + client_tbl = tbl->child = tbl + 2; /* XX-chip-YY-ZZ/ */ + + client_tbl->procname = name; + client_tbl->ctl_name = id; + client_tbl->child = client_tbl + 2; + + /* Next the client sysctls. --km */ + tbl = client_tbl->child; + memcpy(tbl, ctl_template, sizeof(ctl_table) * (len+1)); + for (i = 0; i < len; i++) + tbl[i].extra2 = client; if (!(new_header = register_sysctl_table(new_table, 0))) { printk(KERN_ERR "i2c-proc.o: error: sysctl interface not supported by kernel!\n"); @@ -178,21 +180,21 @@ int i2c_register_entry(struct i2c_client *client, const char *prefix, return -EPERM; } - i2c_entries[id - 256] = new_header; + i2c_entries[id - 256] = new_header; i2c_clients[id - 256] = client; + #ifdef DEBUG if (!new_header || !new_header->ctl_table || !new_header->ctl_table->child || !new_header->ctl_table->child->child || - !new_header->ctl_table->child->child->de) { + !new_header->ctl_table->child->child->de ) { printk (KERN_ERR "i2c-proc.o: NULL pointer when trying to install fill_inode fix!\n"); return id; } #endif /* DEBUG */ - new_header->ctl_table->child->child->de->owner = controlling_mod; - + client_tbl->de->owner = client->driver->owner; return id; } @@ -515,7 +517,7 @@ static int i2c_parse_reals(int *nrels, void *buffer, int bufsize, return 0; } -int i2c_write_reals(int nrels, void *buffer, size_t *bufsize, +static int i2c_write_reals(int nrels, void *buffer, size_t *bufsize, long *results, int magnitude) { #define BUFLEN 20 diff --git a/include/linux/i2c-proc.h b/include/linux/i2c-proc.h index c1433e5f916b7..618734230d462 100644 --- a/include/linux/i2c-proc.h +++ b/include/linux/i2c-proc.h @@ -69,8 +69,7 @@ extern int i2c_proc_real(ctl_table * ctl, int write, struct file *filp, these functions must be updated! */ extern int i2c_register_entry(struct i2c_client *client, const char *prefix, - ctl_table * ctl_template, - struct module *controlling_mod); + ctl_table * ctl_template); extern void i2c_deregister_entry(int id); -- 2.53.0