pmu.c 830 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * linux/arch/arm/kernel/pmu.c
  3. *
  4. * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
  5. * Copyright (C) 2010 ARM Ltd, Will Deacon
  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. #include <linux/err.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <asm/pmu.h>
  16. /*
  17. * PMU locking to ensure mutual exclusion between different subsystems.
  18. */
  19. static unsigned long pmu_lock[BITS_TO_LONGS(ARM_NUM_PMU_DEVICES)];
  20. int
  21. reserve_pmu(enum arm_pmu_type type)
  22. {
  23. return test_and_set_bit_lock(type, pmu_lock) ? -EBUSY : 0;
  24. }
  25. EXPORT_SYMBOL_GPL(reserve_pmu);
  26. void
  27. release_pmu(enum arm_pmu_type type)
  28. {
  29. clear_bit_unlock(type, pmu_lock);
  30. }
  31. EXPORT_SYMBOL_GPL(release_pmu);