863392197987c24eef124c5309cddaeecf40e137
[openembedded.git] /
1 From 5d3426ae63c27b9405be8179beabe1e095b44a35 Mon Sep 17 00:00:00 2001
2 From: Imre Deak <imre.deak@nokia.com>
3 Date: Tue, 5 May 2009 19:00:19 +0200
4 Subject: [PATCH 63/69] DSS2: fix the usage of get_last_off_on_transaction_id
5
6 The function returns int not unsigned since it can fail. Handle the
7 failing case as if the context had been lost. So now:
8
9 1. No get_last_off_on_transaction_id func in platform data->
10    never restore the context
11 2. Return val < 0 -> force the restore
12 3. Return val >= 0 do the restore only if the counter has changed.
13
14 Signed-off-by: Imre Deak <imre.deak@nokia.com>
15 ---
16  arch/arm/plat-omap/include/mach/display.h |    2 +-
17  drivers/video/omap2/dss/core.c            |   18 ++++++++++++------
18  2 files changed, 13 insertions(+), 7 deletions(-)
19
20 diff --git a/arch/arm/plat-omap/include/mach/display.h b/arch/arm/plat-omap/include/mach/display.h
21 index 45b16ca..31ebb96 100644
22 --- a/arch/arm/plat-omap/include/mach/display.h
23 +++ b/arch/arm/plat-omap/include/mach/display.h
24 @@ -234,7 +234,7 @@ struct device;
25  
26  /* Board specific data */
27  struct  omap_dss_board_info {
28 -       unsigned (*get_last_off_on_transaction_id)(struct device *dev);
29 +       int (*get_last_off_on_transaction_id)(struct device *dev);
30         int (*dsi_power_up)(void);
31         void (*dsi_power_down)(void);
32         int num_displays;
33 diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
34 index ae7cd06..6d11b04 100644
35 --- a/drivers/video/omap2/dss/core.c
36 +++ b/drivers/video/omap2/dss/core.c
37 @@ -38,7 +38,7 @@
38  
39  static struct {
40         struct platform_device *pdev;
41 -       unsigned        ctx_id;
42 +       int             ctx_id;
43  
44         struct clk      *dss_ick;
45         struct clk      *dss1_fck;
46 @@ -63,22 +63,28 @@ module_param_named(debug, dss_debug, bool, 0644);
47  #endif
48  
49  /* CONTEXT */
50 -static unsigned dss_get_ctx_id(void)
51 +static int dss_get_ctx_id(void)
52  {
53         struct omap_dss_board_info *pdata = core.pdev->dev.platform_data;
54 +       int r;
55  
56         if (!pdata->get_last_off_on_transaction_id)
57                 return 0;
58 -
59 -       return pdata->get_last_off_on_transaction_id(&core.pdev->dev);
60 +       r = pdata->get_last_off_on_transaction_id(&core.pdev->dev);
61 +       if (r < 0) {
62 +               dev_err(&core.pdev->dev,
63 +                       "getting transaction ID failed, will force context restore\n");
64 +               r = -1;
65 +       }
66 +       return r;
67  }
68  
69  int dss_need_ctx_restore(void)
70  {
71         int id = dss_get_ctx_id();
72  
73 -       if (id != core.ctx_id) {
74 -               DSSDBG("ctx id %u -> id %u\n",
75 +       if (id < 0 || id != core.ctx_id) {
76 +               DSSDBG("ctx id %d -> id %d\n",
77                                 core.ctx_id, id);
78                 core.ctx_id = id;
79                 return 1;
80 -- 
81 1.6.2.4
82