From: 黄涛 Date: Thu, 10 Jul 2014 06:10:23 +0000 (+0800) Subject: input: keyboard: rk_keys: allow work without ADC X-Git-Tag: firefly_0821_release~4916^2~276 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fd6ec123f7a268d5fbf5a1b321911a16896a3812;p=firefly-linux-kernel-4.4.55.git input: keyboard: rk_keys: allow work without ADC --- diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index d554586fc184..8e45f2ee3fe1 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -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) diff --git a/drivers/input/keyboard/rk_keys.c b/drivers/input/keyboard/rk_keys.c index c0f7929908c7..d70a3778714b 100755 --- a/drivers/input/keyboard/rk_keys.c +++ b/drivers/input/keyboard/rk_keys.c @@ -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;