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

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


The PCI and RASTA versions of the uart, spacewire and 1553 drivers 
includes the c-files of the standard versions, but uses a macro to 
rename the register function. So when the standard version is used it 
should be public and when it is included as part of the PCI or RASTA 
versions it should be private. I've rewritten the code so that it adds 
static when included. Will post the new version shortly.

On 2014-03-13 16:01, Joel Sherrill wrote:
>
> On 3/13/2014 9:26 AM, Gedare Bloom wrote:
>> On Thu, Mar 13, 2014 at 10:19 AM, Daniel Cederman <cederman at gaisler.com> wrote:
>>> ---
>>>   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_pci.c |   10 ++++++++++
>>>   c/src/lib/libbsp/sparc/shared/can/occan_pci.c     |    2 ++
>>>   c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c     |    6 ++++++
>>>   c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c  |    5 +++++
>>>   6 files changed, 27 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_pci.c b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c
>>> index 3be26b1..25364c9 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
>>> @@ -73,6 +76,13 @@ void (*b1553brm_pci_int_reg)(void *handler, int irq, void *arg) = 0;
>>>
>>>   static void b1553brmpci_interrupt_handler(int irq, void *arg);
>>>
>>> +int b1553brmpci_register(
>>> + struct ambapp_bus *bus,
>>> + unsigned int clksel,
>>> + unsigned int clkdiv,
>>> + unsigned int brm_freq
>>> + );
>>> +
>> Why is this .c file declaring (non-static) functions?
> And why aren't the arguments indented?
>>>   #include "b1553brm.c"
>>>
>>>   /*
>>> 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_pci.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c
>>> index 2a9a8d6..ec3538b 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,8 @@ static inline unsigned int hw_to_cpu(unsigned int addr) {
>>>   #endif
>>>
>>>   int grspwpci_interrupt_handler(int irq, void *arg);
>>> +int grspwpci_register(struct ambapp_bus *bus);
>>> +
>> Same here. These function prototypes should properly be moved to a
>> header file e.g. grspw_pci.h?
> Agreed. If they are private, they should be static. If they are public,
> they should
> be in a .h.
>>>   #include "grspw.c"
>>>
>>>   /*
>>> 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..440f8da 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 */
>>> @@ -21,6 +24,8 @@ void apbuartpci_interrupt_handler(int irq, void *arg);
>>>   /* AMBA Bus is clocked using the PCI clock (33.3MHz) */
>>>   #define SYS_FREQ_HZ 33333333
>>>
>>> +int apbuartpci_register(struct ambapp_bus *bus);
>>> +
>> And here too.
>>
>>>   #include "apbuart.c"
>>>
>>>   int apbuart_pci_register(struct ambapp_bus *bus)
>>> --
>>> 1.7.9.5
>>>
>>> _______________________________________________
>>> rtems-devel mailing list
>>> rtems-devel at rtems.org
>>> http://www.rtems.org/mailman/listinfo/rtems-devel
>> _______________________________________________
>> rtems-devel mailing list
>> rtems-devel at rtems.org
>> http://www.rtems.org/mailman/listinfo/rtems-devel
>



More information about the devel mailing list