sb: remove absolutely useless idle timer code

This commit is contained in:
Matt Sealey
2010-12-21 17:12:45 -06:00
parent b9267874b6
commit 9a2cb63f4b
4 changed files with 1 additions and 282 deletions

View File

@@ -23,5 +23,4 @@ obj-$(CONFIG_MACH_MX51_EFIKAMX) += mx51_efikamx.o mx51_efikamx_io.o mx51_efikamx
mx51_efikamx_mmc.o mx51_efikamx_ata.o mx51_efikamx_powerkey.o \
mx51_efikamx_audio.o mx51_efikamx_display.o early_setup.o
obj-$(CONFIG_MACH_MX51_EFIKASB) += mx51_efikasb.o mx51_efikasb_gpio.o mx51_efikasb_pmic.o \
mx51_efikasb_idle_timer.o mx51_efikasb_input.o \
mx51_efikasb_lid.o mx51_efikasb_powerkey.o
mx51_efikasb_input.o mx51_efikasb_lid.o mx51_efikasb_powerkey.o

View File

@@ -1,251 +0,0 @@
/*
* Copyright 2009-2010 Pegatron Corporation. All Rights Reserved.
* Copyright 2009-2010 Genesi USA, Inc. All Rights Reserved.
*/
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/keyboard.h>
#include <mach/hardware.h>
#include <mach/gpio.h>
#include <asm/io.h>
#include "mx51_efikasb.h"
#include "iomux.h"
#define DEFAULT_PERIOD 60
#define IDLE_EVENT 1
void mxc_reset_idle_timer(void);
struct efikasb_idle_timer {
int enable;
int timeout;
spinlock_t lock;
struct timer_list timer;
unsigned long period; /* in second */
};
static struct efikasb_idle_timer *idle_timer = NULL;
static BLOCKING_NOTIFIER_HEAD(idle_notifier_list);
int register_idle_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&idle_notifier_list, nb);
}
EXPORT_SYMBOL_GPL(register_idle_notifier);
int unregister_idle_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&idle_notifier_list, nb);
}
EXPORT_SYMBOL_GPL(unregister_idle_notifier);
static int key_event_call(struct notifier_block *blk, unsigned long code, void *_param)
{
switch (code) {
case KBD_KEYCODE:
mxc_reset_idle_timer();
return NOTIFY_OK;
}
return NOTIFY_DONE;
}
static struct notifier_block key_nb = {
.notifier_call = key_event_call,
};
static void idle_timeout_fn(unsigned long data)
{
struct efikasb_idle_timer *efikasb_timer = (struct efikasb_idle_timer *)data;
unsigned long flags;
spin_lock_irqsave(&efikasb_timer->lock, flags);
efikasb_timer->timeout = 1;
efikasb_timer->enable = 0;
spin_unlock_irqrestore(&efikasb_timer->lock, flags);
blocking_notifier_call_chain(&idle_notifier_list, IDLE_EVENT, 1);
}
static void idle_timer_enable(void)
{
unsigned long flags;
if(idle_timer->enable && timer_pending(&idle_timer->timer))
return;
spin_lock_irqsave(&idle_timer->lock, flags);
idle_timer->timer.data = (unsigned long)idle_timer;
idle_timer->timer.function = idle_timeout_fn;
if(idle_timer->period == 0)
idle_timer->period = DEFAULT_PERIOD;
idle_timer->timer.expires = jiffies + idle_timer->period * HZ;
add_timer(&idle_timer->timer);
idle_timer->enable = 1;
idle_timer->timeout = 0;
spin_unlock_irqrestore(&idle_timer->lock, flags);
}
static void idle_timer_disable(void)
{
unsigned long flags;
if(!idle_timer->enable && !timer_pending(&idle_timer->timer))
return;
spin_lock_irqsave(&idle_timer->lock, flags);
del_timer(&idle_timer->timer);
idle_timer->enable = 0;
idle_timer->timeout = 0;
spin_unlock_irqrestore(&idle_timer->lock, flags);
}
static void idle_timer_reset(void)
{
unsigned long flags;
if(!idle_timer->enable && !timer_pending(&idle_timer->timer))
return;
spin_lock_irqsave(&idle_timer->lock, flags);
mod_timer(&idle_timer->timer, jiffies + idle_timer->period * HZ);
idle_timer->timeout = 0;
spin_unlock_irqrestore(&idle_timer->lock, flags);
}
static ssize_t timer_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", idle_timer->enable);
}
static ssize_t timer_enable_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
if(strncmp(buf, "1", 1) == 0)
idle_timer_enable();
else if(strncmp(buf, "0", 1) == 0)
idle_timer_disable();
return count;
}
static ssize_t timer_period_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", (unsigned int) idle_timer->period);
}
static ssize_t timer_period_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
char *end;
int arg;
arg = simple_strtoul(buf, &end, 10);
if(arg < 0) {
return -EINVAL;
}
idle_timer->period = arg;
idle_timer_reset();
return count;
}
static ssize_t timer_timeout_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
if (!idle_timer->enable)
return sprintf(buf, "0\n");
else
return sprintf(buf, "%d\n",
jiffies_to_msecs(idle_timer->timer.expires - jiffies) / 1000);
}
static struct kobj_attribute timer_enable_attribute =
__ATTR(enable, 0666, timer_enable_show, timer_enable_store);
static struct kobj_attribute timer_period_attribute =
__ATTR(period, 0666, timer_period_show, timer_period_store);
static struct kobj_attribute timer_timeout_attribute =
__ATTR(timeout, S_IFREG | S_IRUGO, timer_timeout_show, NULL);
static struct attribute *idle_attrs[] = {
&timer_enable_attribute.attr,
&timer_period_attribute.attr,
&timer_timeout_attribute.attr,
NULL,
};
static struct attribute_group idle_attr_group = {
.attrs = idle_attrs,
};
static struct platform_device mxc_idle_timer_dev = {
.name = "mxc_idle_timer",
};
static int __init mxc_init_idle_timer(void)
{
int retval;
static struct kobject *idle_timer_kobj;
platform_device_register(&mxc_idle_timer_dev);
idle_timer_kobj = kobject_create_and_add("setting", &mxc_idle_timer_dev.dev.kobj);
if(!idle_timer_kobj)
return -ENOMEM;
retval = sysfs_create_group(idle_timer_kobj, &idle_attr_group);
if(retval) {
kobject_put(idle_timer_kobj);
return retval;
}
idle_timer = kzalloc(sizeof(*idle_timer), GFP_KERNEL);
if(!idle_timer) {
sysfs_remove_group(idle_timer_kobj, &idle_attr_group);
kobject_put(idle_timer_kobj);
return -ENOMEM;
}
init_timer(&idle_timer->timer);
idle_timer->lock = SPIN_LOCK_UNLOCKED;
register_keyboard_notifier(&key_nb);
return 0;
}
late_initcall(mxc_init_idle_timer);
void mxc_reset_idle_timer(void)
{
if(idle_timer->timeout) {
blocking_notifier_call_chain(&idle_notifier_list, IDLE_EVENT, 0);
} else {
idle_timer_reset();
}
}
EXPORT_SYMBOL(mxc_reset_idle_timer);

View File

@@ -32,10 +32,6 @@ extern void mxc_power_on_wlan(int on);
extern void efikasb_power_on_wwan(int val);
extern void efikasb_power_on_bt(int val);
extern int register_idle_notifier(struct notifier_block *);
extern int unregister_idle_notifier(struct notifier_block *);
extern void mxc_reset_idle_timer(void);
extern int lid_wake_enable;
extern int mxc_get_lid_sw_status(void);
@@ -139,28 +135,6 @@ static struct notifier_block pm_nb = {
};
#define EVENT_IDLE 1
static int idle_notifier_call(struct notifier_block *nb, unsigned long event, void *v)
{
int value = (int) v;
switch(event) {
case EVENT_IDLE:
input_event(efikasb_inputdev, EV_PWR, KEY_SUSPEND, value);
input_sync(efikasb_inputdev);
return NOTIFY_OK;
}
return NOTIFY_DONE;
}
static struct notifier_block idle_nb = {
.notifier_call = idle_notifier_call,
};
static irqreturn_t wireless_sw_int(int irq, void *dev_id)
{
wireless_sw_state = gpio_get_value(IOMUX_TO_GPIO(WIRELESS_SW_PIN));
@@ -462,7 +436,6 @@ static int __init mxc_init_efikasb_inputdev(void)
mxc_init_wireless_sw();
register_pm_notifier(&pm_nb);
register_idle_notifier(&idle_nb);
return ret;
}

View File

@@ -19,7 +19,6 @@
int lid_wake_enable = 0;
extern int mxc_get_lid_sw_status(void);
extern void mxc_reset_idle_timer(void);
static struct input_dev *efikasb_lid_inputdev;
@@ -31,7 +30,6 @@ static irqreturn_t lid_sw_int(int irq, void *dev_id)
{
int lid_close;
mxc_reset_idle_timer();
lid_close = mxc_get_lid_sw_status();
if(lid_close) {
pr_info("Lid Switch Close\n");