static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } if (state < PM_SUSPEND_MAX && *s) #ifdef CONFIG_EARLYSUSPEND && CONFIG_HAS_WAKELOCK if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #elif defined CONFIG_HAS_WAKELOCK wake_unlock(&main_wake_lock); //Release main lock in the hope of going to sleep if (!has_wake_lock(WAKE_LOCK_SUSPEND)) { wake_timer.data = current; mod_timer(&wake_timer, jiffies + HZ * 5); //To prevent us from freezing indefinitely set_freeze_flag(current); try_to_freeze(); del_timer(&wake_timer); } wake_lock(&main_wake_lock); //Re-grab the main lock so that we do not go into sleep again #else error = enter_state(state); #endif #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_MIN; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } #ifdef CONFIG_FAST_BOOT if (len == 4 && !strncmp(buf, "dmem", len)) { pr_info("%s: fake shut down!!!\n", __func__); fake_shut_down = true; state = PM_SUSPEND_MEM; } #endif if (state < PM_SUSPEND_MAX && *s) { #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #ifdef CONFIG_FAST_BOOT if (fake_shut_down) wakelock_force_suspend(); #endif #else error = enter_state(state); #endif } #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { do_hibernation = 1; //B090162 do_hibernation_codec = 1; //B090162 //sensor driver to early suspend #ifdef CONFIG_TCC_SENSOR_DRV tcc_sensor_early_suspend(); #endif error = hibernate(); #ifdef CONFIG_TCC_SENSOR_DRV tcc_sensor_late_resume(); #endif goto Exit; } else if (len == 5 && !strncmp(buf, "reset", len)) { tcc_usb_notification(); } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } if (state < PM_SUSPEND_MAX && *s) #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #else error = enter_state(state); #endif #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #if defined(CONFIG_MP_MSTAR_STR_BASE) // for mstar str, we skip wakelock // and earlysuspend/lateresume to speedup suspend if (len == 4 && !strncmp(buf, "mstr", len)) { state = PM_SUSPEND_MEM; pm_is_mstar_str = 1; error = enter_state(state); pm_is_mstar_str = 0; goto Exit; } #endif #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } if (state < PM_SUSPEND_MAX && *s) #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #else error = enter_state(state); #endif #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; if (factory_mode == 0) { p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) { #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); break; } #else error = pm_suspend(state); #endif } } #endif Exit: return error ? error : n; } else { return 0; } }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { printk(KERN_ERR "entering hibernate"); error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } printk(KERN_ERR "entering sleep state = %d\n", state); if (state < PM_SUSPEND_MAX && *s) { #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } else { printk(KERN_ERR "not valid state with state = %d", state); } #else error = enter_state(state); #endif } #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } if (state < PM_SUSPEND_MAX && *s) { /*LGE_CHANGE : [email protected] fix bug in suspend statics update*/ #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #else error = enter_state(state); if (error) { suspend_stats.fail++; dpm_save_failed_errno(error); } else suspend_stats.success++; #endif } #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; pr_info("%s\n",__func__); p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } if (state < PM_SUSPEND_MAX && *s) #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; pr_info("%s invoking request_suspend_state - state = %d\n",__func__,state); request_suspend_state(state); } #else error = enter_state(state); #endif #endif Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { suspend_state_t state; int error; error = pm_autosleep_lock(); if (error) return error; if (pm_autosleep_state() > PM_SUSPEND_ON) { error = -EBUSY; goto out; } state = decode_state(buf, n); if (state < PM_SUSPEND_MAX) { #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #else error = pm_suspend(state); #endif } else if (state == PM_SUSPEND_MAX) error = hibernate(); else error = -EINVAL; out: pm_autosleep_unlock(); return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif /* CONFIG_SUSPEND */ char *p; int len; int error = -EINVAL; p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_SUSPEND for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } if (state < PM_SUSPEND_MAX && *s) { printk(KERN_ERR "%s: state:%d (%s)\n", __func__, state, *s); #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { if(state == PM_SUSPEND_ON) { #ifdef FEATURE_FTM_SLEEP if (ftm_sleep == 1) { pr_info("%s: wake lock for FTM\n", __func__); ftm_sleep = 0; wake_lock_timeout(&ftm_wake_lock, 60 * HZ); if (ftm_enable_usb_sw) ftm_enable_usb_sw(1); } #endif /* FEATURE_FTM_SLEEP */ global_state = PM_SUSPEND_ON; } else { #ifdef FEATURE_FTM_SLEEP if (ftm_sleep == 1) { // when ftm sleep cmd if (ftm_enable_usb_sw) ftm_enable_usb_sw(0); } #endif /* FEATURE_FTM_SLEEP */ global_state = PM_SUSPEND_MEM; } error = 0; request_suspend_state(state); #ifdef FEATURE_FTM_SLEEP if (ftm_sleep && global_state == PM_SUSPEND_MEM) { wakelock_force_suspend(); } #endif /* FEATURE_FTM_SLEEP */ } #else error = enter_state(state); #endif } #endif /* CONFIG_SUSPEND */ Exit: return error ? error : n; }
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { #ifdef CONFIG_SUSPEND #ifdef CONFIG_EARLYSUSPEND suspend_state_t state = PM_SUSPEND_ON; #else suspend_state_t state = PM_SUSPEND_STANDBY; #endif const char * const *s; #endif char *p; int len; int error = -EINVAL; #ifdef CONFIG_PM_DEEPSLEEP char temp[20]; #endif p = memchr(buf, '\n', n); len = p ? p - buf : n; /* First, check if we are requested to hibernate */ if (len == 4 && !strncmp(buf, "disk", len)) { error = hibernate(); goto Exit; } #ifdef CONFIG_PM_DEEPSLEEP if (sizeof(temp) - 1 < len) { len = sizeof(temp)-1; printk(KERN_ERR "pm states is invalid\n"); } memset(temp, 0, sizeof(temp)); strncpy(temp, buf, len); if (len == 9 && !strncmp(temp, "deepsleep", len)) { s = &pm_states[PM_SUSPEND_MEM]; if (strlen(*s) > sizeof(temp) - 1) { printk(KERN_ERR "pm states overflow\n"); } else { memset(temp, 0, sizeof(temp)); strncpy(temp, *s, strlen(*s)); pm_deepsleep_enabled = 1; } } else if (pm_deepsleep_enabled == 1 && len == 2 && !strncmp(temp, "on", len)) { pm_deepsleep_enabled = 0; } #endif #ifdef CONFIG_SUSPEND #ifdef CONFIG_PM_DEEPSLEEP for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(temp, *s, len)) break; } #else for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) break; } #endif if (state < PM_SUSPEND_MAX && *s) { #ifdef CONFIG_EARLYSUSPEND if (state == PM_SUSPEND_ON || valid_state(state)) { error = 0; request_suspend_state(state); } #else error = enter_state(state); #endif } #endif Exit: return error ? error : n; }