From patchwork Tue Apr 23 18:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13640561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23B58C4345F for ; Tue, 23 Apr 2024 18:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=emc6Y0nDK5D+p1XxME8QW2C3egx+3IQMFzFapUt/vL8=; b=e3yWhLXEMuXo1R yxSZue/G17uusSE4YnItGZQS0oZIZbAXPs8NsReAZPvDZZPucPnW2wA0dfPqZfv3Kwziy/n/ZiWG0 IgUMCPp3dtTgEjbBV1lBJXd5sRlnPFK/8O1ljYModRWxXfLhwRDIZ3DgP5kOBenZKjKHgdG5tZveC wlp/bppQOgCSzctVdeq7iVocRP/LvHLMtpSF9wb6sMSvzBS4wEZKmJNYfB/bBnGTIyivbtroWECrW uH1CvLETmSf0f4dr51bm/+Xy4AwDQ9VmOLTLhU0y47QLhsKVz4L4dcCuuFt3WlV8yqX/odPJnpIGt UIyP72+gyWuomZKMUF3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzL9t-00000001B7B-34KA; Tue, 23 Apr 2024 18:46:25 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzL9p-00000001B6F-3Y0S for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 18:46:23 +0000 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3c8317d1f25so1238909b6e.3 for ; Tue, 23 Apr 2024 11:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713897979; x=1714502779; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MysULTgnN7k+Xud5MO2Zc39+JXGl3oEbD4FIUD15UgY=; b=aHLPFHo+feg0kt7aH5f0o/2cckmhCjmcVhFsLOjmIHlwdqsqzZ9KLlqgdVoj7hgQAA joJTroaQ3zs6zvVFzgNhTaSFO/nXkEe4/hv9ms+8PomNRgffrcLJxWKhHr5MisZgZOyg do85QA4n9UtLJT0DoYT1RkawJiDwujRpRtTqsiUl2jkRjdP53AS3TNd9zxolg8aL2g9P xchK1wXZugFdAiSIpc90Q2teXqodzNYpMduESPcfT4cNk8SvGUcDGk9FxsKV58+M2Ybz VNj3VkFDhjEQ9wzZpuYzLFMlSG5IZ6lkbPOYQpEO3D32OE0i3ksv9Vvz3lKXomfwmPsT 1tMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713897979; x=1714502779; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MysULTgnN7k+Xud5MO2Zc39+JXGl3oEbD4FIUD15UgY=; b=AqklRGPNdUMQXALrueOFnlpRIlKnoftJvdoxFDv2LOyp7EfkfNGEeQF+7vHdLxcQwu PJGD4u0sULlSdaQuN/jDJ0+iv+8yfvTc/tKhXEPJTK3Ijuva9XdEwR8TIGuauxzLE0ed EvLgeX/ite0NS0Giy5Xn9RbdL7uKU9G72rAMHLXylviBaYimp448wxT17CkhSccelK2B 5p+MdBILnDiVhSN9nSMK2mDXD67lGDUy2ou927mxfXC1UwiQDzY43rMLq//B1LHX6+WT wBZJHr7Ix8JL/XtYOaNxP62YDInA9NRXRdH3nSQ2ShUNBa2R7J4dy5sOR7SKVsZpsI+d MZPg== X-Forwarded-Encrypted: i=1; AJvYcCVA9e4mVoP3XjftR8unkho/iRnZPaE5TvCg6YtlsXkoOpw0aNZ/usV4tP+JyoupMRFgKLRic7riRSpn8m1TRs3UEuNFeNF1e+wiUfdsKlVblkDMD4s= X-Gm-Message-State: AOJu0Yzl59TA+Yug0Im09H0JW41/H9BrbAQsqX/vJBTeMlJ+MdvvBd3j /KRkRke/RzD09zjOVKE2GURLdyGxM601Y9V0nbl0vC5Hxt4SPO4z X-Google-Smtp-Source: AGHT+IHVrjJnk12Cra/vApgCck0OQK7U/htDoLVGpch/iM6o+qAWkpg7ZBWU6UKE5uG8o5Oqw0+BUw== X-Received: by 2002:a05:6808:14d1:b0:3c4:e208:b784 with SMTP id f17-20020a05680814d100b003c4e208b784mr227117oiw.27.1713897979242; Tue, 23 Apr 2024 11:46:19 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id g7-20020a0ce4c7000000b0069b7aca529esm4214773qvm.14.2024.04.23.11.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 11:46:18 -0700 (PDT) From: Doug Berger To: Linus Walleij , Bartosz Golaszewski , Florian Fainelli Cc: bcm-kernel-feedback-list@broadcom.com, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger , Phil Elwell Subject: [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers Date: Tue, 23 Apr 2024 11:46:05 -0700 Message-Id: <20240423184605.2094376-1-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_114621_938140_0BAAC828 X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Forcing a gpiochip to have a fixed base number now leads to a warning message. Remove the need to do so by using the offset value of the gpiochip. Signed-off-by: Phil Elwell Signed-off-by: Doug Berger Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli Reviewed-by: Linus Walleij --- change in v2: gc->base is already initialized to -1 by bgpio_init() so the redundant initialization in this driver was removed. drivers/gpio/gpio-brcmstb.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index a789af4a5c85..790cb278b72a 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -50,7 +50,6 @@ struct brcmstb_gpio_priv { struct irq_domain *irq_domain; struct irq_chip irq_chip; int parent_irq; - int gpio_base; int num_gpios; int parent_wake_irq; }; @@ -92,7 +91,7 @@ brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank *bank) static int brcmstb_gpio_hwirq_to_offset(irq_hw_number_t hwirq, struct brcmstb_gpio_bank *bank) { - return hwirq - (bank->gc.base - bank->parent_priv->gpio_base); + return hwirq - bank->gc.offset; } static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank, @@ -118,7 +117,7 @@ static int brcmstb_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { struct brcmstb_gpio_priv *priv = brcmstb_gpio_gc_to_priv(gc); /* gc_offset is relative to this gpio_chip; want real offset */ - int hwirq = offset + (gc->base - priv->gpio_base); + int hwirq = offset + gc->offset; if (hwirq >= priv->num_gpios) return -ENXIO; @@ -263,7 +262,7 @@ static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank) { struct brcmstb_gpio_priv *priv = bank->parent_priv; struct irq_domain *domain = priv->irq_domain; - int hwbase = bank->gc.base - priv->gpio_base; + int hwbase = bank->gc.offset; unsigned long status; while ((status = brcmstb_gpio_get_active_irqs(bank))) { @@ -412,7 +411,7 @@ static int brcmstb_gpio_of_xlate(struct gpio_chip *gc, if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) return -EINVAL; - offset = gpiospec->args[0] - (gc->base - priv->gpio_base); + offset = gpiospec->args[0] - bank->gc.offset; if (offset >= gc->ngpio || offset < 0) return -EINVAL; @@ -596,8 +595,8 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) const __be32 *p; u32 bank_width; int num_banks = 0; + int num_gpios = 0; int err; - static int gpio_base; unsigned long flags = 0; bool need_wakeup_event = false; @@ -611,7 +610,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) if (IS_ERR(reg_base)) return PTR_ERR(reg_base); - priv->gpio_base = gpio_base; priv->reg_base = reg_base; priv->pdev = pdev; @@ -651,7 +649,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) dev_dbg(dev, "Width 0 found: Empty bank @ %d\n", num_banks); num_banks++; - gpio_base += MAX_GPIO_PER_BANK; + num_gpios += MAX_GPIO_PER_BANK; continue; } @@ -691,7 +689,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) err = -ENOMEM; goto fail; } - gc->base = gpio_base; gc->of_gpio_n_cells = 2; gc->of_xlate = brcmstb_gpio_of_xlate; /* not all ngpio lines are valid, will use bank width later */ @@ -713,7 +710,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) bank->id); goto fail; } - gpio_base += gc->ngpio; + num_gpios += gc->ngpio; dev_dbg(dev, "bank=%d, base=%d, ngpio=%d, width=%d\n", bank->id, gc->base, gc->ngpio, bank->width); @@ -724,7 +721,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) num_banks++; } - priv->num_gpios = gpio_base - priv->gpio_base; + priv->num_gpios = num_gpios; if (priv->parent_irq > 0) { err = brcmstb_gpio_irq_setup(pdev, priv); if (err)