Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp182029imm; Tue, 14 Aug 2018 16:46:02 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw4WkzkjJ8rBitt+ZDv1PqKdHV0JnDnGTW7TLx0x67xE8bAeqwgVw/sDNFTh4ClYDvKaUtm X-Received: by 2002:a62:2646:: with SMTP id m67-v6mr25611447pfm.254.1534290362260; Tue, 14 Aug 2018 16:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534290362; cv=none; d=google.com; s=arc-20160816; b=QUPMh6siE1Y3DsEkE5VacUE3wn8xRm74FcuNHtk26JJHcxmTE2MSNDLtcDKzoDow+A MnV01QXLPy2oUdAdNck3GA7HZ7K2qCDnYMW3GV03RUhvZk86kuVcAJWIIbfRUBhI4H68 tlWz1xWRGzRIN6ATQ9oiYMfXVx8B1dkmAMvgpuCdPf7/UPf16h0w/FmaGboqRSeEvPO8 /zxM0qpHrU6AqdHMvcXUplgjrs5rx8OefFX3hvvFvustQ152uFAUOf8pCjYYeiV4Om8D LF1is4NsR6D9jEgChz+tHA7l99sylEtOIGCdIYn+2NtiDoPavTdVpx3ZRxeOhdB7aEIP B8Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=pKDgZ81NzbFcMi3eyrlG2CCGo1/jgmYW4e2mKAibH3o=; b=zg2c8ShaJsx3DBimd6wiShjXGO/WtxA9cHxZ7mF5AY+kfhTYGAafFBqdCJbetS5LmY 9njVDYO6hZNZF8CYUSBeLR9UwcMyZhXFGZttH5L9c8DUxGQJ868F3hfWYchiXEZyhonZ pIZMVPobpfEBCBqgMC6wnjJnxYuY8aCARfUvmz14dgl/VQE18EdmeA04tyD128RTeOL9 7dUwGOkaGHfWTan9nCpeDV59qKPkCd4jyWrqSQk5rNCruECp9qqmFy1OMgkPq79iG2mH 4q/8yZPl3ySA1Zft7hO4gpnWPWv665BQiArEOq0c2IMNZHCbeaKiTaYtwmSxuvJTJi6m IUfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=SPYdhqby; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si17392390ply.520.2018.08.14.16.45.33; Tue, 14 Aug 2018 16:46:02 -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=@broadcom.com header.s=dkimrelay header.b=SPYdhqby; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727982AbeHOCdm (ORCPT + 99 others); Tue, 14 Aug 2018 22:33:42 -0400 Received: from rnd-relay.smtp.broadcom.com ([192.19.229.170]:43732 "EHLO rnd-relay.smtp.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbeHOCdm (ORCPT ); Tue, 14 Aug 2018 22:33:42 -0400 Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 633CF30C075; Tue, 14 Aug 2018 16:44:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 633CF30C075 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1534290248; bh=IX+4ea/Q3fKYpSOurHAqiHra49GeAkVfHB6TNiMTsZY=; h=From:To:Cc:Subject:Date:From; b=SPYdhqby3daC5XAMgxp/Tv4VT7oWB+IQAp7HfKV/0U8K/bUO2u1RqesPVYFe3Izg+ 4kDNgbL2veanaVS+eQ/zTa64IiIQCQfhNsKOe29O9gE+KcHotOVAK1b57ltZFoIH2d m5Hzo+6dOYSwMahvg4IFIt/kSWxxsHzekCvYga5s= Received: from stbirv-lnx-2.igp.broadcom.net (stbirv-lnx-2.igp.broadcom.net [10.67.48.34]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id 89D92AC07C5; Tue, 14 Aug 2018 16:44:09 -0700 (PDT) Received: by stbirv-lnx-2.igp.broadcom.net (Postfix, from userid 47169) id AF6A727F3D0; Tue, 14 Aug 2018 16:32:07 -0700 (PDT) From: justinpopo6@gmail.com To: linux-gpio@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, f.fainelli@gmail.com, computersforpeace@gmail.com, linus.walleij@linaro.org, gregory.0xf0@gmail.com, Justin Chen Subject: [PATCH] gpio: brcmstb: allow 0 width GPIO banks Date: Tue, 14 Aug 2018 16:31:57 -0700 Message-Id: <1534289517-1805-1-git-send-email-justinpopo6@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Justin Chen Sometimes we have empty banks within the GPIO block. This commit allows proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by incrementing the bank and number of GPIOs, but not initializing them. This will mean a call into the non-existent GPIOs will return an error. Also remove banks and GPIO information from the dev_info print. This information is misleading since the incremented banks and gpio_base do not reflect the actual GPIOs that got initialized. We leave this information out since it is already printed with dev_dbg. Signed-off-by: Justin Chen --- drivers/gpio/gpio-brcmstb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index 16c7f9f..8658910 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -664,6 +664,18 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) struct brcmstb_gpio_bank *bank; struct gpio_chip *gc; + /* + * If bank_width is 0, then there is an empty bank in the + * register block. Special handling for this case. + */ + if (bank_width == 0) { + dev_dbg(dev, "Width 0 found: Empty bank @ %d\n", + num_banks); + num_banks++; + gpio_base += MAX_GPIO_PER_BANK; + continue; + } + bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); if (!bank) { err = -ENOMEM; @@ -740,8 +752,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) goto fail; } - dev_info(dev, "Registered %d banks (GPIO(s): %d-%d)\n", - num_banks, priv->gpio_base, gpio_base - 1); + dev_info(dev, "Brcmstb GPIO registered\n"); if (priv->parent_wake_irq && need_wakeup_event) pm_wakeup_event(dev, 0); -- 2.7.4