[PATCH 38/42] DRVMGR: remove struct driver registration func
Daniel Hellstrom
daniel at gaisler.com
Tue Apr 14 11:33:05 UTC 2015
---
.../lib/libbsp/sparc/leon2/startup/bsppredriver.c | 4 +-
c/src/lib/libbsp/sparc/leon3/amba/amba.c | 8 +-
cpukit/libdrvmgr/drvmgr.c | 6 +-
cpukit/libdrvmgr/drvmgr.h | 4 +-
cpukit/libdrvmgr/drvmgr_confdefs.h | 151 +++++--------------
5 files changed, 50 insertions(+), 123 deletions(-)
diff --git a/c/src/lib/libbsp/sparc/leon2/startup/bsppredriver.c b/c/src/lib/libbsp/sparc/leon2/startup/bsppredriver.c
index 2e41b72..ad3694d 100644
--- a/c/src/lib/libbsp/sparc/leon2/startup/bsppredriver.c
+++ b/c/src/lib/libbsp/sparc/leon2/startup/bsppredriver.c
@@ -31,9 +31,9 @@
* the devmgr_confdefs.h. No specifc drivers needed by BSP since IRQ/TIMER/UART
* is not drvmgr drivers.
*/
-struct drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
+drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
{
- {NULL} /* End array with NULL */
+ NULL /* End array with NULL */
};
/* Defines what cores are avilable on the bus in addition to the standard
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
index 87dcf22..60a236c 100644
--- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
+++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
@@ -38,11 +38,11 @@ extern void apbuart_cons_register_drv(void);
/* All drivers included by BSP, this is overridden by the user by including
* the drvmgr_confdefs.h. By default the Timer and UART driver are included.
*/
-struct drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
+drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
{
- {gptimer_register_drv},
- {apbuart_cons_register_drv},
- {NULL} /* End array with NULL */
+ gptimer_register_drv,
+ apbuart_cons_register_drv,
+ NULL /* End array with NULL */
};
/* Driver resources configuration for AMBA root bus. It is declared weak
diff --git a/cpukit/libdrvmgr/drvmgr.c b/cpukit/libdrvmgr/drvmgr.c
index 7e669b4..7c37afd 100644
--- a/cpukit/libdrvmgr/drvmgr.c
+++ b/cpukit/libdrvmgr/drvmgr.c
@@ -83,7 +83,7 @@ void _DRV_Manager_init_level(int level)
*/
void _DRV_Manager_initialization(void)
{
- struct drvmgr_drv_reg_func *drvreg;
+ drvmgr_drv_reg_func *drvreg;
/* drvmgr is already initialized statically by compiler except
* the lock
@@ -92,9 +92,9 @@ void _DRV_Manager_initialization(void)
/* Call driver register functions. */
drvreg = &drvmgr_drivers[0];
- while (drvreg->drv_reg) {
+ while (*drvreg) {
/* Make driver register */
- drvreg->drv_reg();
+ (*drvreg)();
drvreg++;
}
}
diff --git a/cpukit/libdrvmgr/drvmgr.h b/cpukit/libdrvmgr/drvmgr.h
index ca52b3b..194de66 100644
--- a/cpukit/libdrvmgr/drvmgr.h
+++ b/cpukit/libdrvmgr/drvmgr.h
@@ -315,9 +315,7 @@ struct drvmgr_drv {
* for drivers to register themselfs. Used to select drivers available to the
* driver manager.
*/
-struct drvmgr_drv_reg_func {
- void (*drv_reg)(void);
-};
+typedef void (*drvmgr_drv_reg_func)(void);
/*** DRIVER | DEVICE | BUS FUNCTIONS ***/
diff --git a/cpukit/libdrvmgr/drvmgr_confdefs.h b/cpukit/libdrvmgr/drvmgr_confdefs.h
index 65f89e6..89d50e7 100644
--- a/cpukit/libdrvmgr/drvmgr_confdefs.h
+++ b/cpukit/libdrvmgr/drvmgr_confdefs.h
@@ -24,244 +24,173 @@
extern "C" {
#endif
-extern struct drvmgr_drv_reg_func drvmgr_drivers[];
+extern drvmgr_drv_reg_func drvmgr_drivers[];
#ifdef CONFIGURE_INIT
/*** AMBA Plug & Play Drivers ***/
-#define DRIVER_AMBAPP_GAISLER_GPTIMER_REG {gptimer_register_drv}
extern void gptimer_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_APBUART_REG {apbuart_cons_register_drv}
extern void apbuart_cons_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRETH_REG {greth_register_drv}
extern void greth_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRSPW_REG {grspw_register_drv}
extern void grspw_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRSPW2_REG {grspw2_register_drv}
extern void grspw2_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRCAN_REG {grcan_register_drv}
extern void grcan_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_OCCAN_REG {occan_register_drv}
extern void occan_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GR1553B_REG {gr1553_register}
extern void gr1553_register(void);
-
-#define DRIVER_AMBAPP_GAISLER_GR1553BC_REG {gr1553bc_register}
extern void gr1553bc_register(void);
-
-#define DRIVER_AMBAPP_GAISLER_GR1553BM_REG {gr1553bm_register}
extern void gr1553bm_register(void);
-
-#define DRIVER_AMBAPP_GAISLER_GR1553RT_REG {gr1553rt_register}
extern void gr1553rt_register(void);
-
-#define DRIVER_AMBAPP_GAISLER_B1553BRM_REG {b1553brm_register_drv}
extern void b1553brm_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_B1553RT_REG {b1553rt_register_drv}
extern void b1553rt_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRTM_REG {grtm_register_drv}
extern void grtm_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRTC_REG {grtc_register_drv}
extern void grtc_register_drv(void);
-
-#define DRIVER_AMBAPP_MCTRL_REG {mctrl_register_drv}
-extern void mctrl_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_PCIF_REG {pcif_register_drv}
extern void pcif_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRPCI_REG {grpci_register_drv}
extern void grpci_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRPCI2_REG {grpci2_register_drv}
+extern void mctrl_register_drv(void);
extern void grpci2_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_SPICTRL_REG {spictrl_register_drv}
extern void spictrl_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_I2CMST_REG {i2cmst_register_drv}
extern void i2cmst_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRGPIO_REG {grgpio_register_drv}
extern void grgpio_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRPWM_REG {grpwm_register_drv}
extern void grpwm_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRADCDAC_REG {gradcdac_register_drv}
extern void gradcdac_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_SPWCUC_REG {spwcuc_register}
extern void spwcuc_register(void);
-
-#define DRIVER_AMBAPP_GAISLER_GRCTM_REG {grctm_register}
extern void grctm_register(void);
-
-#define DRIVER_AMBAPP_GAISLER_SPW_ROUTER_REG {router_register_drv}
extern void router_register_drv(void);
-
-#define DRIVER_AMBAPP_GAISLER_AHBSTAT_REG {ahbstat_register_drv}
extern void ahbstat_register_drv(void);
/*** LEON2 AMBA Hard coded bus Drivers ***/
-#define DRIVER_LEON2_AT697PCI_REG {at697pci_register_drv}
extern void at697pci_register_drv(void);
-
-#define DRIVER_LEON2_AMBAPP_REG {ambapp_leon2_register}
extern void ambapp_leon2_register(void);
/*** PCI Bus Drivers (PCI Target drivers) ***/
-#define DRIVER_PCI_GR_RASTA_ADCDAC {gr_rasta_adcdac_register_drv}
extern void gr_rasta_adcdac_register_drv(void);
-
-#define DRIVER_PCI_GR_RASTA_IO {gr_rasta_io_register_drv}
extern void gr_rasta_io_register_drv(void);
-
-#define DRIVER_PCI_GR_RASTA_TMTC {gr_rasta_tmtc_register_drv}
extern void gr_rasta_tmtc_register_drv(void);
-
-#define DRIVER_PCI_GR_701 {gr701_register_drv}
extern void gr701_register_drv(void);
-
-#define DRIVER_PCI_GR_TMTC_1553 {gr_tmtc_1553_register_drv}
extern void gr_tmtc_1553_register_drv(void);
-
-#define DRIVER_PCI_GR_RASTA_SPW_ROUTER {gr_rasta_spw_router_register_drv}
extern void gr_rasta_spw_router_register_drv(void);
-
-#define DRIVER_PCI_GR_LEON4_N2X {gr_cpci_leon4_n2x_register_drv}
extern void gr_cpci_leon4_n2x_register_drv(void);
/* CONFIGURE DRIVER MANAGER */
-struct drvmgr_drv_reg_func drvmgr_drivers[] = {
+drvmgr_drv_reg_func drvmgr_drivers[] = {
/*** AMBA Plug & Play Drivers ***/
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
- DRIVER_AMBAPP_GAISLER_GPTIMER_REG,
+ gptimer_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
- DRIVER_AMBAPP_GAISLER_APBUART_REG,
+ apbuart_cons_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH
- DRIVER_AMBAPP_GAISLER_GRETH_REG,
+ greth_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW
- DRIVER_AMBAPP_GAISLER_GRSPW_REG,
+ grspw_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW2
- DRIVER_AMBAPP_GAISLER_GRSPW2_REG,
+ grspw2_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRCAN
- DRIVER_AMBAPP_GAISLER_GRCAN_REG,
+ grcan_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_OCCAN
- DRIVER_AMBAPP_GAISLER_OCCAN_REG,
+ occan_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553B
- DRIVER_AMBAPP_GAISLER_GR1553B_REG,
+ gr1553_register,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553BC
- DRIVER_AMBAPP_GAISLER_GR1553BC_REG,
+ gr1553bc_register,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553BM
- DRIVER_AMBAPP_GAISLER_GR1553BM_REG,
+ gr1553bm_register,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553RT
- DRIVER_AMBAPP_GAISLER_GR1553RT_REG,
+ gr1553rt_register,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_B1553BRM
- DRIVER_AMBAPP_GAISLER_B1553BRM_REG,
+ b1553brm_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_B1553RT
- DRIVER_AMBAPP_GAISLER_B1553RT_REG,
+ b1553rt_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRTM
- DRIVER_AMBAPP_GAISLER_GRTM_REG,
+ grtm_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRTC
- DRIVER_AMBAPP_GAISLER_GRTC_REG,
+ grtc_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_PCIF
- DRIVER_AMBAPP_GAISLER_PCIF_REG,
+ pcif_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPCI
- DRIVER_AMBAPP_GAISLER_GRPCI_REG,
+ grpci_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPCI2
- DRIVER_AMBAPP_GAISLER_GRPCI2_REG,
+ grpci2_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_MCTRL
- DRIVER_AMBAPP_MCTRL_REG,
+ mctrl_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPICTRL
- DRIVER_AMBAPP_GAISLER_SPICTRL_REG,
+ spictrl_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_I2CMST
- DRIVER_AMBAPP_GAISLER_I2CMST_REG,
+ i2cmst_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRGPIO
- DRIVER_AMBAPP_GAISLER_GRGPIO_REG,
+ grgpio_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPWM
- DRIVER_AMBAPP_GAISLER_GRPWM_REG,
+ grpwm_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRADCDAC
- DRIVER_AMBAPP_GAISLER_GRADCDAC_REG,
+ gradcdac_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPWCUC
- DRIVER_AMBAPP_GAISLER_SPWCUC_REG,
+ spwcuc_register,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRCTM
- DRIVER_AMBAPP_GAISLER_GRCTM_REG,
+ grctm_register,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPW_ROUTER
- DRIVER_AMBAPP_GAISLER_SPW_ROUTER_REG,
+ router_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_AHBSTAT
- DRIVER_AMBAPP_GAISLER_AHBSTAT_REG,
+ ahbstat_register_drv,
#endif
/*** LEON2 AMBA Drivers ***/
#ifdef CONFIGURE_DRIVER_LEON2_AT697PCI
- DRIVER_LEON2_AT697PCI_REG,
+ at697pci_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_LEON2_AMBAPP
- DRIVER_LEON2_AMBAPP_REG,
+ ambapp_leon2_register,
#endif
/*** PCI Target Drivers ***/
#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_ADCDAC
- DRIVER_PCI_GR_RASTA_ADCDAC,
+ gr_rasta_adcdac_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_IO
- DRIVER_PCI_GR_RASTA_IO,
+ gr_rasta_io_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_TMTC
- DRIVER_PCI_GR_RASTA_TMTC,
+ gr_rasta_tmtc_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_PCI_GR_701
- DRIVER_PCI_GR_701,
+ gr701_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_PCI_GR_TMTC_1553
- DRIVER_PCI_GR_TMTC_1553,
+ gr_tmtc_1553_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_SPW_ROUTER
- DRIVER_PCI_GR_RASTA_SPW_ROUTER,
+ gr_rasta_spw_router_register_drv,
#endif
#ifdef CONFIGURE_DRIVER_PCI_GR_LEON4_N2X
- DRIVER_PCI_GR_LEON4_N2X,
+ gr_cpci_leon4_n2x_register_drv,
#endif
--
1.7.0.4
More information about the devel
mailing list