Sun Dec 2 05:46:40 2012 UTC ()
Don't pass NULL struct dkdriver to disk_init.  That's seriously bogus.


(tls)
diff -r1.92.6.1 -r1.92.6.2 src/sys/arch/hp300/dev/rd.c
diff -r1.48 -r1.48.18.1 src/sys/arch/vax/mba/hp.c
diff -r1.51 -r1.51.18.1 src/sys/arch/vax/vsa/hdc9224.c
diff -r1.143 -r1.143.10.1 src/sys/dev/ccd.c
diff -r1.32 -r1.32.14.1 src/sys/dev/ccdvar.h
diff -r1.83 -r1.83.2.1 src/sys/dev/fss.c
diff -r1.64.2.1 -r1.64.2.2 src/sys/dev/dkwedge/dk.c
diff -r1.30.6.1 -r1.30.6.2 src/sys/dev/gpib/rd.c
diff -r1.100.18.1 -r1.100.18.2 src/sys/kern/subr_disk.c

cvs diff -r1.92.6.1 -r1.92.6.2 src/sys/arch/hp300/dev/rd.c (expand / switch to unified diff)

--- src/sys/arch/hp300/dev/rd.c 2012/11/20 03:01:21 1.92.6.1
+++ src/sys/arch/hp300/dev/rd.c 2012/12/02 05:46:39 1.92.6.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rd.c,v 1.92.6.1 2012/11/20 03:01:21 tls Exp $ */ 1/* $NetBSD: rd.c,v 1.92.6.2 2012/12/02 05:46:39 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997 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 Jason R. Thorpe. 8 * by Jason R. Thorpe.
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.
@@ -62,27 +62,27 @@ @@ -62,27 +62,27 @@
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * from: Utah $Hdr: rd.c 1.44 92/12/26$ 65 * from: Utah $Hdr: rd.c 1.44 92/12/26$
66 * 66 *
67 * @(#)rd.c 8.2 (Berkeley) 5/19/94 67 * @(#)rd.c 8.2 (Berkeley) 5/19/94
68 */ 68 */
69 69
70/* 70/*
71 * CS80/SS80 disk driver 71 * CS80/SS80 disk driver
72 */ 72 */
73 73
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.92.6.1 2012/11/20 03:01:21 tls Exp $"); 75__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.92.6.2 2012/12/02 05:46:39 tls Exp $");
76 76
77#include "opt_useleds.h" 77#include "opt_useleds.h"
78 78
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/systm.h> 80#include <sys/systm.h>
81#include <sys/buf.h> 81#include <sys/buf.h>
82#include <sys/bufq.h> 82#include <sys/bufq.h>
83#include <sys/conf.h> 83#include <sys/conf.h>
84#include <sys/device.h> 84#include <sys/device.h>
85#include <sys/disk.h> 85#include <sys/disk.h>
86#include <sys/disklabel.h> 86#include <sys/disklabel.h>
87#include <sys/fcntl.h> 87#include <sys/fcntl.h>
88#include <sys/ioctl.h> 88#include <sys/ioctl.h>
@@ -280,26 +280,39 @@ static dev_type_ioctl(rdioctl); @@ -280,26 +280,39 @@ static dev_type_ioctl(rdioctl);
280static dev_type_strategy(rdstrategy); 280static dev_type_strategy(rdstrategy);
281static dev_type_dump(rddump); 281static dev_type_dump(rddump);
282static dev_type_size(rdsize); 282static dev_type_size(rdsize);
283 283
284const struct bdevsw rd_bdevsw = { 284const struct bdevsw rd_bdevsw = {
285 rdopen, rdclose, rdstrategy, rdioctl, rddump, rdsize, D_DISK 285 rdopen, rdclose, rdstrategy, rdioctl, rddump, rdsize, D_DISK
286}; 286};
287 287
288const struct cdevsw rd_cdevsw = { 288const struct cdevsw rd_cdevsw = {
289 rdopen, rdclose, rdread, rdwrite, rdioctl, 289 rdopen, rdclose, rdread, rdwrite, rdioctl,
290 nostop, notty, nopoll, nommap, nokqfilter, D_DISK 290 nostop, notty, nopoll, nommap, nokqfilter, D_DISK
291}; 291};
292 292
 293static void
 294rdminphys(struct buf *bp)
 295{
 296 struct rd_softc *sc = device_lookup_private(&rd_cd, rdunit(bp->b_dev));
 297
 298 long xmax;
 299 xmax = sc->sc_dev->dv_maxphys;
 300 if (bp->b_bcount > xmax)
 301 bp->b_bcount = xmax;
 302}
 303
 304const struct dkdriver rd_dkdriver = { rdstrategy, rdminphys };
 305
293static int 306static int
294rdmatch(device_t parent, cfdata_t cf, void *aux) 307rdmatch(device_t parent, cfdata_t cf, void *aux)
295{ 308{
296 struct hpibbus_attach_args *ha = aux; 309 struct hpibbus_attach_args *ha = aux;
297 310
298 /* 311 /*
299 * Set punit if operator specified one in the kernel 312 * Set punit if operator specified one in the kernel
300 * configuration file. 313 * configuration file.
301 */ 314 */
302 if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT && 315 if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
303 cf->hpibbuscf_punit < HPIB_NPUNITS) 316 cf->hpibbuscf_punit < HPIB_NPUNITS)
304 ha->ha_punit = cf->hpibbuscf_punit; 317 ha->ha_punit = cf->hpibbuscf_punit;
305 318
@@ -324,27 +337,27 @@ rdattach(device_t parent, device_t self, @@ -324,27 +337,27 @@ rdattach(device_t parent, device_t self,
324 337
325 sc->sc_dev = self; 338 sc->sc_dev = self;
326 bufq_alloc(&sc->sc_tab, "disksort", BUFQ_SORT_RAWBLOCK); 339 bufq_alloc(&sc->sc_tab, "disksort", BUFQ_SORT_RAWBLOCK);
327 340
328 if (rdident(parent, sc, ha) == 0) { 341 if (rdident(parent, sc, ha) == 0) {
329 aprint_error(": didn't respond to describe command!\n"); 342 aprint_error(": didn't respond to describe command!\n");
330 return; 343 return;
331 } 344 }
332 345
333 /* 346 /*
334 * Initialize and attach the disk structure. 347 * Initialize and attach the disk structure.
335 */ 348 */
336 memset(&sc->sc_dkdev, 0, sizeof(sc->sc_dkdev)); 349 memset(&sc->sc_dkdev, 0, sizeof(sc->sc_dkdev));
337 disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), NULL); 350 disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), &rd_dkdriver);
338 disk_attach(&sc->sc_dkdev); 351 disk_attach(&sc->sc_dkdev);
339 352
340 sc->sc_slave = ha->ha_slave; 353 sc->sc_slave = ha->ha_slave;
341 sc->sc_punit = ha->ha_punit; 354 sc->sc_punit = ha->ha_punit;
342 355
343 callout_init(&sc->sc_restart_ch, 0); 356 callout_init(&sc->sc_restart_ch, 0);
344 357
345 /* Initialize the hpib job queue entry */ 358 /* Initialize the hpib job queue entry */
346 sc->sc_hq.hq_softc = sc; 359 sc->sc_hq.hq_softc = sc;
347 sc->sc_hq.hq_slave = sc->sc_slave; 360 sc->sc_hq.hq_slave = sc->sc_slave;
348 sc->sc_hq.hq_start = rdstart; 361 sc->sc_hq.hq_start = rdstart;
349 sc->sc_hq.hq_go = rdgo; 362 sc->sc_hq.hq_go = rdgo;
350 sc->sc_hq.hq_intr = rdintr; 363 sc->sc_hq.hq_intr = rdintr;

cvs diff -r1.48 -r1.48.18.1 src/sys/arch/vax/mba/hp.c (expand / switch to unified diff)

--- src/sys/arch/vax/mba/hp.c 2010/12/14 23:38:30 1.48
+++ src/sys/arch/vax/mba/hp.c 2012/12/02 05:46:39 1.48.18.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hp.c,v 1.48 2010/12/14 23:38:30 matt Exp $ */ 1/* $NetBSD: hp.c,v 1.48.18.1 2012/12/02 05:46:39 tls Exp $ */
2/* 2/*
3 * Copyright (c) 1996 Ludd, University of Lule}, Sweden. 3 * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 32
33/* 33/*
34 * Simple device driver routine for massbuss disks. 34 * Simple device driver routine for massbuss disks.
35 * TODO: 35 * TODO:
36 * Fix support for Standard DEC BAD144 bad block forwarding. 36 * Fix support for Standard DEC BAD144 bad block forwarding.
37 * Be able to to handle soft/hard transfer errors. 37 * Be able to to handle soft/hard transfer errors.
38 * Handle non-data transfer interrupts. 38 * Handle non-data transfer interrupts.
39 * Autoconfiguration of disk drives 'on the fly'. 39 * Autoconfiguration of disk drives 'on the fly'.
40 * Handle disk media changes. 40 * Handle disk media changes.
41 * Dual-port operations should be supported. 41 * Dual-port operations should be supported.
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: hp.c,v 1.48 2010/12/14 23:38:30 matt Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: hp.c,v 1.48.18.1 2012/12/02 05:46:39 tls Exp $");
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/bus.h> 49#include <sys/bus.h>
50#include <sys/cpu.h> 50#include <sys/cpu.h>
51#include <sys/device.h> 51#include <sys/device.h>
52#include <sys/disklabel.h> 52#include <sys/disklabel.h>
53#include <sys/disk.h> 53#include <sys/disk.h>
54#include <sys/dkio.h> 54#include <sys/dkio.h>
55#include <sys/buf.h> 55#include <sys/buf.h>
56#include <sys/bufq.h> 56#include <sys/bufq.h>
57#include <sys/stat.h> 57#include <sys/stat.h>
58#include <sys/ioccom.h> 58#include <sys/ioccom.h>
@@ -108,26 +108,28 @@ const struct cdevsw hp_cdevsw = { @@ -108,26 +108,28 @@ const struct cdevsw hp_cdevsw = {
108 .d_open = hpopen, 108 .d_open = hpopen,
109 .d_close = hpclose, 109 .d_close = hpclose,
110 .d_read = hpread, 110 .d_read = hpread,
111 .d_write = hpwrite, 111 .d_write = hpwrite,
112 .d_ioctl = hpioctl, 112 .d_ioctl = hpioctl,
113 .d_stop = nostop, 113 .d_stop = nostop,
114 .d_tty = notty, 114 .d_tty = notty,
115 .d_poll = nopoll, 115 .d_poll = nopoll,
116 .d_mmap = nommap, 116 .d_mmap = nommap,
117 .d_kqfilter = nokqfilter, 117 .d_kqfilter = nokqfilter,
118 .d_flag = D_DISK 118 .d_flag = D_DISK
119}; 119};
120 120
 121const struct dkdriver hp_dkdriver = { hpstrategy, minphys };
 122
121#define HP_WCSR(reg, val) \ 123#define HP_WCSR(reg, val) \
122 bus_space_write_4(sc->sc_iot, sc->sc_ioh, (reg), (val)) 124 bus_space_write_4(sc->sc_iot, sc->sc_ioh, (reg), (val))
123#define HP_RCSR(reg) \ 125#define HP_RCSR(reg) \
124 bus_space_read_4(sc->sc_iot, sc->sc_ioh, (reg)) 126 bus_space_read_4(sc->sc_iot, sc->sc_ioh, (reg))
125 127
126 128
127/* 129/*
128 * Check if this is a disk drive; done by checking type from mbaattach. 130 * Check if this is a disk drive; done by checking type from mbaattach.
129 */ 131 */
130int 132int
131hpmatch(device_t parent, cfdata_t cf, void *aux) 133hpmatch(device_t parent, cfdata_t cf, void *aux)
132{ 134{
133 struct mba_attach_args * const ma = aux; 135 struct mba_attach_args * const ma = aux;
@@ -164,27 +166,27 @@ hpattach(device_t parent, device_t self, @@ -164,27 +166,27 @@ hpattach(device_t parent, device_t self,
164 */ 166 */
165 bufq_alloc(&sc->sc_md.md_q, "disksort", BUFQ_SORT_CYLINDER); 167 bufq_alloc(&sc->sc_md.md_q, "disksort", BUFQ_SORT_CYLINDER);
166 sc->sc_md.md_softc = sc; /* Pointer to this softc */ 168 sc->sc_md.md_softc = sc; /* Pointer to this softc */
167 sc->sc_md.md_mba = ms; /* Pointer to parent softc */ 169 sc->sc_md.md_mba = ms; /* Pointer to parent softc */
168 sc->sc_md.md_start = hpstart; /* Disk start routine */ 170 sc->sc_md.md_start = hpstart; /* Disk start routine */
169 sc->sc_md.md_attn = hpattn; /* Disk attention routine */ 171 sc->sc_md.md_attn = hpattn; /* Disk attention routine */
170 sc->sc_md.md_finish = hpfinish; /* Disk xfer finish routine */ 172 sc->sc_md.md_finish = hpfinish; /* Disk xfer finish routine */
171 173
172 ms->sc_md[ma->ma_unit] = &sc->sc_md; /* Per-unit backpointer */ 174 ms->sc_md[ma->ma_unit] = &sc->sc_md; /* Per-unit backpointer */
173 175
174 /* 176 /*
175 * Init and attach the disk structure. 177 * Init and attach the disk structure.
176 */ 178 */
177 disk_init(&sc->sc_disk, device_xname(sc->sc_dev), NULL); 179 disk_init(&sc->sc_disk, device_xname(sc->sc_dev), &hp_dkdriver);
178 disk_attach(&sc->sc_disk); 180 disk_attach(&sc->sc_disk);
179 181
180 /* 182 /*
181 * Fake a disklabel to be able to read in the real label. 183 * Fake a disklabel to be able to read in the real label.
182 */ 184 */
183 dl = sc->sc_disk.dk_label; 185 dl = sc->sc_disk.dk_label;
184 186
185 dl->d_secsize = DEV_BSIZE; 187 dl->d_secsize = DEV_BSIZE;
186 dl->d_ntracks = 1; 188 dl->d_ntracks = 1;
187 dl->d_nsectors = 32; 189 dl->d_nsectors = 32;
188 dl->d_secpercyl = 32; 190 dl->d_secpercyl = 32;
189 191
190 /* 192 /*

cvs diff -r1.51 -r1.51.18.1 src/sys/arch/vax/vsa/hdc9224.c (expand / switch to unified diff)

--- src/sys/arch/vax/vsa/hdc9224.c 2010/12/14 23:31:16 1.51
+++ src/sys/arch/vax/vsa/hdc9224.c 2012/12/02 05:46:39 1.51.18.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hdc9224.c,v 1.51 2010/12/14 23:31:16 matt Exp $ */ 1/* $NetBSD: hdc9224.c,v 1.51.18.1 2012/12/02 05:46:39 tls Exp $ */
2/* 2/*
3 * Copyright (c) 1996 Ludd, University of Lule}, Sweden. 3 * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to Ludd by Bertram Barth. 6 * This code is derived from software contributed to Ludd by Bertram Barth.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -41,27 +41,27 @@ @@ -41,27 +41,27 @@
41 * 41 *
42 * Rewritten by Ragge 25 Jun 2000. New features: 42 * Rewritten by Ragge 25 Jun 2000. New features:
43 * - Uses interrupts instead of polling to signal ready. 43 * - Uses interrupts instead of polling to signal ready.
44 * - Can cooperate with the SCSI routines WRT. the DMA area. 44 * - Can cooperate with the SCSI routines WRT. the DMA area.
45 * 45 *
46 * TODO: 46 * TODO:
47 * - Floppy support missing. 47 * - Floppy support missing.
48 * - Bad block forwarding missing. 48 * - Bad block forwarding missing.
49 * - Statistics collection. 49 * - Statistics collection.
50 */ 50 */
51#undef RDDEBUG 51#undef RDDEBUG
52 52
53#include <sys/cdefs.h> 53#include <sys/cdefs.h>
54__KERNEL_RCSID(0, "$NetBSD: hdc9224.c,v 1.51 2010/12/14 23:31:16 matt Exp $"); 54__KERNEL_RCSID(0, "$NetBSD: hdc9224.c,v 1.51.18.1 2012/12/02 05:46:39 tls Exp $");
55 55
56#include <sys/param.h> 56#include <sys/param.h>
57#include <sys/systm.h> 57#include <sys/systm.h>
58#include <sys/buf.h> 58#include <sys/buf.h>
59#include <sys/bufq.h> 59#include <sys/bufq.h>
60#include <sys/cpu.h> 60#include <sys/cpu.h>
61#include <sys/conf.h> 61#include <sys/conf.h>
62#include <sys/device.h> 62#include <sys/device.h>
63#include <sys/disklabel.h> 63#include <sys/disklabel.h>
64#include <sys/disk.h> 64#include <sys/disk.h>
65#include <sys/file.h> 65#include <sys/file.h>
66#include <sys/ioctl.h> 66#include <sys/ioctl.h>
67#include <sys/proc.h> 67#include <sys/proc.h>
@@ -218,26 +218,34 @@ const struct cdevsw rd_cdevsw = { @@ -218,26 +218,34 @@ const struct cdevsw rd_cdevsw = {
218 .d_flag = D_DISK 218 .d_flag = D_DISK
219}; 219};
220 220
221/* At least 0.7 uS between register accesses */ 221/* At least 0.7 uS between register accesses */
222static int rd_dmasize, inq = 0; 222static int rd_dmasize, inq = 0;
223static volatile int u; 223static volatile int u;
224#define WAIT __asm("movl %0,%0;movl %0,%0;movl %0,%0; movl %0,%0" :: "m"(u)) 224#define WAIT __asm("movl %0,%0;movl %0,%0;movl %0,%0; movl %0,%0" :: "m"(u))
225 225
226#define HDC_WREG(x) *(volatile char *)(sc->sc_regs) = (x) 226#define HDC_WREG(x) *(volatile char *)(sc->sc_regs) = (x)
227#define HDC_RREG *(volatile char *)(sc->sc_regs) 227#define HDC_RREG *(volatile char *)(sc->sc_regs)
228#define HDC_WCMD(x) *(volatile char *)(sc->sc_regs + 4) = (x) 228#define HDC_WCMD(x) *(volatile char *)(sc->sc_regs + 4) = (x)
229#define HDC_RSTAT *(volatile char *)(sc->sc_regs + 4) 229#define HDC_RSTAT *(volatile char *)(sc->sc_regs + 4)
230 230
 231static void
 232rdminphys(struct buf *bp)
 233{
 234 if (bp->b_bcount > rd_dmasize)
 235 bp->b_bcount = rd_dmasize;
 236}
 237
 238const struct dkdriver rd_dkdriver = { rdstrategy, rdminphys };
231/* 239/*
232 * new-config's hdcmatch() is similiar to old-config's hdcprobe(),  240 * new-config's hdcmatch() is similiar to old-config's hdcprobe(),
233 * thus we probe for the existence of the controller and reset it. 241 * thus we probe for the existence of the controller and reset it.
234 * NB: we can't initialize the controller yet, since space for hdcsoftc  242 * NB: we can't initialize the controller yet, since space for hdcsoftc
235 * is not yet allocated. Thus we do this in hdcattach()... 243 * is not yet allocated. Thus we do this in hdcattach()...
236 */ 244 */
237int 245int
238hdcmatch(device_t parent, cfdata_t cf, void *aux) 246hdcmatch(device_t parent, cfdata_t cf, void *aux)
239{ 247{
240 struct vsbus_attach_args * const va = aux; 248 struct vsbus_attach_args * const va = aux;
241 volatile char * const hdc_csr = (volatile char *)va->va_addr; 249 volatile char * const hdc_csr = (volatile char *)va->va_addr;
242 int i; 250 int i;
243 251
@@ -291,27 +299,27 @@ hdcattach(device_t parent, device_t self @@ -291,27 +299,27 @@ hdcattach(device_t parent, device_t self
291 sc->sc_dev = self; 299 sc->sc_dev = self;
292 300
293 /* 301 /*
294 * Get interrupt vector, enable instrumentation. 302 * Get interrupt vector, enable instrumentation.
295 */ 303 */
296 scb_vecalloc(va->va_cvec, hdcintr, sc, SCB_ISTACK, &sc->sc_intrcnt); 304 scb_vecalloc(va->va_cvec, hdcintr, sc, SCB_ISTACK, &sc->sc_intrcnt);
297 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL, 305 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
298 device_xname(self), "intr"); 306 device_xname(self), "intr");
299 307
300 sc->sc_regs = vax_map_physmem(va->va_paddr, 1); 308 sc->sc_regs = vax_map_physmem(va->va_paddr, 1);
301 sc->sc_dmabase = (void *)va->va_dmaaddr; 309 sc->sc_dmabase = (void *)va->va_dmaaddr;
302 sc->sc_dmasize = va->va_dmasize; 310 sc->sc_dmasize = va->va_dmasize;
303 sc->sc_intbit = va->va_maskno; 311 sc->sc_intbit = va->va_maskno;
304 rd_dmasize = min(MAXPHYS, sc->sc_dmasize); /* Used in rd_minphys */ 312 rd_dmasize = min(MAXPHYS, sc->sc_dmasize); /* Used in rdminphys */
305 313
306 sc->sc_vd.vd_go = hdc_qstart; 314 sc->sc_vd.vd_go = hdc_qstart;
307 sc->sc_vd.vd_arg = sc; 315 sc->sc_vd.vd_arg = sc;
308 /* 316 /*
309 * Reset controller. 317 * Reset controller.
310 */ 318 */
311 HDC_WCMD(DKC_CMD_RESET); 319 HDC_WCMD(DKC_CMD_RESET);
312 DELAY(1000); 320 DELAY(1000);
313 status = HDC_RSTAT; 321 status = HDC_RSTAT;
314 if (status != (DKC_ST_DONE|DKC_TC_SUCCESS)) { 322 if (status != (DKC_ST_DONE|DKC_TC_SUCCESS)) {
315 aprint_error_dev(self, "RESET failed, status 0x%x\n", status); 323 aprint_error_dev(self, "RESET failed, status 0x%x\n", status);
316 return; 324 return;
317 } 325 }
@@ -355,27 +363,27 @@ rdattach(device_t parent, device_t self, @@ -355,27 +363,27 @@ rdattach(device_t parent, device_t self,
355{ 363{
356 struct hdcsoftc * const sc = device_private(parent); 364 struct hdcsoftc * const sc = device_private(parent);
357 struct rdsoftc * const rd = device_private(self); 365 struct rdsoftc * const rd = device_private(self);
358 struct hdc_attach_args * const ha = aux; 366 struct hdc_attach_args * const ha = aux;
359 struct disklabel *dl; 367 struct disklabel *dl;
360 const char *msg; 368 const char *msg;
361 369
362 rd->sc_dev = self; 370 rd->sc_dev = self;
363 rd->sc_drive = ha->ha_drive; 371 rd->sc_drive = ha->ha_drive;
364 rd->sc_hdc = sc; 372 rd->sc_hdc = sc;
365 /* 373 /*
366 * Initialize and attach the disk structure. 374 * Initialize and attach the disk structure.
367 */ 375 */
368 disk_init(&rd->sc_disk, device_xname(rd->sc_dev), NULL); 376 disk_init(&rd->sc_disk, device_xname(rd->sc_dev), &rd_dkdriver);
369 disk_attach(&rd->sc_disk); 377 disk_attach(&rd->sc_disk);
370 378
371 /* 379 /*
372 * if it's not a floppy then evaluate the on-disk geometry. 380 * if it's not a floppy then evaluate the on-disk geometry.
373 * if necessary correct the label... 381 * if necessary correct the label...
374 */ 382 */
375 rd_readgeom(sc, rd); 383 rd_readgeom(sc, rd);
376 disk_printtype(rd->sc_drive, rd->sc_xbn.media_id); 384 disk_printtype(rd->sc_drive, rd->sc_xbn.media_id);
377 dl = rd->sc_disk.dk_label; 385 dl = rd->sc_disk.dk_label;
378 rdmakelabel(dl, &rd->sc_xbn); 386 rdmakelabel(dl, &rd->sc_xbn);
379 msg = readdisklabel(MAKEDISKDEV(cdevsw_lookup_major(&rd_cdevsw), 387 msg = readdisklabel(MAKEDISKDEV(cdevsw_lookup_major(&rd_cdevsw),
380 device_unit(rd->sc_dev), RAW_PART), 388 device_unit(rd->sc_dev), RAW_PART),
381 rdstrategy, dl, NULL); 389 rdstrategy, dl, NULL);

cvs diff -r1.143 -r1.143.10.1 src/sys/dev/ccd.c (expand / switch to unified diff)

--- src/sys/dev/ccd.c 2011/11/13 23:02:46 1.143
+++ src/sys/dev/ccd.c 2012/12/02 05:46:39 1.143.10.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ccd.c,v 1.143 2011/11/13 23:02:46 christos Exp $ */ 1/* $NetBSD: ccd.c,v 1.143.10.1 2012/12/02 05:46:39 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 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 Jason R. Thorpe, and by Andrew Doran. 8 * by Jason R. Thorpe, 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.
@@ -78,27 +78,27 @@ @@ -78,27 +78,27 @@
78 * sc_stop, sc_bufq and b_resid from master buffers. 78 * sc_stop, sc_bufq and b_resid from master buffers.
79 * 79 *
80 * => a combination of CCDF_INITED, sc_inflight, and sc_iolock is used to 80 * => a combination of CCDF_INITED, sc_inflight, and sc_iolock is used to
81 * serialize I/O and configuration changes. 81 * serialize I/O and configuration changes.
82 * 82 *
83 * => the in-core disk label does not change while the device is open. 83 * => the in-core disk label does not change while the device is open.
84 * 84 *
85 * On memory consumption: ccd fans out I/O requests and so needs to 85 * On memory consumption: ccd fans out I/O requests and so needs to
86 * allocate memory. If the system is desperately low on memory, we 86 * allocate memory. If the system is desperately low on memory, we
87 * single thread I/O. 87 * single thread I/O.
88 */ 88 */
89 89
90#include <sys/cdefs.h> 90#include <sys/cdefs.h>
91__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.143 2011/11/13 23:02:46 christos Exp $"); 91__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.143.10.1 2012/12/02 05:46:39 tls Exp $");
92 92
93#include <sys/param.h> 93#include <sys/param.h>
94#include <sys/systm.h> 94#include <sys/systm.h>
95#include <sys/kernel.h> 95#include <sys/kernel.h>
96#include <sys/proc.h> 96#include <sys/proc.h>
97#include <sys/errno.h> 97#include <sys/errno.h>
98#include <sys/buf.h> 98#include <sys/buf.h>
99#include <sys/kmem.h> 99#include <sys/kmem.h>
100#include <sys/pool.h> 100#include <sys/pool.h>
101#include <sys/module.h> 101#include <sys/module.h>
102#include <sys/namei.h> 102#include <sys/namei.h>
103#include <sys/stat.h> 103#include <sys/stat.h>
104#include <sys/ioctl.h> 104#include <sys/ioctl.h>
@@ -200,26 +200,43 @@ const struct cdevsw ccd_cdevsw = { @@ -200,26 +200,43 @@ const struct cdevsw ccd_cdevsw = {
200 .d_kqfilter = nokqfilter, 200 .d_kqfilter = nokqfilter,
201 .d_flag = D_DISK | D_MPSAFE 201 .d_flag = D_DISK | D_MPSAFE
202}; 202};
203 203
204#ifdef DEBUG 204#ifdef DEBUG
205static void printiinfo(struct ccdiinfo *); 205static void printiinfo(struct ccdiinfo *);
206#endif 206#endif
207 207
208/* Publically visible for the benefit of libkvm and ccdconfig(8). */ 208/* Publically visible for the benefit of libkvm and ccdconfig(8). */
209struct ccd_softc *ccd_softc; 209struct ccd_softc *ccd_softc;
210const int ccd_softc_elemsize = sizeof(struct ccd_softc); 210const int ccd_softc_elemsize = sizeof(struct ccd_softc);
211int numccd = 0; 211int numccd = 0;
212 212
 213static void
 214ccdminphys(struct buf *bp)
 215{
 216 struct ccd_softc *cs;
 217 long xmax;
 218 int unit = ccdunit(bp->b_dev);
 219
 220 cs = &ccd_softc[unit];
 221
 222 xmax = cs->sc_maxphys;
 223
 224 if (bp->b_bcount > xmax)
 225 bp->b_bcount = xmax;
 226}
 227
 228const struct dkdriver ccd_dkdriver = { ccdstrategy, ccdminphys };
 229
213/* 230/*
214 * Called by main() during pseudo-device attachment. All we need 231 * Called by main() during pseudo-device attachment. All we need
215 * to do is allocate enough space for devices to be configured later. 232 * to do is allocate enough space for devices to be configured later.
216 */ 233 */
217void 234void
218ccdattach(int num) 235ccdattach(int num)
219{ 236{
220 struct ccd_softc *cs; 237 struct ccd_softc *cs;
221 int i; 238 int i;
222 239
223 if (num <= 0) { 240 if (num <= 0) {
224#ifdef DIAGNOSTIC 241#ifdef DIAGNOSTIC
225 panic("ccdattach: count <= 0"); 242 panic("ccdattach: count <= 0");
@@ -236,27 +253,27 @@ ccdattach(int num) @@ -236,27 +253,27 @@ ccdattach(int num)
236 253
237 /* Initialize the component buffer pool. */ 254 /* Initialize the component buffer pool. */
238 ccd_cache = pool_cache_init(sizeof(struct ccdbuf), 0, 255 ccd_cache = pool_cache_init(sizeof(struct ccdbuf), 0,
239 0, 0, "ccdbuf", NULL, IPL_BIO, NULL, NULL, NULL); 256 0, 0, "ccdbuf", NULL, IPL_BIO, NULL, NULL, NULL);
240 257
241 /* Initialize per-softc structures. */ 258 /* Initialize per-softc structures. */
242 for (i = 0; i < num; i++) { 259 for (i = 0; i < num; i++) {
243 cs = &ccd_softc[i]; 260 cs = &ccd_softc[i];
244 snprintf(cs->sc_xname, sizeof(cs->sc_xname), "ccd%d", i); 261 snprintf(cs->sc_xname, sizeof(cs->sc_xname), "ccd%d", i);
245 mutex_init(&cs->sc_dvlock, MUTEX_DEFAULT, IPL_NONE); 262 mutex_init(&cs->sc_dvlock, MUTEX_DEFAULT, IPL_NONE);
246 cs->sc_iolock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); 263 cs->sc_iolock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
247 cv_init(&cs->sc_stop, "ccdstop"); 264 cv_init(&cs->sc_stop, "ccdstop");
248 cv_init(&cs->sc_push, "ccdthr"); 265 cv_init(&cs->sc_push, "ccdthr");
249 disk_init(&cs->sc_dkdev, cs->sc_xname, NULL); /* XXX */ 266 disk_init(&cs->sc_dkdev, cs->sc_xname, &ccd_dkdriver);
250 } 267 }
251} 268}
252 269
253static int 270static int
254ccdinit(struct ccd_softc *cs, char **cpaths, struct vnode **vpp, 271ccdinit(struct ccd_softc *cs, char **cpaths, struct vnode **vpp,
255 struct lwp *l) 272 struct lwp *l)
256{ 273{
257 struct ccdcinfo *ci = NULL; 274 struct ccdcinfo *ci = NULL;
258 int ix; 275 int ix;
259 struct vattr va; 276 struct vattr va;
260 struct ccdgeom *ccg = &cs->sc_geom; 277 struct ccdgeom *ccg = &cs->sc_geom;
261 char *tmppath; 278 char *tmppath;
262 int error, path_alloced; 279 int error, path_alloced;
@@ -264,36 +281,38 @@ ccdinit(struct ccd_softc *cs, char **cpa @@ -264,36 +281,38 @@ ccdinit(struct ccd_softc *cs, char **cpa
264 unsigned secsize, maxsecsize; 281 unsigned secsize, maxsecsize;
265 282
266#ifdef DEBUG 283#ifdef DEBUG
267 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) 284 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
268 printf("%s: ccdinit\n", cs->sc_xname); 285 printf("%s: ccdinit\n", cs->sc_xname);
269#endif 286#endif
270 287
271 /* Allocate space for the component info. */ 288 /* Allocate space for the component info. */
272 cs->sc_cinfo = kmem_alloc(cs->sc_nccdisks * sizeof(*cs->sc_cinfo), 289 cs->sc_cinfo = kmem_alloc(cs->sc_nccdisks * sizeof(*cs->sc_cinfo),
273 KM_SLEEP); 290 KM_SLEEP);
274 tmppath = kmem_alloc(MAXPATHLEN, KM_SLEEP); 291 tmppath = kmem_alloc(MAXPATHLEN, KM_SLEEP);
275 292
276 cs->sc_size = 0; 293 cs->sc_size = 0;
 294 cs->sc_maxphys = MACHINE_MAXPHYS;
277 295
278 /* 296 /*
279 * Verify that each component piece exists and record 297 * Verify that each component piece exists and record
280 * relevant information about it. 298 * relevant information about it.
281 */ 299 */
282 maxsecsize = 0; 300 maxsecsize = 0;
283 minsize = 0; 301 minsize = 0;
284 for (ix = 0, path_alloced = 0; ix < cs->sc_nccdisks; ix++) { 302 for (ix = 0, path_alloced = 0; ix < cs->sc_nccdisks; ix++) {
285 ci = &cs->sc_cinfo[ix]; 303 ci = &cs->sc_cinfo[ix];
286 ci->ci_vp = vpp[ix]; 304 ci->ci_vp = vpp[ix];
 305 struct disk *diskp;
287 306
288 /* 307 /*
289 * Copy in the pathname of the component. 308 * Copy in the pathname of the component.
290 */ 309 */
291 memset(tmppath, 0, MAXPATHLEN); /* sanity */ 310 memset(tmppath, 0, MAXPATHLEN); /* sanity */
292 error = copyinstr(cpaths[ix], tmppath, 311 error = copyinstr(cpaths[ix], tmppath,
293 MAXPATHLEN, &ci->ci_pathlen); 312 MAXPATHLEN, &ci->ci_pathlen);
294 if (ci->ci_pathlen == 0) 313 if (ci->ci_pathlen == 0)
295 error = EINVAL; 314 error = EINVAL;
296 if (error) { 315 if (error) {
297#ifdef DEBUG 316#ifdef DEBUG
298 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) 317 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
299 printf("%s: can't copy path, error = %d\n", 318 printf("%s: can't copy path, error = %d\n",
@@ -311,26 +330,31 @@ ccdinit(struct ccd_softc *cs, char **cpa @@ -311,26 +330,31 @@ ccdinit(struct ccd_softc *cs, char **cpa
311 vn_lock(vpp[ix], LK_SHARED | LK_RETRY); 330 vn_lock(vpp[ix], LK_SHARED | LK_RETRY);
312 error = VOP_GETATTR(vpp[ix], &va, l->l_cred); 331 error = VOP_GETATTR(vpp[ix], &va, l->l_cred);
313 VOP_UNLOCK(vpp[ix]); 332 VOP_UNLOCK(vpp[ix]);
314 if (error != 0) { 333 if (error != 0) {
315#ifdef DEBUG 334#ifdef DEBUG
316 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) 335 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
317 printf("%s: %s: getattr failed %s = %d\n", 336 printf("%s: %s: getattr failed %s = %d\n",
318 cs->sc_xname, ci->ci_path, 337 cs->sc_xname, ci->ci_path,
319 "error", error); 338 "error", error);
320#endif 339#endif
321 goto out; 340 goto out;
322 } 341 }
323 ci->ci_dev = va.va_rdev; 342 ci->ci_dev = va.va_rdev;
 343 if ((diskp = disk_find_blk(ci->ci_dev)) == NULL) {
 344 panic("no disk for device %d %d", major(ci->ci_dev),
 345 DISKUNIT(ci->ci_dev));
 346 }
 347 cs->sc_maxphys = MIN(cs->sc_maxphys, disk_maxphys(diskp));
324 348
325 /* 349 /*
326 * Get partition information for the component. 350 * Get partition information for the component.
327 */ 351 */
328 error = getdisksize(vpp[ix], &psize, &secsize); 352 error = getdisksize(vpp[ix], &psize, &secsize);
329 if (error) { 353 if (error) {
330#ifdef DEBUG 354#ifdef DEBUG
331 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) 355 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
332 printf("%s: %s: disksize failed, error = %d\n", 356 printf("%s: %s: disksize failed, error = %d\n",
333 cs->sc_xname, ci->ci_path, error); 357 cs->sc_xname, ci->ci_path, error);
334#endif 358#endif
335 goto out; 359 goto out;
336 } 360 }

cvs diff -r1.32 -r1.32.14.1 src/sys/dev/ccdvar.h (expand / switch to unified diff)

--- src/sys/dev/ccdvar.h 2011/02/08 20:20:26 1.32
+++ src/sys/dev/ccdvar.h 2012/12/02 05:46:39 1.32.14.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ccdvar.h,v 1.32 2011/02/08 20:20:26 rmind Exp $ */ 1/* $NetBSD: ccdvar.h,v 1.32.14.1 2012/12/02 05:46:39 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 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 Jason R. Thorpe. 8 * by Jason R. Thorpe.
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.
@@ -166,26 +166,27 @@ struct ccd_softc { @@ -166,26 +166,27 @@ struct ccd_softc {
166 struct ccdcinfo *sc_cinfo; /* component info */ 166 struct ccdcinfo *sc_cinfo; /* component info */
167 struct ccdiinfo *sc_itable; /* interleave table */ 167 struct ccdiinfo *sc_itable; /* interleave table */
168 struct ccdgeom sc_geom; /* pseudo geometry info */ 168 struct ccdgeom sc_geom; /* pseudo geometry info */
169 char sc_xname[8]; /* XXX external name */ 169 char sc_xname[8]; /* XXX external name */
170 struct disk sc_dkdev; /* generic disk device info */ 170 struct disk sc_dkdev; /* generic disk device info */
171 kmutex_t sc_dvlock; /* lock on device node */ 171 kmutex_t sc_dvlock; /* lock on device node */
172#if defined(_KERNEL) /* XXX ccdconfig(8) refers softc directly using kvm */ 172#if defined(_KERNEL) /* XXX ccdconfig(8) refers softc directly using kvm */
173 struct bufq_state *sc_bufq; /* buffer queue */ 173 struct bufq_state *sc_bufq; /* buffer queue */
174 kmutex_t *sc_iolock; /* lock on I/O start/stop */ 174 kmutex_t *sc_iolock; /* lock on I/O start/stop */
175 kcondvar_t sc_stop; /* when inflight goes zero */ 175 kcondvar_t sc_stop; /* when inflight goes zero */
176 struct lwp *sc_thread; /* for deferred I/O */ 176 struct lwp *sc_thread; /* for deferred I/O */
177 kcondvar_t sc_push; /* for deferred I/O */ 177 kcondvar_t sc_push; /* for deferred I/O */
178 bool sc_zap; /* for deferred I/O */ 178 bool sc_zap; /* for deferred I/O */
 179 size_t sc_maxphys; /* Max I/O size */
179#endif 180#endif
180}; 181};
181 182
182/* sc_flags */ 183/* sc_flags */
183#define CCDF_UNIFORM 0x002 /* use LCCD of sizes for uniform interleave */ 184#define CCDF_UNIFORM 0x002 /* use LCCD of sizes for uniform interleave */
184#define CCDF_NOLABEL 0x004 /* ignore on-disk (raw) disklabel */ 185#define CCDF_NOLABEL 0x004 /* ignore on-disk (raw) disklabel */
185 186
186#define CCDF_INITED 0x010 /* unit has been initialized */ 187#define CCDF_INITED 0x010 /* unit has been initialized */
187#define CCDF_WLABEL 0x020 /* label area is writable */ 188#define CCDF_WLABEL 0x020 /* label area is writable */
188#define CCDF_LABELLING 0x040 /* unit is currently being labelled */ 189#define CCDF_LABELLING 0x040 /* unit is currently being labelled */
189#define CCDF_KLABEL 0x080 /* keep label on close */ 190#define CCDF_KLABEL 0x080 /* keep label on close */
190#define CCDF_VLABEL 0x100 /* label is valid */ 191#define CCDF_VLABEL 0x100 /* label is valid */
191#define CCDF_RLABEL 0x200 /* currently reading label */ 192#define CCDF_RLABEL 0x200 /* currently reading label */

cvs diff -r1.83 -r1.83.2.1 src/sys/dev/fss.c (expand / switch to unified diff)

--- src/sys/dev/fss.c 2012/07/28 16:14:17 1.83
+++ src/sys/dev/fss.c 2012/12/02 05:46:39 1.83.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $ */ 1/* $NetBSD: fss.c,v 1.83.2.1 2012/12/02 05:46:39 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 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 Juergen Hannken-Illjes. 8 * by Juergen Hannken-Illjes.
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.
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * File system snapshot disk driver. 33 * File system snapshot disk driver.
34 * 34 *
35 * Block/character interface to the snapshot of a mounted file system. 35 * Block/character interface to the snapshot of a mounted file system.
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.83.2.1 2012/12/02 05:46:39 tls Exp $");
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/namei.h> 43#include <sys/namei.h>
44#include <sys/proc.h> 44#include <sys/proc.h>
45#include <sys/errno.h> 45#include <sys/errno.h>
46#include <sys/malloc.h> 46#include <sys/malloc.h>
47#include <sys/buf.h> 47#include <sys/buf.h>
48#include <sys/ioctl.h> 48#include <sys/ioctl.h>
49#include <sys/disklabel.h> 49#include <sys/disklabel.h>
50#include <sys/device.h> 50#include <sys/device.h>
51#include <sys/disk.h> 51#include <sys/disk.h>
52#include <sys/stat.h> 52#include <sys/stat.h>
@@ -107,26 +107,39 @@ const struct bdevsw fss_bdevsw = { @@ -107,26 +107,39 @@ const struct bdevsw fss_bdevsw = {
107const struct cdevsw fss_cdevsw = { 107const struct cdevsw fss_cdevsw = {
108 fss_open, fss_close, fss_read, fss_write, fss_ioctl, 108 fss_open, fss_close, fss_read, fss_write, fss_ioctl,
109 nostop, notty, nopoll, nommap, nokqfilter, D_DISK | D_MPSAFE 109 nostop, notty, nopoll, nommap, nokqfilter, D_DISK | D_MPSAFE
110}; 110};
111 111
112static int fss_match(device_t, cfdata_t, void *); 112static int fss_match(device_t, cfdata_t, void *);
113static void fss_attach(device_t, device_t, void *); 113static void fss_attach(device_t, device_t, void *);
114static int fss_detach(device_t, int); 114static int fss_detach(device_t, int);
115 115
116CFATTACH_DECL_NEW(fss, sizeof(struct fss_softc), 116CFATTACH_DECL_NEW(fss, sizeof(struct fss_softc),
117 fss_match, fss_attach, fss_detach, NULL); 117 fss_match, fss_attach, fss_detach, NULL);
118extern struct cfdriver fss_cd; 118extern struct cfdriver fss_cd;
119 119
 120static void
 121fss_minphys(struct buf *bp)
 122{
 123 struct fss_softc *fc = device_lookup_private(&fss_cd, minor(bp->b_dev));
 124
 125 long xmax;
 126 xmax = fc->sc_mount->mnt_maxphys;
 127 if (bp->b_bcount > xmax)
 128 bp->b_bcount = xmax;
 129}
 130
 131const struct dkdriver fss_dkdriver = { fss_strategy, fss_minphys };
 132
120void 133void
121fssattach(int num) 134fssattach(int num)
122{ 135{
123 136
124 mutex_init(&fss_device_lock, MUTEX_DEFAULT, IPL_NONE); 137 mutex_init(&fss_device_lock, MUTEX_DEFAULT, IPL_NONE);
125 if (config_cfattach_attach(fss_cd.cd_name, &fss_ca)) 138 if (config_cfattach_attach(fss_cd.cd_name, &fss_ca))
126 aprint_error("%s: unable to register\n", fss_cd.cd_name); 139 aprint_error("%s: unable to register\n", fss_cd.cd_name);
127} 140}
128 141
129static int 142static int
130fss_match(device_t self, cfdata_t cfdata, void *aux) 143fss_match(device_t self, cfdata_t cfdata, void *aux)
131{ 144{
132 return 1; 145 return 1;
@@ -136,27 +149,27 @@ static void @@ -136,27 +149,27 @@ static void
136fss_attach(device_t parent, device_t self, void *aux) 149fss_attach(device_t parent, device_t self, void *aux)
137{ 150{
138 struct fss_softc *sc = device_private(self); 151 struct fss_softc *sc = device_private(self);
139 152
140 sc->sc_dev = self; 153 sc->sc_dev = self;
141 sc->sc_bdev = NODEV; 154 sc->sc_bdev = NODEV;
142 mutex_init(&sc->sc_slock, MUTEX_DEFAULT, IPL_NONE); 155 mutex_init(&sc->sc_slock, MUTEX_DEFAULT, IPL_NONE);
143 mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); 156 mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
144 cv_init(&sc->sc_work_cv, "fssbs"); 157 cv_init(&sc->sc_work_cv, "fssbs");
145 cv_init(&sc->sc_cache_cv, "cowwait"); 158 cv_init(&sc->sc_cache_cv, "cowwait");
146 bufq_alloc(&sc->sc_bufq, "fcfs", 0); 159 bufq_alloc(&sc->sc_bufq, "fcfs", 0);
147 sc->sc_dkdev = malloc(sizeof(*sc->sc_dkdev), M_DEVBUF, M_WAITOK); 160 sc->sc_dkdev = malloc(sizeof(*sc->sc_dkdev), M_DEVBUF, M_WAITOK);
148 sc->sc_dkdev->dk_info = NULL; 161 sc->sc_dkdev->dk_info = NULL;
149 disk_init(sc->sc_dkdev, device_xname(self), NULL); 162 disk_init(sc->sc_dkdev, device_xname(self), &fss_dkdriver);
150 if (!pmf_device_register(self, NULL, NULL)) 163 if (!pmf_device_register(self, NULL, NULL))
151 aprint_error_dev(self, "couldn't establish power handler\n"); 164 aprint_error_dev(self, "couldn't establish power handler\n");
152 165
153 if (fss_num_attached++ == 0) 166 if (fss_num_attached++ == 0)
154 vfs_hooks_attach(&fss_vfs_hooks); 167 vfs_hooks_attach(&fss_vfs_hooks);
155} 168}
156 169
157static int 170static int
158fss_detach(device_t self, int flags) 171fss_detach(device_t self, int flags)
159{ 172{
160 struct fss_softc *sc = device_private(self); 173 struct fss_softc *sc = device_private(self);
161 174
162 if (sc->sc_flags & FSS_ACTIVE) 175 if (sc->sc_flags & FSS_ACTIVE)

cvs diff -r1.64.2.1 -r1.64.2.2 src/sys/dev/dkwedge/dk.c (expand / switch to unified diff)

--- src/sys/dev/dkwedge/dk.c 2012/11/20 03:02:00 1.64.2.1
+++ src/sys/dev/dkwedge/dk.c 2012/12/02 05:46:40 1.64.2.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dk.c,v 1.64.2.1 2012/11/20 03:02:00 tls Exp $ */ 1/* $NetBSD: dk.c,v 1.64.2.2 2012/12/02 05:46:40 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004, 2005, 2006, 2007 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 Jason R. Thorpe. 8 * by Jason R. Thorpe.
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.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.64.2.1 2012/11/20 03:02:00 tls Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.64.2.2 2012/12/02 05:46:40 tls Exp $");
34 34
35#ifdef _KERNEL_OPT 35#ifdef _KERNEL_OPT
36#include "opt_dkwedge.h" 36#include "opt_dkwedge.h"
37#endif 37#endif
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/proc.h> 41#include <sys/proc.h>
42#include <sys/errno.h> 42#include <sys/errno.h>
43#include <sys/pool.h> 43#include <sys/pool.h>
44#include <sys/ioctl.h> 44#include <sys/ioctl.h>
45#include <sys/disklabel.h> 45#include <sys/disklabel.h>
46#include <sys/disk.h> 46#include <sys/disk.h>
@@ -108,26 +108,28 @@ static dev_type_ioctl(dkioctl); @@ -108,26 +108,28 @@ static dev_type_ioctl(dkioctl);
108static dev_type_strategy(dkstrategy); 108static dev_type_strategy(dkstrategy);
109static dev_type_dump(dkdump); 109static dev_type_dump(dkdump);
110static dev_type_size(dksize); 110static dev_type_size(dksize);
111 111
112const struct bdevsw dk_bdevsw = { 112const struct bdevsw dk_bdevsw = {
113 dkopen, dkclose, dkstrategy, dkioctl, dkdump, dksize, D_DISK 113 dkopen, dkclose, dkstrategy, dkioctl, dkdump, dksize, D_DISK
114}; 114};
115 115
116const struct cdevsw dk_cdevsw = { 116const struct cdevsw dk_cdevsw = {
117 dkopen, dkclose, dkread, dkwrite, dkioctl, 117 dkopen, dkclose, dkread, dkwrite, dkioctl,
118 nostop, notty, nopoll, nommap, nokqfilter, D_DISK 118 nostop, notty, nopoll, nommap, nokqfilter, D_DISK
119}; 119};
120 120
 121const struct dkdriver dk_dkdriver = { dkstrategy, dkminphys };
 122
121static struct dkwedge_softc **dkwedges; 123static struct dkwedge_softc **dkwedges;
122static u_int ndkwedges; 124static u_int ndkwedges;
123static krwlock_t dkwedges_lock; 125static krwlock_t dkwedges_lock;
124 126
125static LIST_HEAD(, dkwedge_discovery_method) dkwedge_discovery_methods; 127static LIST_HEAD(, dkwedge_discovery_method) dkwedge_discovery_methods;
126static krwlock_t dkwedge_discovery_methods_lock; 128static krwlock_t dkwedge_discovery_methods_lock;
127 129
128/* 130/*
129 * dkwedge_match: 131 * dkwedge_match:
130 * 132 *
131 * Autoconfiguration match function for pseudo-device glue. 133 * Autoconfiguration match function for pseudo-device glue.
132 */ 134 */
133static int 135static int
@@ -422,27 +424,27 @@ dkwedge_add(struct dkwedge_info *dkw) @@ -422,27 +424,27 @@ dkwedge_add(struct dkwedge_info *dkw)
422 free(sc, M_DKWEDGE); 424 free(sc, M_DKWEDGE);
423 return (ENOMEM); 425 return (ENOMEM);
424 } 426 }
425 427
426 /* Return the devname to the caller. */ 428 /* Return the devname to the caller. */
427 strlcpy(dkw->dkw_devname, device_xname(sc->sc_dev), 429 strlcpy(dkw->dkw_devname, device_xname(sc->sc_dev),
428 sizeof(dkw->dkw_devname)); 430 sizeof(dkw->dkw_devname));
429 431
430 /* 432 /*
431 * XXX Really ought to make the disk_attach() and the changing 433 * XXX Really ought to make the disk_attach() and the changing
432 * of state to RUNNING atomic. 434 * of state to RUNNING atomic.
433 */ 435 */
434 436
435 disk_init(&sc->sc_dk, device_xname(sc->sc_dev), NULL); 437 disk_init(&sc->sc_dk, device_xname(sc->sc_dev), &dk_dkdriver);
436 disk_blocksize(&sc->sc_dk, DEV_BSIZE << pdk->dk_blkshift); 438 disk_blocksize(&sc->sc_dk, DEV_BSIZE << pdk->dk_blkshift);
437 dkgetproperties(&sc->sc_dk, dkw); 439 dkgetproperties(&sc->sc_dk, dkw);
438 disk_attach(&sc->sc_dk); 440 disk_attach(&sc->sc_dk);
439 441
440 /* Disk wedge is ready for use! */ 442 /* Disk wedge is ready for use! */
441 sc->sc_state = DKW_STATE_RUNNING; 443 sc->sc_state = DKW_STATE_RUNNING;
442 444
443 /* Announce our arrival. */ 445 /* Announce our arrival. */
444 aprint_normal("%s at %s: %s\n", device_xname(sc->sc_dev), pdk->dk_name, 446 aprint_normal("%s at %s: %s\n", device_xname(sc->sc_dev), pdk->dk_name,
445 sc->sc_wname); /* XXX Unicode */ 447 sc->sc_wname); /* XXX Unicode */
446 aprint_normal("%s: %"PRIu64" blocks at %"PRId64", type: %s\n", 448 aprint_normal("%s: %"PRIu64" blocks at %"PRId64", type: %s\n",
447 device_xname(sc->sc_dev), sc->sc_size, sc->sc_offset, sc->sc_ptype); 449 device_xname(sc->sc_dev), sc->sc_size, sc->sc_offset, sc->sc_ptype);
448 450

cvs diff -r1.30.6.1 -r1.30.6.2 src/sys/dev/gpib/rd.c (expand / switch to unified diff)

--- src/sys/dev/gpib/rd.c 2012/11/20 03:02:00 1.30.6.1
+++ src/sys/dev/gpib/rd.c 2012/12/02 05:46:40 1.30.6.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rd.c,v 1.30.6.1 2012/11/20 03:02:00 tls Exp $ */ 1/* $NetBSD: rd.c,v 1.30.6.2 2012/12/02 05:46:40 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996-2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996-2003 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 Jason R. Thorpe. 8 * by Jason R. Thorpe.
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.
@@ -62,27 +62,27 @@ @@ -62,27 +62,27 @@
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * from: Utah $Hdr: rd.c 1.44 92/12/26$ 65 * from: Utah $Hdr: rd.c 1.44 92/12/26$
66 * 66 *
67 * @(#)rd.c 8.2 (Berkeley) 5/19/94 67 * @(#)rd.c 8.2 (Berkeley) 5/19/94
68 */ 68 */
69 69
70/* 70/*
71 * CS80/SS80 disk driver 71 * CS80/SS80 disk driver
72 */ 72 */
73 73
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.30.6.1 2012/11/20 03:02:00 tls Exp $"); 75__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.30.6.2 2012/12/02 05:46:40 tls Exp $");
76 76
77#include <sys/param.h> 77#include <sys/param.h>
78#include <sys/systm.h> 78#include <sys/systm.h>
79#include <sys/buf.h> 79#include <sys/buf.h>
80#include <sys/bufq.h> 80#include <sys/bufq.h>
81#include <sys/callout.h> 81#include <sys/callout.h>
82#include <sys/conf.h> 82#include <sys/conf.h>
83#include <sys/device.h> 83#include <sys/device.h>
84#include <sys/disk.h> 84#include <sys/disk.h>
85#include <sys/disklabel.h> 85#include <sys/disklabel.h>
86#include <sys/endian.h> 86#include <sys/endian.h>
87#include <sys/fcntl.h> 87#include <sys/fcntl.h>
88#include <sys/ioctl.h> 88#include <sys/ioctl.h>
@@ -255,26 +255,39 @@ dev_type_dump(rddump); @@ -255,26 +255,39 @@ dev_type_dump(rddump);
255dev_type_size(rdsize); 255dev_type_size(rdsize);
256 256
257const struct bdevsw rd_bdevsw = { 257const struct bdevsw rd_bdevsw = {
258 rdopen, rdclose, rdstrategy, rdioctl, rddump, rdsize, D_DISK 258 rdopen, rdclose, rdstrategy, rdioctl, rddump, rdsize, D_DISK
259}; 259};
260 260
261const struct cdevsw rd_cdevsw = { 261const struct cdevsw rd_cdevsw = {
262 rdopen, rdclose, rdread, rdwrite, rdioctl, 262 rdopen, rdclose, rdread, rdwrite, rdioctl,
263 nostop, notty, nopoll, nommap, nokqfilter, D_DISK 263 nostop, notty, nopoll, nommap, nokqfilter, D_DISK
264}; 264};
265 265
266extern struct cfdriver rd_cd; 266extern struct cfdriver rd_cd;
267 267
 268static void
 269rdminphys(struct buf *bp)
 270{
 271 struct rd_softc *sc = device_lookup_private(&rd_cd, RDUNIT(bp->b_dev));
 272
 273 long xmax;
 274 xmax = rd->sc_dev->dv_maxphys;
 275 if (bp->b_bcount > xmax)
 276 bp->b_bcount = xmax;
 277}
 278
 279const struct dkdriver rd_dkdriver = { rdstrategy, rdminphys };
 280
268int 281int
269rdlookup(int id, int slave, int punit) 282rdlookup(int id, int slave, int punit)
270{ 283{
271 int i; 284 int i;
272 285
273 for (i = 0; i < numrdidentinfo; i++) { 286 for (i = 0; i < numrdidentinfo; i++) {
274 if (rdidentinfo[i].ri_hwid == id) 287 if (rdidentinfo[i].ri_hwid == id)
275 break; 288 break;
276 } 289 }
277 if (i == numrdidentinfo || punit > rdidentinfo[i].ri_maxunum) 290 if (i == numrdidentinfo || punit > rdidentinfo[i].ri_maxunum)
278 return (-1); 291 return (-1);
279 return (i); 292 return (i);
280} 293}
@@ -380,27 +393,27 @@ rdattach(device_t parent, device_t self, @@ -380,27 +393,27 @@ rdattach(device_t parent, device_t self,
380 */ 393 */
381 printf(": %s\n", rdidentinfo[type].ri_desc); 394 printf(": %s\n", rdidentinfo[type].ri_desc);
382 printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n", 395 printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n",
383 device_xname(sc->sc_dev), rdidentinfo[type].ri_ncyl, 396 device_xname(sc->sc_dev), rdidentinfo[type].ri_ncyl,
384 rdidentinfo[type].ri_ntpc, rdidentinfo[type].ri_nblocks, 397 rdidentinfo[type].ri_ntpc, rdidentinfo[type].ri_nblocks,
385 DEV_BSIZE); 398 DEV_BSIZE);
386 399
387 bufq_alloc(&sc->sc_tab, "fcfs", 0); 400 bufq_alloc(&sc->sc_tab, "fcfs", 0);
388 401
389 /* 402 /*
390 * Initialize and attach the disk structure. 403 * Initialize and attach the disk structure.
391 */ 404 */
392 memset(&sc->sc_dk, 0, sizeof(sc->sc_dk)); 405 memset(&sc->sc_dk, 0, sizeof(sc->sc_dk));
393 disk_init(&sc->sc_dk, device_xname(sc->sc_dev), NULL); 406 disk_init(&sc->sc_dk, device_xname(sc->sc_dev), rd_dkdriver);
394 disk_attach(&sc->sc_dk); 407 disk_attach(&sc->sc_dk);
395 408
396 callout_init(&sc->sc_restart_ch, 0); 409 callout_init(&sc->sc_restart_ch, 0);
397 410
398 if (gpibregister(sc->sc_ic, sc->sc_slave, rdcallback, sc, 411 if (gpibregister(sc->sc_ic, sc->sc_slave, rdcallback, sc,
399 &sc->sc_hdl)) { 412 &sc->sc_hdl)) {
400 aprint_error_dev(sc->sc_dev, "can't register callback\n"); 413 aprint_error_dev(sc->sc_dev, "can't register callback\n");
401 return; 414 return;
402 } 415 }
403 416
404 sc->sc_flags = RDF_ALIVE; 417 sc->sc_flags = RDF_ALIVE;
405#ifdef DEBUG 418#ifdef DEBUG
406 /* always report errors */ 419 /* always report errors */

cvs diff -r1.100.18.1 -r1.100.18.2 src/sys/kern/subr_disk.c (expand / switch to unified diff)

--- src/sys/kern/subr_disk.c 2012/09/12 06:15:34 1.100.18.1
+++ src/sys/kern/subr_disk.c 2012/12/02 05:46:40 1.100.18.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: subr_disk.c,v 1.100.18.1 2012/09/12 06:15:34 tls Exp $ */ 1/* $NetBSD: subr_disk.c,v 1.100.18.2 2012/12/02 05:46:40 tls Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1999, 2000, 2009 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -57,27 +57,27 @@ @@ -57,27 +57,27 @@
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE. 64 * SUCH DAMAGE.
65 * 65 *
66 * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 66 * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94
67 */ 67 */
68 68
69#include <sys/cdefs.h> 69#include <sys/cdefs.h>
70__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.100.18.1 2012/09/12 06:15:34 tls Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.100.18.2 2012/12/02 05:46:40 tls Exp $");
71 71
72#include <sys/param.h> 72#include <sys/param.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
74#include <sys/kmem.h> 74#include <sys/kmem.h>
75#include <sys/buf.h> 75#include <sys/buf.h>
76#include <sys/syslog.h> 76#include <sys/syslog.h>
77#include <sys/disklabel.h> 77#include <sys/disklabel.h>
78#include <sys/conf.h> 78#include <sys/conf.h>
79#include <sys/disk.h> 79#include <sys/disk.h>
80#include <sys/sysctl.h> 80#include <sys/sysctl.h>
81#include <lib/libkern/libkern.h> 81#include <lib/libkern/libkern.h>
82 82
83/* 83/*
@@ -208,26 +208,29 @@ disk_find_blk(dev_t dev) @@ -208,26 +208,29 @@ disk_find_blk(dev_t dev)
208 208
209int disk_maxphys(const struct disk *const diskp) 209int disk_maxphys(const struct disk *const diskp)
210{ 210{
211 struct buf b = { b_bcount: MACHINE_MAXPHYS }; 211 struct buf b = { b_bcount: MACHINE_MAXPHYS };
212 212
213 diskp->dk_driver->d_minphys(&b); 213 diskp->dk_driver->d_minphys(&b);
214 214
215 return b.b_bcount; 215 return b.b_bcount;
216} 216}
217 217
218void 218void
219disk_init(struct disk *diskp, const char *name, const struct dkdriver *driver) 219disk_init(struct disk *diskp, const char *name, const struct dkdriver *driver)
220{ 220{
 221 KASSERT(diskp != NULL);
 222 KASSERT(name != NULL);
 223 KASSERT(driver != NULL);
221 224
222 /* 225 /*
223 * Initialize the wedge-related locks and other fields. 226 * Initialize the wedge-related locks and other fields.
224 */ 227 */
225 mutex_init(&diskp->dk_rawlock, MUTEX_DEFAULT, IPL_NONE); 228 mutex_init(&diskp->dk_rawlock, MUTEX_DEFAULT, IPL_NONE);
226 mutex_init(&diskp->dk_openlock, MUTEX_DEFAULT, IPL_NONE); 229 mutex_init(&diskp->dk_openlock, MUTEX_DEFAULT, IPL_NONE);
227 LIST_INIT(&diskp->dk_wedges); 230 LIST_INIT(&diskp->dk_wedges);
228 diskp->dk_nwedges = 0; 231 diskp->dk_nwedges = 0;
229 diskp->dk_labelsector = LABELSECTOR; 232 diskp->dk_labelsector = LABELSECTOR;
230 disk_blocksize(diskp, DEV_BSIZE); 233 disk_blocksize(diskp, DEV_BSIZE);
231 diskp->dk_name = name; 234 diskp->dk_name = name;
232 diskp->dk_driver = driver; 235 diskp->dk_driver = driver;
233} 236}