From patchwork Fri Dec 29 12:28:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10137049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 77E0060212 for ; Fri, 29 Dec 2017 12:28:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA4A2CD7A for ; Fri, 29 Dec 2017 12:28:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E9002DA29; Fri, 29 Dec 2017 12:28:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B381C2CD7A for ; Fri, 29 Dec 2017 12:28:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750814AbdL2M22 (ORCPT ); Fri, 29 Dec 2017 07:28:28 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33704 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750801AbdL2M21 (ORCPT ); Fri, 29 Dec 2017 07:28:27 -0500 Received: by mail-wm0-f68.google.com with SMTP id g130so5181146wme.0 for ; Fri, 29 Dec 2017 04:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=eAuehg47yZjXlw09sky0TN+B/35tPRMTvhmJMe5hwZs=; b=OwMQ7eqIndDh0Q3aqntYgU7nhyYCL2k3ruuK4e1f5OBHUyWhmG0zPPQ06xFYX+XHX8 5mAhOxSEUik7wqNhewxs4KxxuY/OJ2ACwYiulyRSqMDRIBo/Hgf/zle3fb+W72FSXnvc cEsEzixlW9cHFtLbPDfqkc0R6b92NWqfqYXJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eAuehg47yZjXlw09sky0TN+B/35tPRMTvhmJMe5hwZs=; b=Z0jTteT77egT1vFL7WLF4dWMZ0aM0b2Nki9M6HQX9N/SoxJW1uI/bbupYGkhReJIlw 0shq2kHmWhLrBjxA9mjrXu4w2AVAE4UVjzCg51WS5VRguhpKQEosNrkxBSoq5jiYmCxI Xx+N7kwJJm4Esop9vOMRA7MK996zopuUTjjR2e+IDPPESYQz9j4Ts9SdInILK+IiczB+ lqpBitB4Bd/3ZL6lwu+hrLKcFFo95YIRQIgbldjrLhvH8WRkLReumtogGLS0MaDB8jQ7 vf2xNWClJOF1LwpGiqcIi5Kj9s9yRM8UggYg/aCm80inUWvXxzonvbqVCqJGOq0rpTHG XufQ== X-Gm-Message-State: AKGB3mL7zdR6d15UjnJD3K3bYZaSwHyUu1Ra1J83awIJgxFEJyLg1wNg vrLim/nC9qTdNQYPJIKmw26A6Q== X-Google-Smtp-Source: ACJfBovYiCGnG0/lNidyjOyEcP/kJhOCVYwFTpOgkYBGpngwbivrLg6weGBHqgKaO1fAJG9QnFHc/Q== X-Received: by 10.28.207.130 with SMTP id f124mr25886573wmg.132.1514550506365; Fri, 29 Dec 2017 04:28:26 -0800 (PST) Received: from localhost.localdomain (catv-80-98-14-92.catv.broadband.hu. [80.98.14.92]) by smtp.gmail.com with ESMTPSA id f5sm10907509wrh.24.2017.12.29.04.28.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Dec 2017 04:28:25 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Grygorii Strashko , Santosh Shilimkar , Kevin Hilman , linux-omap@vger.kernel.org Subject: [PATCH] gpio: omap: Give unique labels to each GPIO bank/chip Date: Fri, 29 Dec 2017 13:28:12 +0100 Message-Id: <20171229122812.29743-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As we need to add GPIO lookup tables to the OMAP platforms, we need to reference each GPIO chip with a unique label. Use the GPIO base to name each chip, "gpio-0-31", "gpio-32-63" etc. Also fix a small error on the error path of the probe() where the chip would not be free()ed proberly under all circumstances. Cc: Grygorii Strashko Cc: Santosh Shilimkar Cc: Kevin Hilman Cc: linux-omap@vger.kernel.org Signed-off-by: Linus Walleij --- drivers/gpio/gpio-omap.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index e136d666f1e5..14fc3fb6f96e 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1059,6 +1059,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank) static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) { static int gpio; + const char *label; int irq_base = 0; int ret; @@ -1080,7 +1081,11 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) bank->chip.parent = &omap_mpuio_device.dev; bank->chip.base = OMAP_MPUIO(0); } else { - bank->chip.label = "gpio"; + label = devm_kasprintf(bank->chip.parent, GFP_KERNEL, "gpio-%d-%d", + gpio, gpio + bank->width - 1); + if (!label) + return -ENOMEM; + bank->chip.label = label; bank->chip.base = gpio; } bank->chip.ngpio = bank->width; @@ -1104,7 +1109,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) -1, 0, bank->width, 0); if (irq_base < 0) { dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); - return -ENODEV; + ret = -ENODEV; + goto out_err_chip; } #endif @@ -1123,7 +1129,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) dev_err(bank->chip.parent, "Couldn't add irqchip to gpiochip %d\n", ret); gpiochip_remove(&bank->chip); - return -ENODEV; + ret = -ENODEV; + goto out_err_chip; } gpiochip_set_chained_irqchip(&bank->chip, irqc, bank->irq, NULL); @@ -1132,8 +1139,12 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) omap_gpio_irq_handler, 0, dev_name(bank->chip.parent), bank); if (ret) - gpiochip_remove(&bank->chip); + goto out_err_chip; + + return ret; +out_err_chip: + gpiochip_remove(&bank->chip); return ret; }