Skip to contentSkip to conversation

Possible error in omap16xxcam_set_xclk?

DISCUSSION Matt Callow 1 participant 2 messages Jun 13, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

I've been looking at omap/omap16xxcam.c (with a view to creating an omap1510 equivalent) and have noticed the following:

       int divisor = 1;
       divisor = data->ocp_clk/xclk;
       if ( divisor * xclk < data->ocp_clk)
               ++divisor;

       switch (divisor) {
               case 1:
               case 2:
                       xclk_val = FOSCMOD_TC2_CK2;
                       break;
               case 3:
                       xclk_val = FOSCMOD_TC2_CK3;
                       break;
               case 4:
               case 5:
               case 6:
               case 7:
                       xclk_val = FOSCMOD_TC2_CK4;
                       break;

...

Now, by my reckoning, divisor can only be 1 or 2 when it reaches the case statement. So, should the preceding if statement actually be:

       while ( divisor * xclk < data->ocp_clk)
               ++divisor;

?

regards

Matt Callow

#1 lore raw
Quoted 27 lines · Matt Callow

Hi,

I've been looking at omap/omap16xxcam.c (with a view to creating an omap1510 equivalent) and have noticed the following:

       int divisor = 1;
       divisor = data->ocp_clk/xclk;
       if ( divisor * xclk < data->ocp_clk)
               ++divisor;

       switch (divisor) {
               case 1:
               case 2:
                       xclk_val = FOSCMOD_TC2_CK2;
                       break;
               case 3:
                       xclk_val = FOSCMOD_TC2_CK3;
                       break;
               case 4:
               case 5:
               case 6:
               case 7:
                       xclk_val = FOSCMOD_TC2_CK4;
                       break;

...

Quoted 9 lines

Now, by my reckoning, divisor can only be 1 or 2 when it reaches the case statement. So, should the preceding if statement actually be:

       while ( divisor * xclk < data->ocp_clk)
               ++divisor;

?

No!
Answered my own question! I should have looked more carefully at the code :-)

Matt