From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbeEMWiS (ORCPT ); Sun, 13 May 2018 18:38:18 -0400 Received: from mail-qk0-f182.google.com ([209.85.220.182]:38175 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbeEMWiQ (ORCPT ); Sun, 13 May 2018 18:38:16 -0400 X-Google-Smtp-Source: AB8JxZobc2C3bytn5goKbVHmYMVdhK4CLaSyD8EmHhqim+vGn6toSTGsjNl2J/GL9B7wRZFaA8wVjX9CD6Zl6mHH7ro= MIME-Version: 1.0 In-Reply-To: <20180513140212.3961-1-boris.brezillon@bootlin.com> References: <20180513140212.3961-1-boris.brezillon@bootlin.com> From: Andy Shevchenko Date: Mon, 14 May 2018 01:38:15 +0300 Message-ID: Subject: Re: [PATCH] m68k: Implement ndelay() as an inline function to force type checking/casting To: Boris Brezillon Cc: Geert Uytterhoeven , linux-m68k@vger.kernel.org, David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , "open list:MEMORY TECHNOLOGY..." , Miquel Raynal , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 13, 2018 at 5:02 PM, Boris Brezillon wrote: > ndelay() is supposed to take an unsigned long, but if you define > ndelay() as a macro and the caller pass an unsigned long long instead > of an unsigned long, the unsigned long long to unsigned long cast is > not done and we end up with an "undefined reference to `__udivdi3'" > error at link time. > -#define ndelay(n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000)) > +static inline void ndelay(unsigned long nsec) > +{ > + __delay(DIV_ROUND_UP(nsec * > + ((((HZSCALE) >> 11) * One pair of parens is redundant. > + (loops_per_jiffy >> 11)) >> 6), > + 1000)); Can't you keep as one line as in original? > +} > +#define ndelay(n) ndelay(n) > > #endif /* defined(_M68K_DELAY_H) */ > -- > 2.14.1 > -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHzdL-0007V5-7w for linux-mtd@lists.infradead.org; Sun, 13 May 2018 22:38:28 +0000 Received: by mail-qk0-x22b.google.com with SMTP id s70-v6so8550296qks.13 for ; Sun, 13 May 2018 15:38:16 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20180513140212.3961-1-boris.brezillon@bootlin.com> References: <20180513140212.3961-1-boris.brezillon@bootlin.com> From: Andy Shevchenko Date: Mon, 14 May 2018 01:38:15 +0300 Message-ID: Subject: Re: [PATCH] m68k: Implement ndelay() as an inline function to force type checking/casting To: Boris Brezillon Cc: Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , "open list:MEMORY TECHNOLOGY..." , Miquel Raynal , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Sun, May 13, 2018 at 5:02 PM, Boris Brezillon wrote: > ndelay() is supposed to take an unsigned long, but if you define > ndelay() as a macro and the caller pass an unsigned long long instead > of an unsigned long, the unsigned long long to unsigned long cast is > not done and we end up with an "undefined reference to `__udivdi3'" > error at link time. > -#define ndelay(n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000)) > +static inline void ndelay(unsigned long nsec) > +{ > + __delay(DIV_ROUND_UP(nsec * > + ((((HZSCALE) >> 11) * One pair of parens is redundant. > + (loops_per_jiffy >> 11)) >> 6), > + 1000)); Can't you keep as one line as in original? > +} > +#define ndelay(n) ndelay(n) > > #endif /* defined(_M68K_DELAY_H) */ > -- > 2.14.1 > -- With Best Regards, Andy Shevchenko