#include <regulator/regulator.h>
#include <net/netlink.h>
#include <net/genetlink.h>
+#include <linux/atomic.h>
#include "regnl.h"
-static unsigned int reg_event_seqnum;
+static atomic_t reg_event_seqnum = ATOMIC_INIT(0);
static const struct genl_multicast_group reg_event_mcgrps[] = {
{ .name = REG_GENL_MCAST_GROUP_NAME, },
return -ENOMEM;
/* add the genetlink message header */
- msg_header = genlmsg_put(skb, 0, reg_event_seqnum++,
- ®_event_genl_family, 0,
- REG_GENL_CMD_EVENT);
+ msg_header = genlmsg_put(skb, 0, atomic_inc_return(®_event_seqnum),
+ ®_event_genl_family, 0, REG_GENL_CMD_EVENT);
if (!msg_header) {
nlmsg_free(skb);
return -ENOMEM;