Commit | Line | Data |
---|---|---|
0f4f0672 JI |
1 | /* |
2 | * linux/arch/arm/kernel/pmu.c | |
3 | * | |
4 | * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles | |
49c006b9 | 5 | * Copyright (C) 2010 ARM Ltd, Will Deacon |
0f4f0672 JI |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | */ | |
12 | ||
0f4f0672 | 13 | #include <linux/err.h> |
0f4f0672 JI |
14 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | |
16 | ||
17 | #include <asm/pmu.h> | |
18 | ||
b0e89590 WD |
19 | /* |
20 | * PMU locking to ensure mutual exclusion between different subsystems. | |
21 | */ | |
22 | static unsigned long pmu_lock[BITS_TO_LONGS(ARM_NUM_PMU_DEVICES)]; | |
0f4f0672 | 23 | |
b0e89590 | 24 | int |
7fdd3c49 | 25 | reserve_pmu(enum arm_pmu_type type) |
0f4f0672 | 26 | { |
b0e89590 | 27 | return test_and_set_bit_lock(type, pmu_lock) ? -EBUSY : 0; |
0f4f0672 JI |
28 | } |
29 | EXPORT_SYMBOL_GPL(reserve_pmu); | |
30 | ||
b0e89590 | 31 | void |
7fdd3c49 | 32 | release_pmu(enum arm_pmu_type type) |
0f4f0672 | 33 | { |
b0e89590 | 34 | clear_bit_unlock(type, pmu_lock); |
0f4f0672 | 35 | } |
ec84d529 | 36 | EXPORT_SYMBOL_GPL(release_pmu); |