From owner-freebsd-embedded@FreeBSD.ORG Fri Sep 6 02:20:48 2013 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 647361E7; Fri, 6 Sep 2013 02:20:48 +0000 (UTC) (envelope-from lists.br@gmail.com) Received: from mail-wi0-x235.google.com (mail-wi0-x235.google.com [IPv6:2a00:1450:400c:c05::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9E7092E32; Fri, 6 Sep 2013 02:20:47 +0000 (UTC) Received: by mail-wi0-f181.google.com with SMTP id c10so293201wiw.2 for ; Thu, 05 Sep 2013 19:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=yHZftZgAQydCiMSwkZzmEUfKOZTV0C9Zp0BrcpmhCz8=; b=GS/pL9qQamJc35XgW2Q1YJfiw6iUyHPmCOLpVVyR4jKzCyTtIu/U0YXv3FbUgs8d/o sgC9WhatdUv6RnggXRB8mcWcny6U+OQOxy1QWweqD2ZnRo3PBNq91nKX6P1ErrVYLU1i 2fOjH6FoCDtjkwvDs9fe70XGMs9cFDrVtF63xmt+yfsmJidoqXRoxvNbZaKC00u/VBxs 0GQ3UBkwosiYBs4aQcm2WBL+rneNiifcE/GxrOifwGr2xnHyVesAkhDfv06AZ6+I9etF JdknU1zgSD0ZsCVnQh5xqLIfG8XHkraLEbk2Y9Lo+R6Bdb/VaE7jJNuiOEsTx80LXZm0 /ffg== MIME-Version: 1.0 X-Received: by 10.194.178.166 with SMTP id cz6mr51717wjc.53.1378434046007; Thu, 05 Sep 2013 19:20:46 -0700 (PDT) Received: by 10.216.75.140 with HTTP; Thu, 5 Sep 2013 19:20:45 -0700 (PDT) In-Reply-To: References: <1378420702.1647.18.camel@localhost> <1378421252.1647.21.camel@localhost> Date: Thu, 5 Sep 2013 23:20:45 -0300 Message-ID: Subject: Re: off by one error, maxpins From: Luiz Otavio O Souza To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: freebsd-embedded X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Sep 2013 02:20:48 -0000 Yes, please commit it. And by the way... There is another bug in that code, the gpio driver automatically adjust itself to the number of GPIO pins available on SoC: ar71xx_gpiovar.h:#define AR71XX_GPIO_PINS 12 ar71xx_gpiovar.h:#define AR724X_GPIO_PINS 18 ar71xx_gpiovar.h:#define AR91XX_GPIO_PINS 22 ar933xreg.h:#define AR933X_GPIO_COUNT 30 ar934xreg.h:#define AR934X_GPIO_COUNT 23 But the size of the gpio_pins struct is statically defined (and with a small size for most of the supported SoC): struct ar71xx_gpio_softc { .... struct gpio_pin gpio_pins[AR71XX_GPIO_PINS]; }; I'll write a patch to allocate this structure dynamically based on the SoC we're running on. Luiz On 5 September 2013 20:14, Adrian Chadd wrote: > Commit ahoy. :) > > > -a > > > On 5 September 2013 15:47, Sean Bruno wrote: > > > On Thu, 2013-09-05 at 16:42 -0600, Warner Losh wrote: > > > Shouldn't npins and/or maxpin just be bumped by 1 instead? > > > > > > Warner > > > > > > On Sep 5, 2013, at 4:38 PM, Sean Bruno wrote: > > > > > > > http://people.freebsd.org/~sbruno/maxpin_plus_one.txt > > > > > > > > It looks like its *intentionally* assigned as the h/w specific (GPIO > > COUNT) -1 in ar71xx_gpio_pin_max() > > > > Userland assumes that this value is a 0-based thing. > > > _______________________________________________ > freebsd-embedded@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-embedded > To unsubscribe, send any mail to "freebsd-embedded-unsubscribe@freebsd.org > " >