From patchwork Wed Jul 28 04:12:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 488227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E253C4338F for ; Wed, 28 Jul 2021 04:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 808DD60F9E for ; Wed, 28 Jul 2021 04:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbhG1ENB (ORCPT ); Wed, 28 Jul 2021 00:13:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230007AbhG1ENA (ORCPT ); Wed, 28 Jul 2021 00:13:00 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78A2CC061757; Tue, 27 Jul 2021 21:12:58 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id u15so515666wmj.1; Tue, 27 Jul 2021 21:12:58 -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=AZE/n8nHO8tmFP8WpdcBu1uhnFlE4lMP9BlPoJxj9zA=; b=bQ6nA3hNQAoVZiLJZT8w2r2yHZFLQLdk7bvD6tnFi1lK9517+ev70VExHvG1EGnXNt JglNISt+tq2CdbskMa4ycfxTrDGCbIRspXi1cTF5Jh/g4ubX9Qx1yGG0yffk99tCgO1Y 2JSzAeC4HVrLOYBboFF2QJkm6z87mLTqWKcb/7Awlz7g1aRc7Yq2q5P4FI2dtZHpqsdW Vrz26p9YLoRdbhIpLfUfyyrlJjHpH8y4pgOVjC+TsBiHCDXkiIicbl+j5mn1ICaSrUfm rlJS77bOi2CQNPlbnB9SxQ0lLcj6w0epr4c0MUipp9UL+7Sqt/77YZpRVhBZJqzRvVlv 16+g== 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=AZE/n8nHO8tmFP8WpdcBu1uhnFlE4lMP9BlPoJxj9zA=; b=tk6hBhB8W/RRASllRWj7ZG7OiTCaxkYpeGxLX/kIZgCqIgbiXGPj0z3xQzPkLP4QDC HneH7EHGfPFVIg52a2LMu7Mn6niaSc5sMlEyrwkNjoTEJCLsfeRx79p144Uua3rem4kF dJVkW0PbRpOVhLpaCIZTGDopBBRmYAXF4iRXxnEccfcFjxxxwGhUIV1fiqh5Jb96XnaB doJrZdQQdkwEdJvR/Auivh8F1Pwl8YgMnNT0J5ZvbIDXLOuSDobqdJLV1ULT4kdkIFHI vNWyNEenJ7Dyeml5gQ3ZQMlHdQE7Madv3ZgyJbLJw8HRt+aqe/9EhJl2odO+IKwhd47H 2r4w== X-Gm-Message-State: AOAM5325IhIIRVmFEs6s6XqDHpEYN2wEW95RCvjn1296stRVi7HXIDaj 971l1jQy/L4ZqlhLUU+34TJAroLiuYz9oISy X-Google-Smtp-Source: ABdhPJzqEc5SM3buYkgVZdH+T+9gj2BNkXa9ViCeNClS5OnRiLb1rDZxPlfqgLEmUbdsgXwEi9J6yg== X-Received: by 2002:a7b:c2fa:: with SMTP id e26mr7215903wmk.84.1627445576881; Tue, 27 Jul 2021 21:12:56 -0700 (PDT) Received: from localhost.localdomain (189.red-83-51-242.dynamicip.rima-tde.net. [83.51.242.189]) by smtp.gmail.com with ESMTPSA id e6sm6274184wrg.18.2021.07.27.21.12.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jul 2021 21:12:56 -0700 (PDT) From: Sergio Paracuellos To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, gregory.0xf0@gmail.com, bgolaszewski@baylibre.com, f.fainelli@gmail.com, matthias.bgg@gmail.com, opensource@vdorst.com, andy.shevchenko@gmail.com, git@johnthomson.fastmail.com.au, neil@brown.name, hofrat@osadl.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/3] gpiolib: convert 'devprop_gpiochip_set_names' to support multiple gpiochip banks per device Date: Wed, 28 Jul 2021 06:12:51 +0200 Message-Id: <20210728041253.15382-2-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728041253.15382-1-sergio.paracuellos@gmail.com> References: <20210728041253.15382-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The default gpiolib-of implementation does not work with the multiple gpiochip banks per device structure used for example by the gpio-mt7621 and gpio-brcmstb drivers. To fix these kind of situations driver code is forced to fill the names to avoid the gpiolib code to set names repeated along the banks. Instead of continue with that antipattern fix the gpiolib core function to get expected behaviour for every single situation adding a field 'offset' in the gpiochip structure. Doing in this way, we can assume this offset will be zero for normal driver code where only one gpiochip bank per device is used but can be set explicitly in those drivers that really need more than one gpiochip. Reviewed-by: Andy Shevchenko Reviewed-by: Gregory Fong Signed-off-by: Sergio Paracuellos --- drivers/gpio/gpiolib.c | 32 +++++++++++++++++++++++++++----- include/linux/gpio/driver.h | 4 ++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 27c07108496d..d1b9b721218f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -382,10 +382,18 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) if (count < 0) return 0; - if (count > gdev->ngpio) { - dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", - count, gdev->ngpio); - count = gdev->ngpio; + /* + * When offset is set in the driver side we assume the driver internally + * is using more than one gpiochip per the same device. We have to stop + * setting friendly names if the specified ones with 'gpio-line-names' + * are less than the offset in the device itself. This means all the + * lines are not present for every single pin within all the internal + * gpiochips. + */ + if (count <= chip->offset) { + dev_warn(&gdev->dev, "gpio-line-names too short (length %d), cannot map names for the gpiochip at offset %u\n", + count, chip->offset); + return 0; } names = kcalloc(count, sizeof(*names), GFP_KERNEL); @@ -400,8 +408,22 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) return ret; } + /* + * When more that one gpiochip per device is used, 'count' can + * contain at most number gpiochips x chip->ngpio. We have to + * correctly distribute all defined lines taking into account + * chip->offset as starting point from where we will assign + * the names to pins from the 'names' array. Since property + * 'gpio-line-names' cannot contains gaps, we have to be sure + * we only assign those pins that really exists since chip->ngpio + * can be different of the chip->offset. + */ + count = (count > chip->offset) ? count - chip->offset : count; + if (count > chip->ngpio) + count = chip->ngpio; + for (i = 0; i < count; i++) - gdev->descs[i].name = names[i]; + gdev->descs[i].name = names[chip->offset + i]; kfree(names); diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 3a268781fcec..a0f9901dcae6 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -312,6 +312,9 @@ struct gpio_irq_chip { * get rid of the static GPIO number space in the long run. * @ngpio: the number of GPIOs handled by this controller; the last GPIO * handled is (base + ngpio - 1). + * @offset: when multiple gpio chips belong to the same device this + * can be used as offset within the device so friendly names can + * be properly assigned. * @names: if set, must be an array of strings to use as alternative * names for the GPIOs in this chip. Any entry in the array * may be NULL if there is no alias for the GPIO, however the @@ -398,6 +401,7 @@ struct gpio_chip { int base; u16 ngpio; + u16 offset; const char *const *names; bool can_sleep; From patchwork Wed Jul 28 04:12:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 489005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FEBBC4338F for ; Wed, 28 Jul 2021 04:13:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3009C60F57 for ; Wed, 28 Jul 2021 04:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233766AbhG1ENH (ORCPT ); Wed, 28 Jul 2021 00:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbhG1ENB (ORCPT ); Wed, 28 Jul 2021 00:13:01 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE73C061760; Tue, 27 Jul 2021 21:12:59 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id z4so788584wrv.11; Tue, 27 Jul 2021 21:12:59 -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=fF9kCZueCn/Jy3XohS/GJeKg6N20SNc6dZuJtInQBpc=; b=RTWajS/wlEmJgWECwbC2Qp5975wElCwcTtqNyz5LPQyGlXNxkVONyH81yoHKRZJCmD JmkGvXa9LsUd5IOFI6+7QFGj2Z5yV31jzdiebUZTFH+Fc0dKdwL1Dn7uawJUO4/sUyGt AETCf9UbN+eoXbY50uKvYj6ZWvDqJIqiatDBopdAsGQd7Io7E6dyMhQOo4/iriHCSuJ7 J0AM2oB42248mdHsLUzJSG0DFt0a4ewquJVLc2w6t/0PYU2380pjGmnNNpLARWzuXFFr m3L8zdnhPf+yn7J/H7oPI/wyv+XMwhX2O2fhvz47Wp8bIPwnLc1Hr6kquLDQtqjH62UP mAbg== 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=fF9kCZueCn/Jy3XohS/GJeKg6N20SNc6dZuJtInQBpc=; b=UljYj0TnT7XO2O1fARe53jEa34J9uD92DBgSIjF2A72l2tUtKDfykVXLwQvpXjzmEO Z7F9aGe/6k2r72YIo5FxCKuviYtUH9QqI0SXK1idcjqOuJivc89lB9O47lC0l0y2iJsD 8xlKL/VtfTyIV2AseWxSxIeuID1M399xFka5tCJTsodxeNNzIakTIuAnoYbj8u+mLJVZ mLVkIn3T3h8Mv4hT7ozcz6IWz823S6n/pXrspAej2n90EzPnoVDrHF0VMzbvcrO2WZPn bEww+lrjZnsu9ozxXHXIoBtNzXslgUUZLHMdr6qFtBsDv/THdZS3fCon/JDqHRzw93eO 9Xig== X-Gm-Message-State: AOAM5306WHhGhHlsb1y/arwnwxtN055Uv6hs2RVy8rgpELrjwXlLF9Zq 4m8YGgAb9ERoXELbCnRihOXG5NV2Dyl6EVct X-Google-Smtp-Source: ABdhPJzuvACBda/zdszRKBSYZH7iOQpCKSJvtV8u7ZUDTc/ghOQOA4a28JtBIJ3XWdOCA9fvd+TcNQ== X-Received: by 2002:a5d:5987:: with SMTP id n7mr27773809wri.263.1627445577955; Tue, 27 Jul 2021 21:12:57 -0700 (PDT) Received: from localhost.localdomain (189.red-83-51-242.dynamicip.rima-tde.net. [83.51.242.189]) by smtp.gmail.com with ESMTPSA id e6sm6274184wrg.18.2021.07.27.21.12.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jul 2021 21:12:57 -0700 (PDT) From: Sergio Paracuellos To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, gregory.0xf0@gmail.com, bgolaszewski@baylibre.com, f.fainelli@gmail.com, matthias.bgg@gmail.com, opensource@vdorst.com, andy.shevchenko@gmail.com, git@johnthomson.fastmail.com.au, neil@brown.name, hofrat@osadl.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/3] gpio: mt7621: support gpio-line-names property Date: Wed, 28 Jul 2021 06:12:52 +0200 Message-Id: <20210728041253.15382-3-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728041253.15382-1-sergio.paracuellos@gmail.com> References: <20210728041253.15382-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This driver uses multiple gpiochip banks per device. To support 'gpio-line-names' along the banks 'offset' for each bank must be set explicitly. Reviewed-by: Andy Shevchenko Signed-off-by: Sergio Paracuellos --- drivers/gpio/gpio-mt7621.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c index 82fb20dca53a..5854a9343491 100644 --- a/drivers/gpio/gpio-mt7621.c +++ b/drivers/gpio/gpio-mt7621.c @@ -241,6 +241,7 @@ mediatek_gpio_bank_probe(struct device *dev, if (!rg->chip.label) return -ENOMEM; + rg->chip.offset = bank * MTK_BANK_WIDTH; rg->irq_chip.name = dev_name(dev); rg->irq_chip.parent_device = dev; rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask; From patchwork Wed Jul 28 04:12:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 488226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EB3FC4320A for ; Wed, 28 Jul 2021 04:13:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BCC560FC0 for ; Wed, 28 Jul 2021 04:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbhG1ENJ (ORCPT ); Wed, 28 Jul 2021 00:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231875AbhG1ENC (ORCPT ); Wed, 28 Jul 2021 00:13:02 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3C2FC061765; Tue, 27 Jul 2021 21:13:00 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id z4so788610wrv.11; Tue, 27 Jul 2021 21:13:00 -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=A97sJEVHqRr1cAiROr2GcKYuYpM2uXOvkYVkdzP+alE=; b=LGZBzIxxTU0LtsneW2Zt4TabEXGz8FUY9nGRQX6tL71GImfCJjmanV+lzkdnsaiu4V IMwWX/aAjbR0S2fKQ2/uzehk+IzzykxCJd++kPRK8sHKQqgIlCTjd2iScw1riNGf1pQ7 24vq4boKqagT8vMhoq95PgpQs/T2YkM9/laXVBAWfHsh2xn+vmF/+ip8J5mkV7+u8Os9 NCee/LJGl1ASVK/CadrabDrkVkLZK1+MiYss8BxGS8PxOD3ztmAA7YmUIw4x+vNA92Ts ky6Z7po+qkhsudYllH4BTP1F+Z5Ukn9Ht9P6A5nqMAaC/pwhi99S8UlHQiDc91NJjKxy 1V5A== 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=A97sJEVHqRr1cAiROr2GcKYuYpM2uXOvkYVkdzP+alE=; b=OFOTj+DQUHDzNHDzNfBDba+2ZYFkCi/CZHfMtgGF2H5QFyOI0VVDh4v0rS2PQKyE1o UOzYWo3YnF08/w3RznN88ecCx/pWYE5JHdhnu87/NjJQmjkRhEs1UlVfPlRtQ1EkLlU7 P8moIo6Rxupyc3t/HUQhq1idoKw/cBPPjg7znjRE9HOo40XglIwSndV5Ik0Q1wh436tC OlTsQ9qaH6iHHUeJzZYRI2X5/ZpiaGEa71t4iLec6F+RuFKWjLKzQhD4iaIp8d9NwNu5 Aqzl1EUaDbSQevDOuR13VdtWOIYl0Ity0n/P6ld42IXNrU/+ZvHAEmZEbYUtqLhABxHE /dbA== X-Gm-Message-State: AOAM530vbwUkD/gFdRhFOYa2l52AaPq8x0mRL0o4mjDkK1p3a7QEfAn0 JNAVWqRQueMFmmQJoWb+gba9pv3AF1KuJIRa X-Google-Smtp-Source: ABdhPJyGkewZ2tA1K+FC9Sg+eM8cdaovg7Q9TVMUCxXI0+Xz29CHOucfJxKd9HWY8Q2SsOxMA2eGHg== X-Received: by 2002:a5d:4951:: with SMTP id r17mr11754082wrs.208.1627445579030; Tue, 27 Jul 2021 21:12:59 -0700 (PDT) Received: from localhost.localdomain (189.red-83-51-242.dynamicip.rima-tde.net. [83.51.242.189]) by smtp.gmail.com with ESMTPSA id e6sm6274184wrg.18.2021.07.27.21.12.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jul 2021 21:12:58 -0700 (PDT) From: Sergio Paracuellos To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, gregory.0xf0@gmail.com, bgolaszewski@baylibre.com, f.fainelli@gmail.com, matthias.bgg@gmail.com, opensource@vdorst.com, andy.shevchenko@gmail.com, git@johnthomson.fastmail.com.au, neil@brown.name, hofrat@osadl.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/3] gpio: brcmstb: remove custom 'brcmstb_gpio_set_names' Date: Wed, 28 Jul 2021 06:12:53 +0200 Message-Id: <20210728041253.15382-4-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728041253.15382-1-sergio.paracuellos@gmail.com> References: <20210728041253.15382-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Gpiolib core code has been updated to support setting friendly names through properly 'gpio-line-names'. Instead of redefine behaviour here to skip the core to be executed, just properly assign the desired offset per bank to get in the core the expected behaviour. Reviewed-by: Andy Shevchenko Acked-by: Gregory Fong Signed-off-by: Sergio Paracuellos --- drivers/gpio/gpio-brcmstb.c | 45 +------------------------------------ 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index fcfc1a1f1a5c..a7275159052e 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -603,49 +603,6 @@ static const struct dev_pm_ops brcmstb_gpio_pm_ops = { .resume_noirq = brcmstb_gpio_resume, }; -static void brcmstb_gpio_set_names(struct device *dev, - struct brcmstb_gpio_bank *bank) -{ - struct device_node *np = dev->of_node; - const char **names; - int nstrings, base; - unsigned int i; - - base = bank->id * MAX_GPIO_PER_BANK; - - nstrings = of_property_count_strings(np, "gpio-line-names"); - if (nstrings <= base) - /* Line names not present */ - return; - - names = devm_kcalloc(dev, MAX_GPIO_PER_BANK, sizeof(*names), - GFP_KERNEL); - if (!names) - return; - - /* - * Make sure to not index beyond the end of the number of descriptors - * of the GPIO device. - */ - for (i = 0; i < bank->width; i++) { - const char *name; - int ret; - - ret = of_property_read_string_index(np, "gpio-line-names", - base + i, &name); - if (ret) { - if (ret != -ENODATA) - dev_err(dev, "unable to name line %d: %d\n", - base + i, ret); - break; - } - if (*name) - names[i] = name; - } - - bank->gc.names = names; -} - static int brcmstb_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -759,6 +716,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) gc->of_xlate = brcmstb_gpio_of_xlate; /* not all ngpio lines are valid, will use bank width later */ gc->ngpio = MAX_GPIO_PER_BANK; + gc->offset = bank->id * MAX_GPIO_PER_BANK; if (priv->parent_irq > 0) gc->to_irq = brcmstb_gpio_to_irq; @@ -769,7 +727,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) need_wakeup_event |= !!__brcmstb_gpio_get_active_irqs(bank); gc->write_reg(reg_base + GIO_MASK(bank->id), 0); - brcmstb_gpio_set_names(dev, bank); err = gpiochip_add_data(gc, bank); if (err) { dev_err(dev, "Could not add gpiochip for bank %d\n",