From f65181d5edaa1f3e514eb0eb8f51c4dd9451baac Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Sat, 30 Jul 2011 22:16:08 +0800 Subject: [PATCH] temp revert timed_gpio change --- drivers/staging/android/timed_gpio.c | 61 ++++++---------------------- drivers/staging/android/timed_gpio.h | 1 - 2 files changed, 12 insertions(+), 50 deletions(-) diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c index bb6c212f8674..a646107da26d 100755 --- a/drivers/staging/android/timed_gpio.c +++ b/drivers/staging/android/timed_gpio.c @@ -19,12 +19,10 @@ #include #include #include -#include -#include + #include "timed_output.h" #include "timed_gpio.h" -#define GPIO_TYPE 0 struct timed_gpio_data { struct timed_output_dev dev; @@ -33,40 +31,14 @@ struct timed_gpio_data { unsigned gpio; int max_timeout; u8 active_low; - int adjust_time; -#if (GPIO_TYPE == 1) - struct work_struct timed_gpio_work; -#endif - struct wake_lock irq_wake; }; -#if (GPIO_TYPE == 1) -static void timed_gpio_work_handler(struct work_struct *work) -{ - struct timed_gpio_data *data = - container_of(work, struct timed_gpio_data, timed_gpio_work); - int ret = 0,i = 0; - //set gpio several times once error happened - for(i=0; i<3; i++) - { - ret = gpio_direction_output(data->gpio, data->active_low ? 1 : 0); - if(!ret) - break; - printk("%s:ret=%d,fail to set gpio and set again,i=%d\n",__FUNCTION__,ret,i); - } -} -#endif - static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer) { struct timed_gpio_data *data = container_of(timer, struct timed_gpio_data, timer); - -#if (GPIO_TYPE == 0) + gpio_direction_output(data->gpio, data->active_low ? 1 : 0); -#else - schedule_work(&data->timed_gpio_work); -#endif return HRTIMER_NORESTART; } @@ -87,26 +59,24 @@ static void gpio_enable(struct timed_output_dev *dev, int value) { struct timed_gpio_data *data = container_of(dev, struct timed_gpio_data, dev); - int ret = 0,i = 0; + unsigned long flags; + + spin_lock_irqsave(&data->lock, flags); /* cancel previous timer and set GPIO according to value */ hrtimer_cancel(&data->timer); - //set gpio several times once error happened - for(i=0; i<3; i++) - { - ret = gpio_direction_output(data->gpio, data->active_low ? !value : !!value); - if(!ret) - break; - printk("%s:ret=%d,fail to set gpio and set again,i=%d\n",__FUNCTION__,ret,i); - } + gpio_direction_output(data->gpio, data->active_low ? !value : !!value); + if (value > 0) { - value += data->adjust_time; if (value > data->max_timeout) value = data->max_timeout; + hrtimer_start(&data->timer, ktime_set(value / 1000, (value % 1000) * 1000000), HRTIMER_MODE_REL); } + + spin_unlock_irqrestore(&data->lock, flags); } static int timed_gpio_probe(struct platform_device *pdev) @@ -154,17 +124,10 @@ static int timed_gpio_probe(struct platform_device *pdev) gpio_dat->gpio = cur_gpio->gpio; gpio_dat->max_timeout = cur_gpio->max_timeout; gpio_dat->active_low = cur_gpio->active_low; - gpio_dat->adjust_time = cur_gpio->adjust_time; gpio_direction_output(gpio_dat->gpio, gpio_dat->active_low); } -#if (GPIO_TYPE == 1) - INIT_WORK(&gpio_dat->timed_gpio_work, timed_gpio_work_handler); -#endif - platform_set_drvdata(pdev, gpio_data); - wake_lock_init(&gpio_data->irq_wake, WAKE_LOCK_SUSPEND, "timed_gpio_wake"); - gpio_enable(&gpio_data ->dev, 100); - printk("%s\n",__FUNCTION__); + platform_set_drvdata(pdev, gpio_data); return 0; } @@ -204,7 +167,7 @@ static void __exit timed_gpio_exit(void) platform_driver_unregister(&timed_gpio_driver); } -subsys_initcall(timed_gpio_init); +module_init(timed_gpio_init); module_exit(timed_gpio_exit); MODULE_AUTHOR("Mike Lockwood "); diff --git a/drivers/staging/android/timed_gpio.h b/drivers/staging/android/timed_gpio.h index c8487df9a109..a0e15f8be3f7 100644 --- a/drivers/staging/android/timed_gpio.h +++ b/drivers/staging/android/timed_gpio.h @@ -23,7 +23,6 @@ struct timed_gpio { unsigned gpio; int max_timeout; u8 active_low; - int adjust_time; }; struct timed_gpio_platform_data { -- 2.34.1