1 1.1 nat /* $NetBSD: wsbellmux.c,v 1.1 2017/06/11 03:55:56 nat Exp $ */ 2 1.1 nat /*- 3 1.1 nat * Copyright (c) 2017 Nathanial Sloss <nathanialsloss (at) yahoo.com.au> 4 1.1 nat * All rights reserved. 5 1.1 nat * 6 1.1 nat * Redistribution and use in source and binary forms, with or without 7 1.1 nat * modification, are permitted provided that the following conditions 8 1.1 nat * are met: 9 1.1 nat * 1. Redistributions of source code must retain the above copyright 10 1.1 nat * notice, this list of conditions and the following disclaimer. 11 1.1 nat * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 nat * notice, this list of conditions and the following disclaimer in the 13 1.1 nat * documentation and/or other materials provided with the distribution. 14 1.1 nat * 15 1.1 nat * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 1.1 nat * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 1.1 nat * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 1.1 nat * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 1.1 nat * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 1.1 nat * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 1.1 nat * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 1.1 nat * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 1.1 nat * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 1.1 nat * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 1.1 nat * POSSIBILITY OF SUCH DAMAGE. 26 1.1 nat */ 27 1.1 nat 28 1.1 nat #include <sys/cdefs.h> 29 1.1 nat __KERNEL_RCSID(0, "$NetBSD: wsbellmux.c,v 1.1 2017/06/11 03:55:56 nat Exp $"); 30 1.1 nat 31 1.1 nat #include <sys/param.h> 32 1.1 nat #include <sys/conf.h> 33 1.1 nat #include <sys/types.h> 34 1.1 nat #include <sys/device.h> 35 1.1 nat #include <sys/errno.h> 36 1.1 nat #include <sys/selinfo.h> 37 1.1 nat 38 1.1 nat #include "wsmux.h" 39 1.1 nat 40 1.1 nat #include <dev/wscons/wsconsio.h> 41 1.1 nat #include <dev/wscons/wsbellvar.h> 42 1.1 nat 43 1.1 nat /* 44 1.1 nat * Print function (for parent devices). 45 1.1 nat */ 46 1.1 nat int 47 1.1 nat wsbelldevprint(void *aux, const char *pnp) 48 1.1 nat { 49 1.1 nat 50 1.1 nat if (pnp) 51 1.1 nat aprint_normal("wsbell at %s", pnp); 52 1.1 nat return (UNCONF); 53 1.1 nat } 54 1.1 nat 55 1.1 nat #if NWSMUX > 0 56 1.1 nat int 57 1.1 nat wsbell_add_mux(int unit, struct wsmux_softc *muxsc) 58 1.1 nat { 59 1.1 nat struct wsbell_softc *sc; 60 1.1 nat device_t wsbelldev; 61 1.1 nat cfdriver_t wsbellcd; 62 1.1 nat 63 1.1 nat wsbelldev = device_find_by_driver_unit("wsbell", unit); 64 1.1 nat if (wsbelldev == NULL) 65 1.1 nat return ENXIO; 66 1.1 nat wsbellcd = device_cfdriver(wsbelldev); 67 1.1 nat if (wsbellcd == NULL) 68 1.1 nat return ENXIO; 69 1.1 nat 70 1.1 nat sc = device_lookup_private(wsbellcd, unit); 71 1.1 nat if (sc == NULL) 72 1.1 nat return ENXIO; 73 1.1 nat 74 1.1 nat if (sc->sc_base.me_parent != NULL || sc->sc_base.me_evp != NULL) 75 1.1 nat return (EBUSY); 76 1.1 nat 77 1.1 nat return (wsmux_attach_sc(muxsc, &sc->sc_base)); 78 1.1 nat } 79 1.1 nat #endif 80