Lines Matching +full:no +full:- +full:poll +full:- +full:on +full:- +full:init
1 // SPDX-License-Identifier: GPL-2.0
13 * /dev/vcsuN: similar to /dev/vcsaN but using 4-byte unicode values
14 * instead of 1-byte screen glyph values.
22 * aeb@cwi.nl - efter Friedas begravelse - 950211
24 * machek@k332.feld.cvut.cz - modified not to send characters to wrong console
25 * - fixed some fatal off-by-one bugs (0-- no longer == -1 -> looping and looping and looping...)
26 * - making it shorter - scr_readw are macros which expand in PRETTY long code
36 #include <linux/init.h>
44 #include <linux/poll.h>
64 * This relies on MAX_NR_CONSOLES being <= 63, meaning 63 actual consoles
88 struct vc_data *vc = param->vc; in vcs_notifier()
89 struct vcs_poll_data *poll = in vcs_notifier() local
91 int currcons = poll->cons_num; in vcs_notifier()
108 currcons--; in vcs_notifier()
109 if (currcons != vc->vc_num) in vcs_notifier()
112 poll->event = code; in vcs_notifier()
113 wake_up_interruptible(&poll->waitq); in vcs_notifier()
114 kill_fasync(&poll->fasync, SIGIO, fa_band); in vcs_notifier()
119 vcs_poll_data_free(struct vcs_poll_data *poll) in vcs_poll_data_free() argument
121 unregister_vt_notifier(&poll->notifier); in vcs_poll_data_free()
122 kfree(poll); in vcs_poll_data_free()
128 struct vcs_poll_data *poll = file->private_data, *kill = NULL; in vcs_poll_data_get() local
130 if (poll) in vcs_poll_data_get()
131 return poll; in vcs_poll_data_get()
133 poll = kzalloc(sizeof(*poll), GFP_KERNEL); in vcs_poll_data_get()
134 if (!poll) in vcs_poll_data_get()
136 poll->cons_num = console(file_inode(file)); in vcs_poll_data_get()
137 init_waitqueue_head(&poll->waitq); in vcs_poll_data_get()
138 poll->notifier.notifier_call = vcs_notifier; in vcs_poll_data_get()
143 * support POLLPRI on /dev/vcs* devices i.e. using poll() with in vcs_poll_data_get()
146 poll->event = VT_UPDATE; in vcs_poll_data_get()
148 if (register_vt_notifier(&poll->notifier) != 0) { in vcs_poll_data_get()
149 kfree(poll); in vcs_poll_data_get()
154 * This code may be called either through ->poll() or ->fasync(). in vcs_poll_data_get()
161 spin_lock(&file->f_lock); in vcs_poll_data_get()
162 if (!file->private_data) { in vcs_poll_data_get()
163 file->private_data = poll; in vcs_poll_data_get()
166 kill = poll; in vcs_poll_data_get()
167 poll = file->private_data; in vcs_poll_data_get()
169 spin_unlock(&file->f_lock); in vcs_poll_data_get()
173 return poll; in vcs_poll_data_get()
177 * vcs_vc - return VC for @inode
194 currcons--; in vcs_vc()
202 * vcs_size - return size for a VC in @vc
215 size = vc->vc_rows * vc->vc_cols; in vcs_size()
219 return -EOPNOTSUPP; in vcs_size()
238 return -ENXIO; in vcs_lseek()
251 unsigned int nr, row, col, maxcol = vc->vc_cols; in vcs_read_buf_uni()
261 nr = maxcol - col; in vcs_read_buf_uni()
267 count -= nr * 4; in vcs_read_buf_uni()
280 unsigned int col, maxcol = vc->vc_cols; in vcs_read_buf_noattr()
284 pos += maxcol - col; in vcs_read_buf_noattr()
286 while (count-- > 0) { in vcs_read_buf_noattr()
301 unsigned int col, maxcol = vc->vc_cols; in vcs_read_buf()
306 con_buf[0] = min(vc->vc_rows, 0xFFu); in vcs_read_buf()
307 con_buf[1] = min(vc->vc_cols, 0xFFu); in vcs_read_buf()
314 filled = count - pos; in vcs_read_buf()
317 /* Advance state pointers and move on. */ in vcs_read_buf()
318 count -= min(HEADER_SIZE, count); in vcs_read_buf()
325 * region sizes up/down depending on free space in buffer. in vcs_read_buf()
331 filled--; in vcs_read_buf()
337 pos -= HEADER_SIZE; in vcs_read_buf()
342 pos += maxcol - col; in vcs_read_buf()
353 count--; in vcs_read_buf()
369 struct vcs_poll_data *poll; in vcs_read() local
378 return -ENOMEM; in vcs_read()
390 ret = -EINVAL; in vcs_read()
393 /* we enforce 32-bit alignment for pos and count in unicode mode */ in vcs_read()
397 poll = file->private_data; in vcs_read()
398 if (count && poll) in vcs_read()
399 poll->event = 0; in vcs_read()
408 ret = -ENXIO; in vcs_read()
423 if (count > size - pos) in vcs_read()
424 count = size - pos; in vcs_read()
460 read += this_round - ret; in vcs_read()
461 ret = -EFAULT; in vcs_read()
467 count -= this_round; in vcs_read()
482 unsigned int col, maxcol = vc->vc_cols; in vcs_write_buf_noattr()
486 pos += maxcol - col; in vcs_write_buf_noattr()
491 count--; in vcs_write_buf_noattr()
522 unsigned int col, maxcol = vc->vc_cols; in vcs_write_buf()
531 count--; in vcs_write_buf()
541 pos -= HEADER_SIZE; in vcs_write_buf()
546 /* odd pos -- the first single character */ in vcs_write_buf()
548 count--; in vcs_write_buf()
561 pos += maxcol - col; in vcs_write_buf()
563 /* even pos -- handle attr+character pairs */ in vcs_write_buf()
570 count -= 2; in vcs_write_buf()
581 /* odd pos -- the remaining character */ in vcs_write_buf()
603 return -EOPNOTSUPP; in vcs_write()
607 return -ENOMEM; in vcs_write()
617 ret = -ENXIO; in vcs_write()
627 ret = -EINVAL; in vcs_write()
630 if (count > size - pos) in vcs_write()
631 count = size - pos; in vcs_write()
647 this_round -= ret; in vcs_write()
649 /* Abort loop if no data were copied. Otherwise in vcs_write()
650 * fail with -EFAULT. in vcs_write()
654 ret = -EFAULT; in vcs_write()
661 * Return data written up to now on failure. in vcs_write()
667 ret = -ENXIO; in vcs_write()
679 if (this_round > size - pos) in vcs_write()
680 this_round = size - pos; in vcs_write()
693 count -= this_round; in vcs_write()
698 update_region(vc, (unsigned long)(org0), org - org0); in vcs_write()
714 struct vcs_poll_data *poll = vcs_poll_data_get(file); in vcs_poll() local
717 if (poll) { in vcs_poll()
718 poll_wait(file, &poll->waitq, wait); in vcs_poll()
719 switch (poll->event) { in vcs_poll()
735 vcs_fasync(int fd, struct file *file, int on) in vcs_fasync() argument
737 struct vcs_poll_data *poll = file->private_data; in vcs_fasync() local
739 if (!poll) { in vcs_fasync()
741 if (!on) in vcs_fasync()
743 poll = vcs_poll_data_get(file); in vcs_fasync()
744 if (!poll) in vcs_fasync()
745 return -ENOMEM; in vcs_fasync()
748 return fasync_helper(fd, file, on, &poll->fasync); in vcs_fasync()
761 return -EOPNOTSUPP; in vcs_open()
764 if(currcons && !vc_cons_allocated(currcons-1)) in vcs_open()
765 ret = -ENXIO; in vcs_open()
772 struct vcs_poll_data *poll = file->private_data; in vcs_release() local
774 if (poll) in vcs_release()
775 vcs_poll_data_free(poll); in vcs_release()
783 .poll = vcs_poll,