Changeset 51
- Timestamp:
- 12/08/98 23:52:05 (14 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 1 added
- 9 modified
-
TODO (modified) (1 diff)
-
doc/sysctl (added)
-
kernel/chips/lm75.c (modified) (1 diff)
-
kernel/chips/lm78.c (modified) (1 diff)
-
kernel/include/sensors.h (modified) (2 diffs)
-
kernel/sensors.c (modified) (6 diffs)
-
src/lm75.c (modified) (1 diff)
-
src/lm78.c (modified) (1 diff)
-
src/sensors.c (modified) (6 diffs)
-
src/sensors.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/TODO
r50 r51 11 11 places, probably (everywhere where global vars are accessed). This must be 12 12 done for the i2c modules, too. 13 * Extend sensors.c with a file /proc/sys/dev/sensors/chips, which lists14 all directories under /proc/sys/dev/sensors with their SYSCTL id15 (needed for good sysctl access).16 13 * Extend the mod_inc_use/mod_dec_use through the fill_inode trick, for all 17 14 new /proc files. -
lm-sensors/trunk/kernel/chips/lm75.c
r49 r51 332 332 return res; 333 333 } 334 } else335 334 lm75_initialized --; 335 } 336 336 337 337 return 0; -
lm-sensors/trunk/kernel/chips/lm78.c
r49 r51 879 879 return res; 880 880 } 881 } else882 881 lm78_initialized --; 883 882 } 884 883 return 0; 885 884 } -
lm-sensors/trunk/kernel/include/sensors.h
r49 r51 74 74 extern void sensors_deregister_entry(int id); 75 75 76 77 76 #endif /* def __KERNEL__ */ 78 77 78 79 /* The maximum length of the prefix */ 80 #define SENSORS_PREFIX_MAX 20 79 81 80 82 /* Driver IDs */ … … 90 92 dev table */ 91 93 #endif /* def DEV_HWMON */ 94 95 #define SENSORS_CHIPS 1 96 struct sensors_chips_data { 97 int sysctl_id; 98 char name[SENSORS_PREFIX_MAX + 13]; 99 }; 92 100 93 101 #define LM78_SYSCTL_IN0 1000 /* Volts * 100 */ -
lm-sensors/trunk/kernel/sensors.c
r46 r51 42 42 static void sensors_write_reals(int nrels,void *buffer,int *bufsize, 43 43 long *results, int magnitude); 44 static int sensors_proc_chips(ctl_table *ctl, int write, struct file * filp, 45 void *buffer, size_t *lenp); 46 static int sensors_sysctl_chips (ctl_table *table, int *name, int nlen, 47 void *oldval, size_t *oldlenp, void *newval, 48 size_t newlen, void **context); 44 49 45 50 static int sensors_init(void); … … 63 68 { 0 } 64 69 }; 70 71 static ctl_table sensors_proc_dev_sensors[] = { 72 { SENSORS_CHIPS, "chips", NULL, 0, 0644, NULL, &sensors_proc_chips, 73 &sensors_sysctl_chips }, 74 { 0 } 75 }; 76 77 static ctl_table sensors_proc_dev[] = { 78 { DEV_SENSORS, "sensors", NULL, 0, 0555, sensors_proc_dev_sensors }, 79 { 0 }, 80 }; 81 82 83 static ctl_table sensors_proc[] = { 84 { CTL_DEV, "dev", NULL, 0, 0555, sensors_proc_dev }, 85 { 0 } 86 }; 87 88 89 static struct ctl_table_header *sensors_proc_header; 90 static int sensors_initialized; 65 91 66 92 /* This returns a nice name for a new directory; for example lm78-isa-0310 … … 207 233 } 208 234 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 235 236 int sensors_proc_chips(ctl_table *ctl, int write, struct file * filp, 237 void *buffer, size_t *lenp) 238 { 239 char BUF[SENSORS_PREFIX_MAX + 30]; 240 int buflen,curbufsize,i; 241 struct ctl_table *client_tbl; 242 243 if (write) 244 return 0; 245 246 /* If buffer is size 0, or we try to read when not at the start, we 247 return nothing. Note that I think writing when not at the start 248 does not work either, but anyway, this is straight from the kernel 249 sources. */ 250 if (!*lenp || (filp->f_pos && !write)) { 251 *lenp = 0; 252 return 0; 253 } 254 curbufsize = 0; 255 for (i = 0; i < SENSORS_ENTRY_MAX; i ++) 256 if (sensors_entries[i]) { 257 client_tbl = sensors_entries[i]->ctl_table->child->child; 258 buflen = sprintf(BUF,"%d\t%s\n",client_tbl->ctl_name, 259 client_tbl->procname); 260 if (buflen + curbufsize > *lenp) 261 buflen=*lenp-curbufsize; 262 copy_to_user(buffer,BUF,buflen); 263 curbufsize += buflen; 264 (char *) buffer += buflen; 265 } 266 *lenp = curbufsize; 267 filp->f_pos += curbufsize; 268 return 0; 269 } 270 271 int sensors_sysctl_chips (ctl_table *table, int *name, int nlen, void *oldval, 272 size_t *oldlenp, void *newval, size_t newlen, 273 void **context) 274 { 275 struct sensors_chips_data data; 276 int i,oldlen,nrels,maxels; 277 struct ctl_table *client_tbl; 278 279 if (oldval && oldlenp && ! get_user_data(oldlen,oldlenp) && oldlen) { 280 maxels = oldlen / sizeof(struct sensors_chips_data); 281 nrels = 0; 282 for (i = 0; (i < SENSORS_ENTRY_MAX) && (nrels < maxels); i++) 283 if (sensors_entries[i]) { 284 client_tbl = sensors_entries[i]->ctl_table->child->child; 285 data.sysctl_id = client_tbl->ctl_name; 286 strcpy(data.name,client_tbl->procname); 287 copy_to_user(oldval,&data,sizeof(struct sensors_chips_data)); 288 (char *) oldval += sizeof(struct sensors_chips_data); 289 nrels++; 290 } 291 oldlen = nrels * sizeof(struct sensors_chips_data); 292 put_user(oldlen,oldlenp); 293 } 294 return 0; 295 } 296 209 297 210 298 /* This funcion reads or writes a 'real' value (encoded by the combination … … 263 351 264 352 /* And write them to buffer, converting to reals */ 265 sensors_write_reals(nrels,buffer,lenp,results,mag);266 353 sensors_write_reals(nrels,buffer,lenp,results,mag); 267 354 filp->f_pos += *lenp; … … 478 565 { 479 566 printk("sensors.o version %s (%s)\n",LM_VERSION,LM_DATE); 567 sensors_initialized = 0; 568 if (! (sensors_proc_header = register_sysctl_table(sensors_proc,0))) 569 return -ENOMEM; 570 sensors_initialized ++; 480 571 return 0; 481 572 } … … 483 574 int sensors_cleanup(void) 484 575 { 576 if (sensors_initialized >= 1) { 577 unregister_sysctl_table(sensors_proc_header); 578 sensors_initialized --; 579 } 485 580 return 0; 486 581 } -
lm-sensors/trunk/src/lm75.c
r49 r51 332 332 return res; 333 333 } 334 } else335 334 lm75_initialized --; 335 } 336 336 337 337 return 0; -
lm-sensors/trunk/src/lm78.c
r49 r51 879 879 return res; 880 880 } 881 } else882 881 lm78_initialized --; 883 882 } 884 883 return 0; 885 884 } -
lm-sensors/trunk/src/sensors.c
r46 r51 42 42 static void sensors_write_reals(int nrels,void *buffer,int *bufsize, 43 43 long *results, int magnitude); 44 static int sensors_proc_chips(ctl_table *ctl, int write, struct file * filp, 45 void *buffer, size_t *lenp); 46 static int sensors_sysctl_chips (ctl_table *table, int *name, int nlen, 47 void *oldval, size_t *oldlenp, void *newval, 48 size_t newlen, void **context); 44 49 45 50 static int sensors_init(void); … … 63 68 { 0 } 64 69 }; 70 71 static ctl_table sensors_proc_dev_sensors[] = { 72 { SENSORS_CHIPS, "chips", NULL, 0, 0644, NULL, &sensors_proc_chips, 73 &sensors_sysctl_chips }, 74 { 0 } 75 }; 76 77 static ctl_table sensors_proc_dev[] = { 78 { DEV_SENSORS, "sensors", NULL, 0, 0555, sensors_proc_dev_sensors }, 79 { 0 }, 80 }; 81 82 83 static ctl_table sensors_proc[] = { 84 { CTL_DEV, "dev", NULL, 0, 0555, sensors_proc_dev }, 85 { 0 } 86 }; 87 88 89 static struct ctl_table_header *sensors_proc_header; 90 static int sensors_initialized; 65 91 66 92 /* This returns a nice name for a new directory; for example lm78-isa-0310 … … 207 233 } 208 234 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,58)) */ 235 236 int sensors_proc_chips(ctl_table *ctl, int write, struct file * filp, 237 void *buffer, size_t *lenp) 238 { 239 char BUF[SENSORS_PREFIX_MAX + 30]; 240 int buflen,curbufsize,i; 241 struct ctl_table *client_tbl; 242 243 if (write) 244 return 0; 245 246 /* If buffer is size 0, or we try to read when not at the start, we 247 return nothing. Note that I think writing when not at the start 248 does not work either, but anyway, this is straight from the kernel 249 sources. */ 250 if (!*lenp || (filp->f_pos && !write)) { 251 *lenp = 0; 252 return 0; 253 } 254 curbufsize = 0; 255 for (i = 0; i < SENSORS_ENTRY_MAX; i ++) 256 if (sensors_entries[i]) { 257 client_tbl = sensors_entries[i]->ctl_table->child->child; 258 buflen = sprintf(BUF,"%d\t%s\n",client_tbl->ctl_name, 259 client_tbl->procname); 260 if (buflen + curbufsize > *lenp) 261 buflen=*lenp-curbufsize; 262 copy_to_user(buffer,BUF,buflen); 263 curbufsize += buflen; 264 (char *) buffer += buflen; 265 } 266 *lenp = curbufsize; 267 filp->f_pos += curbufsize; 268 return 0; 269 } 270 271 int sensors_sysctl_chips (ctl_table *table, int *name, int nlen, void *oldval, 272 size_t *oldlenp, void *newval, size_t newlen, 273 void **context) 274 { 275 struct sensors_chips_data data; 276 int i,oldlen,nrels,maxels; 277 struct ctl_table *client_tbl; 278 279 if (oldval && oldlenp && ! get_user_data(oldlen,oldlenp) && oldlen) { 280 maxels = oldlen / sizeof(struct sensors_chips_data); 281 nrels = 0; 282 for (i = 0; (i < SENSORS_ENTRY_MAX) && (nrels < maxels); i++) 283 if (sensors_entries[i]) { 284 client_tbl = sensors_entries[i]->ctl_table->child->child; 285 data.sysctl_id = client_tbl->ctl_name; 286 strcpy(data.name,client_tbl->procname); 287 copy_to_user(oldval,&data,sizeof(struct sensors_chips_data)); 288 (char *) oldval += sizeof(struct sensors_chips_data); 289 nrels++; 290 } 291 oldlen = nrels * sizeof(struct sensors_chips_data); 292 put_user(oldlen,oldlenp); 293 } 294 return 0; 295 } 296 209 297 210 298 /* This funcion reads or writes a 'real' value (encoded by the combination … … 263 351 264 352 /* And write them to buffer, converting to reals */ 265 sensors_write_reals(nrels,buffer,lenp,results,mag);266 353 sensors_write_reals(nrels,buffer,lenp,results,mag); 267 354 filp->f_pos += *lenp; … … 478 565 { 479 566 printk("sensors.o version %s (%s)\n",LM_VERSION,LM_DATE); 567 sensors_initialized = 0; 568 if (! (sensors_proc_header = register_sysctl_table(sensors_proc,0))) 569 return -ENOMEM; 570 sensors_initialized ++; 480 571 return 0; 481 572 } … … 483 574 int sensors_cleanup(void) 484 575 { 576 if (sensors_initialized >= 1) { 577 unregister_sysctl_table(sensors_proc_header); 578 sensors_initialized --; 579 } 485 580 return 0; 486 581 } -
lm-sensors/trunk/src/sensors.h
r49 r51 74 74 extern void sensors_deregister_entry(int id); 75 75 76 77 76 #endif /* def __KERNEL__ */ 78 77 78 79 /* The maximum length of the prefix */ 80 #define SENSORS_PREFIX_MAX 20 79 81 80 82 /* Driver IDs */ … … 90 92 dev table */ 91 93 #endif /* def DEV_HWMON */ 94 95 #define SENSORS_CHIPS 1 96 struct sensors_chips_data { 97 int sysctl_id; 98 char name[SENSORS_PREFIX_MAX + 13]; 99 }; 92 100 93 101 #define LM78_SYSCTL_IN0 1000 /* Volts * 100 */
