Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758266AbdLRLNn (ORCPT ); Mon, 18 Dec 2017 06:13:43 -0500 Received: from mail-ot0-f194.google.com ([74.125.82.194]:37306 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757677AbdLRLNk (ORCPT ); Mon, 18 Dec 2017 06:13:40 -0500 X-Google-Smtp-Source: ACJfBouu5KDkOoph1V8TSH0zGv27k2FzPXRn4s9otXZexLW3HzIBFAuBdZIvk7yG45H34w/Zgn0D9L1etySxRMb7QdE= MIME-Version: 1.0 In-Reply-To: References: From: Arnd Bergmann Date: Mon, 18 Dec 2017 12:13:39 +0100 X-Google-Sender-Auth: -kQGfh9qAsL8RqN3janZXomPqU0 Message-ID: Subject: Re: [PATCH v4 25/36] nds32: Miscellaneous header files To: Greentime Hu Cc: Greentime , Linux Kernel Mailing List , linux-arch , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Networking , Vincent Chen , DTML , Al Viro , David Howells , Will Deacon , Daniel Lezcano , linux-serial@vger.kernel.org, Geert Uytterhoeven , Linus Walleij , Mark Rutland , Greg KH , ren_guo@c-sky.com, Philippe Ombredanne , Vincent Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1142 Lines: 29 On Mon, Dec 18, 2017 at 7:46 AM, Greentime Hu wrote: > From: Greentime Hu > > This patch introduces some miscellaneous header files. > +static inline void __delay(unsigned long loops) > +{ > + __asm__ __volatile__(".align 2\n" > + "1:\n" > + "\taddi\t%0, %0, -1\n" > + "\tbgtz\t%0, 1b\n" > + :"=r"(loops) > + :"0"(loops)); > +} > + > +static inline void __udelay(unsigned long usecs, unsigned long lpj) > +{ > + usecs *= (unsigned long)(((0x8000000000000000ULL / (500000 / HZ)) + > + 0x80000000ULL) >> 32); > + usecs = (unsigned long)(((unsigned long long)usecs * lpj) >> 32); > + __delay(usecs); > +} Do you have a reliable clocksource that you can read here instead of doing the loop? It's generally preferred to have an accurate delay if at all possible, the delay loop calibration is only for those architectures that don't have any way to observe how much time has passed accurately. Arnd