Logo Search packages:      
Sourcecode: linux version File versions  Download package

static int chipcHw_divide ( int  num,
int  denom 
) [static]

Local Divide function.

This function does the divide

Returns:
divide value

Definition at line 748 of file chipcHw.c.

Referenced by chipcHw_getClockFrequency(), and chipcHw_setClockFrequency().

{
      int r;
      int t = 1;

      /* Shift denom and t up to the largest value to optimize algorithm */
      /* t contains the units of each divide */
      while ((denom & 0x40000000) == 0) { /* fails if denom=0 */
            denom = denom << 1;
            t = t << 1;
      }

      /* Intialize the result */
      r = 0;

      do {
            /* Determine if there exists a positive remainder */
            if ((num - denom) >= 0) {
                  /* Accumlate t to the result and calculate a new remainder */
                  num = num - denom;
                  r = r + t;
            }
            /* Continue to shift denom and shift t down to 0 */
            denom = denom >> 1;
            t = t >> 1;
      } while (t != 0);

      return r;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index