ALSA: control: Protect user controls against concurrent access
[firefly-linux-kernel-4.4.55.git] / include / net / inetpeer.h
index 53f464d7cddcd6ce18925c521b99bfaefac66f2f..6ca347a0717efedf386b8ccaa318c5e34c7e643b 100644 (file)
@@ -178,16 +178,9 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
 /* can be called with or without local BH being disabled */
 static inline int inet_getid(struct inet_peer *p, int more)
 {
-       int old, new;
        more++;
        inet_peer_refcheck(p);
-       do {
-               old = atomic_read(&p->ip_id_count);
-               new = old + more;
-               if (!new)
-                       new = 1;
-       } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
-       return new;
+       return atomic_add_return(more, &p->ip_id_count) - more;
 }
 
 #endif /* _NET_INETPEER_H */