Lines Matching +full:led +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2010-2012 by Bruno Prémont <bonbons@linux-vserver.org> *
11 #include <linux/hid-debug.h>
13 #include "hid-ids.h"
29 #include "hid-picolcd.h"
37 if (!data->led[0]) in picolcd_leds_set()
39 report = picolcd_out_report(REPORT_LED_STATE, data->hdev); in picolcd_leds_set()
40 if (!report || report->maxfield != 1 || report->field[0]->report_count != 1) in picolcd_leds_set()
43 spin_lock_irqsave(&data->lock, flags); in picolcd_leds_set()
44 hid_set_field(report->field[0], 0, data->led_state); in picolcd_leds_set()
45 if (!(data->status & PICOLCD_FAILED)) in picolcd_leds_set()
46 hid_hw_request(data->hdev, report, HID_REQ_SET_REPORT); in picolcd_leds_set()
47 spin_unlock_irqrestore(&data->lock, flags); in picolcd_leds_set()
58 dev = led_cdev->dev->parent; in picolcd_led_set_brightness()
64 if (led_cdev != data->led[i]) in picolcd_led_set_brightness()
66 state = (data->led_state >> i) & 1; in picolcd_led_set_brightness()
68 data->led_state &= ~(1 << i); in picolcd_led_set_brightness()
71 data->led_state |= 1 << i; in picolcd_led_set_brightness()
85 dev = led_cdev->dev->parent; in picolcd_led_get_brightness()
89 if (led_cdev == data->led[i]) { in picolcd_led_get_brightness()
90 value = (data->led_state >> i) & 1; in picolcd_led_get_brightness()
98 struct device *dev = &data->hdev->dev; in picolcd_init_leds()
99 struct led_classdev *led; in picolcd_init_leds() local
105 return -ENODEV; in picolcd_init_leds()
106 if (report->maxfield != 1 || report->field[0]->report_count != 1 || in picolcd_init_leds()
107 report->field[0]->report_size != 8) { in picolcd_init_leds()
109 return -EINVAL; in picolcd_init_leds()
113 led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL); in picolcd_init_leds()
114 if (!led) { in picolcd_init_leds()
115 dev_err(dev, "can't allocate memory for LED %d\n", i); in picolcd_init_leds()
116 ret = -ENOMEM; in picolcd_init_leds()
119 name = (void *)(&led[1]); in picolcd_init_leds()
121 led->name = name; in picolcd_init_leds()
122 led->brightness = 0; in picolcd_init_leds()
123 led->max_brightness = 1; in picolcd_init_leds()
124 led->brightness_get = picolcd_led_get_brightness; in picolcd_init_leds()
125 led->brightness_set = picolcd_led_set_brightness; in picolcd_init_leds()
127 data->led[i] = led; in picolcd_init_leds()
128 ret = led_classdev_register(dev, data->led[i]); in picolcd_init_leds()
130 data->led[i] = NULL; in picolcd_init_leds()
131 kfree(led); in picolcd_init_leds()
132 dev_err(dev, "can't register LED %d\n", i); in picolcd_init_leds()
139 if (data->led[i]) { in picolcd_init_leds()
140 led = data->led[i]; in picolcd_init_leds()
141 data->led[i] = NULL; in picolcd_init_leds()
142 led_classdev_unregister(led); in picolcd_init_leds()
143 kfree(led); in picolcd_init_leds()
150 struct led_classdev *led; in picolcd_exit_leds() local
154 led = data->led[i]; in picolcd_exit_leds()
155 data->led[i] = NULL; in picolcd_exit_leds()
156 if (!led) in picolcd_exit_leds()
158 led_classdev_unregister(led); in picolcd_exit_leds()
159 kfree(led); in picolcd_exit_leds()