static void vibrator_enable_set_timeout(struct timed_output_dev *sdev, int timeout) { int ret_mod_timer = 0; printk(KERN_NOTICE "Vibrator: Set duration: %dms\n", timeout); if( timeout == 0 ) { if(Is_vib_shortly == false) { vibrator_ctrl_regulator(VIB_OFF); del_timer(&vibrate_timer); #if defined(CONFIG_HAS_WAKELOCK) wake_unlock(&vib_wl); #endif /*CONFIG_HAS_WAKELOCK*/ } return; } #if defined(CONFIG_HAS_WAKELOCK) wake_lock(&vib_wl); #endif /*CONFIG_HAS_WAKELOCK*/ vibrator_ctrl_regulator(VIB_ON); if(timeout < MIN_TIME_MS) { Is_vib_shortly = true; timeout *= 2; } if(timeout == 5000 || timeout == 10000) { printk(KERN_NOTICE "Vibrator: timeout= %dms, skip off\n", timeout); } else { if(!timer_pending(&vibrate_timer)) { ret_mod_timer = mod_timer(&vibrate_timer, jiffies + msecs_to_jiffies(timeout)); if( ret_mod_timer ) { printk(KERN_NOTICE "Vibrator: ret_mod_timer= %d\n", ret_mod_timer); vibrator_ctrl_regulator(VIB_OFF); #if defined(CONFIG_HAS_WAKELOCK) wake_unlock(&vib_wl); #endif /*CONFIG_HAS_WAKELOCK*/ } } else { #if defined(CONFIG_HAS_WAKELOCK) wake_unlock(&vib_wl); #endif /*CONFIG_HAS_WAKELOCK*/ } } return; }
static void vibrator_off_worker(struct work_struct *work) { vibrator_ctrl_regulator(VIB_OFF); #if defined(CONFIG_HAS_WAKELOCK) wake_unlock(&vib_wl); #endif /*CONFIG_HAS_WAKELOCK*/ }