From dd6c1c2a6c0d3ac239b55105b6726a594ba79c60 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 25 Jan 2021 20:03:47 +0000 Subject: [PATCH] Remove redundantcy from the arm GIC softc A struct recource already contains the bus_space_tag_t and bus_space_handle_t. There is no neec to read them and store them again in the drivers softc. Remove them and use the struct resource directly with bus_read_* and bus_write_*. Reviewed by: mmel Differential Revision: https://reviews.freebsd.org/D28339 --- sys/arm/arm/gic.c | 20 +++++++------------- sys/arm/arm/gic.h | 6 ++---- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c index 8fcf511fda08..1851e69644ed 100644 --- a/sys/arm/arm/gic.c +++ b/sys/arm/arm/gic.c @@ -143,16 +143,18 @@ static u_int arm_gic_map[MAXCPU]; static struct arm_gic_softc *gic_sc = NULL; +/* CPU Interface */ #define gic_c_read_4(_sc, _reg) \ - bus_space_read_4((_sc)->gic_c_bst, (_sc)->gic_c_bsh, (_reg)) + bus_read_4((_sc)->gic_res[GIC_RES_CPU], (_reg)) #define gic_c_write_4(_sc, _reg, _val) \ - bus_space_write_4((_sc)->gic_c_bst, (_sc)->gic_c_bsh, (_reg), (_val)) + bus_write_4((_sc)->gic_res[GIC_RES_CPU], (_reg), (_val)) +/* Distributor Interface */ #define gic_d_read_4(_sc, _reg) \ - bus_space_read_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg)) + bus_read_4((_sc)->gic_res[GIC_RES_DIST], (_reg)) #define gic_d_write_1(_sc, _reg, _val) \ - bus_space_write_1((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val)) + bus_write_1((_sc)->gic_res[GIC_RES_DIST], (_reg), (_val)) #define gic_d_write_4(_sc, _reg, _val) \ - bus_space_write_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val)) + bus_write_4((_sc)->gic_res[GIC_RES_DIST], (_reg), (_val)) static inline void gic_irq_unmask(struct arm_gic_softc *sc, u_int irq) @@ -321,14 +323,6 @@ arm_gic_attach(device_t dev) /* Initialize mutex */ mtx_init(&sc->mutex, "GIC lock", NULL, MTX_SPIN); - /* Distributor Interface */ - sc->gic_d_bst = rman_get_bustag(sc->gic_res[0]); - sc->gic_d_bsh = rman_get_bushandle(sc->gic_res[0]); - - /* CPU Interface */ - sc->gic_c_bst = rman_get_bustag(sc->gic_res[1]); - sc->gic_c_bsh = rman_get_bushandle(sc->gic_res[1]); - /* Disable interrupt forwarding to the CPU interface */ gic_d_write_4(sc, GICD_CTLR, 0x00); diff --git a/sys/arm/arm/gic.h b/sys/arm/arm/gic.h index 3df226c2819a..74cfbbee9d5a 100644 --- a/sys/arm/arm/gic.h +++ b/sys/arm/arm/gic.h @@ -49,11 +49,9 @@ struct arm_gic_softc { device_t gic_dev; void * gic_intrhand; struct gic_irqsrc * gic_irqs; +#define GIC_RES_DIST 0 +#define GIC_RES_CPU 1 struct resource * gic_res[3]; - bus_space_tag_t gic_c_bst; - bus_space_tag_t gic_d_bst; - bus_space_handle_t gic_c_bsh; - bus_space_handle_t gic_d_bsh; uint8_t ver; struct mtx mutex; uint32_t nirqs;