Lines Matching +full:temp +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0
19 static int nvme_get_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, in nvme_get_temp_thresh() argument
20 long *temp) in nvme_get_temp_thresh() argument
22 unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; in nvme_get_temp_thresh()
32 return -EIO; in nvme_get_temp_thresh()
35 *temp = kelvin_to_millicelsius(status & NVME_TEMP_THRESH_MASK); in nvme_get_temp_thresh()
40 static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, in nvme_set_temp_thresh() argument
41 long temp) in nvme_set_temp_thresh() argument
43 unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; in nvme_set_temp_thresh()
46 temp = millicelsius_to_kelvin(temp); in nvme_set_temp_thresh()
47 threshold |= clamp_val(temp, 0, NVME_TEMP_THRESH_MASK); in nvme_set_temp_thresh()
55 return -EIO; in nvme_set_temp_thresh()
62 return nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0, in nvme_hwmon_get_smart_log()
63 NVME_CSI_NVM, data->log, sizeof(*data->log), 0); in nvme_hwmon_get_smart_log()
70 struct nvme_smart_log *log = data->log; in nvme_hwmon_read()
71 int temp; in nvme_hwmon_read() local
80 return nvme_get_temp_thresh(data->ctrl, channel, false, val); in nvme_hwmon_read()
82 return nvme_get_temp_thresh(data->ctrl, channel, true, val); in nvme_hwmon_read()
84 *val = kelvin_to_millicelsius(data->ctrl->cctemp); in nvme_hwmon_read()
90 mutex_lock(&data->read_lock); in nvme_hwmon_read()
98 temp = get_unaligned_le16(log->temperature); in nvme_hwmon_read()
100 temp = le16_to_cpu(log->temp_sensor[channel - 1]); in nvme_hwmon_read()
101 *val = kelvin_to_millicelsius(temp); in nvme_hwmon_read()
104 *val = !!(log->critical_warning & NVME_SMART_CRIT_TEMPERATURE); in nvme_hwmon_read()
107 err = -EOPNOTSUPP; in nvme_hwmon_read()
111 mutex_unlock(&data->read_lock); in nvme_hwmon_read()
122 return nvme_set_temp_thresh(data->ctrl, channel, false, val); in nvme_hwmon_write()
124 return nvme_set_temp_thresh(data->ctrl, channel, true, val); in nvme_hwmon_write()
129 return -EOPNOTSUPP; in nvme_hwmon_write()
134 "Sensor 1",
135 "Sensor 2",
136 "Sensor 3",
137 "Sensor 4",
138 "Sensor 5",
139 "Sensor 6",
140 "Sensor 7",
141 "Sensor 8",
160 if (!channel && data->ctrl->cctemp) in nvme_hwmon_is_visible()
165 if ((!channel && data->ctrl->wctemp) || in nvme_hwmon_is_visible()
166 (channel && data->log->temp_sensor[channel - 1] && in nvme_hwmon_is_visible()
167 !(data->ctrl->quirks & in nvme_hwmon_is_visible()
169 if (data->ctrl->quirks & in nvme_hwmon_is_visible()
181 if (!channel || data->log->temp_sensor[channel - 1]) in nvme_hwmon_is_visible()
192 HWMON_CHANNEL_INFO(temp,
228 struct device *dev = ctrl->device; in nvme_hwmon_init()
235 return -ENOMEM; in nvme_hwmon_init()
237 data->log = kzalloc(sizeof(*data->log), GFP_KERNEL); in nvme_hwmon_init()
238 if (!data->log) { in nvme_hwmon_init()
239 err = -ENOMEM; in nvme_hwmon_init()
243 data->ctrl = ctrl; in nvme_hwmon_init()
244 mutex_init(&data->read_lock); in nvme_hwmon_init()
260 ctrl->hwmon_device = hwmon; in nvme_hwmon_init()
264 kfree(data->log); in nvme_hwmon_init()
272 if (ctrl->hwmon_device) { in nvme_hwmon_exit()
274 dev_get_drvdata(ctrl->hwmon_device); in nvme_hwmon_exit()
276 hwmon_device_unregister(ctrl->hwmon_device); in nvme_hwmon_exit()
277 ctrl->hwmon_device = NULL; in nvme_hwmon_exit()
278 kfree(data->log); in nvme_hwmon_exit()