Lines Matching +full:data +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0
32 return -EIO; in nvme_get_temp_thresh()
55 return -EIO; in nvme_set_temp_thresh()
60 static int nvme_hwmon_get_smart_log(struct nvme_hwmon_data *data) in nvme_hwmon_get_smart_log() argument
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
69 struct nvme_hwmon_data *data = dev_get_drvdata(dev); in nvme_hwmon_read() local
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()
91 err = nvme_hwmon_get_smart_log(data); 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
118 struct nvme_hwmon_data *data = dev_get_drvdata(dev); in nvme_hwmon_write() local
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()
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
156 const struct nvme_hwmon_data *data = _data; in nvme_hwmon_is_visible() local
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()
229 struct nvme_hwmon_data *data; in nvme_hwmon_init() local
233 data = kzalloc(sizeof(*data), GFP_KERNEL); in nvme_hwmon_init()
234 if (!data) 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()
246 err = nvme_hwmon_get_smart_log(data); in nvme_hwmon_init()
253 data, &nvme_hwmon_chip_info, in nvme_hwmon_init()
260 ctrl->hwmon_device = hwmon; in nvme_hwmon_init()
264 kfree(data->log); in nvme_hwmon_init()
266 kfree(data); in nvme_hwmon_init()
272 if (ctrl->hwmon_device) { in nvme_hwmon_exit()
273 struct nvme_hwmon_data *data = in nvme_hwmon_exit() local
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()
279 kfree(data); in nvme_hwmon_exit()