From patchwork Sat Dec 26 07:58:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 561090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BFA86140C90 for ; Sat, 26 Dec 2015 18:59:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=sQh3anlI; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750956AbbLZH6q (ORCPT ); Sat, 26 Dec 2015 02:58:46 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34116 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbbLZH6p (ORCPT ); Sat, 26 Dec 2015 02:58:45 -0500 Received: by mail-pf0-f172.google.com with SMTP id e65so35960207pfe.1; Fri, 25 Dec 2015 23:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=s94QCf9WLOp77yoc/Yc7CZfkIlc29pC6i7B06oF8neM=; b=sQh3anlI6DuTONkn2xw5PrBIvAwpbpgIvmaOEj/gsHwoU2mcmw5a6Tx0X1ay9rj9wI Do8QQvPrt4/Ldl6P4YHjMAY2nt+T/W8MJ+GSAgjwCLweZtFNs3D1uSWByv4WZOABqfnR NqZfrw80nco/fhuQT6pCQ+hfaEp15YQIxl7sZ0CBAJ7nmW/xxRU1n3NqohvUyWLILA8e PVs/zu8b4X9uAnDOZm0+/8868uS3Tc10wdiQciLEqFiKjlqMnmv4e0aBrpCsSoyIk38S QGiIA5924J29YHrfcB28JHdxYJZcDk8hx6iZCUbcd5XvF5GJIyHgQ55MPT/GRzma2G2N LqIQ== X-Received: by 10.98.31.67 with SMTP id f64mr22918676pff.78.1451116725306; Fri, 25 Dec 2015 23:58:45 -0800 (PST) Received: from sudip-pc.vectortproxy.org ([49.206.205.82]) by smtp.gmail.com with ESMTPSA id f67sm21114920pfd.10.2015.12.25.23.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Dec 2015 23:58:44 -0800 (PST) From: Sudip Mukherjee To: Linus Walleij , Alexandre Courbot Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] gpiolib: fix warning about iterator Date: Sat, 26 Dec 2015 13:28:39 +0530 Message-Id: <1451116719-19158-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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: Sudip Mukherjee --- drivers/gpio/gpiolib.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d72ac1f..3619ce4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -189,23 +189,21 @@ EXPORT_SYMBOL_GPL(gpiod_get_direction); */ static int gpiochip_add_to_list(struct gpio_chip *chip) { - struct list_head *pos; struct gpio_chip *iterator; struct gpio_chip *previous = NULL; if (list_empty(&gpio_chips)) { - pos = gpio_chips.next; - goto found; + list_add_tail(&chip->list, &gpio_chips); + return 0; } - list_for_each(pos, &gpio_chips) { - iterator = list_entry(pos, struct gpio_chip, list); + list_for_each_entry(iterator, &gpio_chips, list) { if (iterator->base >= chip->base + chip->ngpio) { /* * Iterator is the first GPIO chip so there is no * previous one */ - if (previous == NULL) { + if (!previous) { goto found; } else { /* @@ -230,7 +228,7 @@ static int gpiochip_add_to_list(struct gpio_chip *chip) return -EBUSY; found: - list_add_tail(&chip->list, pos); + list_add_tail(&chip->list, &iterator->list); return 0; }