[PATCH 5/7-V2] bsps/sparc: Make local functions static and add missing prototypes.

Daniel Cederman cederman at gaisler.com
Fri Mar 14 09:10:14 UTC 2014


The PCI and RASTA versions of the uart, spacewire and 1553 drivers directly includes the c-file of the standard versions
of the drivers, but uses a macro to change the name of the driver register function. When the standard version is
used this function should be global, when it is included as part of the PCI and RASTA versions it should be local and
static.
---
 c/src/lib/libbsp/sparc/leon2/pci/pci.c            |    4 ++--
 c/src/lib/libbsp/sparc/leon3/pci/pci.c            |    4 ++--
 c/src/lib/libbsp/sparc/shared/1553/b1553brm.c     |    5 +++++
 c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c |    3 +++
 c/src/lib/libbsp/sparc/shared/can/occan_pci.c     |    2 ++
 c/src/lib/libbsp/sparc/shared/spw/grspw.c         |    5 +++++
 c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c     |    5 +++++
 c/src/lib/libbsp/sparc/shared/uart/apbuart.c      |    5 +++++
 c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c  |    3 +++
 9 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/leon2/pci/pci.c b/c/src/lib/libbsp/sparc/leon2/pci/pci.c
index 2fdacd1..47284c5 100644
--- a/c/src/lib/libbsp/sparc/leon2/pci/pci.c
+++ b/c/src/lib/libbsp/sparc/leon2/pci/pci.c
@@ -231,7 +231,7 @@ rtems_pci_config_t BSP_pci_configuration = {
 };
 
 
-void init_at697_pci(void) {
+static void init_at697_pci(void) {
 
     /* Reset */
     pcic->pciic = 0xffffffff;
@@ -418,7 +418,7 @@ static inline void swap_res(struct pci_res **p1, struct pci_res **p2) {
  *
  *
 */
-void pci_allocate_resources(void) {
+static void pci_allocate_resources(void) {
 
     unsigned int slot, numfuncs, func, id, pos, size, tmp, i, swapped, addr, dev, fn;
     unsigned char header;
diff --git a/c/src/lib/libbsp/sparc/leon3/pci/pci.c b/c/src/lib/libbsp/sparc/leon3/pci/pci.c
index a110067..88b577e 100644
--- a/c/src/lib/libbsp/sparc/leon3/pci/pci.c
+++ b/c/src/lib/libbsp/sparc/leon3/pci/pci.c
@@ -223,7 +223,7 @@ rtems_pci_config_t BSP_pci_configuration = {
 };
 
 
-int init_grpci(void) {
+static int init_grpci(void) {
 
     volatile unsigned int *page0 =  (unsigned volatile int *) PCI_MEM_START;
     uint32_t data;
@@ -333,7 +333,7 @@ static inline void swap_res(struct pci_res **p1, struct pci_res **p2) {
  *
  *
 */
-void pci_allocate_resources(void) {
+static void pci_allocate_resources(void) {
 
     unsigned int slot, numfuncs, func, pos, i, swapped, addr, dev, fn;
     uint32_t id, tmp, size;
diff --git a/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c b/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c
index deec908..6b94756 100644
--- a/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c
+++ b/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c
@@ -30,6 +30,8 @@
 
 #ifndef B1553BRM_PREFIX
  #define B1553BRM_PREFIX(name) b1553brm##name
+#else
+ #define B1553BRM_REGISTER_STATIC
 #endif
 
 /* default to no translation */
@@ -340,6 +342,9 @@ int brm_register_leon3_ramon_asic(void){
 #endif
 #endif
 
+#ifdef B1553BRM_REGISTER_STATIC
+static
+#endif
 int B1553BRM_PREFIX(_register)(struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq)
 {
     rtems_status_code r;
diff --git a/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c
index 3be26b1..2ae4af5 100644
--- a/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c
+++ b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c
@@ -1,3 +1,6 @@
+#include <ambapp.h>
+#include <b1553brm_pci.h>
+
 /* Select PCI driver */
 #define B1553BRM_NO_AMBA
 #define B1553BRM_PCI
diff --git a/c/src/lib/libbsp/sparc/shared/can/occan_pci.c b/c/src/lib/libbsp/sparc/shared/can/occan_pci.c
index a1fecc5..12273c9 100644
--- a/c/src/lib/libbsp/sparc/shared/can/occan_pci.c
+++ b/c/src/lib/libbsp/sparc/shared/can/occan_pci.c
@@ -3,6 +3,8 @@
  */
 #define OCCAN_WORD_REGS
 
+#include <occan_pci.h>
+
 /* Set registered device name */
 #define OCCAN_DEVNAME "/dev/occanpci0"
 #define OCCAN_DEVNAME_NO(devstr,no) ((devstr)[13]='0'+(no))
diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw.c b/c/src/lib/libbsp/sparc/shared/spw/grspw.c
index 55986ba..4e1ed11 100644
--- a/c/src/lib/libbsp/sparc/shared/spw/grspw.c
+++ b/c/src/lib/libbsp/sparc/shared/spw/grspw.c
@@ -58,6 +58,8 @@
 
 #ifndef GRSPW_PREFIX
  #define GRSPW_PREFIX(name) grspw##name
+#else
+ #define GRSPW_REGISTER_STATIC
 #endif
 
 /* default to no translation */
@@ -373,6 +375,9 @@ static rtems_device_driver grspw_control(
 static rtems_driver_address_table grspw_driver = GRSPW_DRIVER_TABLE_ENTRY;
 static struct ambapp_bus *amba_bus;
 
+#ifdef GRSPW_REGISTER_STATIC
+static
+#endif
 int GRSPW_PREFIX(_register)(struct ambapp_bus *bus)
 {
         rtems_status_code r;
diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c
index 2a9a8d6..fce2fa8 100644
--- a/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c
+++ b/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c
@@ -1,3 +1,7 @@
+#include <ambapp.h>
+#include <rtems/libio.h>
+#include <grspw_pci.h>
+
 /* Select PCI driver */
 #define GRSPW_PCI
 
@@ -70,6 +74,7 @@ static inline unsigned int hw_to_cpu(unsigned int addr) {
 #endif
 
 int grspwpci_interrupt_handler(int irq, void *arg);
+
 #include "grspw.c"
 
 /*
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
index 25d0373..db9bb09 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
@@ -34,6 +34,8 @@
 
 #ifndef APBUART_PREFIX
  #define APBUART_PREFIX(name) apbuart##name
+#else
+ #define APBUART_REGISTER_STATIC
 #endif
 
 #if !defined(APBUART_DEVNAME) || !defined(APBUART_DEVNAME_NO)
@@ -323,6 +325,9 @@ static void apbuart_interrupt(apbuart_priv *uart){
 	}
 }
 
+#ifdef APBUART_REGISTER_STATIC
+static
+#endif
 int APBUART_PREFIX(_register)(struct ambapp_bus *bus) {
 	rtems_status_code r;
 	rtems_device_major_number m;
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c
index 63cac35..9ea3967 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c
@@ -1,3 +1,6 @@
+#include <ambapp.h>
+#include <apbuart_pci.h>
+
 #undef DEBUG
 
 /* Set registered device name */
-- 
1.7.9.5




More information about the devel mailing list