From owner-svn-src-all@FreeBSD.ORG Fri Sep 6 23:47:51 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 51179EEF; Fri, 6 Sep 2013 23:47:51 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 26B8627D4; Fri, 6 Sep 2013 23:47:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r86Nlplo082998; Fri, 6 Sep 2013 23:47:51 GMT (envelope-from loos@svn.freebsd.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r86Nloek082996; Fri, 6 Sep 2013 23:47:50 GMT (envelope-from loos@svn.freebsd.org) Message-Id: <201309062347.r86Nloek082996@svn.freebsd.org> From: Luiz Otavio O Souza Date: Fri, 6 Sep 2013 23:47:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255335 - head/sys/mips/atheros X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Sep 2013 23:47:51 -0000 Author: loos Date: Fri Sep 6 23:47:50 2013 New Revision: 255335 URL: http://svnweb.freebsd.org/changeset/base/255335 Log: Remove the hardcoded limit for the number of gpio_pins that can be used. Allocate it dynamically. Approved by: adrian (mentor) Modified: head/sys/mips/atheros/ar71xx_gpio.c head/sys/mips/atheros/ar71xx_gpiovar.h Modified: head/sys/mips/atheros/ar71xx_gpio.c ============================================================================== --- head/sys/mips/atheros/ar71xx_gpio.c Fri Sep 6 23:39:56 2013 (r255334) +++ head/sys/mips/atheros/ar71xx_gpio.c Fri Sep 6 23:47:50 2013 (r255335) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -418,6 +419,13 @@ ar71xx_gpio_attach(device_t dev) "pinon", &pinon) != 0) pinon = 0; device_printf(dev, "gpio pinmask=0x%x\n", mask); + for (j = 0; j <= maxpin; j++) { + if ((mask & (1 << j)) == 0) + continue; + sc->gpio_npins++; + } + sc->gpio_pins = malloc(sizeof(*sc->gpio_pins) * sc->gpio_npins, + M_DEVBUF, M_WAITOK | M_ZERO); for (i = 0, j = 0; j <= maxpin; j++) { if ((mask & (1 << j)) == 0) continue; @@ -429,7 +437,6 @@ ar71xx_gpio_attach(device_t dev) ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], DEFAULT_CAPS); i++; } - sc->gpio_npins = i; for (i = 0; i < sc->gpio_npins; i++) { j = sc->gpio_pins[i].gp_pin; if ((pinon & (1 << j)) != 0) @@ -455,6 +462,7 @@ ar71xx_gpio_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid, sc->gpio_mem_res); + free(sc->gpio_pins, M_DEVBUF); mtx_destroy(&sc->gpio_mtx); return(0); Modified: head/sys/mips/atheros/ar71xx_gpiovar.h ============================================================================== --- head/sys/mips/atheros/ar71xx_gpiovar.h Fri Sep 6 23:39:56 2013 (r255334) +++ head/sys/mips/atheros/ar71xx_gpiovar.h Fri Sep 6 23:47:50 2013 (r255335) @@ -64,7 +64,7 @@ struct ar71xx_gpio_softc { int gpio_irq_rid; void *gpio_ih; int gpio_npins; - struct gpio_pin gpio_pins[AR71XX_GPIO_PINS]; + struct gpio_pin *gpio_pins; }; #endif /* __AR71XX_GPIOVAR_H__ */