Skip to content

Commit e4ed8d2

Browse files
multics69rafaeljw
authored andcommitted
PM: EM: Add a skeleton code for netlink notification
Add a boilerplate code for netlink notification to register the new protocol family. Also, initialize and register the netlink during booting. The initialization is called at the postcore level, which is late enough after the generic netlink is initialized. Finally, update MAINTAINERS to include new files. Signed-off-by: Changwoo Min <changwoo@igalia.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/20251020220914.320832-5-changwoo@igalia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent bd26631 commit e4ed8d2

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9183,7 +9183,7 @@ F: include/linux/energy_model.h
91839183
F: Documentation/power/energy-model.rst
91849184
F: Documentation/netlink/specs/em.yaml
91859185
F: include/uapi/linux/energy_model.h
9186-
F: kernel/power/em_netlink_autogen.*
9186+
F: kernel/power/em_netlink*.*
91879187

91889188
EPAPR HYPERVISOR BYTE CHANNEL DEVICE DRIVER
91899189
M: Laurentiu Tudor <laurentiu.tudor@nxp.com>

kernel/power/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ obj-$(CONFIG_PM_WAKELOCKS) += wakelock.o
2121

2222
obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
2323

24-
obj-$(CONFIG_ENERGY_MODEL) += energy_model.o
24+
obj-$(CONFIG_ENERGY_MODEL) += em.o
25+
em-y := energy_model.o
26+
em-$(CONFIG_NET) += em_netlink_autogen.o em_netlink.o

kernel/power/em_netlink.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
*
4+
* Generic netlink for energy model.
5+
*
6+
* Copyright (c) 2025 Valve Corporation.
7+
* Author: Changwoo Min <changwoo@igalia.com>
8+
*/
9+
10+
#define pr_fmt(fmt) "energy_model: " fmt
11+
12+
#include <linux/energy_model.h>
13+
#include <net/sock.h>
14+
#include <net/genetlink.h>
15+
#include <uapi/linux/energy_model.h>
16+
17+
#include "em_netlink.h"
18+
#include "em_netlink_autogen.h"
19+
20+
int em_nl_get_pds_doit(struct sk_buff *skb, struct genl_info *info)
21+
{
22+
return -EOPNOTSUPP;
23+
}
24+
25+
int em_nl_get_pd_table_doit(struct sk_buff *skb, struct genl_info *info)
26+
{
27+
return -EOPNOTSUPP;
28+
}
29+
30+
static int __init em_netlink_init(void)
31+
{
32+
return genl_register_family(&em_nl_family);
33+
}
34+
postcore_initcall(em_netlink_init);

kernel/power/em_netlink.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
*
4+
* Generic netlink for energy model.
5+
*
6+
* Copyright (c) 2025 Valve Corporation.
7+
* Author: Changwoo Min <changwoo@igalia.com>
8+
*/
9+
#ifndef _EM_NETLINK_H
10+
#define _EM_NETLINK_H
11+
12+
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_NET)
13+
#else
14+
#endif
15+
16+
#endif /* _EM_NETLINK_H */

0 commit comments

Comments
 (0)