Lines Matching +full:sensor +full:- +full:channel
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
22 unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; in nvme_get_temp_thresh()
32 return -EIO; 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
43 unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; 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()
67 u32 attr, int channel, long *val) in nvme_hwmon_read() argument
70 struct nvme_smart_log *log = data->log; in nvme_hwmon_read()
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()
97 if (!channel) 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()
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()
116 u32 attr, int channel, long val) in nvme_hwmon_write() argument
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",
146 int channel, const char **str) in nvme_hwmon_read_string() argument
148 *str = nvme_hwmon_sensor_names[channel]; in nvme_hwmon_read_string()
154 u32 attr, int channel) in nvme_hwmon_is_visible() argument
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()
176 if (!channel) in nvme_hwmon_is_visible()
181 if (!channel || data->log->temp_sensor[channel - 1]) in nvme_hwmon_is_visible()
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()