diff options
author | marius <marius@FreeBSD.org> | 2005-03-04 16:01:57 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2005-03-04 16:01:57 +0000 |
commit | 9b0e528ff81596f475a663de95cab5058102a540 (patch) | |
tree | c2e7170cd185a2d0aa4961032e0801f83f700e30 /sys/sparc64/fhc | |
parent | ef7b3cc47d9891ce900fa96ee45a96de86c71af6 (diff) | |
download | FreeBSD-src-9b0e528ff81596f475a663de95cab5058102a540.zip FreeBSD-src-9b0e528ff81596f475a663de95cab5058102a540.tar.gz |
Minor changes:
- Use FBSDID.
- Remove unused macro.
- Use auto-generated typedefs for the prototypes of the bus and device
interface functions.
- Terminate the output of device_printf(9) with a newline char.
- Honour the return values of malloc(), OF_getprop(), etc.
- Use __func__ instead of hardcoded function names.
- Print the physical slot number and the board model on attach.
MFC after: 1 month
Diffstat (limited to 'sys/sparc64/fhc')
-rw-r--r-- | sys/sparc64/fhc/fhc.c | 27 | ||||
-rw-r--r-- | sys/sparc64/fhc/fhc_central.c | 13 | ||||
-rw-r--r-- | sys/sparc64/fhc/fhc_nexus.c | 19 | ||||
-rw-r--r-- | sys/sparc64/fhc/fhcvar.h | 19 |
4 files changed, 45 insertions, 33 deletions
diff --git a/sys/sparc64/fhc/fhc.c b/sys/sparc64/fhc/fhc.c index 69e7aab..e6cc2cd 100644 --- a/sys/sparc64/fhc/fhc.c +++ b/sys/sparc64/fhc/fhc.c @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> @@ -46,8 +47,6 @@ #include <sparc64/fhc/fhcvar.h> #include <sparc64/sbus/ofw_sbus.h> -#define INTIGN(map) (((map) & INTMAP_IGN_MASK) >> INTMAP_IGN_SHIFT) - struct fhc_clr { driver_intr_t *fc_func; void *fc_arg; @@ -93,6 +92,11 @@ fhc_attach(device_t dev) sc = device_get_softc(dev); node = sc->sc_node; + if (OF_getprop_alloc(node, "board-model", 1, (void **)&name) != -1) { + device_printf(dev, "board %d, %s\n", sc->sc_board, name); + free(name, M_OFWPROP); + } + for (i = FHC_FANFAIL; i <= FHC_TOD; i++) { bus_space_write_4(sc->sc_bt[i], sc->sc_bh[i], FHC_ICLR, 0x0); bus_space_read_4(sc->sc_bt[i], sc->sc_bh[i], FHC_ICLR); @@ -117,7 +121,7 @@ fhc_attach(device_t dev) sc->sc_nrange = OF_getprop_alloc(node, "ranges", sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges); if (sc->sc_nrange == -1) { - device_printf(dev, "can't get ranges"); + device_printf(dev, "can't get ranges\n"); return (ENXIO); } @@ -126,8 +130,9 @@ fhc_attach(device_t dev) continue; cdev = device_add_child(dev, NULL, -1); if (cdev != NULL) { - fdi = malloc(sizeof(*fdi), M_DEVBUF, - M_WAITOK | M_ZERO); + fdi = malloc(sizeof(*fdi), M_DEVBUF, M_WAITOK | M_ZERO); + if (fdi == NULL) + continue; fdi->fdi_name = name; fdi->fdi_node = child; OF_getprop_alloc(child, "compatible", 1, @@ -196,6 +201,8 @@ fhc_setup_intr(device_t bus, device_t child, struct resource *r, int flags, rid = rman_get_rid(r); fc = malloc(sizeof(*fc), M_DEVBUF, M_WAITOK | M_ZERO); + if (fc == NULL) + return (0); fc->fc_func = func; fc->fc_arg = arg; fc->fc_bt = sc->sc_bt[rid]; @@ -290,7 +297,7 @@ fhc_alloc_resource(device_t bus, device_t child, int type, int *rid, if (rle == NULL) return (NULL); if (rle->res != NULL) - panic("fhc_alloc_resource: resource entry is busy"); + panic("%s: resource entry is busy", __func__); if (isdefault) { start = rle->start; count = ulmax(count, rle->count); @@ -332,9 +339,9 @@ fhc_release_resource(device_t bus, device_t child, int type, int rid, fdi = device_get_ivars(child); rle = resource_list_find(&fdi->fdi_rl, type, rid); if (rle == NULL) - panic("fhc_release_resource: can't find resource"); + panic("%s: can't find resource", __func__); if (rle->res == NULL) - panic("fhc_release_resource: resource entry is not busy"); + panic("%s: resource entry is not busy", __func__); rle->res = NULL; return (error); } diff --git a/sys/sparc64/fhc/fhc_central.c b/sys/sparc64/fhc/fhc_central.c index 50dc669..0fe5eba 100644 --- a/sys/sparc64/fhc/fhc_central.c +++ b/sys/sparc64/fhc/fhc_central.c @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> @@ -45,8 +46,8 @@ #include <sparc64/fhc/fhcvar.h> #include <sparc64/sbus/ofw_sbus.h> -static int fhc_central_probe(device_t dev); -static int fhc_central_attach(device_t dev); +static device_probe_t fhc_central_probe; +static device_attach_t fhc_central_attach; static device_method_t fhc_central_methods[] = { /* Device interface. */ @@ -114,7 +115,7 @@ fhc_central_attach(device_t dev) nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®); if (nreg != FHC_NREG) { - device_printf(dev, "can't get registers"); + device_printf(dev, "can't get registers\n"); return (ENXIO); } for (i = 0; i < nreg; i++) { @@ -124,7 +125,7 @@ fhc_central_attach(device_t dev) sc->sc_memres[i] = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, off, off + size - 1, size, RF_ACTIVE); if (sc->sc_memres[i] == NULL) - panic("fhc_central_attach: can't allocate registers"); + panic("%s: can't allocate registers", __func__); sc->sc_bt[i] = rman_get_bustag(sc->sc_memres[i]); sc->sc_bh[i] = rman_get_bushandle(sc->sc_memres[i]); } diff --git a/sys/sparc64/fhc/fhc_nexus.c b/sys/sparc64/fhc/fhc_nexus.c index 4943329..0ed9751 100644 --- a/sys/sparc64/fhc/fhc_nexus.c +++ b/sys/sparc64/fhc/fhc_nexus.c @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> @@ -46,8 +47,8 @@ #include <sparc64/fhc/fhcreg.h> #include <sparc64/fhc/fhcvar.h> -static int fhc_nexus_probe(device_t dev); -static int fhc_nexus_attach(device_t dev); +static device_probe_t fhc_nexus_probe; +static device_attach_t fhc_nexus_attach; static device_method_t fhc_nexus_methods[] = { /* Device interface. */ @@ -114,7 +115,7 @@ fhc_nexus_attach(device_t dev) reg = nexus_get_reg(dev); nreg = nexus_get_nreg(dev); if (nreg != FHC_NREG) { - device_printf(dev, "wrong number of regs"); + device_printf(dev, "wrong number of regs\n"); return (ENXIO); } for (i = 0; i < nreg; i++) { @@ -124,12 +125,16 @@ fhc_nexus_attach(device_t dev) sc->sc_memres[i] = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, phys, phys + size - 1, size, RF_ACTIVE); if (sc->sc_memres[i] == NULL) - panic("fhc_nexus_attach: can't allocate registers"); + panic("%s: can't allocate registers", __func__); sc->sc_bt[i] = rman_get_bustag(sc->sc_memres[i]); sc->sc_bh[i] = rman_get_bushandle(sc->sc_memres[i]); } - OF_getprop(node, "board#", &sc->sc_board, sizeof(sc->sc_board)); + if (OF_getprop(node, "board#", &sc->sc_board, + sizeof(sc->sc_board)) == -1) { + device_printf(dev, "could not get board number\n"); + return (ENXIO); + } return (fhc_attach(dev)); } diff --git a/sys/sparc64/fhc/fhcvar.h b/sys/sparc64/fhc/fhcvar.h index 5566565..af8539d 100644 --- a/sys/sparc64/fhc/fhcvar.h +++ b/sys/sparc64/fhc/fhcvar.h @@ -43,17 +43,16 @@ struct fhc_softc { int sc_flags; }; -int fhc_probe(device_t dev); -int fhc_attach(device_t dev); +device_probe_t fhc_probe; +device_attach_t fhc_attach; + +bus_print_child_t fhc_print_child; +bus_probe_nomatch_t fhc_probe_nomatch; +bus_setup_intr_t fhc_setup_intr; +bus_teardown_intr_t fhc_teardown_intr; +bus_alloc_resource_t fhc_alloc_resource; +bus_release_resource_t fhc_release_resource; -int fhc_print_child(device_t dev, device_t child); -void fhc_probe_nomatch(device_t dev, device_t child); -int fhc_setup_intr(device_t, device_t, struct resource *, int, driver_intr_t *, - void *, void **); -int fhc_teardown_intr(device_t, device_t, struct resource *, void *); -struct resource *fhc_alloc_resource(device_t, device_t, int, int *, u_long, - u_long, u_long, u_int); -int fhc_release_resource(device_t, device_t, int, int, struct resource *); ofw_bus_get_compat_t fhc_get_compat; ofw_bus_get_model_t fhc_get_model; ofw_bus_get_name_t fhc_get_name; |