Sun Dec 6 23:14:05 2009 UTC ()
Simplify device-activation hooks.


(dyoung)
diff -r1.29 -r1.30 src/sys/dev/pci/ifpci.c
diff -r1.18 -r1.19 src/sys/dev/pci/ifpci2.c
diff -r1.36 -r1.37 src/sys/dev/pci/isic_pci.c

cvs diff -r1.29 -r1.30 src/sys/dev/pci/Attic/ifpci.c (expand / switch to unified diff)

--- src/sys/dev/pci/Attic/ifpci.c 2009/11/26 15:17:10 1.29
+++ src/sys/dev/pci/Attic/ifpci.c 2009/12/06 23:14:05 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ifpci.c,v 1.29 2009/11/26 15:17:10 njoly Exp $ */ 1/* $NetBSD: ifpci.c,v 1.30 2009/12/06 23:14:05 dyoung Exp $ */
2/* 2/*
3 * Copyright (c) 1999 Gary Jennejohn. All rights reserved. 3 * Copyright (c) 1999 Gary Jennejohn. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
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. Neither the name of the author nor the names of any co-contributors 14 * 3. Neither the name of the author nor the names of any co-contributors
@@ -26,34 +26,34 @@ @@ -26,34 +26,34 @@
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 *--------------------------------------------------------------------------- 32 *---------------------------------------------------------------------------
33 * a lot of code was borrowed from i4b_bchan.c and i4b_hscx.c 33 * a lot of code was borrowed from i4b_bchan.c and i4b_hscx.c
34 *--------------------------------------------------------------------------- 34 *---------------------------------------------------------------------------
35 * 35 *
36 * Fritz!Card PCI driver 36 * Fritz!Card PCI driver
37 * ------------------------------------------------ 37 * ------------------------------------------------
38 * 38 *
39 * $Id: ifpci.c,v 1.29 2009/11/26 15:17:10 njoly Exp $ 39 * $Id: ifpci.c,v 1.30 2009/12/06 23:14:05 dyoung Exp $
40 * 40 *
41 * last edit-date: [Fri Jan 5 11:38:58 2001] 41 * last edit-date: [Fri Jan 5 11:38:58 2001]
42 * 42 *
43 *---------------------------------------------------------------------------*/ 43 *---------------------------------------------------------------------------*/
44 44
45#include <sys/cdefs.h> 45#include <sys/cdefs.h>
46__KERNEL_RCSID(0, "$NetBSD: ifpci.c,v 1.29 2009/11/26 15:17:10 njoly Exp $"); 46__KERNEL_RCSID(0, "$NetBSD: ifpci.c,v 1.30 2009/12/06 23:14:05 dyoung Exp $");
47 47
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/kernel.h> 51#include <sys/kernel.h>
52#include <sys/systm.h> 52#include <sys/systm.h>
53#include <sys/mbuf.h> 53#include <sys/mbuf.h>
54 54
55#include <sys/bus.h> 55#include <sys/bus.h>
56#include <sys/device.h> 56#include <sys/device.h>
57 57
58#include <sys/socket.h> 58#include <sys/socket.h>
59#include <net/if.h> 59#include <net/if.h>
@@ -402,43 +402,37 @@ ifpci_detach(device_t self, int flags) @@ -402,43 +402,37 @@ ifpci_detach(device_t self, int flags)
402 struct ifpci_softc *psc = device_private(self); 402 struct ifpci_softc *psc = device_private(self);
403 403
404 bus_space_unmap(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size); 404 bus_space_unmap(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size);
405 bus_space_free(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size); 405 bus_space_free(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size);
406 pci_intr_disestablish(psc->sc_pc, psc->sc_ih); 406 pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
407 407
408 return (0); 408 return (0);
409} 409}
410 410
411int 411int
412ifpci_activate(device_t self, enum devact act) 412ifpci_activate(device_t self, enum devact act)
413{ 413{
414 struct ifpci_softc *psc = device_private(self); 414 struct ifpci_softc *psc = device_private(self);
415 int error = 0, s; 
416 415
417 s = splnet(); 
418 switch (act) { 416 switch (act) {
419 case DVACT_ACTIVATE: 
420 error = EOPNOTSUPP; 
421 break; 
422 
423 case DVACT_DEACTIVATE: 417 case DVACT_DEACTIVATE:
424 psc->sc_isic.sc_intr_valid = ISIC_INTR_DYING; 418 psc->sc_isic.sc_intr_valid = ISIC_INTR_DYING;
425 isdn_layer2_status_ind(&psc->sc_isic.sc_l2, psc->sc_isic.sc_l3token, STI_ATTACH, 0); 419 isdn_layer2_status_ind(&psc->sc_isic.sc_l2, psc->sc_isic.sc_l3token, STI_ATTACH, 0);
426 isdn_detach_isdnif(psc->sc_isic.sc_l3token); 420 isdn_detach_isdnif(psc->sc_isic.sc_l3token);
427 psc->sc_isic.sc_l3token = NULL; 421 psc->sc_isic.sc_l3token = NULL;
428 break; 422 return 0;
 423 default:
 424 return EOPNOTSUPP;
429 } 425 }
430 splx(s); 
431 return (error); 
432} 426}
433 427
434/*---------------------------------------------------------------------------* 428/*---------------------------------------------------------------------------*
435 * AVM read fifo routines 429 * AVM read fifo routines
436 *---------------------------------------------------------------------------*/ 430 *---------------------------------------------------------------------------*/
437 431
438static void 432static void
439avma1pp_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) 433avma1pp_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size)
440{ 434{
441 switch (what) { 435 switch (what) {
442 case ISIC_WHAT_ISAC: 436 case ISIC_WHAT_ISAC:
443 bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, ISAC_FIFO); 437 bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, ISAC_FIFO);
444 bus_space_read_multi_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET, buf, size); 438 bus_space_read_multi_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET, buf, size);

cvs diff -r1.18 -r1.19 src/sys/dev/pci/Attic/ifpci2.c (expand / switch to unified diff)

--- src/sys/dev/pci/Attic/ifpci2.c 2009/11/26 15:17:10 1.18
+++ src/sys/dev/pci/Attic/ifpci2.c 2009/12/06 23:14:05 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ifpci2.c,v 1.18 2009/11/26 15:17:10 njoly Exp $ */ 1/* $NetBSD: ifpci2.c,v 1.19 2009/12/06 23:14:05 dyoung Exp $ */
2/* 2/*
3 * Copyright (c) 1999 Gary Jennejohn. All rights reserved. 3 * Copyright (c) 1999 Gary Jennejohn. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
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. Neither the name of the author nor the names of any co-contributors 14 * 3. Neither the name of the author nor the names of any co-contributors
@@ -26,34 +26,34 @@ @@ -26,34 +26,34 @@
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 *--------------------------------------------------------------------------- 32 *---------------------------------------------------------------------------
33 * a lot of code was borrowed from i4b_bchan.c and i4b_hscx.c 33 * a lot of code was borrowed from i4b_bchan.c and i4b_hscx.c
34 *--------------------------------------------------------------------------- 34 *---------------------------------------------------------------------------
35 * 35 *
36 * Fritz!Card PCI driver 36 * Fritz!Card PCI driver
37 * ------------------------------------------------ 37 * ------------------------------------------------
38 * 38 *
39 * $Id: ifpci2.c,v 1.18 2009/11/26 15:17:10 njoly Exp $ 39 * $Id: ifpci2.c,v 1.19 2009/12/06 23:14:05 dyoung Exp $
40 * 40 *
41 * last edit-date: [Fri Jan 5 11:38:58 2001] 41 * last edit-date: [Fri Jan 5 11:38:58 2001]
42 * 42 *
43 *---------------------------------------------------------------------------*/ 43 *---------------------------------------------------------------------------*/
44 44
45#include <sys/cdefs.h> 45#include <sys/cdefs.h>
46__KERNEL_RCSID(0, "$NetBSD: ifpci2.c,v 1.18 2009/11/26 15:17:10 njoly Exp $"); 46__KERNEL_RCSID(0, "$NetBSD: ifpci2.c,v 1.19 2009/12/06 23:14:05 dyoung Exp $");
47 47
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/kernel.h> 51#include <sys/kernel.h>
52#include <sys/systm.h> 52#include <sys/systm.h>
53#include <sys/mbuf.h> 53#include <sys/mbuf.h>
54 54
55#include <sys/bus.h> 55#include <sys/bus.h>
56#include <sys/device.h> 56#include <sys/device.h>
57 57
58#include <sys/socket.h> 58#include <sys/socket.h>
59#include <net/if.h> 59#include <net/if.h>
@@ -361,43 +361,37 @@ ifpci2_detach(device_t self, int flags) @@ -361,43 +361,37 @@ ifpci2_detach(device_t self, int flags)
361 struct ifpci_softc *psc = device_private(self); 361 struct ifpci_softc *psc = device_private(self);
362 362
363 bus_space_unmap(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size); 363 bus_space_unmap(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size);
364 bus_space_free(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size); 364 bus_space_free(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size);
365 pci_intr_disestablish(psc->sc_pc, psc->sc_ih); 365 pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
366 366
367 return (0); 367 return (0);
368} 368}
369 369
370int 370int
371ifpci2_activate(device_t self, enum devact act) 371ifpci2_activate(device_t self, enum devact act)
372{ 372{
373 struct ifpci_softc *psc = device_private(self); 373 struct ifpci_softc *psc = device_private(self);
374 int error = 0, s; 
375 374
376 s = splnet(); 
377 switch (act) { 375 switch (act) {
378 case DVACT_ACTIVATE: 
379 error = EOPNOTSUPP; 
380 break; 
381 
382 case DVACT_DEACTIVATE: 376 case DVACT_DEACTIVATE:
383 psc->sc_isic.sc_intr_valid = ISIC_INTR_DYING; 377 psc->sc_isic.sc_intr_valid = ISIC_INTR_DYING;
384 isdn_layer2_status_ind(&psc->sc_isic.sc_l2, psc->sc_isic.sc_l3token, STI_ATTACH, 0); 378 isdn_layer2_status_ind(&psc->sc_isic.sc_l2, psc->sc_isic.sc_l3token, STI_ATTACH, 0);
385 isdn_detach_isdnif(psc->sc_isic.sc_l3token); 379 isdn_detach_isdnif(psc->sc_isic.sc_l3token);
386 psc->sc_isic.sc_l3token = NULL; 380 psc->sc_isic.sc_l3token = NULL;
387 break; 381 return 0;
 382 default:
 383 return EOPNOTSUPP;
388 } 384 }
389 splx(s); 
390 return (error); 
391} 385}
392 386
393/*---------------------------------------------------------------------------* 387/*---------------------------------------------------------------------------*
394 * AVM read fifo routines 388 * AVM read fifo routines
395 *---------------------------------------------------------------------------*/ 389 *---------------------------------------------------------------------------*/
396 390
397static void 391static void
398avma1pp2_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) 392avma1pp2_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size)
399{ 393{
400 int i; 394 int i;
401 395
402 switch (what) { 396 switch (what) {
403 case ISIC_WHAT_ISAC: 397 case ISIC_WHAT_ISAC:

cvs diff -r1.36 -r1.37 src/sys/dev/pci/Attic/isic_pci.c (expand / switch to unified diff)

--- src/sys/dev/pci/Attic/isic_pci.c 2009/11/26 15:17:10 1.36
+++ src/sys/dev/pci/Attic/isic_pci.c 2009/12/06 23:14:05 1.37
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: isic_pci.c,v 1.36 2009/11/26 15:17:10 njoly Exp $ */ 1/* $NetBSD: isic_pci.c,v 1.37 2009/12/06 23:14:05 dyoung Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002 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 Martin Husemann <martin@NetBSD.org>. 8 * by Martin Husemann <martin@NetBSD.org>.
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: isic_pci.c,v 1.36 2009/11/26 15:17:10 njoly Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: isic_pci.c,v 1.37 2009/12/06 23:14:05 dyoung Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/errno.h> 36#include <sys/errno.h>
37#include <sys/syslog.h> 37#include <sys/syslog.h>
38#include <sys/device.h> 38#include <sys/device.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40#include <net/if.h> 40#include <net/if.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/malloc.h> 42#include <sys/malloc.h>
43#include <sys/callout.h> 43#include <sys/callout.h>
44 44
45#include <sys/cpu.h> 45#include <sys/cpu.h>
46#include <sys/intr.h> 46#include <sys/intr.h>
@@ -303,29 +303,23 @@ isic_pci_detach(device_t self, int flags @@ -303,29 +303,23 @@ isic_pci_detach(device_t self, int flags
303 struct pci_isic_softc *psc = device_private(self); 303 struct pci_isic_softc *psc = device_private(self);
304 304
305 bus_space_unmap(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size); 305 bus_space_unmap(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size);
306 bus_space_free(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size); 306 bus_space_free(psc->sc_isic.sc_maps[0].t, psc->sc_isic.sc_maps[0].h, psc->sc_size);
307 pci_intr_disestablish(psc->sc_pc, psc->sc_ih); 307 pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
308 308
309 return (0); 309 return (0);
310} 310}
311 311
312static int 312static int
313isic_pci_activate(device_t self, enum devact act) 313isic_pci_activate(device_t self, enum devact act)
314{ 314{
315 struct pci_isic_softc *psc = device_private(self); 315 struct pci_isic_softc *psc = device_private(self);
316 int error = 0, s; 
317 316
318 s = splnet(); 
319 switch (act) { 317 switch (act) {
320 case DVACT_ACTIVATE: 
321 error = EOPNOTSUPP; 
322 break; 
323 
324 case DVACT_DEACTIVATE: 318 case DVACT_DEACTIVATE:
325 psc->sc_isic.sc_intr_valid = ISIC_INTR_DYING; 319 psc->sc_isic.sc_intr_valid = ISIC_INTR_DYING;
326 isic_detach_bri(&psc->sc_isic); 320 isic_detach_bri(&psc->sc_isic);
327 break; 321 return 0;
 322 default:
 323 return EOPNOTSUPP;
328 } 324 }
329 splx(s); 
330 return (error); 
331} 325}