mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-12-04 21:58:18 +00:00
Use unbuffered I/O for 2.6 eeprom to benefit from driver
optimization. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2225 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
ac7a0cf1f4
commit
6d3bdb9ba5
1 file changed
+15
-10
+15
-10
@@ -17,10 +17,13 @@
|
|||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* for open() */
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifdef DEBUG
|
#include <unistd.h>
|
||||||
#include <unistd.h> /* for getuid(), to be removed */
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@@ -293,7 +296,7 @@ int sensors_read_proc(sensors_chip_name name, int feature, double *value)
|
|||||||
int sysctl_name[4] = { CTL_DEV, DEV_SENSORS };
|
int sysctl_name[4] = { CTL_DEV, DEV_SENSORS };
|
||||||
const sensors_chip_feature *the_feature;
|
const sensors_chip_feature *the_feature;
|
||||||
int buflen = BUF_LEN;
|
int buflen = BUF_LEN;
|
||||||
int mag, eepromoffset, i, ret=0;
|
int mag, eepromoffset, fd, ret=0;
|
||||||
char n[NAME_MAX];
|
char n[NAME_MAX];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
@@ -308,16 +311,18 @@ int sensors_read_proc(sensors_chip_name name, int feature, double *value)
|
|||||||
/* total hack for eeprom */
|
/* total hack for eeprom */
|
||||||
if (! strcmp(name.prefix, "eeprom")){
|
if (! strcmp(name.prefix, "eeprom")){
|
||||||
strcat(n, "eeprom");
|
strcat(n, "eeprom");
|
||||||
if ((f = fopen(n, "r")) != NULL) {
|
/* we use unbuffered I/O to benefit from eeprom driver
|
||||||
|
optimization */
|
||||||
|
if ((fd = open(n, O_RDONLY)) >= 0) {
|
||||||
eepromoffset =
|
eepromoffset =
|
||||||
(the_feature->offset / sizeof(long)) +
|
(the_feature->offset / sizeof(long)) +
|
||||||
(16 * (the_feature->sysctl - EEPROM_SYSCTL1));
|
(16 * (the_feature->sysctl - EEPROM_SYSCTL1));
|
||||||
for(i = 0; i <= eepromoffset; i++)
|
if (lseek(fd, eepromoffset, SEEK_SET) < 0
|
||||||
if(EOF == (ret = getc(f)))
|
|| read(fd, &ret, 1) != 1) {
|
||||||
break;
|
close(fd);
|
||||||
fclose(f);
|
|
||||||
if(ret == EOF)
|
|
||||||
return -SENSORS_ERR_PROC;
|
return -SENSORS_ERR_PROC;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
*value = ret;
|
*value = ret;
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in new issue
Block a user