提交 851f7c0e 编写于 作者: K Ksenija Stanojevic 提交者: Greg Kroah-Hartman

Staging: olpc_dcon: Replace timespec with ktime_t

Struct timespec will overflow in year 2038, here it will not cause an
overflow because it is used with timespec_sub, but still has to be
removed as part of y2038 changes. Replace it with ktime_t. Also use
monotonic instead of real-time by replacing functions getnstimeofday
with ktime_get.
Signed-off-by: NKsenija Stanojevic <ksenija.stanojevic@gmail.com>
Reviewed-by: NArnd Bergmann <arnd@arndb.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 51abf45c
...@@ -238,13 +238,12 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep) ...@@ -238,13 +238,12 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
*/ */
static void dcon_load_holdoff(struct dcon_priv *dcon) static void dcon_load_holdoff(struct dcon_priv *dcon)
{ {
struct timespec delta_t, now; ktime_t delta_t, now;
while (1) { while (1) {
getnstimeofday(&now); now = ktime_get();
delta_t = timespec_sub(now, dcon->load_time); delta_t = ktime_sub(now, dcon->load_time);
if (delta_t.tv_sec != 0 || if (ktime_to_ns(delta_t) > NSEC_PER_MSEC * 20) {
delta_t.tv_nsec > NSEC_PER_MSEC * 20) {
break; break;
} }
mdelay(4); mdelay(4);
...@@ -325,19 +324,19 @@ static void dcon_source_switch(struct work_struct *work) ...@@ -325,19 +324,19 @@ static void dcon_source_switch(struct work_struct *work)
/* And turn off the DCON */ /* And turn off the DCON */
pdata->set_dconload(1); pdata->set_dconload(1);
getnstimeofday(&dcon->load_time); dcon->load_time = ktime_get();
pr_info("The CPU has control\n"); pr_info("The CPU has control\n");
break; break;
case DCON_SOURCE_DCON: case DCON_SOURCE_DCON:
{ {
struct timespec delta_t; ktime_t delta_t;
pr_info("dcon_source_switch to DCON\n"); pr_info("dcon_source_switch to DCON\n");
/* Clear DCONLOAD - this implies that the DCON is in control */ /* Clear DCONLOAD - this implies that the DCON is in control */
pdata->set_dconload(0); pdata->set_dconload(0);
getnstimeofday(&dcon->load_time); dcon->load_time = ktime_get();
wait_event_timeout(dcon->waitq, dcon->switched, HZ/2); wait_event_timeout(dcon->waitq, dcon->switched, HZ/2);
...@@ -355,14 +354,14 @@ static void dcon_source_switch(struct work_struct *work) ...@@ -355,14 +354,14 @@ static void dcon_source_switch(struct work_struct *work)
* deassert and reassert, and hope for the best. * deassert and reassert, and hope for the best.
* see http://dev.laptop.org/ticket/9664 * see http://dev.laptop.org/ticket/9664
*/ */
delta_t = timespec_sub(dcon->irq_time, dcon->load_time); delta_t = ktime_sub(dcon->irq_time, dcon->load_time);
if (dcon->switched && delta_t.tv_sec == 0 && if (dcon->switched && ktime_to_ns(delta_t)
delta_t.tv_nsec < NSEC_PER_MSEC * 20) { < NSEC_PER_MSEC * 20) {
pr_err("missed loading, retrying\n"); pr_err("missed loading, retrying\n");
pdata->set_dconload(1); pdata->set_dconload(1);
mdelay(41); mdelay(41);
pdata->set_dconload(0); pdata->set_dconload(0);
getnstimeofday(&dcon->load_time); dcon->load_time = ktime_get();
mdelay(41); mdelay(41);
} }
} }
...@@ -742,7 +741,7 @@ irqreturn_t dcon_interrupt(int irq, void *id) ...@@ -742,7 +741,7 @@ irqreturn_t dcon_interrupt(int irq, void *id)
case 2: /* switch to DCON mode */ case 2: /* switch to DCON mode */
case 1: /* switch to CPU mode */ case 1: /* switch to CPU mode */
dcon->switched = true; dcon->switched = true;
getnstimeofday(&dcon->irq_time); dcon->irq_time = ktime_get();
wake_up(&dcon->waitq); wake_up(&dcon->waitq);
break; break;
...@@ -756,7 +755,7 @@ irqreturn_t dcon_interrupt(int irq, void *id) ...@@ -756,7 +755,7 @@ irqreturn_t dcon_interrupt(int irq, void *id)
*/ */
if (dcon->curr_src != dcon->pending_src && !dcon->switched) { if (dcon->curr_src != dcon->pending_src && !dcon->switched) {
dcon->switched = true; dcon->switched = true;
getnstimeofday(&dcon->irq_time); dcon->irq_time = ktime_get();
wake_up(&dcon->waitq); wake_up(&dcon->waitq);
pr_debug("switching w/ status 0/0\n"); pr_debug("switching w/ status 0/0\n");
} else { } else {
......
...@@ -79,8 +79,8 @@ struct dcon_priv { ...@@ -79,8 +79,8 @@ struct dcon_priv {
/* Variables used during switches */ /* Variables used during switches */
bool switched; bool switched;
struct timespec irq_time; ktime_t irq_time;
struct timespec load_time; ktime_t load_time;
/* Current output type; true == mono, false == color */ /* Current output type; true == mono, false == color */
bool mono; bool mono;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册