From 70c170dbca0bd3b4f47539f810f7ef68cbc08973 Mon Sep 17 00:00:00 2001 From: kfx Date: Sat, 28 Jul 2012 15:54:21 +0800 Subject: [PATCH] adc: update adc driver: request_irq-->request_threaded_irq --- drivers/adc/core.c | 5 +++-- drivers/adc/plat/rk28_adc.c | 2 +- drivers/adc/plat/rk29_adc.c | 2 +- drivers/adc/plat/rk30_adc.c | 18 ++++++------------ 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/adc/core.c b/drivers/adc/core.c index f31dc08899f4..04531911b722 100755 --- a/drivers/adc/core.c +++ b/drivers/adc/core.c @@ -145,16 +145,17 @@ static void adc_finished(struct adc_host *adc, int result) } void adc_core_irq_handle(struct adc_host *adc) { + unsigned long flags; int result = 0; - spin_lock(&adc->lock); + spin_lock_irqsave(&adc->lock, flags); result = adc->ops->read(adc); adc_finished(adc, result); if(!list_empty(&adc->req_head)) schedule_work(&adc->work); - spin_unlock(&adc->lock); + spin_unlock_irqrestore(&adc->lock, flags); } int adc_host_read(struct adc_client *client, enum read_type type) diff --git a/drivers/adc/plat/rk28_adc.c b/drivers/adc/plat/rk28_adc.c index 859d56fdb2a3..29d4b3ce57f6 100755 --- a/drivers/adc/plat/rk28_adc.c +++ b/drivers/adc/plat/rk28_adc.c @@ -94,7 +94,7 @@ static int rk28_adc_probe(struct platform_device *pdev) goto err_alloc; } - ret = request_irq(dev->irq, rk28_adc_irq, 0, pdev->name, dev); + ret = request_threaded_irq(dev->irq, NULL, rk28_adc_irq, IRQF_ONESHOT, pdev->name, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to attach adc irq\n"); goto err_alloc; diff --git a/drivers/adc/plat/rk29_adc.c b/drivers/adc/plat/rk29_adc.c index bf511ca8b425..63f91fb1c1d0 100755 --- a/drivers/adc/plat/rk29_adc.c +++ b/drivers/adc/plat/rk29_adc.c @@ -123,7 +123,7 @@ static int rk29_adc_probe(struct platform_device *pdev) goto err_alloc; } - ret = request_irq(dev->irq, rk29_adc_irq, 0, pdev->name, dev); + ret = request_threaded_irq(dev->irq, NULL, rk29_adc_irq, IRQF_ONESHOT, pdev->name, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to attach adc irq\n"); goto err_alloc; diff --git a/drivers/adc/plat/rk30_adc.c b/drivers/adc/plat/rk30_adc.c index fbfb26a940b5..3a8a03638c62 100755 --- a/drivers/adc/plat/rk30_adc.c +++ b/drivers/adc/plat/rk30_adc.c @@ -45,6 +45,7 @@ static void rk30_adc_stop(struct adc_host *adc) struct rk30_adc_device *dev = adc_priv(adc); adc_writel(0, dev->regs + ADC_CTRL); + udelay(SAMPLE_RATE); } static int rk30_adc_read(struct adc_host *adc) { @@ -75,10 +76,7 @@ struct adc_test_data { }; static void callback(struct adc_client *client, void *param, int result) { - if(result < 70) - dev_info(client->adc->dev, "[chn%d] async_read = %d\n", client->chn, result); - else - dev_dbg(client->adc->dev, "[chn%d] async_read = %d\n", client->chn, result); + dev_dbg(client->adc->dev, "[chn%d] async_read = %d\n", client->chn, result); return; } static void adc_timer(unsigned long data) @@ -86,7 +84,7 @@ static void adc_timer(unsigned long data) struct adc_test_data *test=(struct adc_test_data *)data; queue_work(adc_wq, &test->timer_work); - add_timer(&test->timer); + mod_timer(&test->timer, jiffies+msecs_to_jiffies(20)); } static void adc_timer_work(struct work_struct *work) { @@ -95,10 +93,7 @@ static void adc_timer_work(struct work_struct *work) timer_work); adc_async_read(test->client); sync_read = adc_sync_read(test->client); - if(sync_read < 70) - dev_info(test->client->adc->dev, "[chn%d] sync_read = %d\n", test->client->chn, sync_read); - else - dev_dbg(test->client->adc->dev, "[chn%d] sync_read = %d\n", test->client->chn, sync_read); + dev_dbg(test->client->adc->dev, "[chn%d] sync_read = %d\n", test->client->chn, sync_read); } static int rk30_adc_test(void) @@ -112,8 +107,7 @@ static int rk30_adc_test(void) test[i]->client = adc_register(i, callback, NULL); INIT_WORK(&test[i]->timer_work, adc_timer_work); setup_timer(&test[i]->timer, adc_timer, (unsigned long)test[i]); - test[i]->timer.expires = jiffies + 1; - add_timer(&test[i]->timer); + mod_timer(&test[i]->timer, jiffies+msecs_to_jiffies(20)); } return 0; @@ -141,7 +135,7 @@ static int rk30_adc_probe(struct platform_device *pdev) goto err_alloc; } - ret = request_irq(dev->irq, rk30_adc_irq, 0, pdev->name, dev); + ret = request_threaded_irq(dev->irq, NULL, rk30_adc_irq, IRQF_ONESHOT, pdev->name, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to attach adc irq\n"); goto err_alloc; -- 2.34.1