lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080313160039.b69a5d24.akpm@linux-foundation.org>
Date:	Thu, 13 Mar 2008 16:00:39 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	David Brownell <david-b@...bell.net>
Cc:	linux-kernel@...r.kernel.org, avorontsov@...mvista.com
Subject: Re: [patch 2.6.25-rc5 1/2] gpiolib:  dynamic gpio number allocation

On Thu, 13 Mar 2008 14:49:53 -0800
David Brownell <david-b@...bell.net> wrote:

> From: Anton Vorontsov <avorontsov@...mvista.com>
> 
> If gpio_chip->base is negative during registration, gpiolib performs
> dynamic base allocation. This is useful for devices that aren't always
> present, such as GPIOs on hotplugged devices rather than mainboards.
> (This behavior was previously specified but not implemented.)
> 
> To avoid using any numbers that may have been explicitly assigned but
> not yet registered, this dynamic allocation assigns GPIO numbers from
> the biggest number on down, instead of from the smallest on up.
>
> ..
>
> +/* dynamic allocation of GPIOs, e.g. on a hotplugged device */
> +static int gpiochip_find_base(int ngpio)
> +{
> +	int i;
> +	int spare = 0;
> +	int base = -ENOSPC;
> +
> +	for (i = ARCH_NR_GPIOS - 1; i >= 0 ; i--) {
> +		struct gpio_chip *chip = gpio_desc[i].chip;
> +
> +		if (!chip) {
> +			spare++;
> +			if (spare == ngpio) {
> +				base = i;
> +				break;
> +			}
> +		} else {
> +			spare = 0;
> +			i -= chip->ngpio - 1;
> +		}
> +	}
> +
> +	if (gpio_is_valid(base))
> +		pr_debug("%s: found new base at %d\n", __func__, base);
> +	return base;
> +}

hm.  I suppose that if someone want a huge number of GPIOs then we can
convert this to a bitmap or an IDR tree easily enough.

Shouldn't ARCH_NR_GPIOS be CONFIG_NR_GPIOS?


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ