Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e28ecca6 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Linus Walleij
Browse files

gpio: fix warning about iterator



We were getting build warning about "iterator" being used uninitialized.
Use iterator properly to fix the build warning and in the process remove
the variable "pos" which is not required now.

Signed-off-by: default avatarSudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 60befd2e
Loading
Loading
Loading
Loading
+12 −8
Original line number Original line Diff line number Diff line
@@ -189,23 +189,21 @@ EXPORT_SYMBOL_GPL(gpiod_get_direction);
 */
 */
static int gpiochip_add_to_list(struct gpio_chip *chip)
static int gpiochip_add_to_list(struct gpio_chip *chip)
{
{
	struct list_head *pos;
	struct gpio_chip *iterator;
	struct gpio_chip *iterator;
	struct gpio_chip *previous = NULL;
	struct gpio_chip *previous = NULL;


	if (list_empty(&gpio_chips)) {
	if (list_empty(&gpio_chips)) {
		pos = gpio_chips.next;
		list_add_tail(&chip->list, &gpio_chips);
		goto found;
		return 0;
	}
	}


	list_for_each(pos, &gpio_chips) {
	list_for_each_entry(iterator, &gpio_chips, list) {
		iterator = list_entry(pos, struct gpio_chip, list);
		if (iterator->base >= chip->base + chip->ngpio) {
		if (iterator->base >= chip->base + chip->ngpio) {
			/*
			/*
			 * Iterator is the first GPIO chip so there is no
			 * Iterator is the first GPIO chip so there is no
			 * previous one
			 * previous one
			 */
			 */
			if (previous == NULL) {
			if (!previous) {
				goto found;
				goto found;
			} else {
			} else {
				/*
				/*
@@ -221,7 +219,13 @@ static int gpiochip_add_to_list(struct gpio_chip *chip)
		previous = iterator;
		previous = iterator;
	}
	}


	/* We are beyond the last chip in the list */
	/*
	 * We are beyond the last chip in the list and iterator now
	 * points to the head.
	 * Let iterator point to the last chip in the list.
	 */

	iterator = list_last_entry(&gpio_chips, struct gpio_chip, list);
	if (iterator->base + iterator->ngpio <= chip->base)
	if (iterator->base + iterator->ngpio <= chip->base)
		goto found;
		goto found;


@@ -230,7 +234,7 @@ static int gpiochip_add_to_list(struct gpio_chip *chip)
	return -EBUSY;
	return -EBUSY;


found:
found:
	list_add_tail(&chip->list, pos);
	list_add_tail(&chip->list, &iterator->list);
	return 0;
	return 0;
}
}