summaryrefslogtreecommitdiffstats
path: root/libsensors/SensorBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsensors/SensorBase.cpp')
-rw-r--r--libsensors/SensorBase.cpp40
1 files changed, 8 insertions, 32 deletions
diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp
index 6d6ab25..5649d90 100644
--- a/libsensors/SensorBase.cpp
+++ b/libsensors/SensorBase.cpp
@@ -31,11 +31,9 @@
/*****************************************************************************/
-SensorBase::SensorBase(
- const char* dev_name,
- const char* data_name)
- : dev_name(dev_name), data_name(data_name),
- dev_fd(-1), data_fd(-1)
+SensorBase::SensorBase(const char* data_name)
+ : data_name(data_name),
+ data_fd(-1)
{
if (data_name) {
data_fd = openInput(data_name);
@@ -46,31 +44,9 @@ SensorBase::~SensorBase() {
if (data_fd >= 0) {
close(data_fd);
}
- if (dev_fd >= 0) {
- close(dev_fd);
- }
-}
-
-int SensorBase::open_device() {
- if (dev_fd<0 && dev_name) {
- dev_fd = open(dev_name, O_RDONLY);
- ALOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno));
- }
- return 0;
-}
-
-int SensorBase::close_device() {
- if (dev_fd >= 0) {
- close(dev_fd);
- dev_fd = -1;
- }
- return 0;
}
int SensorBase::getFd() const {
- if (!data_name) {
- return dev_fd;
- }
return data_fd;
}
@@ -90,19 +66,19 @@ int SensorBase::openInput(const char* inputName) {
DIR *dir;
struct dirent *de;
dir = opendir(dirname);
- if(dir == NULL)
+ if (dir == NULL)
return -1;
strcpy(devname, dirname);
filename = devname + strlen(devname);
*filename++ = '/';
- while((de = readdir(dir))) {
- if(de->d_name[0] == '.' &&
+ while ((de = readdir(dir))) {
+ if (de->d_name[0] == '.' &&
(de->d_name[1] == '\0' ||
(de->d_name[1] == '.' && de->d_name[2] == '\0')))
continue;
strcpy(filename, de->d_name);
fd = open(devname, O_RDONLY);
- if (fd>=0) {
+ if (fd >= 0) {
char name[80];
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
name[0] = '\0';
@@ -117,6 +93,6 @@ int SensorBase::openInput(const char* inputName) {
}
}
closedir(dir);
- ALOGE_IF(fd<0, "couldn't find '%s' input device", inputName);
+ ALOGE_IF(fd < 0, "couldn't find '%s' input device", inputName);
return fd;
}