Skip to content

Commit

Permalink
x86/hpet: Shuffle code around for readability sake
Browse files Browse the repository at this point in the history
It doesn't make sense to have init functions in the middle of other
code. Aside of that, further changes in that area create horrible diffs if
the code stays where it is.

No functional change

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Link: https://lkml.kernel.org/r/20190623132434.951733064@linutronix.de
  • Loading branch information
Thomas Gleixner committed Jun 27, 2019
1 parent 8c273f2 commit 6bdec41
Showing 1 changed file with 41 additions and 40 deletions.
81 changes: 41 additions & 40 deletions arch/x86/kernel/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,47 @@ static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu)
0x7FFFFFFF);
}

static struct hpet_dev *hpet_get_unused_timer(void)
{
int i;

if (!hpet_devs)
return NULL;

for (i = 0; i < hpet_num_timers; i++) {
struct hpet_dev *hdev = &hpet_devs[i];

if (!(hdev->flags & HPET_DEV_VALID))
continue;
if (test_and_set_bit(HPET_DEV_USED_BIT,
(unsigned long *)&hdev->flags))
continue;
return hdev;
}
return NULL;
}

static int hpet_cpuhp_online(unsigned int cpu)
{
struct hpet_dev *hdev = hpet_get_unused_timer();

if (hdev)
init_one_hpet_msi_clockevent(hdev, cpu);
return 0;
}

static int hpet_cpuhp_dead(unsigned int cpu)
{
struct hpet_dev *hdev = per_cpu(cpu_hpet_dev, cpu);

if (!hdev)
return 0;
free_irq(hdev->irq, hdev);
hdev->flags &= ~HPET_DEV_USED;
per_cpu(cpu_hpet_dev, cpu) = NULL;
return 0;
}

#ifdef CONFIG_HPET
/* Reserve at least one timer for userspace (/dev/hpet) */
#define RESERVE_TIMERS 1
Expand Down Expand Up @@ -644,46 +685,6 @@ static void __init hpet_reserve_msi_timers(struct hpet_data *hd)
}
#endif

static struct hpet_dev *hpet_get_unused_timer(void)
{
int i;

if (!hpet_devs)
return NULL;

for (i = 0; i < hpet_num_timers; i++) {
struct hpet_dev *hdev = &hpet_devs[i];

if (!(hdev->flags & HPET_DEV_VALID))
continue;
if (test_and_set_bit(HPET_DEV_USED_BIT,
(unsigned long *)&hdev->flags))
continue;
return hdev;
}
return NULL;
}

static int hpet_cpuhp_online(unsigned int cpu)
{
struct hpet_dev *hdev = hpet_get_unused_timer();

if (hdev)
init_one_hpet_msi_clockevent(hdev, cpu);
return 0;
}

static int hpet_cpuhp_dead(unsigned int cpu)
{
struct hpet_dev *hdev = per_cpu(cpu_hpet_dev, cpu);

if (!hdev)
return 0;
free_irq(hdev->irq, hdev);
hdev->flags &= ~HPET_DEV_USED;
per_cpu(cpu_hpet_dev, cpu) = NULL;
return 0;
}
#else

static inline void hpet_msi_capability_lookup(unsigned int start_timer) { }
Expand Down

0 comments on commit 6bdec41

Please sign in to comment.