input: keyboard: rk_keys: allow work without ADC
author黄涛 <huangtao@rock-chips.com>
Thu, 10 Jul 2014 06:10:23 +0000 (14:10 +0800)
committer黄涛 <huangtao@rock-chips.com>
Thu, 10 Jul 2014 06:10:23 +0000 (14:10 +0800)
drivers/input/keyboard/Kconfig
drivers/input/keyboard/rk_keys.c

index d554586fc184a81a9338d7ea0bbc475ef60dbd3b..8e45f2ee3fe1c21d8e034b0ec2eed8b307c28cdb 100644 (file)
@@ -14,7 +14,6 @@ if INPUT_KEYBOARD
 
 config KEYS_RK
         tristate "rk keyboard"
-        depends on ROCKCHIP_ADC 
         default y
         help
           rk keyboard drivers(gpio and adc)
index c0f7929908c71ce00cf3ad98bae6da58a79ddbb5..d70a3778714b65e7de02dcc94dfb6ba3e53359a9 100755 (executable)
@@ -183,6 +183,8 @@ static int rk_key_adc_iio_read(struct rk_keys_drvdata *data)
         struct iio_channel *channel = data->chan;
         int val, ret;
 
+       if (!channel)
+               return INVALID_ADVALUE;
         ret = iio_read_channel_raw(channel, &val);
         if (ret < 0) {
                 pr_err("read channel() error: %d\n", ret);
@@ -244,8 +246,10 @@ static int rk_keys_parse_dt(struct rk_keys_drvdata *pdata,
        u32 code, adc_value, flags;;
        
        chan = iio_channel_get(&pdev->dev, NULL);
-    if (IS_ERR(chan))
-        goto error_ret;
+       if (IS_ERR(chan)) {
+               dev_info(&pdev->dev, "Missing io-channels\n");
+               chan = NULL;
+       }
     pdata->chan = chan;
        
        for_each_child_of_node(node, child_node) {
@@ -413,9 +417,11 @@ static int  keys_probe(struct platform_device *pdev)
        }
 
         //adc polling work
-       INIT_DELAYED_WORK(&ddata->adc_poll_work, adc_key_poll);
-       schedule_delayed_work(&ddata->adc_poll_work,
-                                       msecs_to_jiffies(ADC_SAMPLE_TIME));
+       if (ddata->chan) {
+               INIT_DELAYED_WORK(&ddata->adc_poll_work, adc_key_poll);
+               schedule_delayed_work(&ddata->adc_poll_work,
+                                     msecs_to_jiffies(ADC_SAMPLE_TIME));
+       }
 
     spdata = ddata;
        sinput_dev = input;
@@ -444,7 +450,8 @@ static int keys_remove(struct platform_device *pdev)
        for (i = 0; i < ddata->nbuttons; i++) {
                del_timer_sync(&ddata->button[i].timer);
        }
-       cancel_delayed_work_sync(&ddata->adc_poll_work);
+       if (ddata->chan)
+               cancel_delayed_work_sync(&ddata->adc_poll_work);
        input_unregister_device(input);
        
        sinput_dev = NULL;