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