Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756156Ab2JaJJo (ORCPT ); Wed, 31 Oct 2012 05:09:44 -0400 Received: from mx0.aculab.com ([213.249.233.131]:34843 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755410Ab2JaJJl convert rfc822-to-8bit (ORCPT ); Wed, 31 Oct 2012 05:09:41 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT Subject: RE: [PATCH v3 06/10] net/macb: clean up ring buffer logic Date: Wed, 31 Oct 2012 08:57:43 -0000 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: thread-topic: [PATCH v3 06/10] net/macb: clean up ring buffer logic thread-index: Ac22y4bV06l7Xom8S7upbHJrp2K/HgAeimDw References: <75eb5df193c504e68ebff7d6a6a88d9a1cc678cb.1351591858.git.nicolas.ferre@atmel.com> From: "David Laight" To: =?Windows-1252?Q?H=E5vard_Skinnemoen?= Cc: "Nicolas Ferre" , , , , , , , , Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1031 Lines: 28 > On Tue, Oct 30, 2012 at 4:12 AM, David Laight wrote: > >> Instead of masking head and tail every time we increment them, just let them > >> wrap through UINT_MAX and mask them when subscripting. Add simple accessor > >> functions to do the subscripting properly to minimize the chances of messing > >> this up. > > ... > >> +static unsigned int macb_tx_ring_avail(struct macb *bp) > >> +{ > >> + return TX_RING_SIZE - (bp->tx_head - bp->tx_tail); > >> +} > > > > That one doesn't look quite right to me. > > Surely it should be masking with 'TX_RING_SIZE - 1' > > Why is that? head and tail can never be more than TX_RING_SIZE apart, > so it shouldn't make any difference. It's a ring buffer (I presume) the pointers can be in either order. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/