Skip to content

Commit b98c751

Browse files
arndbStefan Richter
authored andcommitted
firewire: ohci: stop using get_seconds() for BUS_TIME
The ohci driver uses the get_seconds() function to implement the 32-bit CSR_BUS_TIME register. This was added in 2010 commit a48777e ("firewire: add CSR BUS_TIME support"). As get_seconds() returns a 32-bit value (on 32-bit architectures), it seems like a good fit for that register, but it is also deprecated because of the y2038/y2106 overflow problem, and should be replaced throughout the kernel with either ktime_get_real_seconds() or ktime_get_seconds(). I'm using the latter here, which uses monotonic time. This has the advantage of behaving better during concurrent settimeofday() updates or leap second adjustments and won't overflow a 32-bit integer, but the downside of using CLOCK_MONOTONIC instead of CLOCK_REALTIME is that the observed values are not related to external clocks. If we instead need UTC but can live with clock jumps or overflows, then we should use ktime_get_real_seconds() instead, retaining the existing behavior. Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Reviewed-by: Clemens Ladisch <[email protected]> Signed-off-by: Stefan Richter <[email protected]>
1 parent 4d856f7 commit b98c751

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/firewire/ohci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ static u32 update_bus_time(struct fw_ohci *ohci)
17521752

17531753
if (unlikely(!ohci->bus_time_running)) {
17541754
reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds);
1755-
ohci->bus_time = (lower_32_bits(get_seconds()) & ~0x7f) |
1755+
ohci->bus_time = (lower_32_bits(ktime_get_seconds()) & ~0x7f) |
17561756
(cycle_time_seconds & 0x40);
17571757
ohci->bus_time_running = true;
17581758
}

0 commit comments

Comments
 (0)