u64_stats: Introduce u64_stats_set()
authorAhmed S. Darwish <a.darwish@linutronix.de>
Sat, 16 Oct 2021 08:49:06 +0000 (10:49 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Oct 2021 11:54:41 +0000 (12:54 +0100)
Allow to directly set a u64_stats_t value which is used to provide an init
function which sets it directly to zero intead of memset() the value.

Add u64_stats_set() to the u64_stats API.

[bigeasy: commit message. ]

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/u64_stats_sync.h

index e81856c0ba134fd07401f3e0e562828f0c8f1333..e8ec116c916bf7d066c99aabe14d4f79f6450da8 100644 (file)
@@ -83,6 +83,11 @@ static inline u64 u64_stats_read(const u64_stats_t *p)
        return local64_read(&p->v);
 }
 
+static inline void u64_stats_set(u64_stats_t *p, u64 val)
+{
+       local64_set(&p->v, val);
+}
+
 static inline void u64_stats_add(u64_stats_t *p, unsigned long val)
 {
        local64_add(val, &p->v);
@@ -104,6 +109,11 @@ static inline u64 u64_stats_read(const u64_stats_t *p)
        return p->v;
 }
 
+static inline void u64_stats_set(u64_stats_t *p, u64 val)
+{
+       p->v = val;
+}
+
 static inline void u64_stats_add(u64_stats_t *p, unsigned long val)
 {
        p->v += val;