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: 122930 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4626412qgn; Fri, 29 Dec 2017 04:28:30 -0800 (PST) X-Google-Smtp-Source: ACJfBossrz6jnxc7wUo47BpxRUxrowQFVHN0OvqE2ByZdZ9Fh0k+DMX6eVKbHUoky8DUGMAR4cVT X-Received: by 10.84.248.1 with SMTP id p1mr34106389pll.50.1514550510446; Fri, 29 Dec 2017 04:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514550510; cv=none; d=google.com; s=arc-20160816; b=NOyUTWT374EBD0b/1+Soi7ct2Ujf15TeUXvt65gx+gqvXyM8nMBd+ckoDiO2jp5tcV lOK61M2E9qeNS1rkHO9BwJ/auUnnO27bpve/k1aXiPvN/yHi3zPWWO9MbQdWjijubxyk dSAp+5VFkP9wz9HAF9NQTha1F/+cxDiSUh6Ac7KvrbrFj9QOV0aVrgQt7pog6uSlpv7t wkYnIx2KevFMo6Ip3MDW3x/DCkgH4fPVo8r3ChV+lKKdMwSQiPtvO5v2Vp2ixVY2wpY5 QKEhAdA/oGgfNJfY/ilgDk2gHrz/Ii17eeItK+MIrawIPcTjaHxgMvr2yBNarNSsE6DP BrfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ktY2BL4542ICPyjuOfrLIZ9cYalx4tSZTwop1gH+KRc=; b=rvYJfrXXMspFR0owNkaXvNPtfWYaGqbF+0Hra/N0qqNqYntvEpBjqzMzXFo+fnuhQc vXmVCK1kpY2Yh9xJGEnvqiOGdwjntJJxAVINcRN+mPOfGc4huy818GULgQO1wgoZMiuC 4sywBbemLoYMMdB+r4gDNPFfx9iT0IF8a3uZOpBwkrC8lwZIpyRYHcI7Ayx0+e6+QqiJ 7NyvfzFzUjamoiZ6lYeBR7ldGVCqlHT0GCzfSj/IsqeHxGeNjtM3YZKlrh2gRig6z/Td a2Sdr1+Y5yVji1ZXOapNnhws6fUJXKIJGenX4QVsgB1SwYHU1SXqHQS8ERwu9GnvKKKw 2SAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OwMQ7eqI; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g59si28322920plb.658.2017.12.29.04.28.30; Fri, 29 Dec 2017 04:28:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OwMQ7eqI; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750820AbdL2M23 (ORCPT + 6 others); Fri, 29 Dec 2017 07:28:29 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34141 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750806AbdL2M21 (ORCPT ); Fri, 29 Dec 2017 07:28:27 -0500 Received: by mail-wm0-f66.google.com with SMTP id y82so5155648wmg.1 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=dtoRmnp1ACQ3W5+FrdivIJhT84heHSazDffk6adL/aGbdmZJEhFfTgJ2t9aiX8akCy nYL0XmZ76Wlm7SxX4dJvHOUQJU7+I0tTbDtw2zk6PxkyNyTnJKIld2eXIfsxFNQbavOH EhKhzzg6XmRPkFB+G71ZsEfoc0tCmJb64EpJ8+FpI5jv7W38pSYMrmTxwkvUnXSxui3n lXeODILSh56GJADOFf/Jktg4yQ5dbKGjCMmoHNZNJKrpLh+69jmBCPt16jhzGjdtxlqS cVMUDfLbEp1Vmc79SyX7E9qFfdecYiP11xCArVZbIv7/clgd58OnHa6tgraGL5xxCEhn UmbQ== X-Gm-Message-State: AKGB3mItze7DWV8pu14zzH/8CEwmpA3x6VRn9vm/75I371vtel7sttzd o70PzxDFVPunKx9af39ZO1GDD4sPfs4= 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }