Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: irda: pxaficp_ir: use sched_clock() for time management

Instead of using directly the OS timer through direct register access,
use the standard sched_clock(), which will end up in OSCR reading
anyway.

This is a first step for direct access register removal and machine
specific code removal from this driver.

This commit changes the behavior, as previously the minimum turnaround
time was counted in 76ns steps, while with this patch it is counted in
microsecond steps. The strictly equal formula would have been :
while ((sched_clock() - si->last_clk) * 76 < mtt)

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Robert Jarzmik and committed by
David S. Miller
be01891e 5b40f709

+7 -8
+7 -8
drivers/net/irda/pxaficp_ir.c
··· 29 29 30 30 #include <mach/dma.h> 31 31 #include <linux/platform_data/irda-pxaficp.h> 32 - #include <mach/regs-ost.h> 33 32 #include <mach/regs-uart.h> 34 33 35 34 #define FICP __REG(0x40800000) /* Start of FICP area */ ··· 101 102 struct pxa_irda { 102 103 int speed; 103 104 int newspeed; 104 - unsigned long last_oscr; 105 + unsigned long long last_clk; 105 106 106 107 unsigned char *dma_rx_buff; 107 108 unsigned char *dma_tx_buff; ··· 291 292 } 292 293 lsr = STLSR; 293 294 } 294 - si->last_oscr = readl_relaxed(OSCR); 295 + si->last_clk = sched_clock(); 295 296 break; 296 297 297 298 case 0x04: /* Received Data Available */ ··· 302 303 dev->stats.rx_bytes++; 303 304 async_unwrap_char(dev, &dev->stats, &si->rx_buff, STRBR); 304 305 } while (STLSR & LSR_DR); 305 - si->last_oscr = readl_relaxed(OSCR); 306 + si->last_clk = sched_clock(); 306 307 break; 307 308 308 309 case 0x02: /* Transmit FIFO Data Request */ ··· 318 319 /* We need to ensure that the transmitter has finished. */ 319 320 while ((STLSR & LSR_TEMT) == 0) 320 321 cpu_relax(); 321 - si->last_oscr = readl_relaxed(OSCR); 322 + si->last_clk = sched_clock(); 322 323 323 324 /* 324 325 * Ok, we've finished transmitting. Now enable ··· 372 373 373 374 while (ICSR1 & ICSR1_TBY) 374 375 cpu_relax(); 375 - si->last_oscr = readl_relaxed(OSCR); 376 + si->last_clk = sched_clock(); 376 377 377 378 /* 378 379 * HACK: It looks like the TBY bit is dropped too soon. ··· 472 473 473 474 /* stop RX DMA */ 474 475 DCSR(si->rxdma) &= ~DCSR_RUN; 475 - si->last_oscr = readl_relaxed(OSCR); 476 476 icsr0 = ICSR0; 477 + si->last_clk = sched_clock(); 477 478 478 479 if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) { 479 480 if (icsr0 & ICSR0_FRE) { ··· 548 549 skb_copy_from_linear_data(skb, si->dma_tx_buff, skb->len); 549 550 550 551 if (mtt) 551 - while ((unsigned)(readl_relaxed(OSCR) - si->last_oscr)/4 < mtt) 552 + while ((sched_clock() - si->last_clk) * 1000 < mtt) 552 553 cpu_relax(); 553 554 554 555 /* stop RX DMA, disable FICP */