From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Date: Wed, 10 Jan 2018 12:08:08 +0800 Subject: [U-Boot] [PATCH V4 05/32] time: add wait_mask_set/clr_timeout helper functions In-Reply-To: References: <20180110030603.27864-1-peng.fan@nxp.com> <20180110030603.27864-6-peng.fan@nxp.com> Message-ID: <20180110040345.GA29758@shlinux2> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, Jan 10, 2018 at 12:19:28PM +0900, Masahiro Yamada wrote: >2018-01-10 12:05 GMT+09:00 Peng Fan : >> Add heler functions for wait mask set/clr. >> >> Signed-off-by: Peng Fan >> Cc: Stefano Babic >> Cc: Fabio Estevam >> Cc: Masahiro Yamada >> Cc: Simon Glass >> --- >> include/linux/delay.h | 4 ++++ >> lib/time.c | 30 ++++++++++++++++++++++++++++++ >> 2 files changed, 34 insertions(+) >> >> diff --git a/include/linux/delay.h b/include/linux/delay.h >> index 3dcd435d0d..b08fcb8c09 100644 >> --- a/include/linux/delay.h >> +++ b/include/linux/delay.h >> @@ -21,4 +21,8 @@ static inline void ndelay(unsigned long nsec) >> udelay(DIV_ROUND_UP(nsec, 1000)); >> } >> >> +int wait_mask_set_timeout(void *addr, u32 mask, u32 timeout); >> + >> +int wait_mask_clr_timeout(void *addr, u32 mask, u32 timeout); >> + >> #endif /* defined(_LINUX_DELAY_H) */ >> diff --git a/lib/time.c b/lib/time.c >> index aed1a091f2..9701287629 100644 >> --- a/lib/time.c >> +++ b/lib/time.c >> @@ -171,3 +171,33 @@ void udelay(unsigned long usec) >> usec -= kv; >> } while(usec); >> } >> + >> +int wait_mask_set_timeout(void *addr, u32 mask, u32 timeout) >> +{ >> + unsigned long long end_tick; >> + u32 val; >> + >> + end_tick = usec_to_tick(timeout) + get_ticks(); >> + do { >> + val = readl(addr); >> + if ((val & mask) == mask) >> + return 0; >> + } while (end_tick > get_ticks()); >> + >> + return -ETIMEDOUT; >> +} >> + >> +int wait_mask_clr_timeout(void *addr, u32 mask, u32 timeout) >> +{ >> + unsigned long long end_tick; >> + u32 val; >> + >> + end_tick = usec_to_tick(timeout) + get_ticks(); >> + do { >> + val = readl(addr); >> + if (!(val & mask)) >> + return 0; >> + } while (end_tick > get_ticks()); >> + >> + return -ETIMEDOUT; >> +} >> -- > >NACK. > >You are re-inventing wheel. > >Please use include/linux/iopoll.h Thanks for the info. I'll discard this patch and fix the usage in the patchset. Thanks, Peng. > > > > > >-- >Best Regards >Masahiro Yamada >_______________________________________________ >U-Boot mailing list >U-Boot at lists.denx.de >https://lists.denx.de/listinfo/u-boot --