[U-Boot] [PATCH V4 05/32] time: add wait_mask_set/clr_timeout helper functions

Peng Fan van.freenix at gmail.com
Wed Jan 10 04:08:08 UTC 2018


On Wed, Jan 10, 2018 at 12:19:28PM +0900, Masahiro Yamada wrote:
>2018-01-10 12:05 GMT+09:00 Peng Fan <peng.fan at nxp.com>:
>> Add heler functions for wait mask set/clr.
>>
>> Signed-off-by: Peng Fan <peng.fan at nxp.com>
>> Cc: Stefano Babic <sbabic at denx.de>
>> Cc: Fabio Estevam <fabio.estevam at nxp.com>
>> Cc: Masahiro Yamada <yamada.masahiro at socionext.com>
>> Cc: Simon Glass <sjg at chromium.org>
>> ---
>>  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

-- 


More information about the U-Boot mailing list