libnvdimm/altmap: Track namespace boundaries in altmap
[linux-2.6-block.git] / drivers / thermal / user_space.c
CommitLineData
873e65bc 1// SPDX-License-Identifier: GPL-2.0-only
1cc807a2
D
2/*
3 * user_space.c - A simple user space Thermal events notifier
4 *
5 * Copyright (C) 2012 Intel Corp
6 * Copyright (C) 2012 Durgadoss R <durgadoss.r@intel.com>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
1cc807a2
D
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 */
12
1cc807a2 13#include <linux/thermal.h>
998d924b 14#include <linux/slab.h>
0d76d6e1 15
1cc807a2
D
16#include "thermal_core.h"
17
18/**
19 * notify_user_space - Notifies user space about thermal events
20 * @tz - thermal_zone_device
0d76d6e1 21 * @trip - trip point index
1cc807a2
D
22 *
23 * This function notifies the user space through UEvents.
24 */
e15cb144 25static int notify_user_space(struct thermal_zone_device *tz, int trip)
1cc807a2 26{
998d924b
SP
27 char *thermal_prop[5];
28 int i;
29
1cc807a2 30 mutex_lock(&tz->lock);
998d924b
SP
31 thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", tz->type);
32 thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", tz->temperature);
33 thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d", trip);
34 thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", tz->notify_event);
35 thermal_prop[4] = NULL;
36 kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
37 for (i = 0; i < 4; ++i)
38 kfree(thermal_prop[i]);
1cc807a2
D
39 mutex_unlock(&tz->lock);
40 return 0;
41}
42
e15cb144 43static struct thermal_governor thermal_gov_user_space = {
1cc807a2
D
44 .name = "user_space",
45 .throttle = notify_user_space,
1cc807a2 46};
57c5b2ec 47THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);