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

Commit 447fbbdc authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

sound: Use hrtimer_resolution instead of hrtimer_get_res()



No point in converting a timespec now that the value is directly
accessible. Get rid of the null check while at it. Resolution is
guaranteed to be > 0.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarTakashi Iwai <tiwai@suse.de>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: alsa-devel@alsa-project.org
Link: http://lkml.kernel.org/r/20150414203500.799133359@linutronix.de


Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 1e317688
Loading
Loading
Loading
Loading
+1 −8
Original line number Original line Diff line number Diff line
@@ -121,16 +121,9 @@ static struct snd_timer *mytimer;
static int __init snd_hrtimer_init(void)
static int __init snd_hrtimer_init(void)
{
{
	struct snd_timer *timer;
	struct snd_timer *timer;
	struct timespec tp;
	int err;
	int err;


	hrtimer_get_res(CLOCK_MONOTONIC, &tp);
	resolution = hrtimer_resolution;
	if (tp.tv_sec > 0 || !tp.tv_nsec) {
		pr_err("snd-hrtimer: Invalid resolution %u.%09u",
			   (unsigned)tp.tv_sec, (unsigned)tp.tv_nsec);
		return -EINVAL;
	}
	resolution = tp.tv_nsec;


	/* Create a new timer and set up the fields */
	/* Create a new timer and set up the fields */
	err = snd_timer_global_new("hrtimer", SNDRV_TIMER_GLOBAL_HRTIMER,
	err = snd_timer_global_new("hrtimer", SNDRV_TIMER_GLOBAL_HRTIMER,
+6 −9
Original line number Original line Diff line number Diff line
@@ -42,16 +42,13 @@ struct snd_pcsp pcsp_chip;
static int snd_pcsp_create(struct snd_card *card)
static int snd_pcsp_create(struct snd_card *card)
{
{
	static struct snd_device_ops ops = { };
	static struct snd_device_ops ops = { };
	struct timespec tp;
	unsigned int resolution = hrtimer_resolution;
	int err;
	int err, div, min_div, order;
	int div, min_div, order;

	hrtimer_get_res(CLOCK_MONOTONIC, &tp);


	if (!nopcm) {
	if (!nopcm) {
		if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) {
		if (resolution > PCSP_MAX_PERIOD_NS) {
			printk(KERN_ERR "PCSP: Timer resolution is not sufficient "
			printk(KERN_ERR "PCSP: Timer resolution is not sufficient "
				"(%linS)\n", tp.tv_nsec);
				"(%linS)\n", resolution);
			printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI "
			printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI "
				"enabled.\n");
				"enabled.\n");
			printk(KERN_ERR "PCSP: Turned into nopcm mode.\n");
			printk(KERN_ERR "PCSP: Turned into nopcm mode.\n");
@@ -59,13 +56,13 @@ static int snd_pcsp_create(struct snd_card *card)
		}
		}
	}
	}


	if (loops_per_jiffy >= PCSP_MIN_LPJ && tp.tv_nsec <= PCSP_MIN_PERIOD_NS)
	if (loops_per_jiffy >= PCSP_MIN_LPJ && resolution <= PCSP_MIN_PERIOD_NS)
		min_div = MIN_DIV;
		min_div = MIN_DIV;
	else
	else
		min_div = MAX_DIV;
		min_div = MAX_DIV;
#if PCSP_DEBUG
#if PCSP_DEBUG
	printk(KERN_DEBUG "PCSP: lpj=%li, min_div=%i, res=%li\n",
	printk(KERN_DEBUG "PCSP: lpj=%li, min_div=%i, res=%li\n",
	       loops_per_jiffy, min_div, tp.tv_nsec);
	       loops_per_jiffy, min_div, resolution);
#endif
#endif


	div = MAX_DIV / min_div;
	div = MAX_DIV / min_div;