From: H Hartley Sweeten Date: Tue, 4 Nov 2014 17:53:45 +0000 (-0700) Subject: staging: comedi: addi_apci_3120: introduce apci3120_ns_to_timer() X-Git-Tag: omap-for-v3.19/fixes-rc1~73^2~354 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=546bf3382e41b8a5a4c216ea7bdc0f517ce04e22;p=pandora-kernel.git staging: comedi: addi_apci_3120: introduce apci3120_ns_to_timer() The timer divisor calculations in this driver are over complicated. There are three timers on the board. They all use the same base clock with a fixed prescaler for each timer. The base clock used depends on the board version and type: APCI-3120 Rev A boards OSC = 14.29MHz base clock (~70ns) APCI-3120 Rev B boards OSC = 20MHz base clock (50ns) APCI-3001 boards OSC = 20MHz base clock (50ns) The prescalers for each timer are: Timer 0 CLK = OSC/10 Timer 1 CLK = OSC/1000 Timer 2 CLK = OSC/1000 Add a new member to the private data, 'osc_base', to hold the base clock time. Set this member during the board attach. Introduce a helper function to calculate the divisor needed to generate a nanosecond time with a given timer. Use the new helper function in the driver to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- Reading git-diff-tree failed