drivers/thermal/thermal_netlink.c
Source file repositories/reference/linux-study-clean/drivers/thermal/thermal_netlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/thermal_netlink.c- Extension
.c- Size
- 24959 bytes
- Lines
- 938
- Domain
- Driver Families
- Bucket
- drivers/thermal
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/notifier.hlinux/kernel.hnet/sock.hnet/genetlink.huapi/linux/thermal.hthermal_core.h
Detected Declarations
struct paramfunction thermal_group_has_listenersfunction thermal_genl_sampling_tempfunction thermal_genl_event_tz_createfunction thermal_genl_event_tzfunction thermal_genl_event_tz_trip_upfunction thermal_genl_event_tz_trip_changefunction thermal_genl_event_cdev_addfunction thermal_genl_event_cdev_deletefunction thermal_genl_event_cdev_state_updatefunction thermal_genl_event_gov_changefunction thermal_genl_event_cpu_capability_changefunction thermal_genl_event_threshold_addfunction thermal_genl_event_threshold_flushfunction thermal_genl_event_threshold_upfunction thermal_genl_send_eventfunction thermal_notify_tz_createfunction thermal_notify_tz_deletefunction thermal_notify_tz_enablefunction thermal_notify_tz_disablefunction thermal_notify_tz_trip_downfunction thermal_notify_tz_trip_upfunction thermal_notify_tz_trip_changefunction thermal_notify_cdev_state_updatefunction thermal_notify_cdev_addfunction thermal_notify_cdev_deletefunction thermal_notify_tz_gov_changefunction thermal_genl_cpu_capability_eventfunction thermal_notify_threshold_addfunction thermal_notify_threshold_deletefunction thermal_notify_threshold_flushfunction thermal_notify_threshold_downfunction thermal_notify_threshold_upfunction __thermal_genl_cmd_tz_get_idfunction thermal_genl_cmd_tz_get_idfunction thermal_genl_cmd_tz_get_tripfunction for_each_trip_descfunction thermal_genl_cmd_tz_get_tempfunction thermal_genl_cmd_tz_get_govfunction __thermal_genl_cmd_cdev_getfunction thermal_genl_cmd_cdev_getfunction __thermal_genl_cmd_threshold_getfunction thermal_genl_cmd_threshold_getfunction thermal_genl_cmd_threshold_addfunction thermal_genl_cmd_threshold_deletefunction thermal_genl_cmd_threshold_flushfunction thermal_genl_cmd_dumpitfunction thermal_genl_cmd_doit
Annotated Snippet
struct param {
struct nlattr **attrs;
struct sk_buff *msg;
const char *name;
int tz_id;
int cdev_id;
int trip_id;
int trip_temp;
int trip_type;
int trip_hyst;
int temp;
int prev_temp;
int direction;
int cdev_state;
int cdev_max_state;
struct thermal_genl_cpu_caps *cpu_capabilities;
int cpu_capabilities_count;
};
typedef int (*cb_t)(struct param *);
static struct genl_family thermal_genl_family;
static BLOCKING_NOTIFIER_HEAD(thermal_genl_chain);
static int thermal_group_has_listeners(enum thermal_genl_multicast_groups group)
{
return genl_has_listeners(&thermal_genl_family, &init_net, group);
}
/************************** Sampling encoding *******************************/
int thermal_genl_sampling_temp(int id, int temp)
{
struct sk_buff *skb;
void *hdr;
if (!thermal_group_has_listeners(THERMAL_GENL_SAMPLING_GROUP))
return 0;
skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
if (!skb)
return -ENOMEM;
hdr = genlmsg_put(skb, 0, 0, &thermal_genl_family, 0,
THERMAL_GENL_SAMPLING_TEMP);
if (!hdr)
goto out_free;
if (nla_put_u32(skb, THERMAL_GENL_ATTR_TZ_ID, id))
goto out_cancel;
if (nla_put_u32(skb, THERMAL_GENL_ATTR_TZ_TEMP, temp))
goto out_cancel;
genlmsg_end(skb, hdr);
genlmsg_multicast(&thermal_genl_family, skb, 0, THERMAL_GENL_SAMPLING_GROUP, GFP_KERNEL);
return 0;
out_cancel:
genlmsg_cancel(skb, hdr);
out_free:
nlmsg_free(skb);
return -EMSGSIZE;
}
/**************************** Event encoding *********************************/
static int thermal_genl_event_tz_create(struct param *p)
{
if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
nla_put_string(p->msg, THERMAL_GENL_ATTR_TZ_NAME, p->name))
return -EMSGSIZE;
return 0;
}
static int thermal_genl_event_tz(struct param *p)
{
if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id))
return -EMSGSIZE;
return 0;
}
static int thermal_genl_event_tz_trip_up(struct param *p)
{
if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) ||
Annotation
- Immediate include surface: `linux/module.h`, `linux/notifier.h`, `linux/kernel.h`, `net/sock.h`, `net/genetlink.h`, `uapi/linux/thermal.h`, `thermal_core.h`.
- Detected declarations: `struct param`, `function thermal_group_has_listeners`, `function thermal_genl_sampling_temp`, `function thermal_genl_event_tz_create`, `function thermal_genl_event_tz`, `function thermal_genl_event_tz_trip_up`, `function thermal_genl_event_tz_trip_change`, `function thermal_genl_event_cdev_add`, `function thermal_genl_event_cdev_delete`, `function thermal_genl_event_cdev_state_update`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.