lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240114125645.2356445-1-naresh.solanki@9elements.com>
Date: Sun, 14 Jan 2024 18:26:44 +0530
From: Naresh Solanki <naresh.solanki@...ements.com>
To: broonie@...nel.org,
	Liam Girdwood <lgirdwood@...il.com>
Cc: mazziesaccount@...il.com,
	Naresh Solanki <naresh.solanki@...ements.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] regulator: event: Add netlink command for event mask

Add netlink command to enable perticular event(s) broadcasting instead
of all regulator events.

Signed-off-by: Naresh Solanki <naresh.solanki@...ements.com>
---
 drivers/regulator/event.c          | 28 ++++++++++++++++++++++++++++
 include/uapi/regulator/regulator.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/drivers/regulator/event.c b/drivers/regulator/event.c
index ea3bd49544e8..8ae8e606bea8 100644
--- a/drivers/regulator/event.c
+++ b/drivers/regulator/event.c
@@ -14,17 +14,41 @@
 
 static atomic_t reg_event_seqnum = ATOMIC_INIT(0);
 
+static u64 event_mask;
+
 static const struct genl_multicast_group reg_event_mcgrps[] = {
 	{ .name = REG_GENL_MCAST_GROUP_NAME, },
 };
 
+static int reg_genl_cmd_doit(struct sk_buff *skb, struct genl_info *info)
+{
+	if (info->attrs[REG_GENL_ATTR_EVENT_MASK]) {
+		event_mask = nla_get_u64(info->attrs[REG_GENL_ATTR_EVENT_MASK]);
+		pr_info("event_mask -> %llx", event_mask);
+		return 0;
+	}
+	pr_warn("Unknown attribute.");
+	return -EOPNOTSUPP;
+}
+
+static const struct genl_small_ops reg_genl_ops[] = {
+	{
+		.cmd = REG_GENL_CMD_EVENT,
+		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
+		.doit = reg_genl_cmd_doit,
+	}
+};
+
 static struct genl_family reg_event_genl_family __ro_after_init = {
 	.module = THIS_MODULE,
 	.name = REG_GENL_FAMILY_NAME,
 	.version = REG_GENL_VERSION,
 	.maxattr = REG_GENL_ATTR_MAX,
+	.small_ops	= reg_genl_ops,
+	.n_small_ops	= ARRAY_SIZE(reg_genl_ops),
 	.mcgrps = reg_event_mcgrps,
 	.n_mcgrps = ARRAY_SIZE(reg_event_mcgrps),
+	.resv_start_op = __REG_GENL_CMD_MAX,
 };
 
 int reg_generate_netlink_event(const char *reg_name, u64 event)
@@ -35,6 +59,9 @@ int reg_generate_netlink_event(const char *reg_name, u64 event)
 	void *msg_header;
 	int size;
 
+	if (!(event_mask & event))
+		return 0;
+
 	/* allocate memory */
 	size = nla_total_size(sizeof(struct reg_genl_event)) +
 	    nla_total_size(0);
@@ -73,6 +100,7 @@ int reg_generate_netlink_event(const char *reg_name, u64 event)
 
 static int __init reg_event_genetlink_init(void)
 {
+	event_mask = 0;
 	return genl_register_family(&reg_event_genl_family);
 }
 
diff --git a/include/uapi/regulator/regulator.h b/include/uapi/regulator/regulator.h
index 71bf71a22e7f..21ffa36e2ab7 100644
--- a/include/uapi/regulator/regulator.h
+++ b/include/uapi/regulator/regulator.h
@@ -69,6 +69,7 @@ struct reg_genl_event {
 enum {
 	REG_GENL_ATTR_UNSPEC,
 	REG_GENL_ATTR_EVENT,	/* reg event info needed by user space */
+	REG_GENL_ATTR_EVENT_MASK,	/* reg event mask */
 	__REG_GENL_ATTR_MAX,
 };
 

base-commit: 94cc3087aac4103c33c6da84c092301afd783200
-- 
2.41.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ