hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl
[linux/fpc-iii.git] / drivers / char / mem.c
blobd1f4675809f8b110c829a445d528c8d134e2ca8e
1 /*
2 * linux/drivers/char/mem.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * Added devfs support.
7 * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu>
8 * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com>
9 */
11 #include <linux/mm.h>
12 #include <linux/miscdevice.h>
13 #include <linux/slab.h>
14 #include <linux/vmalloc.h>
15 #include <linux/mman.h>
16 #include <linux/random.h>
17 #include <linux/init.h>
18 #include <linux/raw.h>
19 #include <linux/tty.h>
20 #include <linux/capability.h>
21 #include <linux/ptrace.h>
22 #include <linux/device.h>
23 #include <linux/highmem.h>
24 #include <linux/backing-dev.h>
25 #include <linux/bootmem.h>
26 #include <linux/splice.h>
27 #include <linux/pfn.h>
28 #include <linux/export.h>
29 #include <linux/io.h>
30 #include <linux/aio.h>
32 #include <asm/uaccess.h>
34 #ifdef CONFIG_IA64
35 # include <linux/efi.h>
36 #endif
38 #define DEVPORT_MINOR 4
40 static inline unsigned long size_inside_page(unsigned long start,
41 unsigned long size)
43 unsigned long sz;
45 sz = PAGE_SIZE - (start & (PAGE_SIZE - 1));
47 return min(sz, size);
50 #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
51 static inline int valid_phys_addr_range(phys_addr_t addr, size_t count)
53 return addr + count <= __pa(high_memory);
56 static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
58 return 1;
60 #endif
62 #ifdef CONFIG_STRICT_DEVMEM
63 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
65 u64 from = ((u64)pfn) << PAGE_SHIFT;
66 u64 to = from + size;
67 u64 cursor = from;
69 while (cursor < to) {
70 if (!devmem_is_allowed(pfn)) {
71 printk(KERN_INFO
72 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
73 current->comm, from, to);
74 return 0;
76 cursor += PAGE_SIZE;
77 pfn++;
79 return 1;
81 #else
82 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
84 return 1;
86 #endif
88 void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr)
93 * This funcion reads the *physical* memory. The f_pos points directly to the
94 * memory location.
96 static ssize_t read_mem(struct file *file, char __user *buf,
97 size_t count, loff_t *ppos)
99 phys_addr_t p = *ppos;
100 ssize_t read, sz;
101 char *ptr;
103 if (p != *ppos)
104 return 0;
106 if (!valid_phys_addr_range(p, count))
107 return -EFAULT;
108 read = 0;
109 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
110 /* we don't have page 0 mapped on sparc and m68k.. */
111 if (p < PAGE_SIZE) {
112 sz = size_inside_page(p, count);
113 if (sz > 0) {
114 if (clear_user(buf, sz))
115 return -EFAULT;
116 buf += sz;
117 p += sz;
118 count -= sz;
119 read += sz;
122 #endif
124 while (count > 0) {
125 unsigned long remaining;
127 sz = size_inside_page(p, count);
129 if (!range_is_allowed(p >> PAGE_SHIFT, count))
130 return -EPERM;
133 * On ia64 if a page has been mapped somewhere as uncached, then
134 * it must also be accessed uncached by the kernel or data
135 * corruption may occur.
137 ptr = xlate_dev_mem_ptr(p);
138 if (!ptr)
139 return -EFAULT;
141 remaining = copy_to_user(buf, ptr, sz);
142 unxlate_dev_mem_ptr(p, ptr);
143 if (remaining)
144 return -EFAULT;
146 buf += sz;
147 p += sz;
148 count -= sz;
149 read += sz;
152 *ppos += read;
153 return read;
156 static ssize_t write_mem(struct file *file, const char __user *buf,
157 size_t count, loff_t *ppos)
159 phys_addr_t p = *ppos;
160 ssize_t written, sz;
161 unsigned long copied;
162 void *ptr;
164 if (p != *ppos)
165 return -EFBIG;
167 if (!valid_phys_addr_range(p, count))
168 return -EFAULT;
170 written = 0;
172 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
173 /* we don't have page 0 mapped on sparc and m68k.. */
174 if (p < PAGE_SIZE) {
175 sz = size_inside_page(p, count);
176 /* Hmm. Do something? */
177 buf += sz;
178 p += sz;
179 count -= sz;
180 written += sz;
182 #endif
184 while (count > 0) {
185 sz = size_inside_page(p, count);
187 if (!range_is_allowed(p >> PAGE_SHIFT, sz))
188 return -EPERM;
191 * On ia64 if a page has been mapped somewhere as uncached, then
192 * it must also be accessed uncached by the kernel or data
193 * corruption may occur.
195 ptr = xlate_dev_mem_ptr(p);
196 if (!ptr) {
197 if (written)
198 break;
199 return -EFAULT;
202 copied = copy_from_user(ptr, buf, sz);
203 unxlate_dev_mem_ptr(p, ptr);
204 if (copied) {
205 written += sz - copied;
206 if (written)
207 break;
208 return -EFAULT;
211 buf += sz;
212 p += sz;
213 count -= sz;
214 written += sz;
217 *ppos += written;
218 return written;
221 int __weak phys_mem_access_prot_allowed(struct file *file,
222 unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
224 return 1;
227 #ifndef __HAVE_PHYS_MEM_ACCESS_PROT
230 * Architectures vary in how they handle caching for addresses
231 * outside of main memory.
234 #ifdef pgprot_noncached
235 static int uncached_access(struct file *file, phys_addr_t addr)
237 #if defined(CONFIG_IA64)
239 * On ia64, we ignore O_DSYNC because we cannot tolerate memory
240 * attribute aliases.
242 return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
243 #elif defined(CONFIG_MIPS)
245 extern int __uncached_access(struct file *file,
246 unsigned long addr);
248 return __uncached_access(file, addr);
250 #else
252 * Accessing memory above the top the kernel knows about or through a
253 * file pointer
254 * that was marked O_DSYNC will be done non-cached.
256 if (file->f_flags & O_DSYNC)
257 return 1;
258 return addr >= __pa(high_memory);
259 #endif
261 #endif
263 static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
264 unsigned long size, pgprot_t vma_prot)
266 #ifdef pgprot_noncached
267 phys_addr_t offset = pfn << PAGE_SHIFT;
269 if (uncached_access(file, offset))
270 return pgprot_noncached(vma_prot);
271 #endif
272 return vma_prot;
274 #endif
276 #ifndef CONFIG_MMU
277 static unsigned long get_unmapped_area_mem(struct file *file,
278 unsigned long addr,
279 unsigned long len,
280 unsigned long pgoff,
281 unsigned long flags)
283 if (!valid_mmap_phys_addr_range(pgoff, len))
284 return (unsigned long) -EINVAL;
285 return pgoff << PAGE_SHIFT;
288 /* can't do an in-place private mapping if there's no MMU */
289 static inline int private_mapping_ok(struct vm_area_struct *vma)
291 return vma->vm_flags & VM_MAYSHARE;
293 #else
294 #define get_unmapped_area_mem NULL
296 static inline int private_mapping_ok(struct vm_area_struct *vma)
298 return 1;
300 #endif
302 static const struct vm_operations_struct mmap_mem_ops = {
303 #ifdef CONFIG_HAVE_IOREMAP_PROT
304 .access = generic_access_phys
305 #endif
308 static int mmap_mem(struct file *file, struct vm_area_struct *vma)
310 size_t size = vma->vm_end - vma->vm_start;
312 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
313 return -EINVAL;
315 if (!private_mapping_ok(vma))
316 return -ENOSYS;
318 if (!range_is_allowed(vma->vm_pgoff, size))
319 return -EPERM;
321 if (!phys_mem_access_prot_allowed(file, vma->vm_pgoff, size,
322 &vma->vm_page_prot))
323 return -EINVAL;
325 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
326 size,
327 vma->vm_page_prot);
329 vma->vm_ops = &mmap_mem_ops;
331 /* Remap-pfn-range will mark the range VM_IO */
332 if (remap_pfn_range(vma,
333 vma->vm_start,
334 vma->vm_pgoff,
335 size,
336 vma->vm_page_prot)) {
337 return -EAGAIN;
339 return 0;
342 #ifdef CONFIG_DEVKMEM
343 static int mmap_kmem(struct file *file, struct vm_area_struct *vma)
345 unsigned long pfn;
347 /* Turn a kernel-virtual address into a physical page frame */
348 pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;
351 * RED-PEN: on some architectures there is more mapped memory than
352 * available in mem_map which pfn_valid checks for. Perhaps should add a
353 * new macro here.
355 * RED-PEN: vmalloc is not supported right now.
357 if (!pfn_valid(pfn))
358 return -EIO;
360 vma->vm_pgoff = pfn;
361 return mmap_mem(file, vma);
363 #endif
365 #ifdef CONFIG_DEVKMEM
367 * This function reads the *virtual* memory as seen by the kernel.
369 static ssize_t read_kmem(struct file *file, char __user *buf,
370 size_t count, loff_t *ppos)
372 unsigned long p = *ppos;
373 ssize_t low_count, read, sz;
374 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
375 int err = 0;
377 read = 0;
378 if (p < (unsigned long) high_memory) {
379 low_count = count;
380 if (count > (unsigned long)high_memory - p)
381 low_count = (unsigned long)high_memory - p;
383 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
384 /* we don't have page 0 mapped on sparc and m68k.. */
385 if (p < PAGE_SIZE && low_count > 0) {
386 sz = size_inside_page(p, low_count);
387 if (clear_user(buf, sz))
388 return -EFAULT;
389 buf += sz;
390 p += sz;
391 read += sz;
392 low_count -= sz;
393 count -= sz;
395 #endif
396 while (low_count > 0) {
397 sz = size_inside_page(p, low_count);
400 * On ia64 if a page has been mapped somewhere as
401 * uncached, then it must also be accessed uncached
402 * by the kernel or data corruption may occur
404 kbuf = xlate_dev_kmem_ptr((char *)p);
406 if (copy_to_user(buf, kbuf, sz))
407 return -EFAULT;
408 buf += sz;
409 p += sz;
410 read += sz;
411 low_count -= sz;
412 count -= sz;
416 if (count > 0) {
417 kbuf = (char *)__get_free_page(GFP_KERNEL);
418 if (!kbuf)
419 return -ENOMEM;
420 while (count > 0) {
421 sz = size_inside_page(p, count);
422 if (!is_vmalloc_or_module_addr((void *)p)) {
423 err = -ENXIO;
424 break;
426 sz = vread(kbuf, (char *)p, sz);
427 if (!sz)
428 break;
429 if (copy_to_user(buf, kbuf, sz)) {
430 err = -EFAULT;
431 break;
433 count -= sz;
434 buf += sz;
435 read += sz;
436 p += sz;
438 free_page((unsigned long)kbuf);
440 *ppos = p;
441 return read ? read : err;
445 static ssize_t do_write_kmem(unsigned long p, const char __user *buf,
446 size_t count, loff_t *ppos)
448 ssize_t written, sz;
449 unsigned long copied;
451 written = 0;
452 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
453 /* we don't have page 0 mapped on sparc and m68k.. */
454 if (p < PAGE_SIZE) {
455 sz = size_inside_page(p, count);
456 /* Hmm. Do something? */
457 buf += sz;
458 p += sz;
459 count -= sz;
460 written += sz;
462 #endif
464 while (count > 0) {
465 char *ptr;
467 sz = size_inside_page(p, count);
470 * On ia64 if a page has been mapped somewhere as uncached, then
471 * it must also be accessed uncached by the kernel or data
472 * corruption may occur.
474 ptr = xlate_dev_kmem_ptr((char *)p);
476 copied = copy_from_user(ptr, buf, sz);
477 if (copied) {
478 written += sz - copied;
479 if (written)
480 break;
481 return -EFAULT;
483 buf += sz;
484 p += sz;
485 count -= sz;
486 written += sz;
489 *ppos += written;
490 return written;
494 * This function writes to the *virtual* memory as seen by the kernel.
496 static ssize_t write_kmem(struct file *file, const char __user *buf,
497 size_t count, loff_t *ppos)
499 unsigned long p = *ppos;
500 ssize_t wrote = 0;
501 ssize_t virtr = 0;
502 char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
503 int err = 0;
505 if (p < (unsigned long) high_memory) {
506 unsigned long to_write = min_t(unsigned long, count,
507 (unsigned long)high_memory - p);
508 wrote = do_write_kmem(p, buf, to_write, ppos);
509 if (wrote != to_write)
510 return wrote;
511 p += wrote;
512 buf += wrote;
513 count -= wrote;
516 if (count > 0) {
517 kbuf = (char *)__get_free_page(GFP_KERNEL);
518 if (!kbuf)
519 return wrote ? wrote : -ENOMEM;
520 while (count > 0) {
521 unsigned long sz = size_inside_page(p, count);
522 unsigned long n;
524 if (!is_vmalloc_or_module_addr((void *)p)) {
525 err = -ENXIO;
526 break;
528 n = copy_from_user(kbuf, buf, sz);
529 if (n) {
530 err = -EFAULT;
531 break;
533 vwrite(kbuf, (char *)p, sz);
534 count -= sz;
535 buf += sz;
536 virtr += sz;
537 p += sz;
539 free_page((unsigned long)kbuf);
542 *ppos = p;
543 return virtr + wrote ? : err;
545 #endif
547 #ifdef CONFIG_DEVPORT
548 static ssize_t read_port(struct file *file, char __user *buf,
549 size_t count, loff_t *ppos)
551 unsigned long i = *ppos;
552 char __user *tmp = buf;
554 if (!access_ok(VERIFY_WRITE, buf, count))
555 return -EFAULT;
556 while (count-- > 0 && i < 65536) {
557 if (__put_user(inb(i), tmp) < 0)
558 return -EFAULT;
559 i++;
560 tmp++;
562 *ppos = i;
563 return tmp-buf;
566 static ssize_t write_port(struct file *file, const char __user *buf,
567 size_t count, loff_t *ppos)
569 unsigned long i = *ppos;
570 const char __user *tmp = buf;
572 if (!access_ok(VERIFY_READ, buf, count))
573 return -EFAULT;
574 while (count-- > 0 && i < 65536) {
575 char c;
576 if (__get_user(c, tmp)) {
577 if (tmp > buf)
578 break;
579 return -EFAULT;
581 outb(c, i);
582 i++;
583 tmp++;
585 *ppos = i;
586 return tmp-buf;
588 #endif
590 static ssize_t read_null(struct file *file, char __user *buf,
591 size_t count, loff_t *ppos)
593 return 0;
596 static ssize_t write_null(struct file *file, const char __user *buf,
597 size_t count, loff_t *ppos)
599 return count;
602 static ssize_t aio_read_null(struct kiocb *iocb, const struct iovec *iov,
603 unsigned long nr_segs, loff_t pos)
605 return 0;
608 static ssize_t aio_write_null(struct kiocb *iocb, const struct iovec *iov,
609 unsigned long nr_segs, loff_t pos)
611 return iov_length(iov, nr_segs);
614 static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf,
615 struct splice_desc *sd)
617 return sd->len;
620 static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
621 loff_t *ppos, size_t len, unsigned int flags)
623 return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
626 static ssize_t read_zero(struct file *file, char __user *buf,
627 size_t count, loff_t *ppos)
629 size_t written;
631 if (!count)
632 return 0;
634 if (!access_ok(VERIFY_WRITE, buf, count))
635 return -EFAULT;
637 written = 0;
638 while (count) {
639 unsigned long unwritten;
640 size_t chunk = count;
642 if (chunk > PAGE_SIZE)
643 chunk = PAGE_SIZE; /* Just for latency reasons */
644 unwritten = __clear_user(buf, chunk);
645 written += chunk - unwritten;
646 if (unwritten)
647 break;
648 if (signal_pending(current))
649 return written ? written : -ERESTARTSYS;
650 buf += chunk;
651 count -= chunk;
652 cond_resched();
654 return written ? written : -EFAULT;
657 static ssize_t aio_read_zero(struct kiocb *iocb, const struct iovec *iov,
658 unsigned long nr_segs, loff_t pos)
660 size_t written = 0;
661 unsigned long i;
662 ssize_t ret;
664 for (i = 0; i < nr_segs; i++) {
665 ret = read_zero(iocb->ki_filp, iov[i].iov_base, iov[i].iov_len,
666 &pos);
667 if (ret < 0)
668 break;
669 written += ret;
672 return written ? written : -EFAULT;
675 static int mmap_zero(struct file *file, struct vm_area_struct *vma)
677 #ifndef CONFIG_MMU
678 return -ENOSYS;
679 #endif
680 if (vma->vm_flags & VM_SHARED)
681 return shmem_zero_setup(vma);
682 return 0;
685 static ssize_t write_full(struct file *file, const char __user *buf,
686 size_t count, loff_t *ppos)
688 return -ENOSPC;
692 * Special lseek() function for /dev/null and /dev/zero. Most notably, you
693 * can fopen() both devices with "a" now. This was previously impossible.
694 * -- SRB.
696 static loff_t null_lseek(struct file *file, loff_t offset, int orig)
698 return file->f_pos = 0;
702 * The memory devices use the full 32/64 bits of the offset, and so we cannot
703 * check against negative addresses: they are ok. The return value is weird,
704 * though, in that case (0).
706 * also note that seeking relative to the "end of file" isn't supported:
707 * it has no meaning, so it returns -EINVAL.
709 static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
711 loff_t ret;
713 mutex_lock(&file_inode(file)->i_mutex);
714 switch (orig) {
715 case SEEK_CUR:
716 offset += file->f_pos;
717 case SEEK_SET:
718 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
719 if (IS_ERR_VALUE((unsigned long long)offset)) {
720 ret = -EOVERFLOW;
721 break;
723 file->f_pos = offset;
724 ret = file->f_pos;
725 force_successful_syscall_return();
726 break;
727 default:
728 ret = -EINVAL;
730 mutex_unlock(&file_inode(file)->i_mutex);
731 return ret;
734 static int open_port(struct inode *inode, struct file *filp)
736 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
739 #define zero_lseek null_lseek
740 #define full_lseek null_lseek
741 #define write_zero write_null
742 #define read_full read_zero
743 #define aio_write_zero aio_write_null
744 #define open_mem open_port
745 #define open_kmem open_mem
747 static const struct file_operations mem_fops = {
748 .llseek = memory_lseek,
749 .read = read_mem,
750 .write = write_mem,
751 .mmap = mmap_mem,
752 .open = open_mem,
753 .get_unmapped_area = get_unmapped_area_mem,
756 #ifdef CONFIG_DEVKMEM
757 static const struct file_operations kmem_fops = {
758 .llseek = memory_lseek,
759 .read = read_kmem,
760 .write = write_kmem,
761 .mmap = mmap_kmem,
762 .open = open_kmem,
763 .get_unmapped_area = get_unmapped_area_mem,
765 #endif
767 static const struct file_operations null_fops = {
768 .llseek = null_lseek,
769 .read = read_null,
770 .write = write_null,
771 .aio_read = aio_read_null,
772 .aio_write = aio_write_null,
773 .splice_write = splice_write_null,
776 #ifdef CONFIG_DEVPORT
777 static const struct file_operations port_fops = {
778 .llseek = memory_lseek,
779 .read = read_port,
780 .write = write_port,
781 .open = open_port,
783 #endif
785 static const struct file_operations zero_fops = {
786 .llseek = zero_lseek,
787 .read = read_zero,
788 .write = write_zero,
789 .aio_read = aio_read_zero,
790 .aio_write = aio_write_zero,
791 .mmap = mmap_zero,
795 * capabilities for /dev/zero
796 * - permits private mappings, "copies" are taken of the source of zeros
797 * - no writeback happens
799 static struct backing_dev_info zero_bdi = {
800 .name = "char/mem",
801 .capabilities = BDI_CAP_MAP_COPY | BDI_CAP_NO_ACCT_AND_WRITEBACK,
804 static const struct file_operations full_fops = {
805 .llseek = full_lseek,
806 .read = read_full,
807 .write = write_full,
810 static const struct memdev {
811 const char *name;
812 umode_t mode;
813 const struct file_operations *fops;
814 struct backing_dev_info *dev_info;
815 } devlist[] = {
816 [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi },
817 #ifdef CONFIG_DEVKMEM
818 [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi },
819 #endif
820 [3] = { "null", 0666, &null_fops, NULL },
821 #ifdef CONFIG_DEVPORT
822 [4] = { "port", 0, &port_fops, NULL },
823 #endif
824 [5] = { "zero", 0666, &zero_fops, &zero_bdi },
825 [7] = { "full", 0666, &full_fops, NULL },
826 [8] = { "random", 0666, &random_fops, NULL },
827 [9] = { "urandom", 0666, &urandom_fops, NULL },
828 #ifdef CONFIG_PRINTK
829 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
830 #endif
833 static int memory_open(struct inode *inode, struct file *filp)
835 int minor;
836 const struct memdev *dev;
838 minor = iminor(inode);
839 if (minor >= ARRAY_SIZE(devlist))
840 return -ENXIO;
842 dev = &devlist[minor];
843 if (!dev->fops)
844 return -ENXIO;
846 filp->f_op = dev->fops;
847 if (dev->dev_info)
848 filp->f_mapping->backing_dev_info = dev->dev_info;
850 /* Is /dev/mem or /dev/kmem ? */
851 if (dev->dev_info == &directly_mappable_cdev_bdi)
852 filp->f_mode |= FMODE_UNSIGNED_OFFSET;
854 if (dev->fops->open)
855 return dev->fops->open(inode, filp);
857 return 0;
860 static const struct file_operations memory_fops = {
861 .open = memory_open,
862 .llseek = noop_llseek,
865 static char *mem_devnode(struct device *dev, umode_t *mode)
867 if (mode && devlist[MINOR(dev->devt)].mode)
868 *mode = devlist[MINOR(dev->devt)].mode;
869 return NULL;
872 static struct class *mem_class;
874 static int __init chr_dev_init(void)
876 int minor;
877 int err;
879 err = bdi_init(&zero_bdi);
880 if (err)
881 return err;
883 if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
884 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
886 mem_class = class_create(THIS_MODULE, "mem");
887 if (IS_ERR(mem_class))
888 return PTR_ERR(mem_class);
890 mem_class->devnode = mem_devnode;
891 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) {
892 if (!devlist[minor].name)
893 continue;
896 * Create /dev/port?
898 if ((minor == DEVPORT_MINOR) && !arch_has_dev_port())
899 continue;
901 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
902 NULL, devlist[minor].name);
905 return tty_init();
908 fs_initcall(chr_dev_init);