From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757029AbZCLQBn (ORCPT ); Thu, 12 Mar 2009 12:01:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752954AbZCLQBe (ORCPT ); Thu, 12 Mar 2009 12:01:34 -0400 Received: from yw-out-2324.google.com ([74.125.46.30]:41978 "EHLO yw-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752866AbZCLQBd convert rfc822-to-8bit (ORCPT ); Thu, 12 Mar 2009 12:01:33 -0400 MIME-Version: 1.0 In-Reply-To: References: <1236699004-1863-1-git-send-email-timur@freescale.com> <20090310153537.5fd5d84d@lxorguk.ukuu.org.uk> <1236729711.7086.28.camel@pasglop> <20090311003756.25ffa6f4@lxorguk.ukuu.org.uk> <20090311165806.0b6838ab@lxorguk.ukuu.org.uk> <49B80081.5060703@freescale.com> <1236808722.7086.66.camel@pasglop> Date: Thu, 12 Mar 2009 10:01:27 -0600 Message-ID: Subject: Re: [PATCH v4] introduce macro spin_event_timeout() From: Grant Likely To: Timur Tabi Cc: Benjamin Herrenschmidt , Alan Cox , linux-kernel@vger.kernel.org, rdreier@cisco.com, jirislaby@gmail.com, peterz@infradead.org, will.newton@gmail.com, hancockrwd@gmail.com, jeremy@goop.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 12, 2009 at 9:54 AM, Timur Tabi wrote: > On Wed, Mar 11, 2009 at 9:45 PM, Grant Likely wrote: > >>> The other big advantage of that approach is that drivers that aren't in >>> an atomic section can use msleep() and allow the kernel to schedule on >>> that processor. >> >> Ack!  I totally agree. > > I'm glad everyone agrees.  I still don't know how to solve the > problem, though.  I came up with this: > > #define spin_until_timeout(condition, timeout)          \ >       for (unsigned long __timeout = jiffies + (timeout);     \ >               (!(condition) && time_after(jiffies, __timeout)); ) > > Now how do I modify this so that the caller knows whether the loop > terminated because of a timeout or the condition became true? How about this: #define spin_until_timeout(condition, timeout, rc) \ for (unsigned long __timeout = jiffies + (timeout); \ (!(rc = (condition)) && time_after(jiffies, __timeout)); ) g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.