| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $ */ | | 1 | /* $NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette 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.34.2.6 2016/07/17 21:39:17 pgoyette Exp $"); | | 72 | __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $"); |
73 | | | 73 | |
74 | #ifdef _KERNEL_OPT | | 74 | #ifdef _KERNEL_OPT |
75 | #include "opt_dtrace.h" | | 75 | #include "opt_dtrace.h" |
76 | #endif | | 76 | #endif |
77 | | | 77 | |
78 | #include <sys/param.h> | | 78 | #include <sys/param.h> |
79 | #include <sys/conf.h> | | 79 | #include <sys/conf.h> |
80 | #include <sys/kmem.h> | | 80 | #include <sys/kmem.h> |
81 | #include <sys/systm.h> | | 81 | #include <sys/systm.h> |
82 | #include <sys/poll.h> | | 82 | #include <sys/poll.h> |
83 | #include <sys/tty.h> | | 83 | #include <sys/tty.h> |
84 | #include <sys/cpu.h> | | 84 | #include <sys/cpu.h> |
85 | #include <sys/buf.h> | | 85 | #include <sys/buf.h> |
| @@ -147,27 +147,27 @@ devsw_attach(const char *devname, | | | @@ -147,27 +147,27 @@ devsw_attach(const char *devname, |
147 | if (devname == NULL || cdev == NULL) | | 147 | if (devname == NULL || cdev == NULL) |
148 | return (EINVAL); | | 148 | return (EINVAL); |
149 | | | 149 | |
150 | mutex_enter(&device_lock); | | 150 | mutex_enter(&device_lock); |
151 | | | 151 | |
152 | if (bdev != NULL) { | | 152 | if (bdev != NULL) { |
153 | KASSERTMSG(bdev->d_localcount != NULL, | | 153 | KASSERTMSG(bdev->d_localcount != NULL, |
154 | "%s: bdev %s has no d_localcount", __func__, devname); | | 154 | "%s: bdev %s has no d_localcount", __func__, devname); |
155 | KASSERTMSG(bdev->d_localcount != cdev->d_localcount, | | 155 | KASSERTMSG(bdev->d_localcount != cdev->d_localcount, |
156 | "%s: bdev and cdev for %s have same d_localcount", | | 156 | "%s: bdev and cdev for %s have same d_localcount", |
157 | __func__, devname); | | 157 | __func__, devname); |
158 | } | | 158 | } |
159 | if (cdev != NULL) | | 159 | if (cdev != NULL) |
160 | KASSERTMGS(cdev->d_localcount != NULL, | | 160 | KASSERTMSG(cdev->d_localcount != NULL, |
161 | "%s: cdev %s has no d_localcount", __func__, devname); | | 161 | "%s: cdev %s has no d_localcount", __func__, devname); |
162 | | | 162 | |
163 | for (i = 0 ; i < max_devsw_convs ; i++) { | | 163 | for (i = 0 ; i < max_devsw_convs ; i++) { |
164 | conv = &devsw_conv[i]; | | 164 | conv = &devsw_conv[i]; |
165 | if (conv->d_name == NULL || strcmp(devname, conv->d_name) != 0) | | 165 | if (conv->d_name == NULL || strcmp(devname, conv->d_name) != 0) |
166 | continue; | | 166 | continue; |
167 | | | 167 | |
168 | if (*bmajor < 0) | | 168 | if (*bmajor < 0) |
169 | *bmajor = conv->d_bmajor; | | 169 | *bmajor = conv->d_bmajor; |
170 | if (*cmajor < 0) | | 170 | if (*cmajor < 0) |
171 | *cmajor = conv->d_cmajor; | | 171 | *cmajor = conv->d_cmajor; |
172 | | | 172 | |
173 | if (*bmajor != conv->d_bmajor || *cmajor != conv->d_cmajor) { | | 173 | if (*bmajor != conv->d_bmajor || *cmajor != conv->d_cmajor) { |