From patchwork Thu May 9 20:12:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1097665 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AttJ5bip"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 450Ph34Xd4z9sBV for ; Fri, 10 May 2019 06:14:27 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4DC3FC21C2C; Thu, 9 May 2019 20:13:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 90678C21DFA; Thu, 9 May 2019 20:12:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B0091C21DA6; Thu, 9 May 2019 20:12:16 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id CFB6FC21D65 for ; Thu, 9 May 2019 20:12:12 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id m20so4909112wmg.1 for ; Thu, 09 May 2019 13:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wzgBJvZYIvNaTCvNn5belWuYBO0HwCSqVwR28qWunUw=; b=AttJ5bipYNpPR55AhmpC5KiwGBcbmke36du5KQ/wWIQF6xUzADa1tnaLN6QhFXRhEc AzXnKPl7tLAs2hep6p/g08EeS5xKMA1vlOpmW6ULR2jIuZsT5mdeXPOBRpJIKXU0Uwqb 66b9ZZ6hwXxVPq/kXLU8B9yv8Mgd5cMQoNZcs61rfd+y/4y7uEc/qHWQVUGFDjU5xrez 4SBRDJYWi1ZoniccCSyuh6+iuHA4tqOJUS6qh/SNX7pba+xkHvrtEm6CZ+hnzUePcgGJ f41y4TOLpCEIcHlIS24CWEQ+0hDdrpcXNGZQJ+gChVJeY59njcJQU9tnOKA4T1V8ICgE Rmig== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wzgBJvZYIvNaTCvNn5belWuYBO0HwCSqVwR28qWunUw=; b=S24HM+d9WtNnrbaCCpqap99/ChP2TfrHfNSraYqFEeD/4P4Xwa9etOWbfGP6D54p+u AO6SswJxUCayErrIpWqX7j3/+kRpC5cwnSWKyALRzzpZNvO6VzPJ+P+rMIEudqXFaft2 57NsKrnRxXF5cMBE6X1fILLRzj9Er27ZumMIrG6iBi96vazE/aBNgmlTAKy35C+WS/69 RE+7upSqrxoqcsTStOlD2L/B/R5a083fY3M4Ja3eE59hlbXuP3mx0x2gsR32zpgIZnr4 tVlUyYbFGrv6qEAfyT3L6YT8YDEpGylBXIhLGwunky59zlJOXMDS6DWflXcUMfrK/HVB BC5w== X-Gm-Message-State: APjAAAVUf9FuUvLGE9m7OuTO7zqMzbwL5y1qm6TkIuoZiFqvLcgS/Msk 12dJhwU/zm6WA2rIv9UND60= X-Google-Smtp-Source: APXvYqxNMGpdNo12VoxpFkg6AEZ/XHcKnQ2By74j6o38ulhaAWmou0XCAM+E5tnL6uYUlvDySaeqQw== X-Received: by 2002:a1c:ac07:: with SMTP id v7mr4071983wme.49.1557432732536; Thu, 09 May 2019 13:12:12 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:2df8:99ba:e50f:756b]) by smtp.gmail.com with ESMTPSA id a20sm8326402wrf.37.2019.05.09.13.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 13:12:12 -0700 (PDT) From: Simon Goldschmidt To: Marek Vasut Date: Thu, 9 May 2019 22:12:00 +0200 Message-Id: <20190509201200.10336-7-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190509201200.10336-1-simon.k.r.goldschmidt@gmail.com> References: <20190509201200.10336-1-simon.k.r.goldschmidt@gmail.com> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, Chin Liang See Subject: [U-Boot] [PATCH 6/6] gpio: dwapb_gpio: convert to livetree X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Convert 'gpio_dwapb_bind' to iterate over subnodes using livetree functions (inspired from mt7621_gpio.c). Signed-off-by: Simon Goldschmidt --- drivers/gpio/dwapb_gpio.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c index e55fb4ac73..04a2381acd 100644 --- a/drivers/gpio/dwapb_gpio.c +++ b/drivers/gpio/dwapb_gpio.c @@ -17,8 +17,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - #define GPIO_SWPORT_DR(p) (0x00 + (p) * 0xc) #define GPIO_SWPORT_DDR(p) (0x04 + (p) * 0xc) #define GPIO_INTEN 0x30 @@ -150,10 +148,10 @@ static int gpio_dwapb_probe(struct udevice *dev) static int gpio_dwapb_bind(struct udevice *dev) { struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; struct udevice *subdev; fdt_addr_t base; - int ret, node, bank = 0; + int ret, bank = 0; + ofnode node; /* If this is a child device, there is nothing to do here */ if (plat) @@ -165,10 +163,9 @@ static int gpio_dwapb_bind(struct udevice *dev) return -ENXIO; } - for (node = fdt_first_subnode(blob, dev_of_offset(dev)); - node > 0; - node = fdt_next_subnode(blob, node)) { - if (!fdtdec_get_bool(blob, node, "gpio-controller")) + for (node = dev_read_first_subnode(dev); ofnode_valid(node); + node = dev_read_next_subnode(node)) { + if (!ofnode_read_bool(node, "gpio-controller")) continue; plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL); @@ -177,15 +174,15 @@ static int gpio_dwapb_bind(struct udevice *dev) plat->base = base; plat->bank = bank; - plat->pins = fdtdec_get_int(blob, node, "snps,nr-gpios", 0); - plat->name = fdt_stringlist_get(blob, node, "bank-name", 0, - NULL); - if (!plat->name) { + plat->pins = ofnode_read_u32_default(node, "snps,nr-gpios", 0); + + if (ofnode_read_string_index(node, "bank-name", 0, + &plat->name)) { /* * Fall back to node name. This means accessing pins * via bank name won't work. */ - plat->name = fdt_get_name(blob, node, NULL); + plat->name = ofnode_get_name(node); } ret = device_bind(dev, dev->driver, plat->name, @@ -193,7 +190,7 @@ static int gpio_dwapb_bind(struct udevice *dev) if (ret) return ret; - dev_set_of_offset(subdev, node); + dev->node = node; bank++; }