Lines Matching refs:ldev
78 int (*init)(struct hidled_device *ldev);
89 struct hidled_device *ldev; member
113 static int hidled_send(struct hidled_device *ldev, __u8 *buf) in hidled_send() argument
117 mutex_lock(&ldev->lock); in hidled_send()
123 memcpy(ldev->buf, buf, ldev->config->report_size); in hidled_send()
125 if (ldev->config->report_type == RAW_REQUEST) in hidled_send()
126 ret = hid_hw_raw_request(ldev->hdev, buf[0], ldev->buf, in hidled_send()
127 ldev->config->report_size, in hidled_send()
130 else if (ldev->config->report_type == OUTPUT_REPORT) in hidled_send()
131 ret = hid_hw_output_report(ldev->hdev, ldev->buf, in hidled_send()
132 ldev->config->report_size); in hidled_send()
136 mutex_unlock(&ldev->lock); in hidled_send()
141 return ret == ldev->config->report_size ? 0 : -EMSGSIZE; in hidled_send()
145 static int hidled_recv(struct hidled_device *ldev, __u8 *buf) in hidled_recv() argument
149 if (ldev->config->report_type != RAW_REQUEST) in hidled_recv()
152 mutex_lock(&ldev->lock); in hidled_recv()
154 memcpy(ldev->buf, buf, ldev->config->report_size); in hidled_recv()
156 ret = hid_hw_raw_request(ldev->hdev, buf[0], ldev->buf, in hidled_recv()
157 ldev->config->report_size, in hidled_recv()
163 ret = hid_hw_raw_request(ldev->hdev, buf[0], ldev->buf, in hidled_recv()
164 ldev->config->report_size, in hidled_recv()
168 memcpy(buf, ldev->buf, ldev->config->report_size); in hidled_recv()
170 mutex_unlock(&ldev->lock); in hidled_recv()
197 return hidled_send(rgb->ldev, buf); in riso_kagaku_write()
212 return hidled_send(rgb->ldev, buf); in dream_cheeky_write()
215 static int dream_cheeky_init(struct hidled_device *ldev) in dream_cheeky_init() argument
226 return hidled_send(ldev, buf); in dream_cheeky_init()
240 return hidled_send(led->rgb->ldev, buf); in _thingm_write()
263 static int thingm_init(struct hidled_device *ldev) in thingm_init() argument
268 ret = hidled_recv(ldev, buf); in thingm_init()
274 ldev->config = &hidled_config_thingm_v1; in thingm_init()
296 return hidled_send(led->rgb->ldev, dp.data); in delcom_enable_led()
306 return hidled_send(led->rgb->ldev, dp.data); in delcom_set_pwm()
326 static int delcom_init(struct hidled_device *ldev) in delcom_init() argument
331 ret = hidled_recv(ldev, dp.data); in delcom_init()
351 return hidled_send(led->rgb->ldev, buf); in luxafor_write()
413 const struct hidled_config *config = rgb->ldev->config; in hidled_init_led()
427 return devm_led_classdev_register(&rgb->ldev->hdev->dev, &led->cdev); in hidled_init_led()
450 struct hidled_device *ldev; in hidled_probe() local
454 ldev = devm_kzalloc(&hdev->dev, sizeof(*ldev), GFP_KERNEL); in hidled_probe()
455 if (!ldev) in hidled_probe()
458 ldev->buf = devm_kmalloc(&hdev->dev, MAX_REPORT_SIZE, GFP_KERNEL); in hidled_probe()
459 if (!ldev->buf) in hidled_probe()
466 ldev->hdev = hdev; in hidled_probe()
467 mutex_init(&ldev->lock); in hidled_probe()
469 for (i = 0; !ldev->config && i < ARRAY_SIZE(hidled_configs); i++) in hidled_probe()
471 ldev->config = &hidled_configs[i]; in hidled_probe()
473 if (!ldev->config) in hidled_probe()
476 if (ldev->config->init) { in hidled_probe()
477 ret = ldev->config->init(ldev); in hidled_probe()
482 ldev->rgb = devm_kcalloc(&hdev->dev, ldev->config->num_leds, in hidled_probe()
484 if (!ldev->rgb) in hidled_probe()
493 for (i = 0; i < ldev->config->num_leds; i++) { in hidled_probe()
494 ldev->rgb[i].ldev = ldev; in hidled_probe()
495 ldev->rgb[i].num = i; in hidled_probe()
496 ret = hidled_init_rgb(&ldev->rgb[i], minor); in hidled_probe()
503 hid_info(hdev, "%s initialized\n", ldev->config->name); in hidled_probe()