| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: subr_devsw.c,v 1.29 2011/12/12 19:03:12 mrg Exp $ */ | | 1 | /* $NetBSD: subr_devsw.c,v 1.30 2012/02/18 06:29:10 mrg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by MAEKAWA Masahide <gehenna@NetBSD.org>, and by Andrew Doran. | | 8 | * by MAEKAWA Masahide <gehenna@NetBSD.org>, and by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -59,27 +59,27 @@ | | | @@ -59,27 +59,27 @@ |
59 | * o Regardless of whether other threads see the old or new | | 59 | * o Regardless of whether other threads see the old or new |
60 | * pointers, they will point to a correct device switch | | 60 | * pointers, they will point to a correct device switch |
61 | * structure for the operation being performed. | | 61 | * structure for the operation being performed. |
62 | * | | 62 | * |
63 | * XXX Currently, the wrapper methods such as cdev_read() verify | | 63 | * XXX Currently, the wrapper methods such as cdev_read() verify |
64 | * that a device driver does in fact exist before calling the | | 64 | * that a device driver does in fact exist before calling the |
65 | * associated driver method. This should be changed so that | | 65 | * associated driver method. This should be changed so that |
66 | * once the device is has been referenced by a vnode (opened), | | 66 | * once the device is has been referenced by a vnode (opened), |
67 | * calling the other methods should be valid until that reference | | 67 | * calling the other methods should be valid until that reference |
68 | * is dropped. | | 68 | * is dropped. |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #include <sys/cdefs.h> | | 71 | #include <sys/cdefs.h> |
72 | __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.29 2011/12/12 19:03:12 mrg Exp $"); | | 72 | __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.30 2012/02/18 06:29:10 mrg Exp $"); |
73 | | | 73 | |
74 | #include <sys/param.h> | | 74 | #include <sys/param.h> |
75 | #include <sys/conf.h> | | 75 | #include <sys/conf.h> |
76 | #include <sys/kmem.h> | | 76 | #include <sys/kmem.h> |
77 | #include <sys/systm.h> | | 77 | #include <sys/systm.h> |
78 | #include <sys/poll.h> | | 78 | #include <sys/poll.h> |
79 | #include <sys/tty.h> | | 79 | #include <sys/tty.h> |
80 | #include <sys/cpu.h> | | 80 | #include <sys/cpu.h> |
81 | #include <sys/buf.h> | | 81 | #include <sys/buf.h> |
82 | #include <sys/reboot.h> | | 82 | #include <sys/reboot.h> |
83 | | | 83 | |
84 | #ifdef DEVSW_DEBUG | | 84 | #ifdef DEVSW_DEBUG |
85 | #define DPRINTF(x) printf x | | 85 | #define DPRINTF(x) printf x |
| @@ -795,26 +795,27 @@ bdev_type(dev_t dev) | | | @@ -795,26 +795,27 @@ bdev_type(dev_t dev) |
795 | | | 795 | |
796 | int | | 796 | int |
797 | bdev_size(dev_t dev) | | 797 | bdev_size(dev_t dev) |
798 | { | | 798 | { |
799 | const struct bdevsw *d; | | 799 | const struct bdevsw *d; |
800 | int rv, mpflag = 0; | | 800 | int rv, mpflag = 0; |
801 | | | 801 | |
802 | if ((d = bdevsw_lookup(dev)) == NULL || | | 802 | if ((d = bdevsw_lookup(dev)) == NULL || |
803 | d->d_psize == NULL) | | 803 | d->d_psize == NULL) |
804 | return -1; | | 804 | return -1; |
805 | | | 805 | |
806 | /* | | 806 | /* |
807 | * Don't to try lock the device if we're dumping. | | 807 | * Don't to try lock the device if we're dumping. |
| | | 808 | * XXX: is there a better way to test this? |
808 | */ | | 809 | */ |
809 | if ((boothowto & RB_DUMP) == 0) | | 810 | if ((boothowto & RB_DUMP) == 0) |
810 | DEV_LOCK(d); | | 811 | DEV_LOCK(d); |
811 | rv = (*d->d_psize)(dev); | | 812 | rv = (*d->d_psize)(dev); |
812 | if ((boothowto & RB_DUMP) == 0) | | 813 | if ((boothowto & RB_DUMP) == 0) |
813 | DEV_UNLOCK(d); | | 814 | DEV_UNLOCK(d); |
814 | | | 815 | |
815 | return rv; | | 816 | return rv; |
816 | } | | 817 | } |
817 | | | 818 | |
818 | int | | 819 | int |
819 | cdev_open(dev_t dev, int flag, int devtype, lwp_t *l) | | 820 | cdev_open(dev_t dev, int flag, int devtype, lwp_t *l) |
820 | { | | 821 | { |