sh_eth: R8A7740 supports packet shecksumming
[linux/fpc-iii.git] / drivers / char / mem.c
blob5bb1985ec484aef267e3c551c3068ec0dee14b1c
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/shmem_fs.h>
26 #include <linux/splice.h>
27 #include <linux/pfn.h>
28 #include <linux/export.h>
29 #include <linux/io.h>
30 #include <linux/uio.h>
32 #include <linux/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 return 0;
72 cursor += PAGE_SIZE;
73 pfn++;
75 return 1;
77 #else
78 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
80 return 1;
82 #endif
84 #ifndef unxlate_dev_mem_ptr
85 #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
86 void __weak unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
89 #endif
92 * This funcion reads the *physical* memory. The f_pos points directly to the
93 * memory location.
95 static ssize_t read_mem(struct file *file, char __user *buf,
96 size_t count, loff_t *ppos)
98 phys_addr_t p = *ppos;
99 ssize_t read, sz;
100 void *ptr;
102 if (p != *ppos)
103 return 0;
105 if (!valid_phys_addr_range(p, count))
106 return -EFAULT;
107 read = 0;
108 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
109 /* we don't have page 0 mapped on sparc and m68k.. */
110 if (p < PAGE_SIZE) {
111 sz = size_inside_page(p, count);
112 if (sz > 0) {
113 if (clear_user(buf, sz))
114 return -EFAULT;
115 buf += sz;
116 p += sz;
117 count -= sz;
118 read += sz;
121 #endif
123 while (count > 0) {
124 unsigned long remaining;
126 sz = size_inside_page(p, count);
128 if (!range_is_allowed(p >> PAGE_SHIFT, count))
129 return -EPERM;
132 * On ia64 if a page has been mapped somewhere as uncached, then
133 * it must also be accessed uncached by the kernel or data
134 * corruption may occur.
136 ptr = xlate_dev_mem_ptr(p);
137 if (!ptr)
138 return -EFAULT;
140 remaining = copy_to_user(buf, ptr, sz);
141 unxlate_dev_mem_ptr(p, ptr);
142 if (remaining)
143 return -EFAULT;
145 buf += sz;
146 p += sz;
147 count -= sz;
148 read += sz;
151 *ppos += read;
152 return read;
155 static ssize_t write_mem(struct file *file, const char __user *buf,
156 size_t count, loff_t *ppos)
158 phys_addr_t p = *ppos;
159 ssize_t written, sz;
160 unsigned long copied;
161 void *ptr;
163 if (p != *ppos)
164 return -EFBIG;
166 if (!valid_phys_addr_range(p, count))
167 return -EFAULT;
169 written = 0;
171 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
172 /* we don't have page 0 mapped on sparc and m68k.. */
173 if (p < PAGE_SIZE) {
174 sz = size_inside_page(p, count);
175 /* Hmm. Do something? */
176 buf += sz;
177 p += sz;
178 count -= sz;
179 written += sz;
181 #endif
183 while (count > 0) {
184 sz = size_inside_page(p, count);
186 if (!range_is_allowed(p >> PAGE_SHIFT, sz))
187 return -EPERM;
190 * On ia64 if a page has been mapped somewhere as uncached, then
191 * it must also be accessed uncached by the kernel or data
192 * corruption may occur.
194 ptr = xlate_dev_mem_ptr(p);
195 if (!ptr) {
196 if (written)
197 break;
198 return -EFAULT;
201 copied = copy_from_user(ptr, buf, sz);
202 unxlate_dev_mem_ptr(p, ptr);
203 if (copied) {
204 written += sz - copied;
205 if (written)
206 break;
207 return -EFAULT;
210 buf += sz;
211 p += sz;
212 count -= sz;
213 written += sz;
216 *ppos += written;
217 return written;
220 int __weak phys_mem_access_prot_allowed(struct file *file,
221 unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
223 return 1;
226 #ifndef __HAVE_PHYS_MEM_ACCESS_PROT
229 * Architectures vary in how they handle caching for addresses
230 * outside of main memory.
233 #ifdef pgprot_noncached
234 static int uncached_access(struct file *file, phys_addr_t addr)
236 #if defined(CONFIG_IA64)
238 * On ia64, we ignore O_DSYNC because we cannot tolerate memory
239 * attribute aliases.
241 return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
242 #elif defined(CONFIG_MIPS)
244 extern int __uncached_access(struct file *file,
245 unsigned long addr);
247 return __uncached_access(file, addr);
249 #else
251 * Accessing memory above the top the kernel knows about or through a
252 * file pointer
253 * that was marked O_DSYNC will be done non-cached.
255 if (file->f_flags & O_DSYNC)
256 return 1;
257 return addr >= __pa(high_memory);
258 #endif
260 #endif
262 static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
263 unsigned long size, pgprot_t vma_prot)
265 #ifdef pgprot_noncached
266 phys_addr_t offset = pfn << PAGE_SHIFT;
268 if (uncached_access(file, offset))
269 return pgprot_noncached(vma_prot);
270 #endif
271 return vma_prot;
273 #endif
275 #ifndef CONFIG_MMU
276 static unsigned long get_unmapped_area_mem(struct file *file,
277 unsigned long addr,
278 unsigned long len,
279 unsigned long pgoff,
280 unsigned long flags)
282 if (!valid_mmap_phys_addr_range(pgoff, len))
283 return (unsigned long) -EINVAL;
284 return pgoff << PAGE_SHIFT;
287 /* permit direct mmap, for read, write or exec */
288 static unsigned memory_mmap_capabilities(struct file *file)
290 return NOMMU_MAP_DIRECT |
291 NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC;
294 static unsigned zero_mmap_capabilities(struct file *file)
296 return NOMMU_MAP_COPY;
299 /* can't do an in-place private mapping if there's no MMU */
300 static inline int private_mapping_ok(struct vm_area_struct *vma)
302 return vma->vm_flags & VM_MAYSHARE;
304 #else
306 static inline int private_mapping_ok(struct vm_area_struct *vma)
308 return 1;
310 #endif
312 static const struct vm_operations_struct mmap_mem_ops = {
313 #ifdef CONFIG_HAVE_IOREMAP_PROT
314 .access = generic_access_phys
315 #endif
318 static int mmap_mem(struct file *file, struct vm_area_struct *vma)
320 size_t size = vma->vm_end - vma->vm_start;
322 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
323 return -EINVAL;
325 if (!private_mapping_ok(vma))
326 return -ENOSYS;
328 if (!range_is_allowed(vma->vm_pgoff, size))
329 return -EPERM;
331 if (!phys_mem_access_prot_allowed(file, vma->vm_pgoff, size,
332 &vma->vm_page_prot))
333 return -EINVAL;
335 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
336 size,
337 vma->vm_page_prot);
339 vma->vm_ops = &mmap_mem_ops;
341 /* Remap-pfn-range will mark the range VM_IO */
342 if (remap_pfn_range(vma,
343 vma->vm_start,
344 vma->vm_pgoff,
345 size,
346 vma->vm_page_prot)) {
347 return -EAGAIN;
349 return 0;
352 static int mmap_kmem(struct file *file, struct vm_area_struct *vma)
354 unsigned long pfn;
356 /* Turn a kernel-virtual address into a physical page frame */
357 pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;
360 * RED-PEN: on some architectures there is more mapped memory than
361 * available in mem_map which pfn_valid checks for. Perhaps should add a
362 * new macro here.
364 * RED-PEN: vmalloc is not supported right now.
366 if (!pfn_valid(pfn))
367 return -EIO;
369 vma->vm_pgoff = pfn;
370 return mmap_mem(file, vma);
374 * This function reads the *virtual* memory as seen by the kernel.
376 static ssize_t read_kmem(struct file *file, char __user *buf,
377 size_t count, loff_t *ppos)
379 unsigned long p = *ppos;
380 ssize_t low_count, read, sz;
381 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
382 int err = 0;
384 if (!pfn_valid(PFN_DOWN(p)))
385 return -EIO;
387 read = 0;
388 if (p < (unsigned long) high_memory) {
389 low_count = count;
390 if (count > (unsigned long)high_memory - p)
391 low_count = (unsigned long)high_memory - p;
393 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
394 /* we don't have page 0 mapped on sparc and m68k.. */
395 if (p < PAGE_SIZE && low_count > 0) {
396 sz = size_inside_page(p, low_count);
397 if (clear_user(buf, sz))
398 return -EFAULT;
399 buf += sz;
400 p += sz;
401 read += sz;
402 low_count -= sz;
403 count -= sz;
405 #endif
406 while (low_count > 0) {
407 sz = size_inside_page(p, low_count);
410 * On ia64 if a page has been mapped somewhere as
411 * uncached, then it must also be accessed uncached
412 * by the kernel or data corruption may occur
414 kbuf = xlate_dev_kmem_ptr((void *)p);
416 if (copy_to_user(buf, kbuf, sz))
417 return -EFAULT;
418 buf += sz;
419 p += sz;
420 read += sz;
421 low_count -= sz;
422 count -= sz;
426 if (count > 0) {
427 kbuf = (char *)__get_free_page(GFP_KERNEL);
428 if (!kbuf)
429 return -ENOMEM;
430 while (count > 0) {
431 sz = size_inside_page(p, count);
432 if (!is_vmalloc_or_module_addr((void *)p)) {
433 err = -ENXIO;
434 break;
436 sz = vread(kbuf, (char *)p, sz);
437 if (!sz)
438 break;
439 if (copy_to_user(buf, kbuf, sz)) {
440 err = -EFAULT;
441 break;
443 count -= sz;
444 buf += sz;
445 read += sz;
446 p += sz;
448 free_page((unsigned long)kbuf);
450 *ppos = p;
451 return read ? read : err;
455 static ssize_t do_write_kmem(unsigned long p, const char __user *buf,
456 size_t count, loff_t *ppos)
458 ssize_t written, sz;
459 unsigned long copied;
461 written = 0;
462 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
463 /* we don't have page 0 mapped on sparc and m68k.. */
464 if (p < PAGE_SIZE) {
465 sz = size_inside_page(p, count);
466 /* Hmm. Do something? */
467 buf += sz;
468 p += sz;
469 count -= sz;
470 written += sz;
472 #endif
474 while (count > 0) {
475 void *ptr;
477 sz = size_inside_page(p, count);
480 * On ia64 if a page has been mapped somewhere as uncached, then
481 * it must also be accessed uncached by the kernel or data
482 * corruption may occur.
484 ptr = xlate_dev_kmem_ptr((void *)p);
486 copied = copy_from_user(ptr, buf, sz);
487 if (copied) {
488 written += sz - copied;
489 if (written)
490 break;
491 return -EFAULT;
493 buf += sz;
494 p += sz;
495 count -= sz;
496 written += sz;
499 *ppos += written;
500 return written;
504 * This function writes to the *virtual* memory as seen by the kernel.
506 static ssize_t write_kmem(struct file *file, const char __user *buf,
507 size_t count, loff_t *ppos)
509 unsigned long p = *ppos;
510 ssize_t wrote = 0;
511 ssize_t virtr = 0;
512 char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
513 int err = 0;
515 if (!pfn_valid(PFN_DOWN(p)))
516 return -EIO;
518 if (p < (unsigned long) high_memory) {
519 unsigned long to_write = min_t(unsigned long, count,
520 (unsigned long)high_memory - p);
521 wrote = do_write_kmem(p, buf, to_write, ppos);
522 if (wrote != to_write)
523 return wrote;
524 p += wrote;
525 buf += wrote;
526 count -= wrote;
529 if (count > 0) {
530 kbuf = (char *)__get_free_page(GFP_KERNEL);
531 if (!kbuf)
532 return wrote ? wrote : -ENOMEM;
533 while (count > 0) {
534 unsigned long sz = size_inside_page(p, count);
535 unsigned long n;
537 if (!is_vmalloc_or_module_addr((void *)p)) {
538 err = -ENXIO;
539 break;
541 n = copy_from_user(kbuf, buf, sz);
542 if (n) {
543 err = -EFAULT;
544 break;
546 vwrite(kbuf, (char *)p, sz);
547 count -= sz;
548 buf += sz;
549 virtr += sz;
550 p += sz;
552 free_page((unsigned long)kbuf);
555 *ppos = p;
556 return virtr + wrote ? : err;
559 static ssize_t read_port(struct file *file, char __user *buf,
560 size_t count, loff_t *ppos)
562 unsigned long i = *ppos;
563 char __user *tmp = buf;
565 if (!access_ok(VERIFY_WRITE, buf, count))
566 return -EFAULT;
567 while (count-- > 0 && i < 65536) {
568 if (__put_user(inb(i), tmp) < 0)
569 return -EFAULT;
570 i++;
571 tmp++;
573 *ppos = i;
574 return tmp-buf;
577 static ssize_t write_port(struct file *file, const char __user *buf,
578 size_t count, loff_t *ppos)
580 unsigned long i = *ppos;
581 const char __user *tmp = buf;
583 if (!access_ok(VERIFY_READ, buf, count))
584 return -EFAULT;
585 while (count-- > 0 && i < 65536) {
586 char c;
588 if (__get_user(c, tmp)) {
589 if (tmp > buf)
590 break;
591 return -EFAULT;
593 outb(c, i);
594 i++;
595 tmp++;
597 *ppos = i;
598 return tmp-buf;
601 static ssize_t read_null(struct file *file, char __user *buf,
602 size_t count, loff_t *ppos)
604 return 0;
607 static ssize_t write_null(struct file *file, const char __user *buf,
608 size_t count, loff_t *ppos)
610 return count;
613 static ssize_t read_iter_null(struct kiocb *iocb, struct iov_iter *to)
615 return 0;
618 static ssize_t write_iter_null(struct kiocb *iocb, struct iov_iter *from)
620 size_t count = iov_iter_count(from);
621 iov_iter_advance(from, count);
622 return count;
625 static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf,
626 struct splice_desc *sd)
628 return sd->len;
631 static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
632 loff_t *ppos, size_t len, unsigned int flags)
634 return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
637 static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
639 size_t written = 0;
641 while (iov_iter_count(iter)) {
642 size_t chunk = iov_iter_count(iter), n;
644 if (chunk > PAGE_SIZE)
645 chunk = PAGE_SIZE; /* Just for latency reasons */
646 n = iov_iter_zero(chunk, iter);
647 if (!n && iov_iter_count(iter))
648 return written ? written : -EFAULT;
649 written += n;
650 if (signal_pending(current))
651 return written ? written : -ERESTARTSYS;
652 cond_resched();
654 return written;
657 static int mmap_zero(struct file *file, struct vm_area_struct *vma)
659 #ifndef CONFIG_MMU
660 return -ENOSYS;
661 #endif
662 if (vma->vm_flags & VM_SHARED)
663 return shmem_zero_setup(vma);
664 return 0;
667 static unsigned long get_unmapped_area_zero(struct file *file,
668 unsigned long addr, unsigned long len,
669 unsigned long pgoff, unsigned long flags)
671 #ifdef CONFIG_MMU
672 if (flags & MAP_SHARED) {
674 * mmap_zero() will call shmem_zero_setup() to create a file,
675 * so use shmem's get_unmapped_area in case it can be huge;
676 * and pass NULL for file as in mmap.c's get_unmapped_area(),
677 * so as not to confuse shmem with our handle on "/dev/zero".
679 return shmem_get_unmapped_area(NULL, addr, len, pgoff, flags);
682 /* Otherwise flags & MAP_PRIVATE: with no shmem object beneath it */
683 return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
684 #else
685 return -ENOSYS;
686 #endif
689 static ssize_t write_full(struct file *file, const char __user *buf,
690 size_t count, loff_t *ppos)
692 return -ENOSPC;
696 * Special lseek() function for /dev/null and /dev/zero. Most notably, you
697 * can fopen() both devices with "a" now. This was previously impossible.
698 * -- SRB.
700 static loff_t null_lseek(struct file *file, loff_t offset, int orig)
702 return file->f_pos = 0;
706 * The memory devices use the full 32/64 bits of the offset, and so we cannot
707 * check against negative addresses: they are ok. The return value is weird,
708 * though, in that case (0).
710 * also note that seeking relative to the "end of file" isn't supported:
711 * it has no meaning, so it returns -EINVAL.
713 static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
715 loff_t ret;
717 inode_lock(file_inode(file));
718 switch (orig) {
719 case SEEK_CUR:
720 offset += file->f_pos;
721 case SEEK_SET:
722 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
723 if ((unsigned long long)offset >= -MAX_ERRNO) {
724 ret = -EOVERFLOW;
725 break;
727 file->f_pos = offset;
728 ret = file->f_pos;
729 force_successful_syscall_return();
730 break;
731 default:
732 ret = -EINVAL;
734 inode_unlock(file_inode(file));
735 return ret;
738 static int open_port(struct inode *inode, struct file *filp)
740 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
743 #define zero_lseek null_lseek
744 #define full_lseek null_lseek
745 #define write_zero write_null
746 #define write_iter_zero write_iter_null
747 #define open_mem open_port
748 #define open_kmem open_mem
750 static const struct file_operations __maybe_unused mem_fops = {
751 .llseek = memory_lseek,
752 .read = read_mem,
753 .write = write_mem,
754 .mmap = mmap_mem,
755 .open = open_mem,
756 #ifndef CONFIG_MMU
757 .get_unmapped_area = get_unmapped_area_mem,
758 .mmap_capabilities = memory_mmap_capabilities,
759 #endif
762 static const struct file_operations __maybe_unused kmem_fops = {
763 .llseek = memory_lseek,
764 .read = read_kmem,
765 .write = write_kmem,
766 .mmap = mmap_kmem,
767 .open = open_kmem,
768 #ifndef CONFIG_MMU
769 .get_unmapped_area = get_unmapped_area_mem,
770 .mmap_capabilities = memory_mmap_capabilities,
771 #endif
774 static const struct file_operations null_fops = {
775 .llseek = null_lseek,
776 .read = read_null,
777 .write = write_null,
778 .read_iter = read_iter_null,
779 .write_iter = write_iter_null,
780 .splice_write = splice_write_null,
783 static const struct file_operations __maybe_unused port_fops = {
784 .llseek = memory_lseek,
785 .read = read_port,
786 .write = write_port,
787 .open = open_port,
790 static const struct file_operations zero_fops = {
791 .llseek = zero_lseek,
792 .write = write_zero,
793 .read_iter = read_iter_zero,
794 .write_iter = write_iter_zero,
795 .mmap = mmap_zero,
796 .get_unmapped_area = get_unmapped_area_zero,
797 #ifndef CONFIG_MMU
798 .mmap_capabilities = zero_mmap_capabilities,
799 #endif
802 static const struct file_operations full_fops = {
803 .llseek = full_lseek,
804 .read_iter = read_iter_zero,
805 .write = write_full,
808 static const struct memdev {
809 const char *name;
810 umode_t mode;
811 const struct file_operations *fops;
812 fmode_t fmode;
813 } devlist[] = {
814 #ifdef CONFIG_DEVMEM
815 [1] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET },
816 #endif
817 #ifdef CONFIG_DEVKMEM
818 [2] = { "kmem", 0, &kmem_fops, FMODE_UNSIGNED_OFFSET },
819 #endif
820 [3] = { "null", 0666, &null_fops, 0 },
821 #ifdef CONFIG_DEVPORT
822 [4] = { "port", 0, &port_fops, 0 },
823 #endif
824 [5] = { "zero", 0666, &zero_fops, 0 },
825 [7] = { "full", 0666, &full_fops, 0 },
826 [8] = { "random", 0666, &random_fops, 0 },
827 [9] = { "urandom", 0666, &urandom_fops, 0 },
828 #ifdef CONFIG_PRINTK
829 [11] = { "kmsg", 0644, &kmsg_fops, 0 },
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 filp->f_mode |= dev->fmode;
849 if (dev->fops->open)
850 return dev->fops->open(inode, filp);
852 return 0;
855 static const struct file_operations memory_fops = {
856 .open = memory_open,
857 .llseek = noop_llseek,
860 static char *mem_devnode(struct device *dev, umode_t *mode)
862 if (mode && devlist[MINOR(dev->devt)].mode)
863 *mode = devlist[MINOR(dev->devt)].mode;
864 return NULL;
867 static struct class *mem_class;
869 static int __init chr_dev_init(void)
871 int minor;
873 if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
874 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
876 mem_class = class_create(THIS_MODULE, "mem");
877 if (IS_ERR(mem_class))
878 return PTR_ERR(mem_class);
880 mem_class->devnode = mem_devnode;
881 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) {
882 if (!devlist[minor].name)
883 continue;
886 * Create /dev/port?
888 if ((minor == DEVPORT_MINOR) && !arch_has_dev_port())
889 continue;
891 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
892 NULL, devlist[minor].name);
895 return tty_init();
898 fs_initcall(chr_dev_init);