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]
Date:	Tue, 4 Aug 2009 14:14:26 -0700
From:	David Brownell <david-b@...bell.net>
To:	H Hartley Sweeten <hartleys@...ionengravers.com>
Cc:	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpiolib: introduce for_each_gpio_in_chip macro

On Friday 31 July 2009, H Hartley Sweeten wrote:
> gpiolib: introduce for_each_gpio_in_chip macro
> 
> There are a number of places in gpiolib where all the gpio's handled by a
> chip are walked thru using a for() loop.  This introduces a for_each_*
> macro to clarify the code.

I'd rather not.  There are four such loops, and these are
really simple iterators.  Such a macro IMO just obfuscates,
when it's just hiding such trivial index ops.

NAK.

> Signed-off-by: H Hartley Sweeten <hsweeten@...ionengravers.com>
> 
> ---
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 51a8d41..b060f73 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -56,6 +56,11 @@ struct gpio_desc {
>  };
>  static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
>  
> +#define for_each_gpio_in_chip(__gpio, __chip)			\
> +	for ((__gpio) = (__chip)->base;				\
> +		(__gpio) < (__chip)->base + (__chip)->ngpio;	\
> +		(__gpio)++)
> +
>  static inline void desc_set_label(struct gpio_desc *d, const char *label)
>  {
>  #ifdef CONFIG_DEBUG_FS
> @@ -694,14 +699,14 @@ int gpiochip_add(struct gpio_chip *chip)
>  	}
>  
>  	/* these GPIO numbers must not be managed by another gpio_chip */
> -	for (id = base; id < base + chip->ngpio; id++) {
> +	for_each_gpio_in_chip(id, chip) {
>  		if (gpio_desc[id].chip != NULL) {
>  			status = -EBUSY;
>  			break;
>  		}
>  	}
>  	if (status == 0) {
> -		for (id = base; id < base + chip->ngpio; id++) {
> +		for_each_gpio_in_chip(id, chip) {
>  			gpio_desc[id].chip = chip;
>  
>  			/* REVISIT:  most hardware initializes GPIOs as
> @@ -744,14 +749,14 @@ int gpiochip_remove(struct gpio_chip *chip)
>  
>  	spin_lock_irqsave(&gpio_lock, flags);
>  
> -	for (id = chip->base; id < chip->base + chip->ngpio; id++) {
> +	for_each_gpio_in_chip(id, chip) {
>  		if (test_bit(FLAG_REQUESTED, &gpio_desc[id].flags)) {
>  			status = -EBUSY;
>  			break;
>  		}
>  	}
>  	if (status == 0) {
> -		for (id = chip->base; id < chip->base + chip->ngpio; id++)
> +		for_each_gpio_in_chip(id, chip)
>  			gpio_desc[id].chip = NULL;
>  	}
>  
> 
> 



--
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