From patchwork Thu Jul 8 07:04:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 1502118 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=qDZ/aJsg; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GL6k12YZHz9sWc for ; Thu, 8 Jul 2021 17:04:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbhGHHH0 (ORCPT ); Thu, 8 Jul 2021 03:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbhGHHHR (ORCPT ); Thu, 8 Jul 2021 03:07:17 -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 8EAECC061760; Thu, 8 Jul 2021 00:04:34 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id q17so6136565wrv.2; Thu, 08 Jul 2021 00:04:34 -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=0cYXJNeVgZpP/hW6to/t3J7jOfhWKeqEA89IWXaC5Ug=; b=qDZ/aJsgkd0mSiKwPSdBHNbOgx2VrLOeHfgBkSTxRjyCCZClj7cPeBeizJAVXlh38/ DKYESVB7ByXTW3h9oQzZz+8xvx4WEpTAOkuIeymSf/Pm4G25Kl6clW70b+Ds0um8ivD9 R7GvNcxW3tZ0fnkF0/eFWTdZV6/pagfSXatlml7U7AJzkPzWcD2+z6C9HCRrzk5mQ82z LH3xRwYtxyDz1/azyN5MzPdpN7yv9qEYk0kFO/iFPSzMj9wCmBH0tlF/B+PWsgHKi3Dj BMsrLddP5G44QT27aTgKy17FzqcXXp2R3XH03CFd/pvHbKN6grE00AfvOxq99eC4t7aS OhRg== 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=0cYXJNeVgZpP/hW6to/t3J7jOfhWKeqEA89IWXaC5Ug=; b=AIMHZBahy3pE9cv8HMqaRNQ2TvZbjavOp9wSDKjZZI1CpHTniNoKa3/Q3ldJFuWDpZ mSWTU6q/BFJFEfGhY+rOn33RWe1d8wSQ92srbR/iAmfmKnga+Dci3/3t+A3lEtIn9fRN OdYnys5YdVmcO7nCyqYegPUFayyneBwAnJVCvhu6HqFmIRsdE1UJsRoni8xvg1YxELRM 2uzCH+2rA/01WAn3Forh9O8A33WxrRojxzQ3yFMzAfO9I6twgCPbDeiJSmJKrR4vXMId xaG2dCSNmImm+VJEvS8+P44nIY2fIaiARlybPgPg77hEtHN6QBAzbiCt6ItTuUQcXi9d YTLQ== X-Gm-Message-State: AOAM531iFAgNhw7T3wM0fmln3mg1+cO9skTYSBzANxZogld6k0fq0Pxi fav4YC+RrAfU+r9N/EKKxCByK2JAag6uWA== X-Google-Smtp-Source: ABdhPJx0T7iLqBLryGo1YoR+ceHN4tAoSHOGBKGkEv/iL56BdLtVfdOAQLJNjeI3jHFb/Smn5DlSMA== X-Received: by 2002:adf:f710:: with SMTP id r16mr31210880wrp.124.1625727872929; Thu, 08 Jul 2021 00:04:32 -0700 (PDT) Received: from localhost.localdomain (98.red-81-38-58.dynamicip.rima-tde.net. [81.38.58.98]) by smtp.gmail.com with ESMTPSA id u15sm8093305wmq.1.2021.07.08.00.04.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jul 2021 00:04:32 -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 1/3] gpiolib: convert 'devprop_gpiochip_set_names' to support multiple gpiochip baks per device Date: Thu, 8 Jul 2021 09:04:27 +0200 Message-Id: <20210708070429.31871-2-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708070429.31871-1-sergio.paracuellos@gmail.com> References: <20210708070429.31871-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. Signed-off-by: Sergio Paracuellos --- drivers/gpio/gpiolib.c | 34 ++++++++++++++++++++++++++++------ include/linux/gpio/driver.h | 4 ++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 27c07108496d..f3f45b804542 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -382,11 +382,16 @@ 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) + return 0; names = kcalloc(count, sizeof(*names), GFP_KERNEL); if (!names) @@ -400,8 +405,25 @@ 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) { + dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", + 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 Thu Jul 8 07:04:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 1502119 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=i4Dg+LJa; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GL6k150myz9sWl for ; Thu, 8 Jul 2021 17:04:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbhGHHH0 (ORCPT ); Thu, 8 Jul 2021 03:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbhGHHHR (ORCPT ); Thu, 8 Jul 2021 03:07:17 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8916C061762; Thu, 8 Jul 2021 00:04:35 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id f17so6118721wrt.6; Thu, 08 Jul 2021 00:04:35 -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=tNTInr5IxLa0v7wLilD1mcRTGKqtOCNhhjsXECS7NAM=; b=i4Dg+LJaiQMGqhyyUKyrEmb6dSSY274TTdFXoaZgUiT7aXCQHuTs4GLMqHfN+HwOh9 QGcGpOXVavm/bjH5hfJNQX/rmP8z1iiTL+h5CSDsT5pXSITZUXTrAaIManekzaGJ2qdY xJx3jn38/Rip5KMj8x3bq4wU6pzG3+hkSKQZRlXzWJ7DGX9MxFoIDYFN9PzJCsuMnMPb T6BmzngO94C2UBYElE4pEa5Ap5gi2OHaY40M5I8BQxeIw7E6oTJ+d4YOJB8OkJOrfkJF Y/LyFukavxgm33QbXCrTQCxNAkWELi+bdGQVUsMM0ajWwO+e0ec5hzBDUfYBPuXbUS4u 7xtQ== 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=tNTInr5IxLa0v7wLilD1mcRTGKqtOCNhhjsXECS7NAM=; b=OBuCw0zRruwikJgvsOLEh7Xlzr2jaBk+ri/McIYkBGmrluwlgrcWz5FvtREfY42XGJ u0N38MJ2x09/hl2pg/1h2K9y0SacBMyLkOHRcp30xzK6U74v9c5gvHfS4D7KRPrRMc5A vhHE9wQ5+Dqoh3ae29qDvJnvcLH9G/Jcvl5qOqH33RgAwCSlEmKxTVeV13IxSBUR7sD/ qLKieeRoHFFBJ8jfF6n1uYKa2Cbtfr3vqlMRnAbJ+UeuX6GJhtq47vbSN7SPEBpkuvvo w5tInod0ndgmnCeigNM/BfJFVHUyl2rI84cY90IqWcRdVFGoKG+/ePE68RIO+O8Vke0f R0QA== X-Gm-Message-State: AOAM532VOq6hDUAqhi2zkAwaeajsnxoN3GV9DXALaEnij25wlQk+JmpZ HlxkBqvAJGiWbV/uNK2WXUNkkVpL+HHHjA== X-Google-Smtp-Source: ABdhPJzwc7jUz4l6lCr6vRLP7M5sCIq1Nl4php9uprqZPIU5nxSk/qywCKNlfOhKLVeiVYTs13f/kw== X-Received: by 2002:a5d:4e43:: with SMTP id r3mr32661749wrt.132.1625727874198; Thu, 08 Jul 2021 00:04:34 -0700 (PDT) Received: from localhost.localdomain (98.red-81-38-58.dynamicip.rima-tde.net. [81.38.58.98]) by smtp.gmail.com with ESMTPSA id u15sm8093305wmq.1.2021.07.08.00.04.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jul 2021 00:04:33 -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 2/3] gpio: mt7621: support gpio-line-names property Date: Thu, 8 Jul 2021 09:04:28 +0200 Message-Id: <20210708070429.31871-3-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708070429.31871-1-sergio.paracuellos@gmail.com> References: <20210708070429.31871-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. 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 Thu Jul 8 07:04:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 1502120 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=Cwn8F5vy; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GL6k23VfFz9sWl for ; Thu, 8 Jul 2021 17:04:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbhGHHH3 (ORCPT ); Thu, 8 Jul 2021 03:07:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbhGHHHY (ORCPT ); Thu, 8 Jul 2021 03:07:24 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2987CC061764; Thu, 8 Jul 2021 00:04:37 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id t14-20020a05600c198eb029020c8aac53d4so16379055wmq.1; Thu, 08 Jul 2021 00:04:37 -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=Qi7EPW8pW/I0yAkgaQOKC9ugDNgF35OVARmaEmgJKWw=; b=Cwn8F5vy9JikZKZheIsJEDo2QKqWrbdmcrE4AkBuaH8/kk2Ef7dMtZXzqGLk3X5hGI WfOuhv7vRTl7hSuvYcmx6aRhKu+mEDa9tqzl+hWR9hpVu0LRZMA9wBqj3a08M4e++PFR lrPErK5riYTt+57XBSjmgj6RJmM/escT7YiRJT3O0irt3UvkxvPsbK+soASuHZnOlecl 1o+QP8jAKtrBM7bUPAAVNxgdGOEVbsYXHTpQ/CYopq6hjuU/D0JivaHaP8uSjlxCKbw4 LEWqRALNDHv954PUwwMXq/JLi7f5PGpGJHHDpr6bJEa9sDRb/aJpgy/+x6VQoomsZGsI C6jg== 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=Qi7EPW8pW/I0yAkgaQOKC9ugDNgF35OVARmaEmgJKWw=; b=Xm9yDStJRn6nGDZot793SSTeJqxquRr9+VPeIewKsNa2mbQ8Jq3MH889pQVdfLopDR uHpj8grOUTgHWRI/LcJNjlMwTm+AasADVfTCJX0HnOYkl6ZWtZ7Uu6hxKGH+ws86G+b+ vIAXsB1a0SrA+VsyPtpMgugBkuimLCf1+J66BDuM9KLBdITssASpiKJTO2A5LW76f/KU mJB9sWgLn/OD1LRTOfs/zU5Zar1aAvdspvMt5YU+GeEyxXKIu1K+XV1b9cJE635g3geN A+0GtBuLL+E50iKQ7qKjl3IPTu/+aV85EruY4Or8Fc+u3c7UOB2hTlkQ7/7+f7WvnEqi ceiw== X-Gm-Message-State: AOAM530MNYyqgL1JzsZMtL5X8qfnp6iltWB4U5O+8X+SbI3hNKZKlqNa TDJsMfBRU4G4RQT9AXSggCKxFm9konxIhA== X-Google-Smtp-Source: ABdhPJziVIvppULck7oF3vVM83VrYcTW4RZzJVVQbvoYI82XxRS+fCrLP94/iSsWpIsCPOTjXiVNXA== X-Received: by 2002:a7b:c0c1:: with SMTP id s1mr28990524wmh.70.1625727875543; Thu, 08 Jul 2021 00:04:35 -0700 (PDT) Received: from localhost.localdomain (98.red-81-38-58.dynamicip.rima-tde.net. [81.38.58.98]) by smtp.gmail.com with ESMTPSA id u15sm8093305wmq.1.2021.07.08.00.04.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jul 2021 00:04:35 -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 3/3] gpio: brcmstb: remove custom 'brcmstb_gpio_set_names' Date: Thu, 8 Jul 2021 09:04:29 +0200 Message-Id: <20210708070429.31871-4-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708070429.31871-1-sergio.paracuellos@gmail.com> References: <20210708070429.31871-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. Signed-off-by: Sergio Paracuellos Acked-by: Gregory Fong --- 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",