From c6d4eb148176eac8d025ef720a20d13b9e54a56d Mon Sep 17 00:00:00 2001 From: Nanik Tolaram Date: Sun, 8 Feb 2015 20:47:12 +1100 Subject: Remove dead code * Delete dead code that are not used in 60xx/ folder especially inside libsensors/ and libsensors_iio/ * Format code to make it cleaner and easier to view Change-Id: I22361b105cc80b64243906fdf85cf402037763f9 Signed-off-by: Nanik Tolaram --- 60xx/libsensors/MPLSensor.cpp | 40 ++++---------------------- 60xx/libsensors_iio/CompassSensor.IIO.9150.cpp | 1 - 60xx/libsensors_iio/MPLSensor.cpp | 24 ---------------- 3 files changed, 6 insertions(+), 59 deletions(-) diff --git a/60xx/libsensors/MPLSensor.cpp b/60xx/libsensors/MPLSensor.cpp index 69af5a0..4676d0e 100644 --- a/60xx/libsensors/MPLSensor.cpp +++ b/60xx/libsensors/MPLSensor.cpp @@ -178,7 +178,6 @@ MPLSensor::MPLSensor() : ALOGE("could not open the mpu irq device node"); } else { fcntl(mpu_int_fd, F_SETFL, O_NONBLOCK); - //ioctl(mpu_int_fd, MPUIRQ_SET_TIMEOUT, 0); mIrqFds.add(MPUIRQ_FD, mpu_int_fd); mPollFds[MPUIRQ_FD].fd = mpu_int_fd; mPollFds[MPUIRQ_FD].events = POLLIN; @@ -189,7 +188,6 @@ MPLSensor::MPLSensor() : ALOGE("could not open the accel irq device node"); } else { fcntl(accel_fd, F_SETFL, O_NONBLOCK); - //ioctl(accel_fd, SLAVEIRQ_SET_TIMEOUT, 0); mIrqFds.add(ACCELIRQ_FD, accel_fd); mPollFds[ACCELIRQ_FD].fd = accel_fd; mPollFds[ACCELIRQ_FD].events = POLLIN; @@ -200,7 +198,6 @@ MPLSensor::MPLSensor() : ALOGE("could not open the timer irq device node"); } else { fcntl(timer_fd, F_SETFL, O_NONBLOCK); - //ioctl(timer_fd, TIMERIRQ_SET_TIMEOUT, 0); mIrqFds.add(TIMERIRQ_FD, timer_fd); mPollFds[TIMERIRQ_FD].fd = timer_fd; mPollFds[TIMERIRQ_FD].events = POLLIN; @@ -211,7 +208,6 @@ MPLSensor::MPLSensor() : if ((accel_fd == -1) && (timer_fd != -1)) { //no accel irq and timer available mUseTimerIrqAccel = true; - //ALOGD("MPLSensor falling back to timerirq for accel data"); } memset(mPendingEvents, 0, sizeof(mPendingEvents)); @@ -308,7 +304,6 @@ void MPLSensor::clearIrqData(bool* irq_set) if (nread > 0) { irq_set[i] = true; irq_timestamp = irqdata.irqtime; - //ALOGV_IF(EXTRA_VERBOSE, "irq: %d %d (%d)", i, irqdata.interruptcount, j++); } } mPollFds[i].revents = 0; @@ -323,8 +318,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) FUNC_LOG; bool irq_set[5] = { false, false, false, false, false }; - //ALOGV(" setPowerStates: %d dmp_started: %d", enabled_sensors, mDmpStarted); - do { if (LA_ENABLED || GR_ENABLED || RV_ENABLED || O_ENABLED) { @@ -377,7 +370,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) } if (sen_mask != inv_get_dl_config()->requested_sensors) { - //ALOGV("setPowerStates: %lx", sen_mask); rv = inv_set_mpu_sensors(sen_mask); ALOGE_IF(rv != INV_SUCCESS, "error: unable to set MPL sensor power states (sens=%ld retcode = %d)", @@ -406,7 +398,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) mHaveGoodMpuCal = false; mHaveGoodCompassCal = false; } - //ALOGV("Starting DMP"); rv = inv_dmp_start(); ALOGE_IF(rv != INV_SUCCESS, "unable to start dmp"); mDmpStarted = true; @@ -415,7 +406,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) //check if we should stop the DMP if (mDmpStarted && (sen_mask == 0)) { - //ALOGV("Stopping DMP"); rv = inv_dmp_stop(); ALOGE_IF(rv != INV_SUCCESS, "error: unable to stop DMP (retcode = %d)", rv); @@ -575,7 +565,6 @@ void MPLSensor::cbProcData() { mNewData = 1; mSampleCount++; - //ALOGV_IF(EXTRA_VERBOSE, "new data (%d)", sampleCount); } //these handlers transform mpl data into one of the Android sensor types @@ -604,7 +593,6 @@ void MPLSensor::accelHandler(sensors_event_t* s, uint32_t* pending_mask, s->acceleration.v[0] = s->acceleration.v[0] * 9.81; s->acceleration.v[1] = s->acceleration.v[1] * 9.81; s->acceleration.v[2] = s->acceleration.v[2] * 9.81; - //ALOGV_IF(EXTRA_VERBOSE, "accel data: %f %f %f", s->acceleration.v[0], s->acceleration.v[1], s->acceleration.v[2]); if (res == INV_SUCCESS) *pending_mask |= (1 << index); } @@ -762,7 +750,6 @@ void MPLSensor::orienHandler(sensors_event_t* s, uint32_t* pending_mask, res = inv_get_float_array(INV_ROTATION_MATRIX, rot_mat); - //ComputeAndOrientation(heading[0], euler, s->orientation.v); calcOrientationSensor(rot_mat, s->orientation.v); s->orientation.status = estimateCompassAccuracy(); @@ -777,7 +764,6 @@ void MPLSensor::orienHandler(sensors_event_t* s, uint32_t* pending_mask, int MPLSensor::enable(int32_t handle, int en) { FUNC_LOG; - //ALOGV("handle : %d en: %d", handle, en); int what = -1; @@ -813,8 +799,6 @@ int MPLSensor::enable(int32_t handle, int en) int newState = en ? 1 : 0; int err = 0; - //ALOGV_IF((uint32_t(newState) << what) != (mEnabled & (1 << what)), - // "sensor state change what=%d", what); pthread_mutex_lock(&mMplMutex); if ((uint32_t(newState) << what) != (mEnabled & (1 << what))) { @@ -905,14 +889,10 @@ int MPLSensor::update_delay() rate = 1; if (rate != mCurFifoRate) { - //ALOGD("set fifo rate: %d %llu", rate, wanted); inv_error_t res; // = inv_dmp_stop(); res = inv_set_fifo_rate(rate); ALOGE_IF(res != INV_SUCCESS, "error setting FIFO rate"); - //res = inv_dmp_start(); - //ALOGE_IF(res != INV_SUCCESS, "error re-starting DMP"); - mCurFifoRate = rate; rv = (res == INV_SUCCESS); } @@ -948,7 +928,6 @@ int64_t MPLSensor::now_ns(void) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - //ALOGV("Time %lld", (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec); return (int64_t) ts.tv_sec * 1000000000 + ts.tv_nsec; } @@ -965,7 +944,6 @@ int MPLSensor::readEvents(sensors_event_t* data, int count) pthread_mutex_lock(&mMplMutex); if (mDmpStarted) { - //ALOGV_IF(EXTRA_VERBOSE, "Update Data"); rv = inv_update_data(); ALOGE_IF(rv != INV_SUCCESS, "inv_update_data error (code %d)", (int) rv); } @@ -1012,26 +990,22 @@ int MPLSensor::readEvents(sensors_event_t* data, int count) int MPLSensor::getFd() const { - //ALOGV("MPLSensor::getFd returning %d", data_fd); return data_fd; } int MPLSensor::getAccelFd() const { - //ALOGV("MPLSensor::getAccelFd returning %d", accel_fd); return accel_fd; } int MPLSensor::getTimerFd() const { - //ALOGV("MPLSensor::getTimerFd returning %d", timer_fd); return timer_fd; } int MPLSensor::getPowerFd() const { int hdl = (uintptr_t) inv_get_serial_handle(); - //ALOGV("MPLSensor::getPowerFd returning %d", hdl); return hdl; } @@ -1110,18 +1084,16 @@ int MPLSensor::populateSensorList(struct sensor_t *list, size_t len) /* fill in accel values */ unsigned short accelId = inv_get_accel_id(); - if(accelId == 0) - { - ALOGE("Can not get accel id"); - } + if(accelId == 0) { + ALOGE("Can not get accel id"); + } fillAccel(accelId, list); /* fill in compass values */ unsigned short compassId = inv_get_compass_id(); - if(compassId == 0) - { - ALOGE("Can not get compass id"); - } + if(compassId == 0) { + ALOGE("Can not get compass id"); + } fillCompass(compassId, list); /* fill in gyro values */ diff --git a/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp b/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp index 14b92e7..be8c912 100644 --- a/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp +++ b/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp @@ -288,7 +288,6 @@ void CompassSensor::fillList(struct sensor_t *list) list->maxRange = COMPASS_MPU9150_RANGE; /* since target platform would use AK8963 instead of AK8975, need to adopt AK8963's resolution here */ - // list->resolution = COMPASS_MPU9150_RESOLUTION; list->resolution = COMPASS_AKM8963_RESOLUTION; list->power = COMPASS_MPU9150_POWER; list->minDelay = COMPASS_MPU9150_MINDELAY; diff --git a/60xx/libsensors_iio/MPLSensor.cpp b/60xx/libsensors_iio/MPLSensor.cpp index d070231..0aa6556 100644 --- a/60xx/libsensors_iio/MPLSensor.cpp +++ b/60xx/libsensors_iio/MPLSensor.cpp @@ -588,8 +588,6 @@ void MPLSensor::loadDMP() LOGV_IF(PROCESS_VERBOSE, "HAL:DMP loaded"); } fclose(fptr); - - // onDMP(1); //Can't enable here. See note onDMP() } void MPLSensor::inv_get_sensors_orientation() @@ -742,7 +740,6 @@ int MPLSensor::setAccelInitialState() mPendingEvents[Accelerometer].data[1] = value * CONVERT_A_Y; value = absinfo_z.value; mPendingEvents[Accelerometer].data[2] = value * CONVERT_A_Z; - //mHasPendingEvent = true; } return 0; } @@ -1357,9 +1354,6 @@ int MPLSensor::enable(int32_t handle, int en) LOGV_IF(PROCESS_VERBOSE, "HAL:%s sensor state change what=%d", sname.string(), what); - // pthread_mutex_lock(&mMplMutex); - // pthread_mutex_lock(&mHALMutex); - if ((uint32_t(newState) << what) != (mEnabled & (1 << what))) { short flags = newState; uint32_t lastEnabled = mEnabled, changed = 0; @@ -1407,9 +1401,6 @@ int MPLSensor::enable(int32_t handle, int en) enableSensors(sen_mask, flags, changed); } - // pthread_mutex_unlock(&mMplMutex); - // pthread_mutex_unlock(&mHALMutex); - #ifdef INV_PLAYBACK_DBG /* apparently the logging needs to be go through this sequence to properly flush the log file */ @@ -1543,9 +1534,7 @@ int MPLSensor::setDelay(int32_t handle, int64_t ns) break; } - // pthread_mutex_lock(&mHALMutex); int res = update_delay(); - // pthread_mutex_unlock(&mHALMutex); return res; } @@ -1868,12 +1857,8 @@ int MPLSensor::readEvents(sensors_event_t* /*data*/, int /*count*/) { } } - // pthread_mutex_lock(&mMplMutex); - // pthread_mutex_lock(&mHALMutex); - ssize_t rsize = read(iio_fd, rdata, nbyte); if (sensors == 0) { - // read(iio_fd, rdata, nbyte); rsize = read(iio_fd, rdata, sizeof(mIIOBuffer)); } @@ -2015,9 +2000,6 @@ int MPLSensor::readEvents(sensors_event_t* /*data*/, int /*count*/) { mCachedQuaternionData[2], mCachedQuaternionData[3], mSensorTimestamp); } - // pthread_mutex_unlock(&mMplMutex); - // pthread_mutex_unlock(&mHALMutex); - return numEventReceived; } @@ -2032,9 +2014,6 @@ int MPLSensor::readCompassEvents(sensors_event_t* /*data*/, int count) int numEventReceived = 0; int done = 0; - // pthread_mutex_lock(&mMplMutex); - // pthread_mutex_lock(&mHALMutex); - done = mCompassSensor->readSample(mCachedCompassData, &mCompassTimestamp); #ifdef COMPASS_YAS53x if (mCompassSensor->checkCoilsReset()) { @@ -2057,9 +2036,6 @@ int MPLSensor::readCompassEvents(sensors_event_t* /*data*/, int count) } } - // pthread_mutex_unlock(&mMplMutex); - // pthread_mutex_unlock(&mHALMutex); - return numEventReceived; } -- cgit v1.2.3