From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752287AbcGOMuC (ORCPT ); Fri, 15 Jul 2016 08:50:02 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:33723 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbcGOMuA (ORCPT ); Fri, 15 Jul 2016 08:50:00 -0400 MIME-Version: 1.0 In-Reply-To: <20160715122429.GA2620@tetsubishi> References: <1465202936-16832-1-git-send-email-bgolaszewski@baylibre.com> <1465202936-16832-6-git-send-email-bgolaszewski@baylibre.com> <20160715122429.GA2620@tetsubishi> From: Bartosz Golaszewski Date: Fri, 15 Jul 2016 14:49:58 +0200 Message-ID: Subject: Re: [RESEND PATCH 05/14] eeprom: at24: hide the read/write loop behind a macro To: Wolfram Sang Cc: linux-i2c , LKML , Andrew Lunn , Srinivas Kandagatla , Maxime Ripard , GregKH Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-07-15 14:24 GMT+02:00 Wolfram Sang : >> +/* >> + * Both reads and writes fail if the previous write didn't complete yet. This >> + * macro loops a few times waiting at least long enough for one entire page >> + * write to work. >> + * >> + * It takes two parameters: a variable in which the future timeout in jiffies >> + * will be stored and a temporary variable holding the time of the last >> + * iteration of processing the request. Both should be unsigned integers >> + * holding at least 32 bits. >> + */ >> +#define loop_until_timeout(tout, op_time) \ >> + for (tout = jiffies + msecs_to_jiffies(write_timeout), \ >> + op_time = jiffies; \ >> + time_before(op_time, tout); \ >> + usleep_range(1000, 1500), op_time = jiffies) > > There is one subtle change coming with this change: the do-while loop is > guaranteed to run at least once while the for-loop doesn't. > While it's technically possible, it will never happen as long as write_timeout is set to some sensible value. Thanks, Bartosz