[PATCH 02/52] libcpu/powerpc/mpc8xx/clock: Fix warnings and clean up

Joel Sherrill joel.sherrill at oarcorp.com
Wed Oct 8 19:15:53 UTC 2014


---
 c/src/lib/libbsp/powerpc/mbx8xx/clock/p_clock.c | 42 ++++++++++++------
 c/src/lib/libcpu/powerpc/mpc8xx/clock/clock.c   | 58 ++++++++++++-------------
 2 files changed, 55 insertions(+), 45 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/clock/p_clock.c b/c/src/lib/libbsp/powerpc/mbx8xx/clock/p_clock.c
index d55121c..d1fd075 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/clock/p_clock.c
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/clock/p_clock.c
@@ -1,6 +1,9 @@
+/**
+ *  @file
+ *  @brief mbx8xx Clock Tick connection code.
+ */
+
 /*
- *  Clock Tick interrupt conexion code.
- *
  *  COPYRIGHT (c) 1989-1997.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -21,23 +24,32 @@ extern void clockOff (void*);
 extern int clockIsOn(void*);
 extern void Clock_isr(void*);
 
-static rtems_irq_connect_data clockIrqData = {BSP_PERIODIC_TIMER,
-					      (rtems_irq_hdl)Clock_isr,
-                                              0,
-					      (rtems_irq_enable)clockOn,
-					      (rtems_irq_disable)clockOff,
-					      (rtems_irq_is_enabled)clockIsOn};
+static rtems_irq_connect_data clockIrqData = {
+  BSP_PERIODIC_TIMER,
+  (rtems_irq_hdl)Clock_isr,
+  0,
+  (rtems_irq_enable)clockOn,
+  (rtems_irq_disable)clockOff,
+  (rtems_irq_is_enabled)clockIsOn
+};
+
+/*
+ * Prototypes
+ */
+int BSP_get_clock_irq_level(void);
+int BSP_connect_clock_handler(rtems_irq_hdl hdl);
+int BSP_disconnect_clock_handler(void);
 
 int BSP_get_clock_irq_level(void)
 {
   /*
-   * Caution : if you change this, you must change the
+   * Caution: if you change this, you must change the
    * definition of BSP_PERIODIC_TIMER accordingly
    */
   return 6;
 }
 
-int BSP_disconnect_clock_handler (void)
+int BSP_disconnect_clock_handler(void)
 {
   if (!BSP_get_current_rtems_irq_handler(&clockIrqData)) {
      printk("Unable to stop system clock\n");
@@ -46,16 +58,18 @@ int BSP_disconnect_clock_handler (void)
   return BSP_remove_rtems_irq_handler (&clockIrqData);
 }
 
-int BSP_connect_clock_handler (rtems_irq_hdl hdl)
+int BSP_connect_clock_handler(rtems_irq_hdl hdl)
 {
   if (!BSP_get_current_rtems_irq_handler(&clockIrqData)) {
-     printk("Unable to get system clock handler\n");
+    printk("Unable to get system clock handler\n");
     rtems_fatal_error_occurred(1);
   }
-  if (!BSP_remove_rtems_irq_handler (&clockIrqData)) {
-   printk("Unable to remove current system clock handler\n");
+
+  if (!BSP_remove_rtems_irq_handler(&clockIrqData)) {
+    printk("Unable to remove current system clock handler\n");
     rtems_fatal_error_occurred(1);
   }
+
   /*
    * Reinit structure
    */
diff --git a/c/src/lib/libcpu/powerpc/mpc8xx/clock/clock.c b/c/src/lib/libcpu/powerpc/mpc8xx/clock/clock.c
index 6ccc796..0d79883 100644
--- a/c/src/lib/libcpu/powerpc/mpc8xx/clock/clock.c
+++ b/c/src/lib/libcpu/powerpc/mpc8xx/clock/clock.c
@@ -2,7 +2,9 @@
  *
  *  This routine initializes the PIT on the MPC8xx.
  *  The tick frequency is specified by the bsp.
- *
+ */
+
+/*
  *  Author: Jay Monkman (jmonkman at frasca.com)
  *  Copyright (C) 1998 by Frasca International, Inc.
  *
@@ -49,14 +51,16 @@ extern int BSP_disconnect_clock_handler(void);
 extern uint32_t bsp_clicks_per_usec;
 extern uint32_t bsp_clock_speed;
 
-void Clock_exit( void );
-
 /*
- * These are set by clock driver during its init
+ *  Prototypes
  */
-
-rtems_device_major_number rtems_clock_major = ~0;
-rtems_device_minor_number rtems_clock_minor;
+rtems_isr Clock_isr(rtems_vector_number vector);
+void Clock_exit( void );
+void clockOn(void* unused);
+void clockOff(void* unused);
+int clockIsOn(void* unused);
+void Install_clock(rtems_isr_entry clock_isr);
+void ReInstall_clock(rtems_isr_entry new_clock_isr);
 
 /*
  *  ISR Handler
@@ -103,9 +107,9 @@ void clockOn(void* unused)
       mfi_value  = (plprcr_val & (0x000f0000)) >> (31-15);
       pdf_value  = (plprcr_val & (0x00000006)) >> (31-30);
       extclk = (((uint64_t)bsp_clock_speed)
-		* ((pdf_value + 1) * (mfd_value + 1))
-		/ (mfi_value * (mfd_value + 1) + mfn_value)
-		* (1 << s_value));
+          * ((pdf_value + 1) * (mfd_value + 1))
+          / (mfi_value * (mfd_value + 1) + mfn_value)
+          * (1 << s_value));
     }
     else {
       /*
@@ -116,20 +120,21 @@ void clockOn(void* unused)
       extclk    = bsp_clock_speed / (mf_value+1);
     }
     pit_value = (extclk
-		 / 1000
-		 / 4
-		 * rtems_configuration_get_microseconds_per_tick()
-		 / 1000);
+       / 1000
+       / 4
+       * rtems_configuration_get_microseconds_per_tick()
+       / 1000);
     m8xx.sccr |=  (1<<23);
     force_prescaler = true;
   }
   else {
     pit_value = (rtems_configuration_get_microseconds_per_tick() *
-		 bsp_clicks_per_usec);
+                    bsp_clicks_per_usec);
 
     m8xx.sccr &= ~(1<<23);
   }
-if ((pit_value > 0xffff) || force_prescaler){
+
+  if ((pit_value > 0xffff) || force_prescaler) {
     /*
      * try to activate prescaler
      * NOTE: divider generates odd values now...
@@ -152,12 +157,12 @@ if ((pit_value > 0xffff) || force_prescaler){
   m8xx.piscr = M8xx_PISCR_PIRQ(desiredLevel) |
     M8xx_PISCR_PTE | M8xx_PISCR_PS | M8xx_PISCR_PIE;
 }
+
 /*
  * Called via atexit()
  * Remove the clock interrupt handler by setting handler to NULL
  */
-void
-clockOff(void* unused)
+void clockOff(void* unused)
 {
   /* disable PIT and PIT interrupts */
   m8xx.piscr &= ~(M8xx_PISCR_PTE | M8xx_PISCR_PIE);
@@ -165,7 +170,8 @@ clockOff(void* unused)
 
 int clockIsOn(void* unused)
 {
-  if (m8xx.piscr & M8xx_PISCR_PIE) return 1;
+  if (m8xx.piscr & M8xx_PISCR_PIE)
+    return 1;
   return 0;
 }
 
@@ -173,8 +179,7 @@ int clockIsOn(void* unused)
  * Called via atexit()
  * Remove the clock interrupt handler by setting handler to NULL
  */
-void
-Clock_exit(void)
+void Clock_exit(void)
 {
   (void) BSP_disconnect_clock_handler ();
 }
@@ -187,13 +192,11 @@ void Install_clock(rtems_isr_entry clock_isr)
   atexit(Clock_exit);
 }
 
-void
-ReInstall_clock(rtems_isr_entry new_clock_isr)
+void ReInstall_clock(rtems_isr_entry new_clock_isr)
 {
   BSP_connect_clock_handler (new_clock_isr);
 }
 
-
 rtems_device_driver Clock_initialize(
   rtems_device_major_number major,
   rtems_device_minor_number minor,
@@ -202,12 +205,5 @@ rtems_device_driver Clock_initialize(
 {
   Install_clock( Clock_isr );
 
-  /*
-   * make major/minor avail to others such as shared memory driver
-   */
-
-  rtems_clock_major = major;
-  rtems_clock_minor = minor;
-
   return RTEMS_SUCCESSFUL;
 }
-- 
1.9.3




More information about the devel mailing list