Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp753285imm; Fri, 31 Aug 2018 12:16:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbAJlQbgaKUTgkxJOQwFFSSxXpJDb189ctI72TLOp3CsCOX1kG03wLgIcQGE/kUhSbMcrRb X-Received: by 2002:a62:5cc1:: with SMTP id q184-v6mr17568987pfb.241.1535743004067; Fri, 31 Aug 2018 12:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535743004; cv=none; d=google.com; s=arc-20160816; b=aJr3whphmlCtGcBK2fvILZ9dkJmFAxANSL1hT/2ChVXJtQIrR8fmU4n5xX77FaHuru U2CIM2GtU+tlAIcsphpNBj7iXO8SwF5iHm+LQYsRqrf3rIxCdLYPhUOfLZf/SI4na83g 0X32Z1KN7cfB0ch3TXisp2/vlGbzNuHpV010p2TtAv8nt0NJf4wBznOPSltok4xXOl3H tjjdHckLdzmm2VgB4lv6K6ZSEgLKj3xVxBQaEU1y7u1kjUJsdUdVfzhOWNFpVcMUXSuP otzSZ+U4K3nqu+yxrtjBOis1f8menxxw3BrzWU7B2pPxJCYKq+X7epjeTCU9BMLNn/iq 9y0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=23MEsB3WE6rDoSI2ZBb7wJHnp8NdvE2+R4eyD8SloWY=; b=g/XaG0vFsUQITyeHU2zduPasM/Sx/0x2SH1KKDVAEhUP4Fnh9iizlftjVHwKlBKYxc ZwVysM4UBEuajD5nnuO90w8A6csRqXp0LNhpFvwQ1EsNV+wDggFDYaYNIUJWCFL06zV3 MvlQa77/ouGje61iTmcArvlG3DsZD7rFc++kSHufjvvW/9TjuVpTmWrjy5/zEiP0VoL1 Bucn0awOX2ZgKymm1BZnHceDIi1374uO/s+XtR5Io6me8evoDXVM72cxGznxy47BjNMX eHUkgTJ5cYempVAACVAfTqu85EWmSju6BUytcAlgQWp85NTcOukmuln7KXdM+R1ol7Kf NB4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ymlBV0qP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si9692204pgq.637.2018.08.31.12.16.28; Fri, 31 Aug 2018 12:16:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ymlBV0qP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727568AbeHaXWV (ORCPT + 99 others); Fri, 31 Aug 2018 19:22:21 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:38808 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727500AbeHaXWU (ORCPT ); Fri, 31 Aug 2018 19:22:20 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7VJDSUO085363; Fri, 31 Aug 2018 14:13:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535742808; bh=23MEsB3WE6rDoSI2ZBb7wJHnp8NdvE2+R4eyD8SloWY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ymlBV0qP/nSQFtdsvzhDDtAtdIcRRf26xV4N1XyxUIWoZentPz63aWUlc2NPJ8p3E XLFbwD0RcM9r8F/83b9mIrD6frgFI02SpyqrowXjOByldRFLq1eZtaGEZ1l8TdXHLc 0nkWrYg9tHh3PqjbFlQ+Panz7Dfd34g7LQ87Ols8= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJDSxl025220; Fri, 31 Aug 2018 14:13:28 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 31 Aug 2018 14:13:28 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 31 Aug 2018 14:13:28 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJDRw0004124; Fri, 31 Aug 2018 14:13:27 -0500 Received: from localhost (uda0226330.dhcp.ti.com [172.22.167.21]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w7VJDRx13199; Fri, 31 Aug 2018 14:13:27 -0500 (CDT) From: "Andrew F. Davis" To: Sekhar Nori , Kevin Hilman , Keerthy , Linus Walleij CC: , , "Andrew F . Davis" Subject: [PATCH 2/5] gpio: davinci: Use dev name for label and automatic base selection Date: Fri, 31 Aug 2018 14:13:23 -0500 Message-ID: <20180831191326.25106-2-afd@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180831191326.25106-1-afd@ti.com> References: <20180831191326.25106-1-afd@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use dev_name to get a unique label and use -1 for a base to get our selection automatically. We pull in all GPIOs per chip now so this does not have the effect of out of order labels like before. We do these both together so we can drop all the static data in one patch. This also lets us normalize the return paths as we don't need any cleanup after this change. Signed-off-by: Andrew F. Davis --- drivers/gpio/gpio-davinci.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index a5ece8ea79bc..14d1729927d3 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -41,7 +41,6 @@ struct davinci_gpio_regs { typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq); #define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */ -#define MAX_LABEL_SIZE 20 static void __iomem *gpio_base; static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0}; @@ -166,14 +165,12 @@ davinci_gpio_get_pdata(struct platform_device *pdev) static int davinci_gpio_probe(struct platform_device *pdev) { - static int ctrl_num, bank_base; int gpio, bank, i, ret = 0; unsigned int ngpio, nbank, nirq; struct davinci_gpio_controller *chips; struct davinci_gpio_platform_data *pdata; struct device *dev = &pdev->dev; struct resource *res; - char label[MAX_LABEL_SIZE]; pdata = davinci_gpio_get_pdata(pdev); if (!pdata) { @@ -228,10 +225,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) } } - snprintf(label, MAX_LABEL_SIZE, "davinci_gpio.%d", ctrl_num++); - chips->chip.label = devm_kstrdup(dev, label, GFP_KERNEL); - if (!chips->chip.label) - return -ENOMEM; + chips->chip.label = dev_name(dev); chips->chip.direction_input = davinci_direction_in; chips->chip.get = davinci_gpio_get; @@ -239,7 +233,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) chips->chip.set = davinci_gpio_set; chips->chip.ngpio = ngpio; - chips->chip.base = bank_base; + chips->chip.base = -1; #ifdef CONFIG_OF_GPIO chips->chip.of_gpio_n_cells = 2; @@ -252,28 +246,20 @@ static int davinci_gpio_probe(struct platform_device *pdev) } #endif spin_lock_init(&chips->lock); - bank_base += ngpio; for (gpio = 0, bank = 0; gpio < ngpio; gpio += 32, bank++) chips->regs[bank] = gpio_base + offset_array[bank]; ret = devm_gpiochip_add_data(dev, &chips->chip, chips); if (ret) - goto err; + return ret; platform_set_drvdata(pdev, chips); ret = davinci_gpio_irq_setup(pdev); if (ret) - goto err; + return ret; return 0; - -err: - /* Revert the static variable increments */ - ctrl_num--; - bank_base -= ngpio; - - return ret; } /*--------------------------------------------------------------------------*/ -- 2.18.0