The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/radio.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: radio.c,v 1.12 2003/10/19 01:44:48 simonb Exp $ */
    2 /* $OpenBSD: radio.c,v 1.2 2001/12/05 10:27:06 mickey Exp $ */
    3 /* $RuOBSD: radio.c,v 1.7 2001/12/04 06:03:05 tm Exp $ */
    4 
    5 /*
    6  * Copyright (c) 2001 Maxim Tsyplakov <tm@oganer.net>
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
   24  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   26  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
   27  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28  */
   29 
   30 /* This is the /dev/radio driver from OpenBSD */
   31 
   32 #include <sys/cdefs.h>
   33 __KERNEL_RCSID(0, "$NetBSD: radio.c,v 1.12 2003/10/19 01:44:48 simonb Exp $");
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/proc.h>
   38 #include <sys/errno.h>
   39 #include <sys/ioctl.h>
   40 #include <sys/device.h>
   41 #include <sys/vnode.h>
   42 #include <sys/radioio.h>
   43 #include <sys/conf.h>
   44 
   45 #include <dev/radio_if.h>
   46 #include <dev/radiovar.h>
   47 
   48 int     radioprobe(struct device *, struct cfdata *, void *);
   49 void    radioattach(struct device *, struct device *, void *);
   50 int     radioprint(void *, const char *);
   51 int     radiodetach(struct device *, int);
   52 int     radioactivate(struct device *, enum devact);
   53 
   54 CFATTACH_DECL(radio, sizeof(struct radio_softc),
   55     radioprobe, radioattach, radiodetach, radioactivate);
   56 
   57 dev_type_open(radioopen);
   58 dev_type_close(radioclose);
   59 dev_type_ioctl(radioioctl);
   60 
   61 const struct cdevsw radio_cdevsw = {
   62         radioopen, radioclose, noread, nowrite, radioioctl,
   63         nostop, notty, nopoll, nommap, nokqfilter,
   64 };
   65 
   66 extern struct cfdriver radio_cd;
   67 
   68 int
   69 radioprobe(struct device *parent, struct cfdata *match, void *aux)
   70 {
   71         return (1);
   72 }
   73 
   74 void
   75 radioattach(struct device *parent, struct device *self, void *aux)
   76 {
   77         struct radio_softc *sc = (void *)self;
   78         struct radio_attach_args *sa = aux;
   79         struct radio_hw_if *hwp = sa->hwif;
   80         void  *hdlp = sa->hdl;
   81 
   82         printf("\n");
   83         sc->hw_if = hwp;
   84         sc->hw_hdl = hdlp;
   85         sc->sc_dev = parent;
   86 }
   87 
   88 int
   89 radioopen(dev_t dev, int flags, int fmt, struct proc *p)
   90 {
   91         int     unit;
   92         struct radio_softc *sc;
   93 
   94         unit = RADIOUNIT(dev);
   95         if (unit >= radio_cd.cd_ndevs ||
   96             (sc = radio_cd.cd_devs[unit]) == NULL ||
   97              sc->hw_if == NULL)
   98                 return (ENXIO); 
   99 
  100         if (sc->hw_if->open != NULL)
  101                 return (sc->hw_if->open(sc->hw_hdl, flags, fmt, p));
  102         else
  103                 return (0);
  104 }
  105 
  106 int
  107 radioclose(dev_t dev, int flags, int fmt, struct proc *p) 
  108 {
  109         struct radio_softc *sc;
  110 
  111         sc = radio_cd.cd_devs[RADIOUNIT(dev)];
  112 
  113         if (sc->hw_if->close != NULL)
  114                 return (sc->hw_if->close(sc->hw_hdl, flags, fmt, p));
  115         else
  116                 return (0);
  117 }
  118 
  119 int
  120 radioioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
  121 {
  122         struct radio_softc *sc;
  123         int unit, error;
  124 
  125         unit = RADIOUNIT(dev);
  126         if (unit >= radio_cd.cd_ndevs ||
  127             (sc = radio_cd.cd_devs[unit]) == NULL || sc->hw_if == NULL)
  128                 return (ENXIO);
  129 
  130         error = EOPNOTSUPP;
  131         switch (cmd) {
  132         case RIOCGINFO:
  133                 if (sc->hw_if->get_info)
  134                         error = (sc->hw_if->get_info)(sc->hw_hdl,
  135                                         (struct radio_info *)data);
  136                         break;
  137         case RIOCSINFO:
  138                 if (sc->hw_if->set_info)
  139                         error = (sc->hw_if->set_info)(sc->hw_hdl,
  140                                 (struct radio_info *)data);
  141                 break;
  142         case RIOCSSRCH:
  143                 if (sc->hw_if->search)
  144                         error = (sc->hw_if->search)(sc->hw_hdl,
  145                                         *(int *)data);
  146                 break;
  147         default:
  148                 error = EINVAL;
  149         }
  150 
  151         return (error);
  152 }
  153 
  154 /*
  155  * Called from hardware driver. This is where the MI radio driver gets
  156  * probed/attached to the hardware driver
  157  */
  158 struct device *
  159 radio_attach_mi(struct radio_hw_if *rhwp, void *hdlp, struct device *dev)
  160 {
  161         struct radio_attach_args arg;
  162 
  163         arg.hwif = rhwp;
  164         arg.hdl = hdlp;
  165         return (config_found(dev, &arg, radioprint));
  166 }
  167 
  168 int
  169 radioprint(void *aux, const char *pnp)
  170 {
  171         if (pnp != NULL)
  172                 aprint_normal("radio at %s", pnp);
  173         return (UNCONF);
  174 }
  175 
  176 int
  177 radiodetach(struct device *self, int flags)
  178 {
  179         /*struct radio_softc *sc = (struct radio_softc *)self;*/
  180         int maj, mn;
  181 
  182         /* locate the major number */
  183         maj = cdevsw_lookup_major(&radio_cdevsw);
  184 
  185         /* Nuke the vnodes for any open instances (calls close). */
  186         mn = self->dv_unit;
  187         vdevgone(maj, mn, mn, VCHR);
  188 
  189         return (0);
  190 }
  191 
  192 int
  193 radioactivate(struct device *self, enum devact act)
  194 {
  195         struct radio_softc *sc = (struct radio_softc *)self;
  196 
  197         switch (act) {
  198         case DVACT_ACTIVATE:
  199                 return (EOPNOTSUPP);
  200 
  201         case DVACT_DEACTIVATE:
  202                 sc->sc_dying = 1;
  203                 break;
  204         }
  205         return (0);
  206 }

Cache object: 6a7fd89d6d644ae45542974602119b56


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.