From patchwork Tue Jul 27 15:20:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 1510551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Q+/0M+04; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GZ0q82yBbz9sS8 for ; Wed, 28 Jul 2021 01:20:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236847AbhG0PUb (ORCPT ); Tue, 27 Jul 2021 11:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236755AbhG0PUb (ORCPT ); Tue, 27 Jul 2021 11:20:31 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2190CC061757; Tue, 27 Jul 2021 08:20:31 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id a192-20020a1c7fc90000b0290253b32e8796so1627131wmd.0; Tue, 27 Jul 2021 08:20:31 -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=DP/29jrsNE3Itg3laVPBbkDgOhT4a+h/CDIuGeSCY2c=; b=Q+/0M+04g3dUkkwBNOkN0KIn2BZz+5Gnl5dqHMgBT2pZxsQTheNG7FctLaxeIPxShE CulnmsISiBE+bQkcWKHpqIbHKGwCvZA1AVgtfwbNFTv7iMHknwZIc5tL3rftY880JhQ7 Qa+pj5RAjVn5AfAfKU+0JhMeO/VFZ1sKlMT+R4iT5hJoNSpb2/rNOOK2QZzEb9/kLBl3 RBL2f9mR9HOqhonXNxcbdjqiMNX+H9Rt4gElw0qkE+QgoKhhyQJlZ7AzgDMqFf1myyJW j1SjMmvq92MAp4yjuxRuKOEF1PdKn+ktT4+UpSUdkKziw8YZgUwWDtGXUKnmCaAiAENb eaog== 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=DP/29jrsNE3Itg3laVPBbkDgOhT4a+h/CDIuGeSCY2c=; b=gqC+kkYAIbGwLona9VtQq5Y4msi0mnZVqxhC60sgaRWZrlplODuBXCTpFmcIVqBOM2 F2pwnbY41+WPb7ZjCTuyV6vulgU9sQW5Gf2eKAa21Ja7rdog+Cl8+8ejJLQslSzbZFKc T7SHxWQHFZRFYP9MWgCY5MUsCao3f2YhJ+ZkOOvvK91I/y0he6pXYLR3iiOJHB5Rc+iH ZpqdySCUHLOeOIAb7hn9sDWokEIn51DjR2y6x2h0mTvOV2f3HmJLPnalks9i8NjmObbU ryW8gvP5MU+Kobp5eMefULeeLaihp9Fi4lbmvQ/aextr0fXafj7cbxhfhk1RX+yEuTfl 3k9Q== X-Gm-Message-State: AOAM532rKdMFZMjiSzw9pfXajtLr7V7ZBvYoL3hvnjcZJsuZNg5y38Z6 yGi+MWiVoUrClwG6J/rqizBBu8w0v1vasuay X-Google-Smtp-Source: ABdhPJzORKidfJSZlHrtnxnQBRMWF4TBx8diLTy8IQZ0ogn+PAeRCGrAHgajMqF8ggabzYW47xs7FA== X-Received: by 2002:a1c:1d44:: with SMTP id d65mr11629151wmd.181.1627399229482; Tue, 27 Jul 2021 08:20:29 -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 w185sm3372393wmb.11.2021.07.27.08.20.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jul 2021 08:20:29 -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 v3 1/3] gpiolib: convert 'devprop_gpiochip_set_names' to support multiple gpiochip banks per device Date: Tue, 27 Jul 2021 17:20:24 +0200 Message-Id: <20210727152026.31019-2-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210727152026.31019-1-sergio.paracuellos@gmail.com> References: <20210727152026.31019-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 Signed-off-by: Sergio Paracuellos Reviewed-by: Gregory Fong --- 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..84ed4b73fa3e 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 Tue Jul 27 15:20:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 1510553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DgHlWin2; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GZ0qX2xRhz9sRN for ; Wed, 28 Jul 2021 01:20:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236860AbhG0PUq (ORCPT ); Tue, 27 Jul 2021 11:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236848AbhG0PUc (ORCPT ); Tue, 27 Jul 2021 11:20:32 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B97AC061757; Tue, 27 Jul 2021 08:20:32 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id n21so7829787wmq.5; Tue, 27 Jul 2021 08:20:31 -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=DgHlWin2WuK0dY2Acl+41XD7r+nmM2VFzDR6yW4G1It4PsUM1TWb+kxFaScXFIW6S3 h++ek1rzpJvaSmYA7y1B8cop5UjKNS6UMnTVwWfFkwxLFmQ4LMQhVtgepDxgmxqhYCTI l+92mZcJ2h0J/lONVWeZj4KuLcTV8md9UdggK/Odwr8wo4YGUJNtWmtjbQkW4TRSw9Ev E7g9Q5s/D8V9vw6vNRYEpDefylODmz/IDhauADhhLBiCThc9tVvnflMND2omn9EELS1x KaHGphQL8wGtYBBV13Nd+QglHMNt2gySlyKCSVh5mYY9MQo8sX7CEMisBpkDNUhQ3WxP 4lNA== 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=ehyHi76C9RcmNhH+GtKtHUNV/1H2Yby73e/NpPHYrfo6Ihz7UUX9d87R4GUFkD6v/q YFF51W4+C67KESRE1GB9SzMkRuG+vBlqTOFUckXdpHkXlB8JQGasepXg1Fv2/CFrpWKD rvKwcZQ+qTFXbDZcZHg1CddokfRkdJQ5sm0Pe010Kd/UpCU+B0QrOJ710lKEE/6eumyI 1ly1WrzHCdnkZL6KHn9X1N79f0Edeufrj6U6W1t15MUgvXakQW8PDJAR04fWJ1LLTSDf 404qDfZVIE/fhgi7eswtJNEFpWZ9vtWRPEtnJ9R4Tg/RAfTGTip+8CM5RiNwDU9sv81d oYig== X-Gm-Message-State: AOAM53094qyzcP2azD5z+t2PflwmJnahFzU9EvI05jbiS4DiCwwpiY6M 5a6dAxLkqhe2CSubO4qN7P3iJADRcmzAJ/tI X-Google-Smtp-Source: ABdhPJydpmb6LagxYHNdn4jM7Q6Rs4EhM2aFjcSxsebf2eJJZWnBlr1BhvCrBNSPWnFTQaat8mnlqQ== X-Received: by 2002:a05:600c:4141:: with SMTP id h1mr22577539wmm.83.1627399230443; Tue, 27 Jul 2021 08:20:30 -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 w185sm3372393wmb.11.2021.07.27.08.20.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jul 2021 08:20:30 -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 v3 2/3] gpio: mt7621: support gpio-line-names property Date: Tue, 27 Jul 2021 17:20:25 +0200 Message-Id: <20210727152026.31019-3-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210727152026.31019-1-sergio.paracuellos@gmail.com> References: <20210727152026.31019-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 Tue Jul 27 15:20:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 1510552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=VpOIOtiI; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GZ0qT2g9Lz9sRN for ; Wed, 28 Jul 2021 01:20:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237046AbhG0PUl (ORCPT ); Tue, 27 Jul 2021 11:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236901AbhG0PUd (ORCPT ); Tue, 27 Jul 2021 11:20:33 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219B9C061764; Tue, 27 Jul 2021 08:20:33 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id k4so7817214wms.3; Tue, 27 Jul 2021 08:20:33 -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=VpOIOtiIbqj8QEZDSZ2iuEe1kRowCX7PH/pmrU+EAxYHJRX9YNyaPRcfLhvBSVzybL sJw21Pd99DpQjh9LcrCpAuhk3BmrA94nbKSHX8chSa+BsEBnhcGBdJwviOW6Gt8kpkUZ GahMria5iyNigyH79NEPOuvPQc3rIZROQ3B4o/8y/kXskH7PxkDiVDAHk9DR3yW+m/Nl LmyP/KOI/k6B55iCC1QSDNUM3TzcvmFe4ZD2RU99SWRv5fFmdR3Dap7cxmiIhyV+QaFi 9AaGf/x5OzY2W2Ltb65P9hUHj9i+V6N39N+2ZR2YUXtdBH/G0t4CmOmL6c0wCK4hRHyY 97bQ== 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=ghyV4yuNQWCF+lEWCZQVRMc7e3BvanGp9+1bOTfhLpziti4M71PbqsYmATOSJevqDR VmaWHqliSfiYAKxyJo/+UbtJf4r7utv9ztECrbaut8AYDADwJUq7C8uclozGvSud6LHt pVFTBAq/lPvK2Wx0L6xRpDgw6uy+jjD1Mwe177Hb9XGVcFrU5K4YOIBqMHIYWy8Rp2Kl CBTRYNCXHBRU0PI2dLJmiOh2SSycX9z4JQ+8LfyBu7BgAmQDhiyQGyQIEyW9k4wp4Jmc kWbSgxfRY7Ouu+hqZLTg90NuU2OX/ImnUpVLqEoZ9wuVYk8hYi4x0GbVdDo96Zixl1d2 TZ4A== X-Gm-Message-State: AOAM533dw2ZqVJJ2elxAI8FeTSm2vPWJrFb5yYL7joX7a7bbwQCc1ISZ npvqJF0hFhPSSR/lS/SMyP/OCufv/Uzdpsz0 X-Google-Smtp-Source: ABdhPJyhRyZ1EZ3YKM8HxTwp3POX7+E0ZO9ReE5j9PAoCL6apZ1uXjjcYL1OGvn6T0bm6KNwXuHbhA== X-Received: by 2002:a7b:c5d8:: with SMTP id n24mr22930583wmk.51.1627399231434; Tue, 27 Jul 2021 08:20:31 -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 w185sm3372393wmb.11.2021.07.27.08.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jul 2021 08:20:31 -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 v3 3/3] gpio: brcmstb: remove custom 'brcmstb_gpio_set_names' Date: Tue, 27 Jul 2021 17:20:26 +0200 Message-Id: <20210727152026.31019-4-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210727152026.31019-1-sergio.paracuellos@gmail.com> References: <20210727152026.31019-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",