Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1405934imm; Sun, 2 Sep 2018 22:41:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZJB7tWoyWzX+gV/ttxiiIzkx6fa8KVzdmHSOxNwcBRZlJQ5n03jSvuxUuqFyPKbsNHgIu6 X-Received: by 2002:a63:5964:: with SMTP id j36-v6mr24707790pgm.222.1535953310262; Sun, 02 Sep 2018 22:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535953310; cv=none; d=google.com; s=arc-20160816; b=xKmRT2uSenY5Fwzr1MxIdYEnMZtMwzyCyDjWch6URYn7chaxuMmu5o/6ZCyIdCBtAF pu4Hz+Ay6LALlMcaXDOIYuXlyo+5ThB7MNtGpiC5rvEFgJ1OGWKFMxlE/lCuBel9ZRhP 7u5WYWAq8OD1T3bH1SqRL2W4bge1LO668P89nYkECrO5X/a0mjDYlUnEOEVMF8SaqPIz n6+o7HIHsVLrgPjY6R/3wyObw7Zf5vT4gowO1nui2tq4HsB6t8K5bFFzaBf4qJgYtSvp NrDg6NM6qDzGjx4Le+6Tb2MMkqqyP/f7D9va+Cj6fqnZHVyeQG1bQnwVLM4PjOSwGNdF 5QRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=g4xGaqKMpXcbeL5xP/9xBCamdKbR+W8OmCTcFKxmJ6I=; b=gaFDRLmASNlTKwNhTGI7N7RGrAAw8mPn/hgPxqu0nwEra2A0HoAVv0Lv1WmzP0L4kq ZS/oyXeqLATXS6uAHE7ZlOIDGn1nxUbmWHJ/82PpSm5NOgzKRRWuixJ64VKMuZsVtjKV cJZUPkhLt9y9gtwCX7lThqRXnGgTNHyLh2PoFVQsJtwHPqvTRgY9CfQzOaUPVAJACyFM 6bydLyqVZ6iPoNR+4uW1uVo0JJAsj2J3nY7XnemUYZ7KiCzR+VYDrMUZ9zLqSFHk2TSU qR9IgvMMj/ULWw2at1bYyykrnWWYquVzcrGCOLFR9az3kILm+UchCatE4y71zhurRpsz wbhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fbOmR4uU; 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 x67-v6si17260773pfa.80.2018.09.02.22.41.35; Sun, 02 Sep 2018 22:41:50 -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=fbOmR4uU; 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 S1725969AbeICJ7C (ORCPT + 99 others); Mon, 3 Sep 2018 05:59:02 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36922 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeICJ7C (ORCPT ); Mon, 3 Sep 2018 05:59:02 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w835eRNC015057; Mon, 3 Sep 2018 00:40:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535953227; bh=g4xGaqKMpXcbeL5xP/9xBCamdKbR+W8OmCTcFKxmJ6I=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=fbOmR4uUDlPO+QhPNPkE48npS1KtwZ3hEVcsCgiDBgweYMyS0cwYFTwtF2gf+jw/k bJXbE15wNE5sQbGLorlzgCGp5iR5K+yT01TAzySh/cYvn13+4bhrO4Dc5F1CuPb0DG IT+yVlmy/UeRi9gPFhZ90iP3wVY0+KkUFhykUHN8= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w835eREH011016; Mon, 3 Sep 2018 00:40:27 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 3 Sep 2018 00:40:26 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 3 Sep 2018 00:40:26 -0500 Received: from [172.24.191.45] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w835eOQZ008441; Mon, 3 Sep 2018 00:40:25 -0500 Subject: Re: [PATCH 2/5] gpio: davinci: Use dev name for label and automatic base selection To: "Andrew F. Davis" , Sekhar Nori , Kevin Hilman , Linus Walleij CC: , References: <20180831191326.25106-1-afd@ti.com> <20180831191326.25106-2-afd@ti.com> From: Keerthy Message-ID: <2a02c241-ac91-1bac-380d-122858bb03c3@ti.com> Date: Mon, 3 Sep 2018 11:10:23 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180831191326.25106-2-afd@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit 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 On Saturday 01 September 2018 12:43 AM, Andrew F. Davis wrote: > 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. echo 28 > /sys/class/gpio/export / # echo 28 > /sys/class/gpi[ 12.839205] export_store: invalid GPIO 28 o/export echo 2 > /sys/class/gp[ 22.165728] export_store: invalid GPIO 2 io/export / # echo 1 > /sys/class/gp[ 25.961392] export_store: invalid GPIO 1 io/export / # echo 3 > /sys/class/gp[ 29.981918] export_store: invalid GPIO 3 io/export Export fails with this patch. I am testing this on keystone-k2g-evm. > > 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; > } > > /*--------------------------------------------------------------------------*/ >