当前位置: 首页>>代码示例>>C++>>正文


C++ pm_suspend函数代码示例

本文整理汇总了C++中pm_suspend函数的典型用法代码示例。如果您正苦于以下问题:C++ pm_suspend函数的具体用法?C++ pm_suspend怎么用?C++ pm_suspend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pm_suspend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: store_hibernate

/**
 * store_hibernate - Initiate partition hibernation
 * @classdev:	sysdev class struct
 * @attr:		class device attribute struct
 * @buf:		buffer
 * @count:		buffer size
 *
 * Write the stream ID received from the HMC to this file
 * to trigger hibernating the partition
 *
 * Return value:
 * 	number of bytes printed to buffer / other on failure
 **/
static ssize_t store_hibernate(struct sysdev_class *classdev,
			       const char *buf, size_t count)
{
	int rc;

	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	stream_id = simple_strtoul(buf, NULL, 16);

	do {
		rc = pseries_suspend_begin(PM_SUSPEND_MEM);
		if (rc == -EAGAIN)
			ssleep(1);
	} while (rc == -EAGAIN);

	if (!rc) {
		stop_topology_update();
		rc = pm_suspend(PM_SUSPEND_MEM);
		start_topology_update();
	}

	stream_id = 0;

	if (!rc)
		rc = count;
	return rc;
}
开发者ID:swrite,项目名称:ali_kernel,代码行数:41,代码来源:suspend.c

示例2: store_hibernate

/**
 * store_hibernate - Initiate partition hibernation
 * @dev:		subsys root device
 * @attr:		device attribute struct
 * @buf:		buffer
 * @count:		buffer size
 *
 * Write the stream ID received from the HMC to this file
 * to trigger hibernating the partition
 *
 * Return value:
 * 	number of bytes printed to buffer / other on failure
 **/
static ssize_t store_hibernate(struct device *dev,
			       struct device_attribute *attr,
			       const char *buf, size_t count)
{
	int rc;

	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	stream_id = simple_strtoul(buf, NULL, 16);

	do {
		rc = pseries_suspend_begin(PM_SUSPEND_MEM);
		if (rc == -EAGAIN)
			ssleep(1);
	} while (rc == -EAGAIN);

	if (!rc)
		rc = pm_suspend(PM_SUSPEND_MEM);

	stream_id = 0;

	if (!rc)
		rc = count;
	return rc;
}
开发者ID:08opt,项目名称:linux,代码行数:39,代码来源:suspend.c

示例3: try_to_suspend

static void try_to_suspend(struct work_struct *work)
{
	unsigned int initial_count, final_count;

	if (!pm_get_wakeup_count(&initial_count, true)) {
#ifdef CONFIG_HTC_POWER_DEBUG
		pr_info("[P] suspend abort, wakeup event nonzero\n");
		htc_print_active_wakeup_sources();
#endif
		goto out;
	}

	mutex_lock(&autosleep_lock);

	if (!pm_save_wakeup_count(initial_count)) {
#ifdef CONFIG_HTC_POWER_DEBUG
		pr_info("[P] suspend abort, events not matched or being processed\n");
#endif
		mutex_unlock(&autosleep_lock);
		goto out;
	}

	if (autosleep_state == PM_SUSPEND_ON) {
#ifdef CONFIG_HTC_POWER_DEBUG
		pr_info("[P] suspend abort, autosleep_state is ON\n");
#endif
		mutex_unlock(&autosleep_lock);
		return;
	}
	if (autosleep_state >= PM_SUSPEND_MAX)
		hibernate();
	else {
#ifdef CONFIG_HTC_POWER_DEBUG
		pr_info("[R] suspend start\n");
#endif
		pm_suspend(autosleep_state);
	}

	mutex_unlock(&autosleep_lock);

	if (!pm_get_wakeup_count(&final_count, false)) {

#ifdef CONFIG_HTC_POWER_DEBUG
		pr_info("[R] resume end\n");
#endif
		goto out;
	}
	if (final_count == initial_count) {
#ifdef CONFIG_HTC_POWER_DEBUG
		pr_info("[P] wakeup occured for an unknown reason, wait HZ/2\n");
#endif
		schedule_timeout_uninterruptible(HZ / 2);
	}
#ifdef CONFIG_HTC_POWER_DEBUG
	pr_info("[R] resume end\n");
#endif

 out:
	queue_up_suspend_work();
}
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:60,代码来源:autosleep.c

示例4: state_store

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)
		error = pm_suspend(state);
	else if (state == PM_SUSPEND_MAX)
		error = hibernate();
	else
		error = -EINVAL;

 out:
	pm_autosleep_unlock();
	return error ? error : n;
}
开发者ID:qkdang,项目名称:m462,代码行数:27,代码来源:main.c

示例5: pm_timeout

static void
pm_timeout(void *arg)
{
    struct pm_softc *sc = arg;
    int s, reload;

    s = splhigh();
    sc->idlecnt++;
    splx(s);

    DPRINTF(("pm: idlecnt=%d\n", sc->idlecnt));

    if (sc->sustime != 0 && sc->idlecnt >= sc->sustime) {
#ifdef CONFIG_CONS
        cons_puts("\nThe system is about to suspend...");
#endif
        pm_suspend();
    } else {
        reload = 0;
        if (sc->dimtime != 0 && sc->idlecnt >= sc->dimtime) {
            pm_lcd_off();
            if (sc->sustime != 0)
                reload = 1;
        } else
            reload = 1;

        if (reload)
            timer_callout(&sc->timer, 1000, &pm_timeout, sc);
    }
}
开发者ID:AdamRLukaitis,项目名称:prex,代码行数:30,代码来源:pm.c

示例6: agent_thread_fn

static int agent_thread_fn(void *data)
{
	while (1) {
		wait_event_interruptible(agent_wq, pci_pm_state >= 2);
		try_to_freeze();

		if (signal_pending(current) || pci_pm_state < 2)
			continue;

		/* With a preemptible kernel (or SMP), this could race with
		 * a userspace-driven suspend request.  It's probably best
		 * to avoid mixing the two with such a configuration (or
		 * else fix it by adding a mutex to state_store that we can
		 * synchronize with).
		 */

		wake_from_pci = 1;

		pm_suspend(pci_pm_state == 3 ? PM_SUSPEND_MEM :
		                               PM_SUSPEND_STANDBY);

		wake_from_pci = 0;
	}

	return 0;
}
开发者ID:0-T-0,项目名称:ps4-linux,代码行数:26,代码来源:suspend.c

示例7: pm_sysctl_proc_handler

static int
pm_sysctl_proc_handler(ctl_table *ctl, int write, struct file *filp,
		       void *buffer, size_t *lenp)
{
	int ret = -EIO;
	printk("PM: task %s (pid %d) uses deprecated sysctl PM interface\n",
		current->comm, current->pid);
	if (write)
		ret = pm_suspend(PM_SUSPEND_MEM);
	return ret;
}
开发者ID:sarnobat,项目名称:knoppix,代码行数:11,代码来源:pm.c

示例8: rk3288_pm_dbg

static int  __init rk3288_pm_dbg(void)
{
#if 1    
        console_suspend_enabled=0;
        do{
            pm_suspend(PM_SUSPEND_MEM);
        }
        while(1);
        
#endif

}
开发者ID:OneEducation,项目名称:kernel-rk310-lollipop-firefly,代码行数:12,代码来源:rk3288.c

示例9: state_store

static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
	suspend_state_t state;
	struct timespec ts_entry, ts_exit;
	u64 elapsed_msecs64;
	u32 elapsed_msecs32;
	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) {
		/*
		 * We want to prevent system from frequent periodic wake-ups
		 * when sleeping time is less or equival certain interval.
		 * It's done in order to save power in certain cases, one of
		 * the examples is GPS tracking, but not only.
		 */
		getnstimeofday(&ts_entry);
		error = pm_suspend(state);
		getnstimeofday(&ts_exit);

		elapsed_msecs64 = timespec_to_ns(&ts_exit) -
			timespec_to_ns(&ts_entry);
		do_div(elapsed_msecs64, NSEC_PER_MSEC);
		elapsed_msecs32 = elapsed_msecs64;

		if (elapsed_msecs32 <= SBO_SLEEP_MSEC) {
			if (suspend_short_count == SBO_CNT)
				suspend_backoff();
			else
				suspend_short_count++;
		} else {
			suspend_short_count = 0;
		}
	} else if (state == PM_SUSPEND_MAX)
		error = hibernate();
	else
		error = -EINVAL;

 out:
	pm_autosleep_unlock();
	return error ? error : n;
}
开发者ID:GustavoRD78,项目名称:78Kernel-6.0.1-23.5.A.0.570,代码行数:52,代码来源:main.c

示例10: try_to_suspend

static void try_to_suspend(struct work_struct *work)
{
	unsigned int initial_count, final_count;
	int error = 0;

	if (!pm_get_wakeup_count(&initial_count, true))
		goto out;

	mutex_lock(&autosleep_lock);

	if (!pm_save_wakeup_count(initial_count) ||
		system_state != SYSTEM_RUNNING) {
		mutex_unlock(&autosleep_lock);
		goto out;
	}

	if (autosleep_state == PM_SUSPEND_ON) {
		mutex_unlock(&autosleep_lock);
		return;
	}
	if (autosleep_state >= PM_SUSPEND_MAX)
		hibernate();
	else
		error = pm_suspend(autosleep_state);

	mutex_unlock(&autosleep_lock);

#ifdef CONFIG_SEC_PM
	if (error)
		goto out;
#endif

	if (!pm_get_wakeup_count(&final_count, false))
		goto out;

	/*
	 * If the wakeup occured for an unknown reason, wait to prevent the
	 * system from trying to suspend and waking up in a tight loop.
	 */
	if (final_count == initial_count)
		schedule_timeout_uninterruptible(HZ / 2);

 out:
#ifdef CONFIG_SEC_PM
	if (error) {
		pr_info("PM: suspend returned(%d)\n", error);
		schedule_timeout_uninterruptible(HZ / 2);
	}
#endif

	queue_up_suspend_work();
}
开发者ID:toxicdog,项目名称:AEL_NOTE4_N910FXXU1ANK4,代码行数:52,代码来源:autosleep.c

示例11: rk3288_init_suspend

static void rk3288_init_suspend(void)
{
    printk("%s\n",__FUNCTION__);
    rockchip_suspend_init();       
    //rkpm_pie_init();
    rk3288_suspend_init();
   rkpm_set_ops_pwr_dmns(rk_pm_soc_pd_suspend,rk_pm_soc_pd_resume);  
    #if 0    
    console_suspend_enabled=0;
    do{
        pm_suspend(PM_SUSPEND_MEM);
    }
    while(1);
    #endif
}
开发者ID:Astralix,项目名称:kernel,代码行数:15,代码来源:rk3288.c

示例12: try_to_suspend

static void try_to_suspend(struct work_struct *work)
{
	unsigned int initial_count, final_count;

	if (!pm_get_wakeup_count(&initial_count, true))
		goto out;

	mutex_lock(&autosleep_lock);

	if (!pm_save_wakeup_count(initial_count)) {
		mutex_unlock(&autosleep_lock);
		goto out;
	}

	if (autosleep_state == PM_SUSPEND_ON) {
		mutex_unlock(&autosleep_lock);
		return;
	}
	if (autosleep_state >= PM_SUSPEND_MAX)
		hibernate();
	else
		pm_suspend(autosleep_state);

	mutex_unlock(&autosleep_lock);

	if (!pm_get_wakeup_count(&final_count, false))
		goto out;

	/*
	 * If the wakeup occured for an unknown reason, wait to prevent the
	 * system from trying to suspend and waking up in a tight loop.
	 */
	if (final_count == initial_count)
		schedule_timeout_uninterruptible(HZ / 2);

 out:
	queue_up_suspend_work();
}
开发者ID:FenomenalMOD,项目名称:FenomenalMOD_otus,代码行数:38,代码来源:autosleep.c

示例13: pm_set_power

/*
 * PM service for other drivers.
 */
int
pm_set_power(int state)
{
    int error;

    switch (state) {
    case PWR_ON:
        error = pm_resume();
        break;
    case PWR_SUSPEND:
        error = pm_suspend();
        break;
    case PWR_OFF:
        error = pm_poweroff();
        break;
    case PWR_REBOOT:
        error = pm_reboot();
        break;
    default:
        error = EINVAL;
    }
    return error;
}
开发者ID:AdamRLukaitis,项目名称:prex,代码行数:26,代码来源:pm.c

示例14: try_to_suspend

static void try_to_suspend(struct work_struct *work)
{
	unsigned int initial_count, final_count;
	int error = 0;
#ifdef CONFIG_PM_SLEEP_HISTORY
	int i;
	static unsigned int autosleep_active;
	static struct wakeup_source *last_ws[4];
	struct timespec ts;

	if (autosleep_active == 0) {
		autosleep_active = 1;
		getnstimeofday(&ts);
		sleep_history_marker(SLEEP_HISTORY_AUTOSLEEP_ENTRY,
			&ts, NULL);
	}
#endif
	if (!pm_get_wakeup_count(&initial_count, true))
		goto out;

	mutex_lock(&autosleep_lock);

	if (!pm_save_wakeup_count(initial_count)) {
		mutex_unlock(&autosleep_lock);
		goto out;
	}

#ifdef CONFIG_PM_SLEEP_HISTORY
	memset(last_ws, 0, sizeof(last_ws));
	pm_get_last_wakeup_sources(&last_ws[0],
		sizeof(last_ws)/sizeof(struct wakeup_source *));
	autosleep_active = 0;
	getnstimeofday(&ts);
	if (last_ws[0]) {
		sleep_history_marker(SLEEP_HISTORY_AUTOSLEEP_EXIT,
			&ts, last_ws[0]);

		for (i = 1;  last_ws[i] && i < sizeof(last_ws)/sizeof(struct wakeup_source *); i++)
			sleep_history_marker(SLEEP_HISTORY_AUTOSLEEP_EXIT,
				NULL, last_ws[i]);
		memset(last_ws, 0, sizeof(last_ws));
	} else
		sleep_history_marker(SLEEP_HISTORY_AUTOSLEEP_EXIT,
			&ts, autosleep_ws);
#endif
	if (autosleep_state == PM_SUSPEND_ON) {
		mutex_unlock(&autosleep_lock);
		return;
	}
	if (autosleep_state >= PM_SUSPEND_MAX)
		hibernate();
	else
		error = pm_suspend(autosleep_state);

	mutex_unlock(&autosleep_lock);

#ifdef CONFIG_PM_SLEEP_HISTORY
	if (autosleep_active == 0) {
		autosleep_active = 1;
		getnstimeofday(&ts);
		sleep_history_marker(SLEEP_HISTORY_AUTOSLEEP_ENTRY,
			&ts, NULL);
	}

	if (error)
		goto out;

	if (!pm_get_wakeup_count(&final_count, false)) {
		__pm_wakeup_event(autosleep_ws, AUTOSLEEP_SUSPEND_BLOCK_TIME);
		goto out;
	}
#else
	if (error)
		goto out;

	if (!pm_get_wakeup_count(&final_count, false)) {
		__pm_wakeup_event(autosleep_ws, AUTOSLEEP_SUSPEND_BLOCK_TIME);
		goto out;
	}
#endif

	/*
	 * If the wakeup occured for an unknown reason, wait to prevent the
	 * system from trying to suspend and waking up in a tight loop.
	 */
	if (final_count == initial_count)
		schedule_timeout_uninterruptible(HZ / 2);

 out:
#ifdef CONFIG_PM_SLEEP_HISTORY
	memset(last_ws, 0, sizeof(last_ws));
	pm_get_last_wakeup_sources(&last_ws[0],
		sizeof(last_ws)/sizeof(struct wakeup_source *));
	if (autosleep_state == PM_SUSPEND_ON) {
		autosleep_active = 0;
		getnstimeofday(&ts);
		if (last_ws[0]) {
			sleep_history_marker(SLEEP_HISTORY_AUTOSLEEP_EXIT,
				&ts, last_ws[0]);

//.........这里部分代码省略.........
开发者ID:hallometa,项目名称:Gear_S_Kernel,代码行数:101,代码来源:autosleep.c

示例15: pm_notify

/*
 * PM event notification.
 */
void
pm_notify(int event)
{
    struct pm_softc *sc = pm_softc;
    int s;

    if (event == PME_USER_ACTIVITY) {
        /*
         * Reload suspend timer for user activity.
         */
        s = splhigh();
        sc->idlecnt = 0;
        splx(s);

        if (!sc->lcd_on)
            pm_lcd_on();
        return;
    }

    DPRINTF(("pm: notify %d\n", event));

    if (sc->powtask != TASK_NULL) {
        /*
         * Power server exists.
         */
        switch (event) {
        case PME_PWRBTN_PRESS:
        case PME_SLPBTN_PRESS:
        case PME_LOW_BATTERY:
        case PME_LCD_CLOSE:
            /*
             * Post an exception to the power server.
             * Then, the power server will query PM event.
             */
            sc->lastevt = event;
            DPRINTF(("pm: post %d\n", event));
            exception_post(sc->powtask, SIGPWR);
            break;
        case PME_LCD_OPEN:
            sc->lastevt = PME_NO_EVENT;
            pm_lcd_on();
            break;
        }
    } else {
        /*
         * No power server.
         * Map power event to default action.
         */
        switch (event) {
        case PME_PWRBTN_PRESS:
            pm_poweroff();
            break;
        case PME_SLPBTN_PRESS:
        case PME_LOW_BATTERY:
            pm_suspend();
            break;
        case PME_LCD_OPEN:
            pm_lcd_on();
            break;
        case PME_LCD_CLOSE:
            pm_lcd_off();
            break;
        }
    }
}
开发者ID:AdamRLukaitis,项目名称:prex,代码行数:68,代码来源:pm.c


注:本文中的pm_suspend函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。