]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
clockevents: Add module refcount
authorThomas Gleixner <tglx@linutronix.de>
Thu, 25 Apr 2013 20:31:49 +0000 (20:31 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 May 2013 09:09:17 +0000 (11:09 +0200)
We want to be able to remove clockevent modules as well. Add a
refcount so we don't remove a module with an active clock event
device.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130425143436.307435149@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/clockchips.h
kernel/time/clockevents.c
kernel/time/tick-broadcast.c
kernel/time/tick-common.c

index 2f498f66c1bb95e879bdbb8f469f2761ea9e674a..ae1193bcf074b8d13808932d879548dfd7f1420e 100644 (file)
@@ -30,6 +30,7 @@ enum clock_event_nofitiers {
 #include <linux/notifier.h>
 
 struct clock_event_device;
+struct module;
 
 /* Clock event mode commands */
 enum clock_event_mode {
@@ -83,6 +84,7 @@ enum clock_event_mode {
  * @irq:               IRQ number (only for non CPU local devices)
  * @cpumask:           cpumask to indicate for which CPUs this device works
  * @list:              list head for the management code
+ * @owner:             module reference
  */
 struct clock_event_device {
        void                    (*event_handler)(struct clock_event_device *);
@@ -112,6 +114,7 @@ struct clock_event_device {
        int                     irq;
        const struct cpumask    *cpumask;
        struct list_head        list;
+       struct module           *owner;
 } ____cacheline_aligned;
 
 /*
index 0e3a8448e1155991b9973082ab40bd13b6b0a177..89e394caa7697cf3163842c7de11b61032cf33a6 100644 (file)
@@ -357,6 +357,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
         * released list and do a notify add later.
         */
        if (old) {
+               module_put(old->owner);
                clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED);
                list_del(&old->list);
                list_add(&old->list, &clockevents_released);
index 3500caaa0bfdda96add10ca0d538b09c90842d33..0e374cd2e0efeec1a5528d96106253477097db5e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/profile.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
+#include <linux/module.h>
 
 #include "tick-internal.h"
 
@@ -73,6 +74,8 @@ void tick_install_broadcast_device(struct clock_event_device *dev)
             tick_broadcast_device.evtdev->rating >= dev->rating) ||
             (dev->features & CLOCK_EVT_FEAT_C3STOP))
                return;
+       if (!try_module_get(dev->owner))
+               return;
 
        clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
        if (cur)
index 84c7cfca4d7db5893da0a2cb59ff2c1b60ef53cb..433a1e11d13bacbe793fae4c32664aa76636b72c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/percpu.h>
 #include <linux/profile.h>
 #include <linux/sched.h>
+#include <linux/module.h>
 
 #include <asm/irq_regs.h>
 
@@ -257,6 +258,9 @@ void tick_check_new_device(struct clock_event_device *newdev)
                        goto out_bc;
        }
 
+       if (!try_module_get(newdev->owner))
+               return;
+
        /*
         * Replace the eventually existing device by the new
         * device. If the current device is the broadcast device, do