Commit e78f70ba authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Thomas Gleixner
Browse files

time/timecounter: Fix the lie that struct cyclecounter is const



In both the read callback for struct cyclecounter, and in struct
timecounter, struct cyclecounter is declared as a const pointer.

Unfortunatly, a number of users of this pointer treat it as a non-const
pointer as it is burried in a larger structure that is heavily modified by
the callback function when accessed.  This lie had been hidden by the fact
that container_of() "casts away" a const attribute of a pointer without any
compiler warning happening at all.

Fix this all up by removing the const attribute in the needed places so
that everyone can see that the structure really isn't const, but can,
and is, modified by the users of it.

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/2025070124-backyard-hurt-783a@gregkh
parent d0b3b7b2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ static struct timecounter xilinx_tc = {
	.cc = NULL,
};

static u64 xilinx_cc_read(const struct cyclecounter *cc)
static u64 xilinx_cc_read(struct cyclecounter *cc)
{
	return xilinx_read(NULL);
}
+1 −1
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ static u64 arch_counter_read(struct clocksource *cs)
	return arch_timer_read_counter();
}

static u64 arch_counter_read_cc(const struct cyclecounter *cc)
static u64 arch_counter_read_cc(struct cyclecounter *cc)
{
	return arch_timer_read_counter();
}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@

#include "rockchip_canfd.h"

static u64 rkcanfd_timestamp_read(const struct cyclecounter *cc)
static u64 rkcanfd_timestamp_read(struct cyclecounter *cc)
{
	const struct rkcanfd_priv *priv = container_of(cc, struct rkcanfd_priv, cc);

+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

#include "mcp251xfd.h"

static u64 mcp251xfd_timestamp_raw_read(const struct cyclecounter *cc)
static u64 mcp251xfd_timestamp_raw_read(struct cyclecounter *cc)
{
	const struct mcp251xfd_priv *priv;
	u32 ts_raw = 0;
+1 −1
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ static inline int gs_usb_get_timestamp(const struct gs_usb *parent,
	return 0;
}

static u64 gs_usb_timestamp_read(const struct cyclecounter *cc) __must_hold(&dev->tc_lock)
static u64 gs_usb_timestamp_read(struct cyclecounter *cc) __must_hold(&dev->tc_lock)
{
	struct gs_usb *parent = container_of(cc, struct gs_usb, cc);
	u32 timestamp = 0;
Loading