| 1 | /* |
|---|
| 2 | sensors.c - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | monitoring |
|---|
| 4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| 5 | |
|---|
| 6 | This program is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU General Public License as published by |
|---|
| 8 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | This program is distributed in the hope that it will be useful, |
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | GNU General Public License for more details. |
|---|
| 15 | |
|---|
| 16 | You should have received a copy of the GNU General Public License |
|---|
| 17 | along with this program; if not, write to the Free Software |
|---|
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include <linux/version.h> |
|---|
| 22 | #include <linux/module.h> |
|---|
| 23 | #include <linux/kernel.h> |
|---|
| 24 | #include <linux/malloc.h> |
|---|
| 25 | #include <linux/ctype.h> |
|---|
| 26 | #include <linux/sysctl.h> |
|---|
| 27 | #include <linux/proc_fs.h> |
|---|
| 28 | #include <linux/ioport.h> |
|---|
| 29 | #include <asm/uaccess.h> |
|---|
| 30 | |
|---|
| 31 | #include "version.h" |
|---|
| 32 | #include <linux/i2c.h> |
|---|
| 33 | #include "i2c-isa.h" |
|---|
| 34 | #include "sensors.h" |
|---|
| 35 | |
|---|
| 36 | #include <linux/init.h> |
|---|
| 37 | |
|---|
| 38 | #ifdef MODULE |
|---|
| 39 | extern int init_module(void); |
|---|
| 40 | extern int cleanup_module(void); |
|---|
| 41 | static int sensors_cleanup(void); |
|---|
| 42 | #endif /* MODULE */ |
|---|
| 43 | |
|---|
| 44 | #ifndef THIS_MODULE |
|---|
| 45 | #define THIS_MODULE NULL |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | static int sensors_create_name(char **name, const char *prefix, |
|---|
| 49 | struct i2c_adapter *adapter, int addr); |
|---|
| 50 | static int sensors_parse_reals(int *nrels, void *buffer, int bufsize, |
|---|
| 51 | long *results, int magnitude); |
|---|
| 52 | static int sensors_write_reals(int nrels, void *buffer, int *bufsize, |
|---|
| 53 | long *results, int magnitude); |
|---|
| 54 | static int sensors_proc_chips(ctl_table * ctl, int write, |
|---|
| 55 | struct file *filp, void *buffer, |
|---|
| 56 | size_t * lenp); |
|---|
| 57 | static int sensors_sysctl_chips(ctl_table * table, int *name, int nlen, |
|---|
| 58 | void *oldval, size_t * oldlenp, |
|---|
| 59 | void *newval, size_t newlen, |
|---|
| 60 | void **context); |
|---|
| 61 | |
|---|
| 62 | static int __init sensors_init(void); |
|---|
| 63 | |
|---|
| 64 | #define SENSORS_ENTRY_MAX 20 |
|---|
| 65 | static struct ctl_table_header *sensors_entries[SENSORS_ENTRY_MAX]; |
|---|
| 66 | |
|---|
| 67 | static struct i2c_client *sensors_clients[SENSORS_ENTRY_MAX]; |
|---|
| 68 | static unsigned short sensors_inodes[SENSORS_ENTRY_MAX]; |
|---|
| 69 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1) |
|---|
| 70 | static void sensors_fill_inode(struct inode *inode, int fill); |
|---|
| 71 | static void sensors_dir_fill_inode(struct inode *inode, int fill); |
|---|
| 72 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1) */ |
|---|
| 73 | |
|---|
| 74 | static ctl_table sysctl_table[] = { |
|---|
| 75 | {CTL_DEV, "dev", NULL, 0, 0555}, |
|---|
| 76 | {0}, |
|---|
| 77 | {DEV_SENSORS, "sensors", NULL, 0, 0555}, |
|---|
| 78 | {0}, |
|---|
| 79 | {0, NULL, NULL, 0, 0555}, |
|---|
| 80 | {0} |
|---|
| 81 | }; |
|---|
| 82 | |
|---|
| 83 | static ctl_table sensors_proc_dev_sensors[] = { |
|---|
| 84 | {SENSORS_CHIPS, "chips", NULL, 0, 0644, NULL, &sensors_proc_chips, |
|---|
| 85 | &sensors_sysctl_chips}, |
|---|
| 86 | {0} |
|---|
| 87 | }; |
|---|
| 88 | |
|---|
| 89 | static ctl_table sensors_proc_dev[] = { |
|---|
| 90 | {DEV_SENSORS, "sensors", NULL, 0, 0555, sensors_proc_dev_sensors}, |
|---|
| 91 | {0}, |
|---|
| 92 | }; |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | static ctl_table sensors_proc[] = { |
|---|
| 96 | {CTL_DEV, "dev", NULL, 0, 0555, sensors_proc_dev}, |
|---|
| 97 | {0} |
|---|
| 98 | }; |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | static struct ctl_table_header *sensors_proc_header; |
|---|
| 102 | static int sensors_initialized; |
|---|
| 103 | |
|---|
| 104 | /* This returns a nice name for a new directory; for example lm78-isa-0310 |
|---|
| 105 | (for a LM78 chip on the ISA bus at port 0x310), or lm75-i2c-3-4e (for |
|---|
| 106 | a LM75 chip on the third i2c bus at address 0x4e). |
|---|
| 107 | name is allocated first. */ |
|---|
| 108 | int sensors_create_name(char **name, const char *prefix, |
|---|
| 109 | struct i2c_adapter *adapter, int addr) |
|---|
| 110 | { |
|---|
| 111 | char name_buffer[50]; |
|---|
| 112 | int id; |
|---|
| 113 | if (i2c_is_isa_adapter(adapter)) |
|---|
| 114 | sprintf(name_buffer, "%s-isa-%04x", prefix, addr); |
|---|
| 115 | else { |
|---|
| 116 | if ((id = i2c_adapter_id(adapter)) < 0) |
|---|
| 117 | return -ENOENT; |
|---|
| 118 | sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr); |
|---|
| 119 | } |
|---|
| 120 | *name = kmalloc(strlen(name_buffer) + 1, GFP_KERNEL); |
|---|
| 121 | strcpy(*name, name_buffer); |
|---|
| 122 | return 0; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | /* This rather complex function must be called when you want to add an entry |
|---|
| 126 | to /proc/sys/dev/sensors/chips. It also creates a new directory within |
|---|
| 127 | /proc/sys/dev/sensors/. |
|---|
| 128 | ctl_template should be a template of the newly created directory. It is |
|---|
| 129 | copied in memory. The extra2 field of each file is set to point to client. |
|---|
| 130 | If any driver wants subdirectories within the newly created directory, |
|---|
| 131 | this function must be updated! |
|---|
| 132 | controlling_mod is the controlling module. It should usually be |
|---|
| 133 | THIS_MODULE when calling. Note that this symbol is not defined in |
|---|
| 134 | kernels before 2.3.13; define it to NULL in that case. We will not use it |
|---|
| 135 | for anything older than 2.3.27 anyway. */ |
|---|
| 136 | int sensors_register_entry(struct i2c_client *client, const char *prefix, |
|---|
| 137 | ctl_table * ctl_template, |
|---|
| 138 | struct module *controlling_mod) |
|---|
| 139 | { |
|---|
| 140 | int i, res, len, id; |
|---|
| 141 | ctl_table *new_table; |
|---|
| 142 | char *name; |
|---|
| 143 | struct ctl_table_header *new_header; |
|---|
| 144 | |
|---|
| 145 | if ((res = sensors_create_name(&name, prefix, client->adapter, |
|---|
| 146 | client->addr))) return res; |
|---|
| 147 | |
|---|
| 148 | for (id = 0; id < SENSORS_ENTRY_MAX; id++) |
|---|
| 149 | if (!sensors_entries[id]) { |
|---|
| 150 | break; |
|---|
| 151 | } |
|---|
| 152 | if (id == SENSORS_ENTRY_MAX) { |
|---|
| 153 | kfree(name); |
|---|
| 154 | return -ENOMEM; |
|---|
| 155 | } |
|---|
| 156 | id += 256; |
|---|
| 157 | |
|---|
| 158 | len = 0; |
|---|
| 159 | while (ctl_template[len].procname) |
|---|
| 160 | len++; |
|---|
| 161 | len += 7; |
|---|
| 162 | if (!(new_table = kmalloc(sizeof(ctl_table) * len, GFP_KERNEL))) { |
|---|
| 163 | kfree(name); |
|---|
| 164 | return -ENOMEM; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | memcpy(new_table, sysctl_table, 6 * sizeof(ctl_table)); |
|---|
| 168 | new_table[0].child = &new_table[2]; |
|---|
| 169 | new_table[2].child = &new_table[4]; |
|---|
| 170 | new_table[4].child = &new_table[6]; |
|---|
| 171 | new_table[4].procname = name; |
|---|
| 172 | new_table[4].ctl_name = id; |
|---|
| 173 | memcpy(new_table + 6, ctl_template, (len - 6) * sizeof(ctl_table)); |
|---|
| 174 | for (i = 6; i < len; i++) |
|---|
| 175 | new_table[i].extra2 = client; |
|---|
| 176 | |
|---|
| 177 | if (!(new_header = register_sysctl_table(new_table, 0))) { |
|---|
| 178 | kfree(new_table); |
|---|
| 179 | kfree(name); |
|---|
| 180 | return -ENOMEM; |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | sensors_entries[id - 256] = new_header; |
|---|
| 184 | |
|---|
| 185 | sensors_clients[id - 256] = client; |
|---|
| 186 | #ifdef DEBUG |
|---|
| 187 | if (!new_header || !new_header->ctl_table || |
|---|
| 188 | !new_header->ctl_table->child || |
|---|
| 189 | !new_header->ctl_table->child->child || |
|---|
| 190 | !new_header->ctl_table->child->child->de) { |
|---|
| 191 | printk |
|---|
| 192 | ("sensors.o: NULL pointer when trying to install fill_inode fix!\n"); |
|---|
| 193 | return id; |
|---|
| 194 | } |
|---|
| 195 | #endif /* DEBUG */ |
|---|
| 196 | sensors_inodes[id - 256] = |
|---|
| 197 | new_header->ctl_table->child->child->de->low_ino; |
|---|
| 198 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) |
|---|
| 199 | new_header->ctl_table->child->child->de->owner = controlling_mod; |
|---|
| 200 | #else |
|---|
| 201 | new_header->ctl_table->child->child->de->fill_inode = |
|---|
| 202 | &sensors_dir_fill_inode; |
|---|
| 203 | #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) */ |
|---|
| 204 | |
|---|
| 205 | return id; |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | void sensors_deregister_entry(int id) |
|---|
| 209 | { |
|---|
| 210 | ctl_table *table; |
|---|
| 211 | char *temp; |
|---|
| 212 | id -= 256; |
|---|
| 213 | if (sensors_entries[id]) { |
|---|
| 214 | table = sensors_entries[id]->ctl_table; |
|---|
| 215 | unregister_sysctl_table(sensors_entries[id]); |
|---|
| 216 | /* Below two-step kfree is needed to keep gcc happy about const points */ |
|---|
| 217 | (const char *) temp = table[4].procname; |
|---|
| 218 | kfree(temp); |
|---|
| 219 | kfree(table); |
|---|
| 220 | sensors_entries[id] = NULL; |
|---|
| 221 | sensors_clients[id] = NULL; |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | /* Monitor access for /proc/sys/dev/sensors; make unloading sensors.o |
|---|
| 226 | impossible if some process still uses it or some file in it */ |
|---|
| 227 | void sensors_fill_inode(struct inode *inode, int fill) |
|---|
| 228 | { |
|---|
| 229 | if (fill) |
|---|
| 230 | MOD_INC_USE_COUNT; |
|---|
| 231 | else |
|---|
| 232 | MOD_DEC_USE_COUNT; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | /* Monitor access for /proc/sys/dev/sensors/ directories; make unloading |
|---|
| 236 | the corresponding module impossible if some process still uses it or |
|---|
| 237 | some file in it */ |
|---|
| 238 | void sensors_dir_fill_inode(struct inode *inode, int fill) |
|---|
| 239 | { |
|---|
| 240 | int i; |
|---|
| 241 | struct i2c_client *client; |
|---|
| 242 | |
|---|
| 243 | #ifdef DEBUG |
|---|
| 244 | if (!inode) { |
|---|
| 245 | printk("sensors.o: Warning: inode NULL in fill_inode()\n"); |
|---|
| 246 | return; |
|---|
| 247 | } |
|---|
| 248 | #endif /* def DEBUG */ |
|---|
| 249 | |
|---|
| 250 | for (i = 0; i < SENSORS_ENTRY_MAX; i++) |
|---|
| 251 | if (sensors_clients[i] |
|---|
| 252 | && (sensors_inodes[i] == inode->i_ino)) break; |
|---|
| 253 | #ifdef DEBUG |
|---|
| 254 | if (i == SENSORS_ENTRY_MAX) { |
|---|
| 255 | printk |
|---|
| 256 | ("sensors.o: Warning: inode (%ld) not found in fill_inode()\n", |
|---|
| 257 | inode->i_ino); |
|---|
| 258 | return; |
|---|
| 259 | } |
|---|
| 260 | #endif /* def DEBUG */ |
|---|
| 261 | client = sensors_clients[i]; |
|---|
| 262 | if (fill) |
|---|
| 263 | client->driver->inc_use(client); |
|---|
| 264 | else |
|---|
| 265 | client->driver->dec_use(client); |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | int sensors_proc_chips(ctl_table * ctl, int write, struct file *filp, |
|---|
| 269 | void *buffer, size_t * lenp) |
|---|
| 270 | { |
|---|
| 271 | char BUF[SENSORS_PREFIX_MAX + 30]; |
|---|
| 272 | int buflen, curbufsize, i; |
|---|
| 273 | struct ctl_table *client_tbl; |
|---|
| 274 | |
|---|
| 275 | if (write) |
|---|
| 276 | return 0; |
|---|
| 277 | |
|---|
| 278 | /* If buffer is size 0, or we try to read when not at the start, we |
|---|
| 279 | return nothing. Note that I think writing when not at the start |
|---|
| 280 | does not work either, but anyway, this is straight from the kernel |
|---|
| 281 | sources. */ |
|---|
| 282 | if (!*lenp || (filp->f_pos && !write)) { |
|---|
| 283 | *lenp = 0; |
|---|
| 284 | return 0; |
|---|
| 285 | } |
|---|
| 286 | curbufsize = 0; |
|---|
| 287 | for (i = 0; i < SENSORS_ENTRY_MAX; i++) |
|---|
| 288 | if (sensors_entries[i]) { |
|---|
| 289 | client_tbl = |
|---|
| 290 | sensors_entries[i]->ctl_table->child->child; |
|---|
| 291 | buflen = |
|---|
| 292 | sprintf(BUF, "%d\t%s\n", client_tbl->ctl_name, |
|---|
| 293 | client_tbl->procname); |
|---|
| 294 | if (buflen + curbufsize > *lenp) |
|---|
| 295 | buflen = *lenp - curbufsize; |
|---|
| 296 | if(copy_to_user(buffer, BUF, buflen)) |
|---|
| 297 | return -EFAULT; |
|---|
| 298 | curbufsize += buflen; |
|---|
| 299 | (char *) buffer += buflen; |
|---|
| 300 | } |
|---|
| 301 | *lenp = curbufsize; |
|---|
| 302 | filp->f_pos += curbufsize; |
|---|
| 303 | return 0; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | int sensors_sysctl_chips(ctl_table * table, int *name, int nlen, |
|---|
| 307 | void *oldval, size_t * oldlenp, void *newval, |
|---|
| 308 | size_t newlen, void **context) |
|---|
| 309 | { |
|---|
| 310 | struct sensors_chips_data data; |
|---|
| 311 | int i, oldlen, nrels, maxels,ret=0; |
|---|
| 312 | struct ctl_table *client_tbl; |
|---|
| 313 | |
|---|
| 314 | if (oldval && oldlenp && !((ret = get_user(oldlen, oldlenp))) && |
|---|
| 315 | oldlen) { |
|---|
| 316 | maxels = oldlen / sizeof(struct sensors_chips_data); |
|---|
| 317 | nrels = 0; |
|---|
| 318 | for (i = 0; (i < SENSORS_ENTRY_MAX) && (nrels < maxels); |
|---|
| 319 | i++) |
|---|
| 320 | if (sensors_entries[i]) { |
|---|
| 321 | client_tbl = |
|---|
| 322 | sensors_entries[i]->ctl_table->child-> |
|---|
| 323 | child; |
|---|
| 324 | data.sysctl_id = client_tbl->ctl_name; |
|---|
| 325 | strcpy(data.name, client_tbl->procname); |
|---|
| 326 | if(copy_to_user(oldval, &data, |
|---|
| 327 | sizeof(struct |
|---|
| 328 | sensors_chips_data))) |
|---|
| 329 | return -EFAULT; |
|---|
| 330 | (char *) oldval += |
|---|
| 331 | sizeof(struct sensors_chips_data); |
|---|
| 332 | nrels++; |
|---|
| 333 | } |
|---|
| 334 | oldlen = nrels * sizeof(struct sensors_chips_data); |
|---|
| 335 | if(put_user(oldlen, oldlenp)) |
|---|
| 336 | return -EFAULT; |
|---|
| 337 | } |
|---|
| 338 | return ret; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | /* This funcion reads or writes a 'real' value (encoded by the combination |
|---|
| 343 | of an integer and a magnitude, the last is the power of ten the value |
|---|
| 344 | should be divided with) to a /proc/sys directory. To use this function, |
|---|
| 345 | you must (before registering the ctl_table) set the extra2 field to the |
|---|
| 346 | client, and the extra1 field to a function of the form: |
|---|
| 347 | void func(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 348 | int *nrels_mag, long *results) |
|---|
| 349 | This function can be called for three values of operation. If operation |
|---|
| 350 | equals SENSORS_PROC_REAL_INFO, the magnitude should be returned in |
|---|
| 351 | nrels_mag. If operation equals SENSORS_PROC_REAL_READ, values should |
|---|
| 352 | be read into results. nrels_mag should return the number of elements |
|---|
| 353 | read; the maximum number is put in it on entry. Finally, if operation |
|---|
| 354 | equals SENSORS_PROC_REAL_WRITE, the values in results should be |
|---|
| 355 | written to the chip. nrels_mag contains on entry the number of elements |
|---|
| 356 | found. |
|---|
| 357 | In all cases, client points to the client we wish to interact with, |
|---|
| 358 | and ctl_name is the SYSCTL id of the file we are accessing. */ |
|---|
| 359 | int sensors_proc_real(ctl_table * ctl, int write, struct file *filp, |
|---|
| 360 | void *buffer, size_t * lenp) |
|---|
| 361 | { |
|---|
| 362 | #define MAX_RESULTS 32 |
|---|
| 363 | int mag, nrels = MAX_RESULTS; |
|---|
| 364 | long results[MAX_RESULTS]; |
|---|
| 365 | sensors_real_callback callback = ctl->extra1; |
|---|
| 366 | struct i2c_client *client = ctl->extra2; |
|---|
| 367 | int res; |
|---|
| 368 | |
|---|
| 369 | /* If buffer is size 0, or we try to read when not at the start, we |
|---|
| 370 | return nothing. Note that I think writing when not at the start |
|---|
| 371 | does not work either, but anyway, this is straight from the kernel |
|---|
| 372 | sources. */ |
|---|
| 373 | if (!*lenp || (filp->f_pos && !write)) { |
|---|
| 374 | *lenp = 0; |
|---|
| 375 | return 0; |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | /* Get the magnitude */ |
|---|
| 379 | callback(client, SENSORS_PROC_REAL_INFO, ctl->ctl_name, &mag, |
|---|
| 380 | NULL); |
|---|
| 381 | |
|---|
| 382 | if (write) { |
|---|
| 383 | /* Read the complete input into results, converting to longs */ |
|---|
| 384 | res = sensors_parse_reals(&nrels, buffer, *lenp, results, mag); |
|---|
| 385 | if (res) |
|---|
| 386 | return res; |
|---|
| 387 | |
|---|
| 388 | if (!nrels) |
|---|
| 389 | return 0; |
|---|
| 390 | |
|---|
| 391 | /* Now feed this information back to the client */ |
|---|
| 392 | callback(client, SENSORS_PROC_REAL_WRITE, ctl->ctl_name, |
|---|
| 393 | &nrels, results); |
|---|
| 394 | |
|---|
| 395 | filp->f_pos += *lenp; |
|---|
| 396 | return 0; |
|---|
| 397 | } else { /* read */ |
|---|
| 398 | /* Get the information from the client into results */ |
|---|
| 399 | callback(client, SENSORS_PROC_REAL_READ, ctl->ctl_name, |
|---|
| 400 | &nrels, results); |
|---|
| 401 | |
|---|
| 402 | /* And write them to buffer, converting to reals */ |
|---|
| 403 | res = sensors_write_reals(nrels, buffer, lenp, results, mag); |
|---|
| 404 | if (res) |
|---|
| 405 | return res; |
|---|
| 406 | filp->f_pos += *lenp; |
|---|
| 407 | return 0; |
|---|
| 408 | } |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | /* This function is equivalent to sensors_proc_real, only it interacts with |
|---|
| 412 | the sysctl(2) syscall, and returns no reals, but integers */ |
|---|
| 413 | int sensors_sysctl_real(ctl_table * table, int *name, int nlen, |
|---|
| 414 | void *oldval, size_t * oldlenp, void *newval, |
|---|
| 415 | size_t newlen, void **context) |
|---|
| 416 | { |
|---|
| 417 | long results[MAX_RESULTS]; |
|---|
| 418 | int oldlen, nrels = MAX_RESULTS,ret=0; |
|---|
| 419 | sensors_real_callback callback = table->extra1; |
|---|
| 420 | struct i2c_client *client = table->extra2; |
|---|
| 421 | |
|---|
| 422 | /* Check if we need to output the old values */ |
|---|
| 423 | if (oldval && oldlenp && !((ret=get_user(oldlen, oldlenp))) && oldlen) { |
|---|
| 424 | callback(client, SENSORS_PROC_REAL_READ, table->ctl_name, |
|---|
| 425 | &nrels, results); |
|---|
| 426 | |
|---|
| 427 | /* Note the rounding factor! */ |
|---|
| 428 | if (nrels * sizeof(long) < oldlen) |
|---|
| 429 | oldlen = nrels * sizeof(long); |
|---|
| 430 | oldlen = (oldlen / sizeof(long)) * sizeof(long); |
|---|
| 431 | if(copy_to_user(oldval, results, oldlen)) |
|---|
| 432 | return -EFAULT; |
|---|
| 433 | if(put_user(oldlen, oldlenp)) |
|---|
| 434 | return -EFAULT; |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | if (newval && newlen) { |
|---|
| 438 | /* Note the rounding factor! */ |
|---|
| 439 | newlen -= newlen % sizeof(long); |
|---|
| 440 | nrels = newlen / sizeof(long); |
|---|
| 441 | if(copy_from_user(results, newval, newlen)) |
|---|
| 442 | return -EFAULT; |
|---|
| 443 | |
|---|
| 444 | /* Get the new values back to the client */ |
|---|
| 445 | callback(client, SENSORS_PROC_REAL_WRITE, table->ctl_name, |
|---|
| 446 | &nrels, results); |
|---|
| 447 | } |
|---|
| 448 | return ret; |
|---|
| 449 | } |
|---|
| 450 | |
|---|
| 451 | |
|---|
| 452 | /* nrels contains initially the maximum number of elements which can be |
|---|
| 453 | put in results, and finally the number of elements actually put there. |
|---|
| 454 | A magnitude of 1 will multiply everything with 10; etc. |
|---|
| 455 | buffer, bufsize is the character buffer we read from and its length. |
|---|
| 456 | results will finally contain the parsed integers. |
|---|
| 457 | |
|---|
| 458 | Buffer should contain several reals, separated by whitespace. A real |
|---|
| 459 | has the following syntax: |
|---|
| 460 | [ Minus ] Digit* [ Dot Digit* ] |
|---|
| 461 | (everything between [] is optional; * means zero or more). |
|---|
| 462 | When the next character is unparsable, everything is skipped until the |
|---|
| 463 | next whitespace. |
|---|
| 464 | |
|---|
| 465 | WARNING! This is tricky code. I have tested it, but there may still be |
|---|
| 466 | hidden bugs in it, even leading to crashes and things! |
|---|
| 467 | */ |
|---|
| 468 | int sensors_parse_reals(int *nrels, void *buffer, int bufsize, |
|---|
| 469 | long *results, int magnitude) |
|---|
| 470 | { |
|---|
| 471 | int maxels, min, mag; |
|---|
| 472 | long res,ret=0; |
|---|
| 473 | char nextchar = 0; |
|---|
| 474 | |
|---|
| 475 | maxels = *nrels; |
|---|
| 476 | *nrels = 0; |
|---|
| 477 | |
|---|
| 478 | while (bufsize && (*nrels < maxels)) { |
|---|
| 479 | |
|---|
| 480 | /* Skip spaces at the start */ |
|---|
| 481 | while (bufsize && |
|---|
| 482 | !((ret=get_user(nextchar, (char *) buffer))) && |
|---|
| 483 | isspace((int) nextchar)) { |
|---|
| 484 | bufsize--; |
|---|
| 485 | ((char *) buffer)++; |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | if (ret) |
|---|
| 489 | return -EFAULT; |
|---|
| 490 | /* Well, we may be done now */ |
|---|
| 491 | if (!bufsize) |
|---|
| 492 | return 0; |
|---|
| 493 | |
|---|
| 494 | /* New defaults for our result */ |
|---|
| 495 | min = 0; |
|---|
| 496 | res = 0; |
|---|
| 497 | mag = magnitude; |
|---|
| 498 | |
|---|
| 499 | /* Check for a minus */ |
|---|
| 500 | if (!((ret=get_user(nextchar, (char *) buffer))) |
|---|
| 501 | && (nextchar == '-')) { |
|---|
| 502 | min = 1; |
|---|
| 503 | bufsize--; |
|---|
| 504 | ((char *) buffer)++; |
|---|
| 505 | } |
|---|
| 506 | if (ret) |
|---|
| 507 | return -EFAULT; |
|---|
| 508 | |
|---|
| 509 | /* Digits before a decimal dot */ |
|---|
| 510 | while (bufsize && |
|---|
| 511 | !((ret=get_user(nextchar, (char *) buffer))) && |
|---|
| 512 | isdigit((int) nextchar)) { |
|---|
| 513 | res = res * 10 + nextchar - '0'; |
|---|
| 514 | bufsize--; |
|---|
| 515 | ((char *) buffer)++; |
|---|
| 516 | } |
|---|
| 517 | if (ret) |
|---|
| 518 | return -EFAULT; |
|---|
| 519 | |
|---|
| 520 | /* If mag < 0, we must actually divide here! */ |
|---|
| 521 | while (mag < 0) { |
|---|
| 522 | res = res / 10; |
|---|
| 523 | mag++; |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | if (bufsize && (nextchar == '.')) { |
|---|
| 527 | /* Skip the dot */ |
|---|
| 528 | bufsize--; |
|---|
| 529 | ((char *) buffer)++; |
|---|
| 530 | |
|---|
| 531 | /* Read digits while they are significant */ |
|---|
| 532 | while (bufsize && (mag > 0) && |
|---|
| 533 | !((ret=get_user(nextchar, (char *) buffer))) && |
|---|
| 534 | isdigit((int) nextchar)) { |
|---|
| 535 | res = res * 10 + nextchar - '0'; |
|---|
| 536 | mag--; |
|---|
| 537 | bufsize--; |
|---|
| 538 | ((char *) buffer)++; |
|---|
| 539 | } |
|---|
| 540 | if (ret) |
|---|
| 541 | return -EFAULT; |
|---|
| 542 | } |
|---|
| 543 | /* If we are out of data, but mag > 0, we need to scale here */ |
|---|
| 544 | while (mag > 0) { |
|---|
| 545 | res = res * 10; |
|---|
| 546 | mag--; |
|---|
| 547 | } |
|---|
| 548 | |
|---|
| 549 | /* Skip everything until we hit whitespace */ |
|---|
| 550 | while (bufsize && |
|---|
| 551 | !((ret=get_user(nextchar, (char *) buffer))) && |
|---|
| 552 | isspace((int) nextchar)) { |
|---|
| 553 | bufsize--; |
|---|
| 554 | ((char *) buffer)++; |
|---|
| 555 | } |
|---|
| 556 | if (ret) |
|---|
| 557 | return -EFAULT; |
|---|
| 558 | |
|---|
| 559 | /* Put res in results */ |
|---|
| 560 | results[*nrels] = (min ? -1 : 1) * res; |
|---|
| 561 | (*nrels)++; |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | /* Well, there may be more in the buffer, but we need no more data. |
|---|
| 565 | Ignore anything that is left. */ |
|---|
| 566 | return 0; |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | int sensors_write_reals(int nrels, void *buffer, int *bufsize, |
|---|
| 570 | long *results, int magnitude) |
|---|
| 571 | { |
|---|
| 572 | #define BUFLEN 20 |
|---|
| 573 | char BUF[BUFLEN + 1]; /* An individual representation should fit! */ |
|---|
| 574 | char printfstr[10]; |
|---|
| 575 | int nr = 0; |
|---|
| 576 | int buflen, mag, times; |
|---|
| 577 | int curbufsize = 0; |
|---|
| 578 | |
|---|
| 579 | while ((nr < nrels) && (curbufsize < *bufsize)) { |
|---|
| 580 | mag = magnitude; |
|---|
| 581 | |
|---|
| 582 | if (nr != 0) { |
|---|
| 583 | if(put_user(' ', (char *) buffer)) |
|---|
| 584 | return -EFAULT; |
|---|
| 585 | curbufsize++; |
|---|
| 586 | ((char *) buffer)++; |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | /* Fill BUF with the representation of the next string */ |
|---|
| 590 | if (mag <= 0) { |
|---|
| 591 | buflen = sprintf(BUF, "%ld", results[nr]); |
|---|
| 592 | if (buflen < 0) { /* Oops, a sprintf error! */ |
|---|
| 593 | *bufsize = 0; |
|---|
| 594 | return -EINVAL; |
|---|
| 595 | } |
|---|
| 596 | while ((mag < 0) && (buflen < BUFLEN)) { |
|---|
| 597 | BUF[buflen++] = '0'; |
|---|
| 598 | mag++; |
|---|
| 599 | } |
|---|
| 600 | BUF[buflen] = 0; |
|---|
| 601 | } else { |
|---|
| 602 | times = 1; |
|---|
| 603 | for (times = 1; mag-- > 0; times *= 10); |
|---|
| 604 | if (results[nr] < 0) { |
|---|
| 605 | BUF[0] = '-'; |
|---|
| 606 | buflen = 1; |
|---|
| 607 | } else |
|---|
| 608 | buflen = 0; |
|---|
| 609 | strcpy(printfstr, "%ld.%0Xld"); |
|---|
| 610 | printfstr[6] = magnitude + '0'; |
|---|
| 611 | buflen += |
|---|
| 612 | sprintf(BUF + buflen, printfstr, |
|---|
| 613 | abs(results[nr]) / times, |
|---|
| 614 | abs(results[nr]) % times); |
|---|
| 615 | if (buflen < 0) { /* Oops, a sprintf error! */ |
|---|
| 616 | *bufsize = 0; |
|---|
| 617 | return -EINVAL; |
|---|
| 618 | } |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | /* Now copy it to the user-space buffer */ |
|---|
| 622 | if (buflen + curbufsize > *bufsize) |
|---|
| 623 | buflen = *bufsize - curbufsize; |
|---|
| 624 | if(copy_to_user(buffer, BUF, buflen)) |
|---|
| 625 | return -EFAULT; |
|---|
| 626 | curbufsize += buflen; |
|---|
| 627 | (char *) buffer += buflen; |
|---|
| 628 | |
|---|
| 629 | nr++; |
|---|
| 630 | } |
|---|
| 631 | if (curbufsize < *bufsize) { |
|---|
| 632 | if(put_user('\n', (char *) buffer)) |
|---|
| 633 | return -EFAULT; |
|---|
| 634 | curbufsize++; |
|---|
| 635 | } |
|---|
| 636 | *bufsize = curbufsize; |
|---|
| 637 | return 0; |
|---|
| 638 | } |
|---|
| 639 | |
|---|
| 640 | |
|---|
| 641 | /* Very inefficient for ISA detects, and won't work for 10-bit addresses! */ |
|---|
| 642 | int sensors_detect(struct i2c_adapter *adapter, |
|---|
| 643 | struct sensors_address_data *address_data, |
|---|
| 644 | sensors_found_addr_proc * found_proc) |
|---|
| 645 | { |
|---|
| 646 | int addr, i, found, j, err; |
|---|
| 647 | struct sensors_force_data *this_force; |
|---|
| 648 | int is_isa = i2c_is_isa_adapter(adapter); |
|---|
| 649 | int adapter_id = |
|---|
| 650 | is_isa ? SENSORS_ISA_BUS : i2c_adapter_id(adapter); |
|---|
| 651 | |
|---|
| 652 | /* Forget it if we can't probe using SMBUS_QUICK */ |
|---|
| 653 | if ((!is_isa) |
|---|
| 654 | && !i2c_check_functionality(adapter, |
|---|
| 655 | I2C_FUNC_SMBUS_QUICK)) return -1; |
|---|
| 656 | |
|---|
| 657 | for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { |
|---|
| 658 | if ((is_isa && check_region(addr, 1)) || |
|---|
| 659 | (!is_isa && i2c_check_addr(adapter, addr))) |
|---|
| 660 | continue; |
|---|
| 661 | |
|---|
| 662 | /* If it is in one of the force entries, we don't do any detection |
|---|
| 663 | at all */ |
|---|
| 664 | found = 0; |
|---|
| 665 | for (i = 0; |
|---|
| 666 | !found |
|---|
| 667 | && (this_force = |
|---|
| 668 | address_data->forces + i, this_force->force); i++) { |
|---|
| 669 | for (j = 0; |
|---|
| 670 | !found |
|---|
| 671 | && (this_force->force[j] != SENSORS_I2C_END); |
|---|
| 672 | j += 2) { |
|---|
| 673 | if ( |
|---|
| 674 | ((adapter_id == this_force->force[j]) |
|---|
| 675 | || |
|---|
| 676 | ((this_force-> |
|---|
| 677 | force[j] == SENSORS_ANY_I2C_BUS) |
|---|
| 678 | && !is_isa)) |
|---|
| 679 | && (addr == this_force->force[j + 1])) { |
|---|
| 680 | #ifdef DEBUG |
|---|
| 681 | printk |
|---|
| 682 | ("sensors.o: found force parameter for adapter %d, addr %04x\n", |
|---|
| 683 | adapter_id, addr); |
|---|
| 684 | #endif |
|---|
| 685 | if ( |
|---|
| 686 | (err = |
|---|
| 687 | found_proc(adapter, addr, 0, |
|---|
| 688 | this_force-> |
|---|
| 689 | kind))) return err; |
|---|
| 690 | found = 1; |
|---|
| 691 | } |
|---|
| 692 | } |
|---|
| 693 | } |
|---|
| 694 | if (found) |
|---|
| 695 | continue; |
|---|
| 696 | |
|---|
| 697 | /* If this address is in one of the ignores, we can forget about it |
|---|
| 698 | right now */ |
|---|
| 699 | for (i = 0; |
|---|
| 700 | !found |
|---|
| 701 | && (address_data->ignore[i] != SENSORS_I2C_END); |
|---|
| 702 | i += 2) { |
|---|
| 703 | if ( |
|---|
| 704 | ((adapter_id == address_data->ignore[i]) |
|---|
| 705 | || |
|---|
| 706 | ((address_data-> |
|---|
| 707 | ignore[i] == SENSORS_ANY_I2C_BUS) |
|---|
| 708 | && !is_isa)) |
|---|
| 709 | && (addr == address_data->ignore[i + 1])) { |
|---|
| 710 | #ifdef DEBUG |
|---|
| 711 | printk |
|---|
| 712 | ("sensors.o: found ignore parameter for adapter %d, " |
|---|
| 713 | "addr %04x\n", adapter_id, addr); |
|---|
| 714 | #endif |
|---|
| 715 | found = 1; |
|---|
| 716 | } |
|---|
| 717 | } |
|---|
| 718 | for (i = 0; |
|---|
| 719 | !found |
|---|
| 720 | && (address_data->ignore_range[i] != SENSORS_I2C_END); |
|---|
| 721 | i += 3) { |
|---|
| 722 | if ( |
|---|
| 723 | ((adapter_id == address_data->ignore_range[i]) |
|---|
| 724 | || |
|---|
| 725 | ((address_data-> |
|---|
| 726 | ignore_range[i] == |
|---|
| 727 | SENSORS_ANY_I2C_BUS) & !is_isa)) |
|---|
| 728 | && (addr >= address_data->ignore_range[i + 1]) |
|---|
| 729 | && (addr <= address_data->ignore_range[i + 2])) { |
|---|
| 730 | #ifdef DEBUG |
|---|
| 731 | printk |
|---|
| 732 | ("sensors.o: found ignore_range parameter for adapter %d, " |
|---|
| 733 | "addr %04x\n", adapter_id, addr); |
|---|
| 734 | #endif |
|---|
| 735 | found = 1; |
|---|
| 736 | } |
|---|
| 737 | } |
|---|
| 738 | if (found) |
|---|
| 739 | continue; |
|---|
| 740 | |
|---|
| 741 | /* Now, we will do a detection, but only if it is in the normal or |
|---|
| 742 | probe entries */ |
|---|
| 743 | if (is_isa) { |
|---|
| 744 | for (i = 0; |
|---|
| 745 | !found |
|---|
| 746 | && (address_data->normal_isa[i] != |
|---|
| 747 | SENSORS_ISA_END); i += 1) { |
|---|
| 748 | if (addr == address_data->normal_isa[i]) { |
|---|
| 749 | #ifdef DEBUG |
|---|
| 750 | printk |
|---|
| 751 | ("sensors.o: found normal isa entry for adapter %d, " |
|---|
| 752 | "addr %04x\n", adapter_id, |
|---|
| 753 | addr); |
|---|
| 754 | #endif |
|---|
| 755 | found = 1; |
|---|
| 756 | } |
|---|
| 757 | } |
|---|
| 758 | for (i = 0; |
|---|
| 759 | !found |
|---|
| 760 | && (address_data->normal_isa_range[i] != |
|---|
| 761 | SENSORS_ISA_END); i += 3) { |
|---|
| 762 | if ( |
|---|
| 763 | (addr >= |
|---|
| 764 | address_data->normal_isa_range[i]) |
|---|
| 765 | && (addr <= |
|---|
| 766 | address_data->normal_isa_range[i + |
|---|
| 767 | 1]) |
|---|
| 768 | && |
|---|
| 769 | ((addr |
|---|
| 770 | - |
|---|
| 771 | address_data->normal_isa_range[i]) % |
|---|
| 772 | address_data->normal_isa_range[i + |
|---|
| 773 | 2] == |
|---|
| 774 | 0)) { |
|---|
| 775 | #ifdef DEBUG |
|---|
| 776 | printk |
|---|
| 777 | ("sensors.o: found normal isa_range entry for adapter %d, " |
|---|
| 778 | "addr %04x", adapter_id, |
|---|
| 779 | addr); |
|---|
| 780 | #endif |
|---|
| 781 | found = 1; |
|---|
| 782 | } |
|---|
| 783 | } |
|---|
| 784 | } else { |
|---|
| 785 | for (i = 0; |
|---|
| 786 | !found |
|---|
| 787 | && (address_data->normal_i2c[i] != |
|---|
| 788 | SENSORS_I2C_END); i += 1) { |
|---|
| 789 | if (addr == address_data->normal_i2c[i]) { |
|---|
| 790 | found = 1; |
|---|
| 791 | #ifdef DEBUG |
|---|
| 792 | printk |
|---|
| 793 | ("sensors.o: found normal i2c entry for adapter %d, " |
|---|
| 794 | "addr %02x", adapter_id, |
|---|
| 795 | addr); |
|---|
| 796 | #endif |
|---|
| 797 | } |
|---|
| 798 | } |
|---|
| 799 | for (i = 0; |
|---|
| 800 | !found |
|---|
| 801 | && (address_data->normal_i2c_range[i] != |
|---|
| 802 | SENSORS_I2C_END); i += 2) { |
|---|
| 803 | if ( |
|---|
| 804 | (addr >= |
|---|
| 805 | address_data->normal_i2c_range[i]) |
|---|
| 806 | && (addr <= |
|---|
| 807 | address_data->normal_i2c_range[i + |
|---|
| 808 | 1])) |
|---|
| 809 | { |
|---|
| 810 | #ifdef DEBUG |
|---|
| 811 | printk |
|---|
| 812 | ("sensors.o: found normal i2c_range entry for adapter %d, " |
|---|
| 813 | "addr %04x\n", adapter_id, |
|---|
| 814 | addr); |
|---|
| 815 | #endif |
|---|
| 816 | found = 1; |
|---|
| 817 | } |
|---|
| 818 | } |
|---|
| 819 | } |
|---|
| 820 | |
|---|
| 821 | for (i = 0; |
|---|
| 822 | !found && (address_data->probe[i] != SENSORS_I2C_END); |
|---|
| 823 | i += 2) { |
|---|
| 824 | if (((adapter_id == address_data->probe[i]) || |
|---|
| 825 | ((address_data-> |
|---|
| 826 | probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) |
|---|
| 827 | && (addr == address_data->probe[i + 1])) { |
|---|
| 828 | #ifdef DEBUG |
|---|
| 829 | printk |
|---|
| 830 | ("sensors.o: found probe parameter for adapter %d, " |
|---|
| 831 | "addr %04x\n", adapter_id, addr); |
|---|
| 832 | #endif |
|---|
| 833 | found = 1; |
|---|
| 834 | } |
|---|
| 835 | } |
|---|
| 836 | for (i = 0; |
|---|
| 837 | !found |
|---|
| 838 | && (address_data->probe_range[i] != SENSORS_I2C_END); |
|---|
| 839 | i += 3) { |
|---|
| 840 | if ( |
|---|
| 841 | ((adapter_id == address_data->probe_range[i]) |
|---|
| 842 | || |
|---|
| 843 | ((address_data-> |
|---|
| 844 | probe_range[i] == |
|---|
| 845 | SENSORS_ANY_I2C_BUS) & !is_isa)) |
|---|
| 846 | && (addr >= address_data->probe_range[i + 1]) |
|---|
| 847 | && (addr <= address_data->probe_range[i + 2])) { |
|---|
| 848 | found = 1; |
|---|
| 849 | #ifdef DEBUG |
|---|
| 850 | printk |
|---|
| 851 | ("sensors.o: found probe_range parameter for adapter %d, " |
|---|
| 852 | "addr %04x\n", adapter_id, addr); |
|---|
| 853 | #endif |
|---|
| 854 | } |
|---|
| 855 | } |
|---|
| 856 | if (!found) |
|---|
| 857 | continue; |
|---|
| 858 | |
|---|
| 859 | /* OK, so we really should examine this address. First check |
|---|
| 860 | whether there is some client here at all! */ |
|---|
| 861 | if (is_isa || |
|---|
| 862 | (i2c_smbus_xfer |
|---|
| 863 | (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0)) |
|---|
| 864 | if ((err = found_proc(adapter, addr, 0, -1))) |
|---|
| 865 | return err; |
|---|
| 866 | } |
|---|
| 867 | return 0; |
|---|
| 868 | } |
|---|
| 869 | |
|---|
| 870 | int __init sensors_init(void) |
|---|
| 871 | { |
|---|
| 872 | printk("sensors.o version %s (%s)\n", LM_VERSION, LM_DATE); |
|---|
| 873 | sensors_initialized = 0; |
|---|
| 874 | if (! |
|---|
| 875 | (sensors_proc_header = |
|---|
| 876 | register_sysctl_table(sensors_proc, 0))) return -ENOMEM; |
|---|
| 877 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1)) |
|---|
| 878 | sensors_proc_header->ctl_table->child->de->owner = THIS_MODULE; |
|---|
| 879 | #else |
|---|
| 880 | sensors_proc_header->ctl_table->child->de->fill_inode = |
|---|
| 881 | &sensors_fill_inode; |
|---|
| 882 | #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1)) */ |
|---|
| 883 | sensors_initialized++; |
|---|
| 884 | return 0; |
|---|
| 885 | } |
|---|
| 886 | |
|---|
| 887 | EXPORT_SYMBOL(sensors_deregister_entry); |
|---|
| 888 | EXPORT_SYMBOL(sensors_detect); |
|---|
| 889 | EXPORT_SYMBOL(sensors_proc_real); |
|---|
| 890 | EXPORT_SYMBOL(sensors_register_entry); |
|---|
| 891 | EXPORT_SYMBOL(sensors_sysctl_real); |
|---|
| 892 | |
|---|
| 893 | #ifdef MODULE |
|---|
| 894 | |
|---|
| 895 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); |
|---|
| 896 | MODULE_DESCRIPTION("LM78 driver"); |
|---|
| 897 | |
|---|
| 898 | int sensors_cleanup(void) |
|---|
| 899 | { |
|---|
| 900 | if (sensors_initialized >= 1) { |
|---|
| 901 | unregister_sysctl_table(sensors_proc_header); |
|---|
| 902 | sensors_initialized--; |
|---|
| 903 | } |
|---|
| 904 | return 0; |
|---|
| 905 | } |
|---|
| 906 | |
|---|
| 907 | int init_module(void) |
|---|
| 908 | { |
|---|
| 909 | return sensors_init(); |
|---|
| 910 | } |
|---|
| 911 | |
|---|
| 912 | int cleanup_module(void) |
|---|
| 913 | { |
|---|
| 914 | return sensors_cleanup(); |
|---|
| 915 | } |
|---|
| 916 | |
|---|
| 917 | #else /* ndef MODULE */ |
|---|
| 918 | |
|---|
| 919 | #ifdef CONFIG_SENSORS_ADM1021 |
|---|
| 920 | extern int sensors_adm1021_init(void); |
|---|
| 921 | #endif |
|---|
| 922 | #ifdef CONFIG_SENSORS_ADM9240 |
|---|
| 923 | extern int sensors_adm9024_init(void); |
|---|
| 924 | #endif |
|---|
| 925 | #ifdef CONFIG_SENSORS_GL518SM |
|---|
| 926 | extern int sensors_gl518sm_init(void); |
|---|
| 927 | #endif |
|---|
| 928 | #ifdef CONFIG_SENSORS_LM75 |
|---|
| 929 | extern int sensors_lm75_init(void); |
|---|
| 930 | #endif |
|---|
| 931 | #ifdef CONFIG_SENSORS_LM78 |
|---|
| 932 | extern int sensors_lm78_init(void); |
|---|
| 933 | #endif |
|---|
| 934 | #ifdef CONFIG_SENSORS_LM80 |
|---|
| 935 | extern int sensors_lm80_init(void); |
|---|
| 936 | #endif |
|---|
| 937 | #ifdef CONFIG_SENSORS_SIS5595 |
|---|
| 938 | extern int sensors_sis5595_init(void); |
|---|
| 939 | #endif |
|---|
| 940 | #ifdef CONFIG_SENSORS_W83781D |
|---|
| 941 | extern int sensors_w83781d_init(void); |
|---|
| 942 | #endif |
|---|
| 943 | #ifdef CONFIG_SENSORS_EEPROM |
|---|
| 944 | extern int sensors_eeprom_init(void); |
|---|
| 945 | #endif |
|---|
| 946 | #ifdef CONFIG_SENSORS_LTC1710 |
|---|
| 947 | extern int sensors_ltc1710_init(void); |
|---|
| 948 | #endif |
|---|
| 949 | |
|---|
| 950 | int __init sensors_init_all(void) |
|---|
| 951 | { |
|---|
| 952 | sensors_init(); |
|---|
| 953 | #ifdef CONFIG_SENSORS_ADM1021 |
|---|
| 954 | sensors_adm1021_init(); |
|---|
| 955 | #endif |
|---|
| 956 | #ifdef CONFIG_SENSORS_ADM9024 |
|---|
| 957 | sensors_adm9024_init(); |
|---|
| 958 | #endif |
|---|
| 959 | #ifdef CONFIG_SENSORS_GL518SM |
|---|
| 960 | sensors_gl518sm_init(); |
|---|
| 961 | #endif |
|---|
| 962 | #ifdef CONFIG_SENSORS_LM75 |
|---|
| 963 | sensors_lm75_init(); |
|---|
| 964 | #endif |
|---|
| 965 | #ifdef CONFIG_SENSORS_LM78 |
|---|
| 966 | sensors_lm78_init(); |
|---|
| 967 | #endif |
|---|
| 968 | #ifdef CONFIG_SENSORS_LM80 |
|---|
| 969 | sensors_lm80_init(); |
|---|
| 970 | #endif |
|---|
| 971 | #ifdef CONFIG_SENSORS_SIS5595 |
|---|
| 972 | sensors_sis5595_init(); |
|---|
| 973 | #endif |
|---|
| 974 | #ifdef CONFIG_SENSORS_W83781D |
|---|
| 975 | sensors_w83781d_init(); |
|---|
| 976 | #endif |
|---|
| 977 | #ifdef CONFIG_SENSORS_EEPROM |
|---|
| 978 | sensors_eeprom_init(); |
|---|
| 979 | #endif |
|---|
| 980 | #ifdef CONFIG_SENSORS_LTC1710 |
|---|
| 981 | sensors_ltc1710_init(); |
|---|
| 982 | #endif |
|---|
| 983 | return 0; |
|---|
| 984 | } |
|---|
| 985 | |
|---|
| 986 | #endif /* MODULE */ |
|---|