Commit 52c324f8 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

cpuidle: Combine cpuidle_enabled() with cpuidle_select()



Since both cpuidle_enabled() and cpuidle_select() are only called by
cpuidle_idle_call(), it is not really useful to keep them separate
and combining them will help to avoid complicating cpuidle_idle_call()
even further if governors are changed to return error codes sometimes.

This code modification shouldn't lead to any functional changes.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d1db0eea
Loading
Loading
Loading
Loading
+6 −20
Original line number Original line Diff line number Diff line
@@ -64,26 +64,6 @@ int cpuidle_play_dead(void)
	return -ENODEV;
	return -ENODEV;
}
}


/**
 * cpuidle_enabled - check if the cpuidle framework is ready
 * @dev: cpuidle device for this cpu
 * @drv: cpuidle driver for this cpu
 *
 * Return 0 on success, otherwise:
 * -NODEV : the cpuidle framework is not available
 * -EBUSY : the cpuidle framework is not initialized
 */
int cpuidle_enabled(struct cpuidle_driver *drv, struct cpuidle_device *dev)
{
	if (off || !initialized)
		return -ENODEV;

	if (!drv || !dev || !dev->enabled)
		return -EBUSY;

	return 0;
}

/**
/**
 * cpuidle_enter_state - enter the state and update stats
 * cpuidle_enter_state - enter the state and update stats
 * @dev: cpuidle device for this cpu
 * @dev: cpuidle device for this cpu
@@ -138,6 +118,12 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
 */
 */
int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
{
{
	if (off || !initialized)
		return -ENODEV;

	if (!drv || !dev || !dev->enabled)
		return -EBUSY;

	return cpuidle_curr_governor->select(drv, dev);
	return cpuidle_curr_governor->select(drv, dev);
}
}


+0 −5
Original line number Original line Diff line number Diff line
@@ -120,8 +120,6 @@ struct cpuidle_driver {
#ifdef CONFIG_CPU_IDLE
#ifdef CONFIG_CPU_IDLE
extern void disable_cpuidle(void);
extern void disable_cpuidle(void);


extern int cpuidle_enabled(struct cpuidle_driver *drv,
			  struct cpuidle_device *dev);
extern int cpuidle_select(struct cpuidle_driver *drv,
extern int cpuidle_select(struct cpuidle_driver *drv,
			  struct cpuidle_device *dev);
			  struct cpuidle_device *dev);
extern int cpuidle_enter(struct cpuidle_driver *drv,
extern int cpuidle_enter(struct cpuidle_driver *drv,
@@ -149,9 +147,6 @@ extern int cpuidle_play_dead(void);
extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
#else
#else
static inline void disable_cpuidle(void) { }
static inline void disable_cpuidle(void) { }
static inline int cpuidle_enabled(struct cpuidle_driver *drv,
				  struct cpuidle_device *dev)
{return -ENODEV; }
static inline int cpuidle_select(struct cpuidle_driver *drv,
static inline int cpuidle_select(struct cpuidle_driver *drv,
				 struct cpuidle_device *dev)
				 struct cpuidle_device *dev)
{return -ENODEV; }
{return -ENODEV; }
+7 −13
Original line number Original line Diff line number Diff line
@@ -101,19 +101,13 @@ static int cpuidle_idle_call(void)
	rcu_idle_enter();
	rcu_idle_enter();


	/*
	/*
	 * Check if the cpuidle framework is ready, otherwise fallback
	 * Ask the cpuidle framework to choose a convenient idle state.
	 * to the default arch specific idle method
	 * Fall back to the default arch specific idle method on errors.
	 */
	ret = cpuidle_enabled(drv, dev);

	if (!ret) {
		/*
		 * Ask the governor to choose an idle state it thinks
		 * it is convenient to go to. There is *always* a
		 * convenient idle state
	 */
	 */
	next_state = cpuidle_select(drv, dev);
	next_state = cpuidle_select(drv, dev);


	ret = next_state;
	if (ret >= 0) {
		/*
		/*
		 * The idle task must be scheduled, it is pointless to
		 * The idle task must be scheduled, it is pointless to
		 * go to idle, just update no idle residency and get
		 * go to idle, just update no idle residency and get
@@ -140,7 +134,7 @@ static int cpuidle_idle_call(void)
					CLOCK_EVT_NOTIFY_BROADCAST_ENTER,
					CLOCK_EVT_NOTIFY_BROADCAST_ENTER,
					&dev->cpu);
					&dev->cpu);


			if (!ret) {
			if (ret >= 0) {
				trace_cpu_idle_rcuidle(next_state, dev->cpu);
				trace_cpu_idle_rcuidle(next_state, dev->cpu);


				/*
				/*
@@ -175,7 +169,7 @@ static int cpuidle_idle_call(void)
	 * We can't use the cpuidle framework, let's use the default
	 * We can't use the cpuidle framework, let's use the default
	 * idle routine
	 * idle routine
	 */
	 */
	if (ret)
	if (ret < 0)
		arch_cpu_idle();
		arch_cpu_idle();


	__current_set_polling();
	__current_set_polling();