On Wed, Nov 21, 2012 at 11:32:46AM +0200, Alexander Shishkin wrote:
> Peter Chen <peter.c...@freescale.com> writes:
> 
> > I can use this API, how can this API consolidate both of the case
> > (<OTGSC_BSV and >OTGSC_AVV)?
> 
> Ok, then how about
> 
> static int hw_wait_reg(struct ci13xxx *ci, enum ci13xxx_regs reg, u32 mask,
>                      u32 value, unsigned long timeout)
> {
>       unsigned long elapse = jiffies + timeout;
> 
>       while (hw_read(ci, reg, mask) != value) {
>               if (time_after(jiffies, elapse)) {
>                       dev_err(ci->dev, "timeout waiting for %08x in %d\n",
>                               mask, reg);
>                       return -ETIMEDOUT;
>               }
>               msleep(20);
>       }
> 
>       return 0;
> }
> 
> with that:
> 
> ret = hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0, CI_VBUS_STABLE_TIMEOUT);
> if (ret) {
>       /* go idle */
> }
> ...
> ret = hw_wait_reg(ci, OP_OTGSC, OTGSC_AVV, OTGSC_AVV,
>                 CI_VBUS_STABLE_TIMEOUT);
> 
> should do the trick.
OK, I will change like above at coming version
> 
> Regards,
> --
> Alex
> 

-- 

Best Regards,
Peter Chen

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to