Lines Matching refs:udev
42 struct uleds_device *udev = container_of(led_cdev, struct uleds_device, in uleds_brightness_set() local
45 if (udev->brightness != brightness) { in uleds_brightness_set()
46 udev->brightness = brightness; in uleds_brightness_set()
47 udev->new_data = true; in uleds_brightness_set()
48 wake_up_interruptible(&udev->waitq); in uleds_brightness_set()
54 struct uleds_device *udev; in uleds_open() local
56 udev = kzalloc(sizeof(*udev), GFP_KERNEL); in uleds_open()
57 if (!udev) in uleds_open()
60 udev->led_cdev.name = udev->user_dev.name; in uleds_open()
61 udev->led_cdev.brightness_set = uleds_brightness_set; in uleds_open()
63 mutex_init(&udev->mutex); in uleds_open()
64 init_waitqueue_head(&udev->waitq); in uleds_open()
65 udev->state = ULEDS_STATE_UNKNOWN; in uleds_open()
67 file->private_data = udev; in uleds_open()
76 struct uleds_device *udev = file->private_data; in uleds_write() local
83 ret = mutex_lock_interruptible(&udev->mutex); in uleds_write()
87 if (udev->state == ULEDS_STATE_REGISTERED) { in uleds_write()
97 if (copy_from_user(&udev->user_dev, buffer, in uleds_write()
103 name = udev->user_dev.name; in uleds_write()
110 if (udev->user_dev.max_brightness <= 0) { in uleds_write()
114 udev->led_cdev.max_brightness = udev->user_dev.max_brightness; in uleds_write()
117 &udev->led_cdev); in uleds_write()
121 udev->new_data = true; in uleds_write()
122 udev->state = ULEDS_STATE_REGISTERED; in uleds_write()
126 mutex_unlock(&udev->mutex); in uleds_write()
134 struct uleds_device *udev = file->private_data; in uleds_read() local
137 if (count < sizeof(udev->brightness)) in uleds_read()
141 retval = mutex_lock_interruptible(&udev->mutex); in uleds_read()
145 if (udev->state != ULEDS_STATE_REGISTERED) { in uleds_read()
147 } else if (!udev->new_data && (file->f_flags & O_NONBLOCK)) { in uleds_read()
149 } else if (udev->new_data) { in uleds_read()
150 retval = copy_to_user(buffer, &udev->brightness, in uleds_read()
151 sizeof(udev->brightness)); in uleds_read()
152 udev->new_data = false; in uleds_read()
153 retval = sizeof(udev->brightness); in uleds_read()
156 mutex_unlock(&udev->mutex); in uleds_read()
162 retval = wait_event_interruptible(udev->waitq, in uleds_read()
163 udev->new_data || in uleds_read()
164 udev->state != ULEDS_STATE_REGISTERED); in uleds_read()
172 struct uleds_device *udev = file->private_data; in uleds_poll() local
174 poll_wait(file, &udev->waitq, wait); in uleds_poll()
176 if (udev->new_data) in uleds_poll()
184 struct uleds_device *udev = file->private_data; in uleds_release() local
186 if (udev->state == ULEDS_STATE_REGISTERED) { in uleds_release()
187 udev->state = ULEDS_STATE_UNKNOWN; in uleds_release()
189 &udev->led_cdev); in uleds_release()
191 kfree(udev); in uleds_release()