From 2ad68c18b8b0f9f068aca1f3396643636d39a8ce Mon Sep 17 00:00:00 2001 From: wdc Date: Mon, 19 May 2014 21:56:55 +0800 Subject: [PATCH] rk_keys: not to read adc value when suspend --- drivers/input/keyboard/rk_keys.c | 54 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/input/keyboard/rk_keys.c b/drivers/input/keyboard/rk_keys.c index 066777e6f5ef..c5ae44194cc8 100755 --- a/drivers/input/keyboard/rk_keys.c +++ b/drivers/input/keyboard/rk_keys.c @@ -191,31 +191,33 @@ static int rk_key_adc_iio_read(struct rk_keys_drvdata *data) static void adc_key_poll(struct work_struct *work) { - struct rk_keys_drvdata *ddata; - int i, result = -1; - - ddata = container_of(work, struct rk_keys_drvdata, adc_poll_work.work); - if (!ddata->in_suspend) - result = rk_key_adc_iio_read(ddata); + struct rk_keys_drvdata *ddata; + int i, result = -1; + + ddata = container_of(work, struct rk_keys_drvdata, adc_poll_work.work); + if (!ddata->in_suspend) + { + result = rk_key_adc_iio_read(ddata); + if(result > INVALID_ADVALUE && result < EMPTY_ADVALUE) + ddata->result = result; + for (i = 0; i < ddata->nbuttons; i++) + { + struct rk_keys_button *button = &ddata->button[i]; + if(!button->adc_value) + continue; + if(result < button->adc_value + DRIFT_ADVALUE && + result > button->adc_value - DRIFT_ADVALUE) + button->adc_state = 1; + else + button->adc_state = 0; + if(button->state != button->adc_state) + mod_timer(&button->timer, + jiffies + msecs_to_jiffies(DEFAULT_DEBOUNCE_INTERVAL)); + } + } - if(result > INVALID_ADVALUE && result < EMPTY_ADVALUE) - ddata->result = result; - for (i = 0; i < ddata->nbuttons; i++) { - struct rk_keys_button *button = &ddata->button[i]; - if(!button->adc_value) - continue; - - if(result < button->adc_value + DRIFT_ADVALUE && - result > button->adc_value - DRIFT_ADVALUE) - button->adc_state = 1; - else - button->adc_state = 0; - if(button->state != button->adc_state) - mod_timer(&button->timer, - jiffies + msecs_to_jiffies(DEFAULT_DEBOUNCE_INTERVAL)); - } schedule_delayed_work(&ddata->adc_poll_work, - msecs_to_jiffies(ADC_SAMPLE_TIME)); + msecs_to_jiffies(ADC_SAMPLE_TIME)); } static int rk_key_type_get(struct device_node *node, struct rk_keys_button *button) @@ -223,11 +225,11 @@ static int rk_key_type_get(struct device_node *node, struct rk_keys_button *butt u32 adc_value; if (!of_property_read_u32(node, "rockchip,adc_value", &adc_value)) - return TYPE_ADC; - else if(of_get_gpio(node, 0) >= 0) + return TYPE_ADC; + else if(of_get_gpio(node, 0) >= 0) return TYPE_GPIO; else - return -1; + return -1; } static int rk_keys_parse_dt(struct rk_keys_drvdata *pdata, -- 2.34.1