Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright 2020 Linaro Limited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Generic netlink for thermal management framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <net/genetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <trace/hooks/thermal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <uapi/linux/thermal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "thermal_core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) static const struct genl_multicast_group thermal_genl_mcgrps[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	{ .name = THERMAL_GENL_SAMPLING_GROUP_NAME, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	{ .name = THERMAL_GENL_EVENT_GROUP_NAME,  },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static const struct nla_policy thermal_genl_policy[THERMAL_GENL_ATTR_MAX + 1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	/* Thermal zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	[THERMAL_GENL_ATTR_TZ]			= { .type = NLA_NESTED },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	[THERMAL_GENL_ATTR_TZ_ID]		= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	[THERMAL_GENL_ATTR_TZ_TEMP]		= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	[THERMAL_GENL_ATTR_TZ_TRIP]		= { .type = NLA_NESTED },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	[THERMAL_GENL_ATTR_TZ_TRIP_ID]		= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	[THERMAL_GENL_ATTR_TZ_TRIP_TEMP]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	[THERMAL_GENL_ATTR_TZ_TRIP_TYPE]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	[THERMAL_GENL_ATTR_TZ_TRIP_HYST]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	[THERMAL_GENL_ATTR_TZ_MODE]		= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	[THERMAL_GENL_ATTR_TZ_CDEV_WEIGHT]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	[THERMAL_GENL_ATTR_TZ_NAME]		= { .type = NLA_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 						    .len = THERMAL_NAME_LENGTH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	/* Governor(s) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	[THERMAL_GENL_ATTR_TZ_GOV]		= { .type = NLA_NESTED },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	[THERMAL_GENL_ATTR_TZ_GOV_NAME]		= { .type = NLA_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 						    .len = THERMAL_NAME_LENGTH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/* Cooling devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	[THERMAL_GENL_ATTR_CDEV]		= { .type = NLA_NESTED },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	[THERMAL_GENL_ATTR_CDEV_ID]		= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	[THERMAL_GENL_ATTR_CDEV_CUR_STATE]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	[THERMAL_GENL_ATTR_CDEV_MAX_STATE]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	[THERMAL_GENL_ATTR_CDEV_NAME]		= { .type = NLA_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 						    .len = THERMAL_NAME_LENGTH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) struct param {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct nlattr **attrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct sk_buff *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	int tz_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	int cdev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	int trip_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	int trip_temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	int trip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int trip_hyst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	int temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int cdev_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	int cdev_max_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) typedef int (*cb_t)(struct param *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static struct genl_family thermal_gnl_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /************************** Sampling encoding *******************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) int thermal_genl_sampling_temp(int id, int temp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	void *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	hdr = genlmsg_put(skb, 0, 0, &thermal_gnl_family, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			  THERMAL_GENL_SAMPLING_TEMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (!hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	if (nla_put_u32(skb, THERMAL_GENL_ATTR_TZ_ID, id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		goto out_cancel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (nla_put_u32(skb, THERMAL_GENL_ATTR_TZ_TEMP, temp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		goto out_cancel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	genlmsg_end(skb, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	genlmsg_multicast(&thermal_gnl_family, skb, 0, 0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) out_cancel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	genlmsg_cancel(skb, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	nlmsg_free(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**************************** Event encoding *********************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static int thermal_genl_event_tz_create(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	    nla_put_string(p->msg, THERMAL_GENL_ATTR_TZ_NAME, p->name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static int thermal_genl_event_tz(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static int thermal_genl_event_tz_trip_up(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static int thermal_genl_event_tz_trip_add(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, p->trip_type) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, p->trip_temp) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, p->trip_hyst))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int thermal_genl_event_tz_trip_delete(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static int thermal_genl_event_cdev_add(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (nla_put_string(p->msg, THERMAL_GENL_ATTR_CDEV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			   p->name) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_CDEV_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			p->cdev_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_CDEV_MAX_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			p->cdev_max_state))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static int thermal_genl_event_cdev_delete(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_CDEV_ID, p->cdev_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static int thermal_genl_event_cdev_state_update(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_CDEV_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			p->cdev_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	    nla_put_u32(p->msg, THERMAL_GENL_ATTR_CDEV_CUR_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			p->cdev_state))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static int thermal_genl_event_gov_change(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	    nla_put_string(p->msg, THERMAL_GENL_ATTR_GOV_NAME, p->name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int thermal_genl_event_tz_delete(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	__attribute__((alias("thermal_genl_event_tz")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) int thermal_genl_event_tz_enable(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	__attribute__((alias("thermal_genl_event_tz")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int thermal_genl_event_tz_disable(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	__attribute__((alias("thermal_genl_event_tz")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int thermal_genl_event_tz_trip_down(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	__attribute__((alias("thermal_genl_event_tz_trip_up")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int thermal_genl_event_tz_trip_change(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	__attribute__((alias("thermal_genl_event_tz_trip_add")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static cb_t event_cb[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	[THERMAL_GENL_EVENT_TZ_CREATE]		= thermal_genl_event_tz_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	[THERMAL_GENL_EVENT_TZ_DELETE]		= thermal_genl_event_tz_delete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	[THERMAL_GENL_EVENT_TZ_ENABLE]		= thermal_genl_event_tz_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	[THERMAL_GENL_EVENT_TZ_DISABLE]		= thermal_genl_event_tz_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	[THERMAL_GENL_EVENT_TZ_TRIP_UP]		= thermal_genl_event_tz_trip_up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	[THERMAL_GENL_EVENT_TZ_TRIP_DOWN]	= thermal_genl_event_tz_trip_down,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	[THERMAL_GENL_EVENT_TZ_TRIP_CHANGE]	= thermal_genl_event_tz_trip_change,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	[THERMAL_GENL_EVENT_TZ_TRIP_ADD]	= thermal_genl_event_tz_trip_add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	[THERMAL_GENL_EVENT_TZ_TRIP_DELETE]	= thermal_genl_event_tz_trip_delete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	[THERMAL_GENL_EVENT_CDEV_ADD]		= thermal_genl_event_cdev_add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	[THERMAL_GENL_EVENT_CDEV_DELETE]	= thermal_genl_event_cdev_delete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	[THERMAL_GENL_EVENT_CDEV_STATE_UPDATE]	= thermal_genl_event_cdev_state_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	[THERMAL_GENL_EVENT_TZ_GOV_CHANGE]	= thermal_genl_event_gov_change,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  * Generic netlink event encoding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static int thermal_genl_send_event(enum thermal_genl_event event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				   struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	struct sk_buff *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	int ret = -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	void *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	int enable_thermal_genl = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	trace_android_vh_enable_thermal_genl_check(event, p->tz_id, &enable_thermal_genl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (!enable_thermal_genl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (!msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	p->msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	hdr = genlmsg_put(msg, 0, 0, &thermal_gnl_family, 0, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (!hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		goto out_free_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	ret = event_cb[event](p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		goto out_cancel_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	genlmsg_end(msg, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	genlmsg_multicast(&thermal_gnl_family, msg, 0, 1, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) out_cancel_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	genlmsg_cancel(msg, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) out_free_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	nlmsg_free(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int thermal_notify_tz_create(int tz_id, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	struct param p = { .tz_id = tz_id, .name = name };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_CREATE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int thermal_notify_tz_delete(int tz_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	struct param p = { .tz_id = tz_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DELETE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) int thermal_notify_tz_enable(int tz_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	struct param p = { .tz_id = tz_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_ENABLE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) int thermal_notify_tz_disable(int tz_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	struct param p = { .tz_id = tz_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) int thermal_notify_tz_trip_down(int tz_id, int trip_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	struct param p = { .tz_id = tz_id, .trip_id = trip_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) int thermal_notify_tz_trip_up(int tz_id, int trip_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	struct param p = { .tz_id = tz_id, .trip_id = trip_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) int thermal_notify_tz_trip_add(int tz_id, int trip_id, int trip_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			       int trip_temp, int trip_hyst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	struct param p = { .tz_id = tz_id, .trip_id = trip_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			   .trip_type = trip_type, .trip_temp = trip_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			   .trip_hyst = trip_hyst };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_ADD, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) int thermal_notify_tz_trip_delete(int tz_id, int trip_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	struct param p = { .tz_id = tz_id, .trip_id = trip_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DELETE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int thermal_notify_tz_trip_change(int tz_id, int trip_id, int trip_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 				  int trip_temp, int trip_hyst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	struct param p = { .tz_id = tz_id, .trip_id = trip_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 			   .trip_type = trip_type, .trip_temp = trip_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 			   .trip_hyst = trip_hyst };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_CHANGE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) int thermal_notify_cdev_state_update(int cdev_id, int cdev_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	struct param p = { .cdev_id = cdev_id, .cdev_state = cdev_state };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_STATE_UPDATE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) int thermal_notify_cdev_add(int cdev_id, const char *name, int cdev_max_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	struct param p = { .cdev_id = cdev_id, .name = name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 			   .cdev_max_state = cdev_max_state };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_ADD, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) int thermal_notify_cdev_delete(int cdev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	struct param p = { .cdev_id = cdev_id };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_DELETE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) int thermal_notify_tz_gov_change(int tz_id, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	struct param p = { .tz_id = tz_id, .name = name };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_GOV_CHANGE, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) /*************************** Command encoding ********************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static int __thermal_genl_cmd_tz_get_id(struct thermal_zone_device *tz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 					void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	struct sk_buff *msg = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_ID, tz->id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	    nla_put_string(msg, THERMAL_GENL_ATTR_TZ_NAME, tz->type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) static int thermal_genl_cmd_tz_get_id(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	struct sk_buff *msg = p->msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	struct nlattr *start_tz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	start_tz = nla_nest_start(msg, THERMAL_GENL_ATTR_TZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	if (!start_tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	ret = for_each_thermal_zone(__thermal_genl_cmd_tz_get_id, msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		goto out_cancel_nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	nla_nest_end(msg, start_tz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) out_cancel_nest:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	nla_nest_cancel(msg, start_tz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) static int thermal_genl_cmd_tz_get_trip(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	struct sk_buff *msg = p->msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	struct thermal_zone_device *tz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	struct nlattr *start_trip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	int i, id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	tz = thermal_zone_get_by_id(id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	if (!tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	start_trip = nla_nest_start(msg, THERMAL_GENL_ATTR_TZ_TRIP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	if (!start_trip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	mutex_lock(&tz->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	for (i = 0; i < tz->trips; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		enum thermal_trip_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		int temp, hyst = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		tz->ops->get_trip_type(tz, i, &type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		tz->ops->get_trip_temp(tz, i, &temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		if (tz->ops->get_trip_hyst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 			tz->ops->get_trip_hyst(tz, i, &hyst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, temp) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, hyst))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 			goto out_cancel_nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	mutex_unlock(&tz->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	nla_nest_end(msg, start_trip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) out_cancel_nest:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	mutex_unlock(&tz->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) static int thermal_genl_cmd_tz_get_temp(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	struct sk_buff *msg = p->msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	struct thermal_zone_device *tz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	int temp, ret, id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	tz = thermal_zone_get_by_id(id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	if (!tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	ret = thermal_zone_get_temp(tz, &temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_ID, id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TEMP, temp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) static int thermal_genl_cmd_tz_get_gov(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	struct sk_buff *msg = p->msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	struct thermal_zone_device *tz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	int id, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	tz = thermal_zone_get_by_id(id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	if (!tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	mutex_lock(&tz->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_ID, id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	    nla_put_string(msg, THERMAL_GENL_ATTR_TZ_GOV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			   tz->governor->name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		ret = -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	mutex_unlock(&tz->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static int __thermal_genl_cmd_cdev_get(struct thermal_cooling_device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 				       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	struct sk_buff *msg = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	if (nla_put_u32(msg, THERMAL_GENL_ATTR_CDEV_ID, cdev->id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	if (nla_put_string(msg, THERMAL_GENL_ATTR_CDEV_NAME, cdev->type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) static int thermal_genl_cmd_cdev_get(struct param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	struct sk_buff *msg = p->msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	struct nlattr *start_cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	start_cdev = nla_nest_start(msg, THERMAL_GENL_ATTR_CDEV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	if (!start_cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	ret = for_each_thermal_cooling_device(__thermal_genl_cmd_cdev_get, msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		goto out_cancel_nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	nla_nest_end(msg, start_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) out_cancel_nest:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	nla_nest_cancel(msg, start_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static cb_t cmd_cb[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	[THERMAL_GENL_CMD_TZ_GET_ID]	= thermal_genl_cmd_tz_get_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	[THERMAL_GENL_CMD_TZ_GET_TRIP]	= thermal_genl_cmd_tz_get_trip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	[THERMAL_GENL_CMD_TZ_GET_TEMP]	= thermal_genl_cmd_tz_get_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	[THERMAL_GENL_CMD_TZ_GET_GOV]	= thermal_genl_cmd_tz_get_gov,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	[THERMAL_GENL_CMD_CDEV_GET]	= thermal_genl_cmd_cdev_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) static int thermal_genl_cmd_dumpit(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 				   struct netlink_callback *cb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	struct param p = { .msg = skb };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	const struct genl_dumpit_info *info = genl_dumpit_info(cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	int cmd = info->op.cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	void *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	hdr = genlmsg_put(skb, 0, 0, &thermal_gnl_family, 0, cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	if (!hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 		return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	ret = cmd_cb[cmd](&p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 		goto out_cancel_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	genlmsg_end(skb, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) out_cancel_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	genlmsg_cancel(skb, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) static int thermal_genl_cmd_doit(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 				 struct genl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	struct param p = { .attrs = info->attrs };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	struct sk_buff *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	void *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	int cmd = info->genlhdr->cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	int ret = -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	if (!msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	p.msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	hdr = genlmsg_put_reply(msg, info, &thermal_gnl_family, 0, cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	if (!hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 		goto out_free_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	ret = cmd_cb[cmd](&p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 		goto out_cancel_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	genlmsg_end(msg, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	return genlmsg_reply(msg, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) out_cancel_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	genlmsg_cancel(msg, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) out_free_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	nlmsg_free(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) static const struct genl_small_ops thermal_genl_ops[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 		.cmd = THERMAL_GENL_CMD_TZ_GET_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		.dumpit = thermal_genl_cmd_dumpit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		.cmd = THERMAL_GENL_CMD_TZ_GET_TRIP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		.doit = thermal_genl_cmd_doit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		.cmd = THERMAL_GENL_CMD_TZ_GET_TEMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		.doit = thermal_genl_cmd_doit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 		.cmd = THERMAL_GENL_CMD_TZ_GET_GOV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		.doit = thermal_genl_cmd_doit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 		.cmd = THERMAL_GENL_CMD_CDEV_GET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 		.dumpit = thermal_genl_cmd_dumpit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) static struct genl_family thermal_gnl_family __ro_after_init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	.hdrsize	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	.name		= THERMAL_GENL_FAMILY_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	.version	= THERMAL_GENL_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	.maxattr	= THERMAL_GENL_ATTR_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	.policy		= thermal_genl_policy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	.small_ops	= thermal_genl_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	.n_small_ops	= ARRAY_SIZE(thermal_genl_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	.mcgrps		= thermal_genl_mcgrps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 	.n_mcgrps	= ARRAY_SIZE(thermal_genl_mcgrps),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) int __init thermal_netlink_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	return genl_register_family(&thermal_gnl_family);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) }