Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee3c86f3 authored by Javi Merino's avatar Javi Merino Committed by Linus Torvalds
Browse files

cpuidle: menu: use DIV_ROUND_CLOSEST_ULL()



Now that the kernel provides DIV_ROUND_CLOSEST_ULL(), drop the internal
implementation and use the kernel one.

Signed-off-by: default avatarJavi Merino <javi.merino@arm.com>
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent aa776201
Loading
Loading
Loading
Loading
+1 −7
Original line number Original line Diff line number Diff line
@@ -190,12 +190,6 @@ static DEFINE_PER_CPU(struct menu_device, menu_devices);


static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev);
static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev);


/* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */
static u64 div_round64(u64 dividend, u32 divisor)
{
	return div_u64(dividend + (divisor / 2), divisor);
}

/*
/*
 * Try detecting repeating patterns by keeping track of the last 8
 * Try detecting repeating patterns by keeping track of the last 8
 * intervals, and checking if the standard deviation of that set
 * intervals, and checking if the standard deviation of that set
@@ -317,7 +311,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
	 * operands are 32 bits.
	 * operands are 32 bits.
	 * Make sure to round up for half microseconds.
	 * Make sure to round up for half microseconds.
	 */
	 */
	data->predicted_us = div_round64((uint64_t)data->next_timer_us *
	data->predicted_us = DIV_ROUND_CLOSEST_ULL((uint64_t)data->next_timer_us *
					 data->correction_factor[data->bucket],
					 data->correction_factor[data->bucket],
					 RESOLUTION * DECAY);
					 RESOLUTION * DECAY);