diff options
author | Andres Salomon <dilinger@queued.net> | 2012-10-01 17:45:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-22 14:39:21 -0400 |
commit | c40f20da3b3f0738ced45533c743217e00090062 (patch) | |
tree | 2edab75da6ce9c46274f788188e04b519bf6b1fc | |
parent | 802562807af61fc8b6f830725e127bf53e0a7f1c (diff) |
staging/olpc_dcon: move wait queue into dcon_priv struct
Another global variable (dcon_wait_queue) moved into the dcon_priv struct.
In the process, replace an instance of a manually implemented
wait_event_timeout. This code came from Jordan's original gxfb_dcon.c
driver waaaay back in 2006; well past time for a replacement.
Signed-off-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/olpc_dcon/olpc_dcon.c | 22 | ||||
-rw-r--r-- | drivers/staging/olpc_dcon/olpc_dcon.h | 1 |
2 files changed, 7 insertions, 16 deletions
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 7dcd0603318..38f988b7f16 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c | |||
@@ -46,8 +46,6 @@ static struct dcon_platform_data *pdata; | |||
46 | /* Platform devices */ | 46 | /* Platform devices */ |
47 | static struct platform_device *dcon_device; | 47 | static struct platform_device *dcon_device; |
48 | 48 | ||
49 | static DECLARE_WAIT_QUEUE_HEAD(dcon_wait_queue); | ||
50 | |||
51 | static unsigned short normal_i2c[] = { 0x0d, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x0d, I2C_CLIENT_END }; |
52 | 50 | ||
53 | static s32 dcon_write(struct dcon_priv *dcon, u8 reg, u16 val) | 51 | static s32 dcon_write(struct dcon_priv *dcon, u8 reg, u16 val) |
@@ -280,7 +278,6 @@ static void dcon_source_switch(struct work_struct *work) | |||
280 | { | 278 | { |
281 | struct dcon_priv *dcon = container_of(work, struct dcon_priv, | 279 | struct dcon_priv *dcon = container_of(work, struct dcon_priv, |
282 | switch_source); | 280 | switch_source); |
283 | DECLARE_WAITQUEUE(wait, current); | ||
284 | int source = dcon->pending_src; | 281 | int source = dcon->pending_src; |
285 | 282 | ||
286 | if (dcon->curr_src == source) | 283 | if (dcon->curr_src == source) |
@@ -297,11 +294,9 @@ static void dcon_source_switch(struct work_struct *work) | |||
297 | if (dcon_write(dcon, DCON_REG_MODE, | 294 | if (dcon_write(dcon, DCON_REG_MODE, |
298 | dcon->disp_mode | MODE_SCAN_INT)) | 295 | dcon->disp_mode | MODE_SCAN_INT)) |
299 | pr_err("couldn't enable scanline interrupt!\n"); | 296 | pr_err("couldn't enable scanline interrupt!\n"); |
300 | else { | 297 | else |
301 | /* Wait up to one second for the scanline interrupt */ | 298 | /* Wait up to one second for the scanline interrupt */ |
302 | wait_event_timeout(dcon_wait_queue, | 299 | wait_event_timeout(dcon->waitq, dcon->switched, HZ); |
303 | dcon->switched == true, HZ); | ||
304 | } | ||
305 | 300 | ||
306 | if (!dcon->switched) | 301 | if (!dcon->switched) |
307 | pr_err("Timeout entering CPU mode; expect a screen glitch.\n"); | 302 | pr_err("Timeout entering CPU mode; expect a screen glitch.\n"); |
@@ -332,21 +327,15 @@ static void dcon_source_switch(struct work_struct *work) | |||
332 | break; | 327 | break; |
333 | case DCON_SOURCE_DCON: | 328 | case DCON_SOURCE_DCON: |
334 | { | 329 | { |
335 | int t; | ||
336 | struct timespec delta_t; | 330 | struct timespec delta_t; |
337 | 331 | ||
338 | pr_info("dcon_source_switch to DCON\n"); | 332 | pr_info("dcon_source_switch to DCON\n"); |
339 | 333 | ||
340 | add_wait_queue(&dcon_wait_queue, &wait); | ||
341 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
342 | |||
343 | /* Clear DCONLOAD - this implies that the DCON is in control */ | 334 | /* Clear DCONLOAD - this implies that the DCON is in control */ |
344 | pdata->set_dconload(0); | 335 | pdata->set_dconload(0); |
345 | getnstimeofday(&dcon->load_time); | 336 | getnstimeofday(&dcon->load_time); |
346 | 337 | ||
347 | t = schedule_timeout(HZ/2); | 338 | wait_event_timeout(dcon->waitq, dcon->switched, HZ/2); |
348 | remove_wait_queue(&dcon_wait_queue, &wait); | ||
349 | set_current_state(TASK_RUNNING); | ||
350 | 339 | ||
351 | if (!dcon->switched) { | 340 | if (!dcon->switched) { |
352 | pr_err("Timeout entering DCON mode; expect a screen glitch.\n"); | 341 | pr_err("Timeout entering DCON mode; expect a screen glitch.\n"); |
@@ -614,6 +603,7 @@ static int dcon_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
614 | return -ENOMEM; | 603 | return -ENOMEM; |
615 | 604 | ||
616 | dcon->client = client; | 605 | dcon->client = client; |
606 | init_waitqueue_head(&dcon->waitq); | ||
617 | INIT_WORK(&dcon->switch_source, dcon_source_switch); | 607 | INIT_WORK(&dcon->switch_source, dcon_source_switch); |
618 | dcon->reboot_nb.notifier_call = dcon_reboot_notify; | 608 | dcon->reboot_nb.notifier_call = dcon_reboot_notify; |
619 | dcon->reboot_nb.priority = -1; | 609 | dcon->reboot_nb.priority = -1; |
@@ -756,7 +746,7 @@ irqreturn_t dcon_interrupt(int irq, void *id) | |||
756 | case 1: /* switch to CPU mode */ | 746 | case 1: /* switch to CPU mode */ |
757 | dcon->switched = true; | 747 | dcon->switched = true; |
758 | getnstimeofday(&dcon->irq_time); | 748 | getnstimeofday(&dcon->irq_time); |
759 | wake_up(&dcon_wait_queue); | 749 | wake_up(&dcon->waitq); |
760 | break; | 750 | break; |
761 | 751 | ||
762 | case 0: | 752 | case 0: |
@@ -770,7 +760,7 @@ irqreturn_t dcon_interrupt(int irq, void *id) | |||
770 | if (dcon->curr_src != dcon->pending_src && !dcon->switched) { | 760 | if (dcon->curr_src != dcon->pending_src && !dcon->switched) { |
771 | dcon->switched = true; | 761 | dcon->switched = true; |
772 | getnstimeofday(&dcon->irq_time); | 762 | getnstimeofday(&dcon->irq_time); |
773 | wake_up(&dcon_wait_queue); | 763 | wake_up(&dcon->waitq); |
774 | pr_debug("switching w/ status 0/0\n"); | 764 | pr_debug("switching w/ status 0/0\n"); |
775 | } else { | 765 | } else { |
776 | pr_debug("scanline interrupt w/CPU\n"); | 766 | pr_debug("scanline interrupt w/CPU\n"); |
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index 167a41778be..e3f8437a8ac 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h | |||
@@ -52,6 +52,7 @@ struct dcon_priv { | |||
52 | struct fb_info *fbinfo; | 52 | struct fb_info *fbinfo; |
53 | struct backlight_device *bl_dev; | 53 | struct backlight_device *bl_dev; |
54 | 54 | ||
55 | wait_queue_head_t waitq; | ||
55 | struct work_struct switch_source; | 56 | struct work_struct switch_source; |
56 | struct notifier_block reboot_nb; | 57 | struct notifier_block reboot_nb; |
57 | struct notifier_block fbevent_nb; | 58 | struct notifier_block fbevent_nb; |