clockevents: Implement unbind functionality

Provide a sysfs interface to allow unbinding of clockevent
devices. The device is unbound if it is unused or if there is a
replacement device available. Unbinding of broadcast devices is not
supported as we don't want to foster that nonsense. If no replacement
device is available the unbind returns -EBUSY. Unbind is available
from the kernel and through sysfs, which is necessary to drop the
module refcount.

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.499216659@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
Thomas Gleixner
2013-04-25 20:31:50 +00:00
parent 45cb8e01b2
commit 03e13cf5ee
5 changed files with 162 additions and 4 deletions

View File

@@ -31,6 +31,8 @@
#include <linux/tick.h>
#include <linux/kthread.h>
#include "tick-internal.h"
void timecounter_init(struct timecounter *tc,
const struct cyclecounter *cc,
u64 start_tstamp)
@@ -174,7 +176,6 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 maxsec)
static struct clocksource *curr_clocksource;
static LIST_HEAD(clocksource_list);
static DEFINE_MUTEX(clocksource_mutex);
#define CS_NAME_LEN 32
static char override_name[CS_NAME_LEN];
static int finished_booting;
@@ -864,7 +865,7 @@ sysfs_show_current_clocksources(struct device *dev,
return count;
}
static size_t clocksource_get_uname(const char *buf, char *dst, size_t cnt)
size_t sysfs_get_uname(const char *buf, char *dst, size_t cnt)
{
size_t ret = cnt;
@@ -899,7 +900,7 @@ static ssize_t sysfs_override_clocksource(struct device *dev,
mutex_lock(&clocksource_mutex);
ret = clocksource_get_uname(buf, override_name, count);
ret = sysfs_get_uname(buf, override_name, count);
if (ret >= 0)
clocksource_select();
@@ -925,7 +926,7 @@ static ssize_t sysfs_unbind_clocksource(struct device *dev,
char name[CS_NAME_LEN];
size_t ret;
ret = clocksource_get_uname(buf, name, count);
ret = sysfs_get_uname(buf, name, count);
if (ret < 0)
return ret;