OMAP4 CM module functions : timeout error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

checking some patches thru www.kernel.org
I noticed in

/arch/arm/mach-omap2/cm4xxx.c

in function

int omap4_cm_wait_idlest_ready(u32 prcm_mod, u8 prcm_dev_offs)
...
       while (((omap4_cm_read_mod_reg(cm_id, prcm_mod_offs, prcm_dev_offs,
                                      OMAP4_CM_CLKCTRL_DREG) & mask) != 0) &&
              (i++ < MAX_MODULE_READY_TIME))
               udelay(1);

       return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
...

lets assume MAX_MODULE_READY_TIME==1, so it is easier to
see what happens if we exit the loop on the last possible
good read or because i has grown too big(==timeout).

First read&check is not good, i==0, so we delay. i==1.
If second and last read&check is good, we exit loop, i==1, so we return -EBUSY.   WRONG!!
If second and last read&check is not good, we then check i, i is too big so exit loop, i==2, so we return -EBUSY.   OK!!
So if exit while loop because i gets too big,
we have MAX_MODULE_READY_TIME udelay(1) and i has grown
to MAX_MODULE_READY_TIME+1.

Simple correction could be something like

-      return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
+      return (i > MAX_MODULE_READY_TIME) ? -EBUSY : 0;

Signed-off-by: "Juha Leppanen" <juha_motorsportcom@xxxxxxxxxx>

No reply needed to me,
my spam filter will probably eat your reply.

Reported-by: "Juha Leppanen" <juha_motorsportcom@xxxxxxxxxx>
tag would be nice in kernel.org :)
Not so many kernel hackers give credit these days :(

Happy hacking,

Mr. Juha Leppanen
Kuopio, Finland


....................................................................
Luukku Plus -paketilla pääset eroon tila- ja turvallisuusongelmista.
Hanki Luukku Plus ja helpotat elämääsi. http://www.mtv3.fi/luukku
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux