Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/char/vc_screen.c |
| 3 | * |
| 4 | * Provide access to virtual console memory. |
| 5 | * /dev/vcs0: the screen as it is being viewed right now (possibly scrolled) |
| 6 | * /dev/vcsN: the screen of /dev/ttyN (1 <= N <= 63) |
| 7 | * [minor: N] |
| 8 | * |
| 9 | * /dev/vcsaN: idem, but including attributes, and prefixed with |
| 10 | * the 4 bytes lines,columns,x,y (as screendump used to give). |
| 11 | * Attribute/character pair is in native endianity. |
| 12 | * [minor: N+128] |
| 13 | * |
| 14 | * This replaces screendump and part of selection, so that the system |
| 15 | * administrator can control access using file system permissions. |
| 16 | * |
| 17 | * aeb@cwi.nl - efter Friedas begravelse - 950211 |
| 18 | * |
| 19 | * machek@k332.feld.cvut.cz - modified not to send characters to wrong console |
| 20 | * - fixed some fatal off-by-one bugs (0-- no longer == -1 -> looping and looping and looping...) |
| 21 | * - making it shorter - scr_readw are macros which expand in PRETTY long code |
| 22 | */ |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/major.h> |
| 26 | #include <linux/errno.h> |
| 27 | #include <linux/tty.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/interrupt.h> |
| 29 | #include <linux/mm.h> |
| 30 | #include <linux/init.h> |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 31 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/vt_kern.h> |
| 33 | #include <linux/selection.h> |
| 34 | #include <linux/kbd_kern.h> |
| 35 | #include <linux/console.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/device.h> |
Jonathan Corbet | f97259e | 2008-05-16 13:47:50 -0600 | [diff] [blame] | 37 | #include <linux/smp_lock.h> |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <asm/uaccess.h> |
| 40 | #include <asm/byteorder.h> |
| 41 | #include <asm/unaligned.h> |
| 42 | |
| 43 | #undef attr |
| 44 | #undef org |
| 45 | #undef addr |
| 46 | #define HEADER_SIZE 4 |
| 47 | |
| 48 | static int |
| 49 | vcs_size(struct inode *inode) |
| 50 | { |
| 51 | int size; |
| 52 | int minor = iminor(inode); |
| 53 | int currcons = minor & 127; |
| 54 | struct vc_data *vc; |
| 55 | |
| 56 | if (currcons == 0) |
| 57 | currcons = fg_console; |
| 58 | else |
| 59 | currcons--; |
| 60 | if (!vc_cons_allocated(currcons)) |
| 61 | return -ENXIO; |
| 62 | vc = vc_cons[currcons].d; |
| 63 | |
| 64 | size = vc->vc_rows * vc->vc_cols; |
| 65 | |
| 66 | if (minor & 128) |
| 67 | size = 2*size + HEADER_SIZE; |
| 68 | return size; |
| 69 | } |
| 70 | |
| 71 | static loff_t vcs_lseek(struct file *file, loff_t offset, int orig) |
| 72 | { |
| 73 | int size; |
| 74 | |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 75 | mutex_lock(&con_buf_mtx); |
Josef Sipek | a7113a9 | 2006-12-08 02:36:55 -0800 | [diff] [blame] | 76 | size = vcs_size(file->f_path.dentry->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | switch (orig) { |
| 78 | default: |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 79 | mutex_unlock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | return -EINVAL; |
| 81 | case 2: |
| 82 | offset += size; |
| 83 | break; |
| 84 | case 1: |
| 85 | offset += file->f_pos; |
| 86 | case 0: |
| 87 | break; |
| 88 | } |
| 89 | if (offset < 0 || offset > size) { |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 90 | mutex_unlock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | return -EINVAL; |
| 92 | } |
| 93 | file->f_pos = offset; |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 94 | mutex_unlock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | return file->f_pos; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | static ssize_t |
| 100 | vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) |
| 101 | { |
Josef Sipek | a7113a9 | 2006-12-08 02:36:55 -0800 | [diff] [blame] | 102 | struct inode *inode = file->f_path.dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | unsigned int currcons = iminor(inode); |
| 104 | struct vc_data *vc; |
| 105 | long pos; |
| 106 | long viewed, attr, read; |
| 107 | int col, maxcol; |
| 108 | unsigned short *org = NULL; |
| 109 | ssize_t ret; |
| 110 | |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 111 | mutex_lock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | pos = *ppos; |
| 114 | |
| 115 | /* Select the proper current console and verify |
| 116 | * sanity of the situation under the console lock. |
| 117 | */ |
| 118 | acquire_console_sem(); |
| 119 | |
| 120 | attr = (currcons & 128); |
| 121 | currcons = (currcons & 127); |
| 122 | if (currcons == 0) { |
| 123 | currcons = fg_console; |
| 124 | viewed = 1; |
| 125 | } else { |
| 126 | currcons--; |
| 127 | viewed = 0; |
| 128 | } |
| 129 | ret = -ENXIO; |
| 130 | if (!vc_cons_allocated(currcons)) |
| 131 | goto unlock_out; |
| 132 | vc = vc_cons[currcons].d; |
| 133 | |
| 134 | ret = -EINVAL; |
| 135 | if (pos < 0) |
| 136 | goto unlock_out; |
| 137 | read = 0; |
| 138 | ret = 0; |
| 139 | while (count) { |
| 140 | char *con_buf0, *con_buf_start; |
| 141 | long this_round, size; |
| 142 | ssize_t orig_count; |
| 143 | long p = pos; |
| 144 | |
| 145 | /* Check whether we are above size each round, |
| 146 | * as copy_to_user at the end of this loop |
| 147 | * could sleep. |
| 148 | */ |
| 149 | size = vcs_size(inode); |
| 150 | if (pos >= size) |
| 151 | break; |
| 152 | if (count > size - pos) |
| 153 | count = size - pos; |
| 154 | |
| 155 | this_round = count; |
| 156 | if (this_round > CON_BUF_SIZE) |
| 157 | this_round = CON_BUF_SIZE; |
| 158 | |
| 159 | /* Perform the whole read into the local con_buf. |
| 160 | * Then we can drop the console spinlock and safely |
| 161 | * attempt to move it to userspace. |
| 162 | */ |
| 163 | |
| 164 | con_buf_start = con_buf0 = con_buf; |
| 165 | orig_count = this_round; |
| 166 | maxcol = vc->vc_cols; |
| 167 | if (!attr) { |
| 168 | org = screen_pos(vc, p, viewed); |
| 169 | col = p % maxcol; |
| 170 | p += maxcol - col; |
| 171 | while (this_round-- > 0) { |
| 172 | *con_buf0++ = (vcs_scr_readw(vc, org++) & 0xff); |
| 173 | if (++col == maxcol) { |
| 174 | org = screen_pos(vc, p, viewed); |
| 175 | col = 0; |
| 176 | p += maxcol; |
| 177 | } |
| 178 | } |
| 179 | } else { |
| 180 | if (p < HEADER_SIZE) { |
| 181 | size_t tmp_count; |
| 182 | |
| 183 | con_buf0[0] = (char)vc->vc_rows; |
| 184 | con_buf0[1] = (char)vc->vc_cols; |
| 185 | getconsxy(vc, con_buf0 + 2); |
| 186 | |
| 187 | con_buf_start += p; |
| 188 | this_round += p; |
| 189 | if (this_round > CON_BUF_SIZE) { |
| 190 | this_round = CON_BUF_SIZE; |
| 191 | orig_count = this_round - p; |
| 192 | } |
| 193 | |
| 194 | tmp_count = HEADER_SIZE; |
| 195 | if (tmp_count > this_round) |
| 196 | tmp_count = this_round; |
| 197 | |
| 198 | /* Advance state pointers and move on. */ |
| 199 | this_round -= tmp_count; |
| 200 | p = HEADER_SIZE; |
| 201 | con_buf0 = con_buf + HEADER_SIZE; |
| 202 | /* If this_round >= 0, then p is even... */ |
| 203 | } else if (p & 1) { |
| 204 | /* Skip first byte for output if start address is odd |
| 205 | * Update region sizes up/down depending on free |
| 206 | * space in buffer. |
| 207 | */ |
| 208 | con_buf_start++; |
| 209 | if (this_round < CON_BUF_SIZE) |
| 210 | this_round++; |
| 211 | else |
| 212 | orig_count--; |
| 213 | } |
| 214 | if (this_round > 0) { |
| 215 | unsigned short *tmp_buf = (unsigned short *)con_buf0; |
| 216 | |
| 217 | p -= HEADER_SIZE; |
| 218 | p /= 2; |
| 219 | col = p % maxcol; |
| 220 | |
| 221 | org = screen_pos(vc, p, viewed); |
| 222 | p += maxcol - col; |
| 223 | |
| 224 | /* Buffer has even length, so we can always copy |
| 225 | * character + attribute. We do not copy last byte |
| 226 | * to userspace if this_round is odd. |
| 227 | */ |
| 228 | this_round = (this_round + 1) >> 1; |
| 229 | |
| 230 | while (this_round) { |
| 231 | *tmp_buf++ = vcs_scr_readw(vc, org++); |
| 232 | this_round --; |
| 233 | if (++col == maxcol) { |
| 234 | org = screen_pos(vc, p, viewed); |
| 235 | col = 0; |
| 236 | p += maxcol; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /* Finally, release the console semaphore while we push |
| 243 | * all the data to userspace from our temporary buffer. |
| 244 | * |
| 245 | * AKPM: Even though it's a semaphore, we should drop it because |
| 246 | * the pagefault handling code may want to call printk(). |
| 247 | */ |
| 248 | |
| 249 | release_console_sem(); |
| 250 | ret = copy_to_user(buf, con_buf_start, orig_count); |
| 251 | acquire_console_sem(); |
| 252 | |
| 253 | if (ret) { |
| 254 | read += (orig_count - ret); |
| 255 | ret = -EFAULT; |
| 256 | break; |
| 257 | } |
| 258 | buf += orig_count; |
| 259 | pos += orig_count; |
| 260 | read += orig_count; |
| 261 | count -= orig_count; |
| 262 | } |
| 263 | *ppos += read; |
| 264 | if (read) |
| 265 | ret = read; |
| 266 | unlock_out: |
| 267 | release_console_sem(); |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 268 | mutex_unlock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | return ret; |
| 270 | } |
| 271 | |
| 272 | static ssize_t |
| 273 | vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
| 274 | { |
Josef Sipek | a7113a9 | 2006-12-08 02:36:55 -0800 | [diff] [blame] | 275 | struct inode *inode = file->f_path.dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | unsigned int currcons = iminor(inode); |
| 277 | struct vc_data *vc; |
| 278 | long pos; |
| 279 | long viewed, attr, size, written; |
| 280 | char *con_buf0; |
| 281 | int col, maxcol; |
| 282 | u16 *org0 = NULL, *org = NULL; |
| 283 | size_t ret; |
| 284 | |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 285 | mutex_lock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
| 287 | pos = *ppos; |
| 288 | |
| 289 | /* Select the proper current console and verify |
| 290 | * sanity of the situation under the console lock. |
| 291 | */ |
| 292 | acquire_console_sem(); |
| 293 | |
| 294 | attr = (currcons & 128); |
| 295 | currcons = (currcons & 127); |
| 296 | |
| 297 | if (currcons == 0) { |
| 298 | currcons = fg_console; |
| 299 | viewed = 1; |
| 300 | } else { |
| 301 | currcons--; |
| 302 | viewed = 0; |
| 303 | } |
| 304 | ret = -ENXIO; |
| 305 | if (!vc_cons_allocated(currcons)) |
| 306 | goto unlock_out; |
| 307 | vc = vc_cons[currcons].d; |
| 308 | |
| 309 | size = vcs_size(inode); |
| 310 | ret = -EINVAL; |
| 311 | if (pos < 0 || pos > size) |
| 312 | goto unlock_out; |
| 313 | if (count > size - pos) |
| 314 | count = size - pos; |
| 315 | written = 0; |
| 316 | while (count) { |
| 317 | long this_round = count; |
| 318 | size_t orig_count; |
| 319 | long p; |
| 320 | |
| 321 | if (this_round > CON_BUF_SIZE) |
| 322 | this_round = CON_BUF_SIZE; |
| 323 | |
| 324 | /* Temporarily drop the console lock so that we can read |
| 325 | * in the write data from userspace safely. |
| 326 | */ |
| 327 | release_console_sem(); |
| 328 | ret = copy_from_user(con_buf, buf, this_round); |
| 329 | acquire_console_sem(); |
| 330 | |
| 331 | if (ret) { |
| 332 | this_round -= ret; |
| 333 | if (!this_round) { |
| 334 | /* Abort loop if no data were copied. Otherwise |
| 335 | * fail with -EFAULT. |
| 336 | */ |
| 337 | if (written) |
| 338 | break; |
| 339 | ret = -EFAULT; |
| 340 | goto unlock_out; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | /* The vcs_size might have changed while we slept to grab |
| 345 | * the user buffer, so recheck. |
| 346 | * Return data written up to now on failure. |
| 347 | */ |
| 348 | size = vcs_size(inode); |
| 349 | if (pos >= size) |
| 350 | break; |
| 351 | if (this_round > size - pos) |
| 352 | this_round = size - pos; |
| 353 | |
| 354 | /* OK, now actually push the write to the console |
| 355 | * under the lock using the local kernel buffer. |
| 356 | */ |
| 357 | |
| 358 | con_buf0 = con_buf; |
| 359 | orig_count = this_round; |
| 360 | maxcol = vc->vc_cols; |
| 361 | p = pos; |
| 362 | if (!attr) { |
| 363 | org0 = org = screen_pos(vc, p, viewed); |
| 364 | col = p % maxcol; |
| 365 | p += maxcol - col; |
| 366 | |
| 367 | while (this_round > 0) { |
| 368 | unsigned char c = *con_buf0++; |
| 369 | |
| 370 | this_round--; |
| 371 | vcs_scr_writew(vc, |
| 372 | (vcs_scr_readw(vc, org) & 0xff00) | c, org); |
| 373 | org++; |
| 374 | if (++col == maxcol) { |
| 375 | org = screen_pos(vc, p, viewed); |
| 376 | col = 0; |
| 377 | p += maxcol; |
| 378 | } |
| 379 | } |
| 380 | } else { |
| 381 | if (p < HEADER_SIZE) { |
| 382 | char header[HEADER_SIZE]; |
| 383 | |
| 384 | getconsxy(vc, header + 2); |
| 385 | while (p < HEADER_SIZE && this_round > 0) { |
| 386 | this_round--; |
| 387 | header[p++] = *con_buf0++; |
| 388 | } |
| 389 | if (!viewed) |
| 390 | putconsxy(vc, header + 2); |
| 391 | } |
| 392 | p -= HEADER_SIZE; |
| 393 | col = (p/2) % maxcol; |
| 394 | if (this_round > 0) { |
| 395 | org0 = org = screen_pos(vc, p/2, viewed); |
| 396 | if ((p & 1) && this_round > 0) { |
| 397 | char c; |
| 398 | |
| 399 | this_round--; |
| 400 | c = *con_buf0++; |
| 401 | #ifdef __BIG_ENDIAN |
| 402 | vcs_scr_writew(vc, c | |
| 403 | (vcs_scr_readw(vc, org) & 0xff00), org); |
| 404 | #else |
| 405 | vcs_scr_writew(vc, (c << 8) | |
| 406 | (vcs_scr_readw(vc, org) & 0xff), org); |
| 407 | #endif |
| 408 | org++; |
| 409 | p++; |
| 410 | if (++col == maxcol) { |
| 411 | org = screen_pos(vc, p/2, viewed); |
| 412 | col = 0; |
| 413 | } |
| 414 | } |
| 415 | p /= 2; |
| 416 | p += maxcol - col; |
| 417 | } |
| 418 | while (this_round > 1) { |
| 419 | unsigned short w; |
| 420 | |
Dave Jones | ee02594 | 2005-12-28 20:01:04 -0500 | [diff] [blame] | 421 | w = get_unaligned(((unsigned short *)con_buf0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | vcs_scr_writew(vc, w, org++); |
| 423 | con_buf0 += 2; |
| 424 | this_round -= 2; |
| 425 | if (++col == maxcol) { |
| 426 | org = screen_pos(vc, p, viewed); |
| 427 | col = 0; |
| 428 | p += maxcol; |
| 429 | } |
| 430 | } |
| 431 | if (this_round > 0) { |
| 432 | unsigned char c; |
| 433 | |
| 434 | c = *con_buf0++; |
| 435 | #ifdef __BIG_ENDIAN |
| 436 | vcs_scr_writew(vc, (vcs_scr_readw(vc, org) & 0xff) | (c << 8), org); |
| 437 | #else |
| 438 | vcs_scr_writew(vc, (vcs_scr_readw(vc, org) & 0xff00) | c, org); |
| 439 | #endif |
| 440 | } |
| 441 | } |
| 442 | count -= orig_count; |
| 443 | written += orig_count; |
| 444 | buf += orig_count; |
| 445 | pos += orig_count; |
| 446 | if (org0) |
| 447 | update_region(vc, (unsigned long)(org0), org - org0); |
| 448 | } |
| 449 | *ppos += written; |
| 450 | ret = written; |
| 451 | |
| 452 | unlock_out: |
| 453 | release_console_sem(); |
| 454 | |
Matthias Kaehlcke | c831c33 | 2007-05-08 00:39:49 -0700 | [diff] [blame] | 455 | mutex_unlock(&con_buf_mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
| 457 | return ret; |
| 458 | } |
| 459 | |
| 460 | static int |
| 461 | vcs_open(struct inode *inode, struct file *filp) |
| 462 | { |
| 463 | unsigned int currcons = iminor(inode) & 127; |
Jonathan Corbet | f97259e | 2008-05-16 13:47:50 -0600 | [diff] [blame] | 464 | int ret = 0; |
| 465 | |
Arnd Bergmann | ec79d60 | 2010-06-01 22:53:01 +0200 | [diff] [blame] | 466 | tty_lock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | if(currcons && !vc_cons_allocated(currcons-1)) |
Jonathan Corbet | f97259e | 2008-05-16 13:47:50 -0600 | [diff] [blame] | 468 | ret = -ENXIO; |
Arnd Bergmann | ec79d60 | 2010-06-01 22:53:01 +0200 | [diff] [blame] | 469 | tty_unlock(); |
Jonathan Corbet | f97259e | 2008-05-16 13:47:50 -0600 | [diff] [blame] | 470 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | } |
| 472 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 473 | static const struct file_operations vcs_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | .llseek = vcs_lseek, |
| 475 | .read = vcs_read, |
| 476 | .write = vcs_write, |
| 477 | .open = vcs_open, |
| 478 | }; |
| 479 | |
gregkh@suse.de | ca8eca6 | 2005-03-23 09:53:09 -0800 | [diff] [blame] | 480 | static struct class *vc_class; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
Kay Sievers | 4995f8e | 2009-03-09 14:18:52 +0100 | [diff] [blame] | 482 | void vcs_make_sysfs(int index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | { |
Kay Sievers | 4995f8e | 2009-03-09 14:18:52 +0100 | [diff] [blame] | 484 | device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, |
| 485 | "vcs%u", index + 1); |
| 486 | device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, |
| 487 | "vcsa%u", index + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | } |
Alan Cox | d09d7dd | 2006-09-29 01:59:47 -0700 | [diff] [blame] | 489 | |
Kay Sievers | 4995f8e | 2009-03-09 14:18:52 +0100 | [diff] [blame] | 490 | void vcs_remove_sysfs(int index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | { |
Kay Sievers | 4995f8e | 2009-03-09 14:18:52 +0100 | [diff] [blame] | 492 | device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 1)); |
| 493 | device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 129)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | int __init vcs_init(void) |
| 497 | { |
Kay Sievers | c46a7ae | 2009-07-20 16:04:55 +0100 | [diff] [blame] | 498 | unsigned int i; |
| 499 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) |
| 501 | panic("unable to get major %d for vcs device", VCS_MAJOR); |
gregkh@suse.de | ca8eca6 | 2005-03-23 09:53:09 -0800 | [diff] [blame] | 502 | vc_class = class_create(THIS_MODULE, "vc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | |
Greg Kroah-Hartman | 03457cd | 2008-07-21 20:03:34 -0700 | [diff] [blame] | 504 | device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); |
| 505 | device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); |
Kay Sievers | c46a7ae | 2009-07-20 16:04:55 +0100 | [diff] [blame] | 506 | for (i = 0; i < MIN_NR_CONSOLES; i++) |
| 507 | vcs_make_sysfs(i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | return 0; |
| 509 | } |