Lines Matching refs:ccp
90 static int ccp_get_errno(struct ccp_device *ccp) in ccp_get_errno() argument
92 switch (ccp->buffer[0]) { in ccp_get_errno()
103 hid_dbg(ccp->hdev, "unknown device response error: %d", ccp->buffer[0]); in ccp_get_errno()
109 static int send_usb_cmd(struct ccp_device *ccp, u8 command, u8 byte1, u8 byte2, u8 byte3) in send_usb_cmd() argument
114 memset(ccp->buffer, 0x00, OUT_BUFFER_SIZE); in send_usb_cmd()
115 ccp->buffer[0] = command; in send_usb_cmd()
116 ccp->buffer[1] = byte1; in send_usb_cmd()
117 ccp->buffer[2] = byte2; in send_usb_cmd()
118 ccp->buffer[3] = byte3; in send_usb_cmd()
120 reinit_completion(&ccp->wait_input_report); in send_usb_cmd()
122 ret = hid_hw_output_report(ccp->hdev, ccp->buffer, OUT_BUFFER_SIZE); in send_usb_cmd()
126 t = wait_for_completion_timeout(&ccp->wait_input_report, msecs_to_jiffies(REQ_TIMEOUT)); in send_usb_cmd()
130 return ccp_get_errno(ccp); in send_usb_cmd()
135 struct ccp_device *ccp = hid_get_drvdata(hdev); in ccp_raw_event() local
138 if (completion_done(&ccp->wait_input_report)) in ccp_raw_event()
141 memcpy(ccp->buffer, data, min(IN_BUFFER_SIZE, size)); in ccp_raw_event()
142 complete(&ccp->wait_input_report); in ccp_raw_event()
148 static int get_data(struct ccp_device *ccp, int command, int channel, bool two_byte_data) in get_data() argument
152 mutex_lock(&ccp->mutex); in get_data()
154 ret = send_usb_cmd(ccp, command, channel, 0, 0); in get_data()
158 ret = ccp->buffer[1]; in get_data()
160 ret = (ret << 8) + ccp->buffer[2]; in get_data()
163 mutex_unlock(&ccp->mutex); in get_data()
167 static int set_pwm(struct ccp_device *ccp, int channel, long val) in set_pwm() argument
177 mutex_lock(&ccp->mutex); in set_pwm()
179 ret = send_usb_cmd(ccp, CTL_SET_FAN_FPWM, channel, val, 0); in set_pwm()
181 ccp->target[channel] = -ENODATA; in set_pwm()
183 mutex_unlock(&ccp->mutex); in set_pwm()
187 static int set_target(struct ccp_device *ccp, int channel, long val) in set_target() argument
192 ccp->target[channel] = val; in set_target()
194 mutex_lock(&ccp->mutex); in set_target()
195 ret = send_usb_cmd(ccp, CTL_SET_FAN_TARGET, channel, val >> 8, val); in set_target()
197 mutex_unlock(&ccp->mutex); in set_target()
204 struct ccp_device *ccp = dev_get_drvdata(dev); in ccp_read_string() local
210 *str = ccp->fan_label[channel]; in ccp_read_string()
226 struct ccp_device *ccp = dev_get_drvdata(dev); in ccp_read() local
233 ret = get_data(ccp, CTL_GET_TMP, channel, true); in ccp_read()
245 ret = get_data(ccp, CTL_GET_FAN_RPM, channel, true); in ccp_read()
253 if (ccp->target[channel] < 0) in ccp_read()
255 *val = ccp->target[channel]; in ccp_read()
264 ret = get_data(ccp, CTL_GET_FAN_PWM, channel, false); in ccp_read()
276 ret = get_data(ccp, CTL_GET_VOLT, channel, true); in ccp_read()
295 struct ccp_device *ccp = dev_get_drvdata(dev); in ccp_write() local
301 return set_pwm(ccp, channel, val); in ccp_write()
309 return set_target(ccp, channel, val); in ccp_write()
323 const struct ccp_device *ccp = data; in ccp_is_visible() local
327 if (!test_bit(channel, ccp->temp_cnct)) in ccp_is_visible()
340 if (!test_bit(channel, ccp->fan_cnct)) in ccp_is_visible()
355 if (!test_bit(channel, ccp->fan_cnct)) in ccp_is_visible()
426 static int get_fan_cnct(struct ccp_device *ccp) in get_fan_cnct() argument
432 ret = send_usb_cmd(ccp, CTL_GET_FAN_CNCT, 0, 0, 0); in get_fan_cnct()
437 mode = ccp->buffer[channel + 1]; in get_fan_cnct()
441 set_bit(channel, ccp->fan_cnct); in get_fan_cnct()
442 ccp->target[channel] = -ENODATA; in get_fan_cnct()
446 scnprintf(ccp->fan_label[channel], LABEL_LENGTH, in get_fan_cnct()
450 scnprintf(ccp->fan_label[channel], LABEL_LENGTH, in get_fan_cnct()
454 scnprintf(ccp->fan_label[channel], LABEL_LENGTH, in get_fan_cnct()
464 static int get_temp_cnct(struct ccp_device *ccp) in get_temp_cnct() argument
470 ret = send_usb_cmd(ccp, CTL_GET_TMP_CNCT, 0, 0, 0); in get_temp_cnct()
475 mode = ccp->buffer[channel + 1]; in get_temp_cnct()
479 set_bit(channel, ccp->temp_cnct); in get_temp_cnct()
487 struct ccp_device *ccp; in ccp_probe() local
490 ccp = devm_kzalloc(&hdev->dev, sizeof(*ccp), GFP_KERNEL); in ccp_probe()
491 if (!ccp) in ccp_probe()
494 ccp->buffer = devm_kmalloc(&hdev->dev, OUT_BUFFER_SIZE, GFP_KERNEL); in ccp_probe()
495 if (!ccp->buffer) in ccp_probe()
510 ccp->hdev = hdev; in ccp_probe()
511 hid_set_drvdata(hdev, ccp); in ccp_probe()
512 mutex_init(&ccp->mutex); in ccp_probe()
513 init_completion(&ccp->wait_input_report); in ccp_probe()
518 ret = get_temp_cnct(ccp); in ccp_probe()
522 ret = get_fan_cnct(ccp); in ccp_probe()
525 ccp->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsaircpro", in ccp_probe()
526 ccp, &ccp_chip_info, 0); in ccp_probe()
527 if (IS_ERR(ccp->hwmon_dev)) { in ccp_probe()
528 ret = PTR_ERR(ccp->hwmon_dev); in ccp_probe()
543 struct ccp_device *ccp = hid_get_drvdata(hdev); in ccp_remove() local
545 hwmon_device_unregister(ccp->hwmon_dev); in ccp_remove()