From nobody Fri Oct 3 01:09:32 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AF4B2D9ECF for ; Tue, 9 Sep 2025 09:15:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757409353; cv=none; b=TMTAg9Y/BXSl+skcjTvUfmRl4HLYYBhKP8w8qo8A8BD+o+BtW1dx12r564RQabIScpcNBMhO0WOB65VReX7DhevEDyUXq/BZg5UTaIrvt/Ohz764eoigZhiIVD58Z2UaemDX3abXBqdSU5naIOlrYsLC4emoJdM2QErMEL+E+1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757409353; c=relaxed/simple; bh=m3C6YMA5NpordnkRgnAsfsyx2uMyKsrWO0yN6UpIPP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MqmWDwiIUux2TL6lD1CIP1q9mTSDG0ndc8lGNCl/MY52y1jZhDncTBnadEi65wyxDQZeyUTwF76zVyqavxBIyXzvK6C9777IN+4t4S+lqY1Mr4v5QbG8IKMCJ82VZf8SS5LcQsjYApJqEUH2Lxt7e+bT7wrjr3P+bGHFw4++erk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=Y43vgzqc; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="Y43vgzqc" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45cb6180b60so33818455e9.0 for ; Tue, 09 Sep 2025 02:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1757409350; x=1758014150; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bfVsXcyRTPM0823GsALirp0A0UZxDbq+MOQO0Rm+6MM=; b=Y43vgzqcU8Qarv+KOPsEAj/DOnRwQ6o23H+Je3U77Z9Zc6irNpbooWFxaxOD6GbDcQ h27gDR98ysMvBDcXKinLu3ooLnennjAxASQuII3sdDZagHGTwKZ9i/VmM3ei2wFcOx5n Sjr6JfLvF+xUhbeEacj0D3IcC90+4BPuYBPoJKMfTdbiWL5NxowfNykflPW2ZYMvkqWT juDDaaFTMlG5r3HJ9e1r+/V0hhlu6fIMlKbh5avP/WkzIhcnY84ecOp/LC0RrrZAToYh eHzhxNKENiSFsqqwHpU6lzi/Tf2eMLQ+YR4NQj6fHPJZGqdc1IAbepp3d77usvFuOLck CL/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757409350; x=1758014150; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bfVsXcyRTPM0823GsALirp0A0UZxDbq+MOQO0Rm+6MM=; b=t5PuOkQ5sa+unSOEuziEYBMNrQh40uRfaZ5IqoJM1auPeijilpKMAoSdvO1o6WY4jV cA3SbRUiznuJz3F6ybHQyecfjBMJ1Y7EADwwVn94goe5XFZEYgBOXjEiBO5wGNUBwqbn 6W+evsLZVaS4hXEgtfJ/e1tRqoBeXLeKhU7pNwSgNZ1aY3nRWSYgzgbhdllEG+kQeAcY iYC65manxR358w9hG/7iAqvMLz9LAuY2pgdrYgj7HKQcRn1IRt1AFzut60XabF60fiJY lMU9dZ7tEyjvAnoVOYVlI/ERmgQmEKL/IhDoRBr5l/+97wIuHXO7yQPq8L4/AEqLWswc 9olg== X-Forwarded-Encrypted: i=1; AJvYcCXuEyDlf3fA2g061aKGMsLIHmBmfgFIHGv13vFPrzYEw0uTiXSsfWChzUK0whBXeZmKTmxcGmqj4M8xW5E=@vger.kernel.org X-Gm-Message-State: AOJu0YwTtOjw0ysFqaaZ8JIwXfDKPecVjR5T6lPmdVdaU6tSPYPqMglx a100EzxXBsrC/gmSv9gQ0moQF3qjvfuuvHduB18ApnlDrg3MuuG7k4OpwBRtuMKKAcM= X-Gm-Gg: ASbGncvLUfVNafG4aJiNeSeThxMOg2j9WaTF3Y7OhQUW3dIXy8CM+VeU3bJpoqopxT4 gJlC4sUqxq2xm2EQTWSMVvpypcCTLpjSbS2bXJkJ9c2+apACXWMiBzTDU8OFOgTXaM7RwbgKI2d MGlf4TMJBZVYsEskHSxMElkQDmSLk/3YQCHPpGy/n7Mhg4jVzk+pSmT8mlARD1365U++a/GxaTh +wdpDURk5jI64euYpu+pElWjwE05ivMm2Q66BPDD8tjGifrPMXBLD1LtStx4gBsZgYDvG39Co3f SEpvFavJIGvzaF3mvhSYmgxoWFd3CKboRzylO1SNedMa2vmH/iwtCPUfGHPT23aNDwPwtEMAHyW g+xDWM66/1j8mjk5BrQ== X-Google-Smtp-Source: AGHT+IFWuFmitLzvuFEhGEXuEuX7h1gnAXktOXE047kf9ZXksjM66NyEnLgZClefDTe7m/DeVUPeow== X-Received: by 2002:a05:600c:6304:b0:45b:43cc:e558 with SMTP id 5b1f17b1804b1-45dddef818cmr82339105e9.35.1757409349756; Tue, 09 Sep 2025 02:15:49 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:c1ee:7be9:3ebb:6cc0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7521c9caasm1900039f8f.19.2025.09.09.02.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 02:15:48 -0700 (PDT) From: Bartosz Golaszewski Date: Tue, 09 Sep 2025 11:15:31 +0200 Subject: [PATCH 04/15] gpio: ath79: use new generic GPIO chip API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250909-gpio-mmio-gpio-conv-part4-v1-4-9f723dc3524a@linaro.org> References: <20250909-gpio-mmio-gpio-conv-part4-v1-0-9f723dc3524a@linaro.org> In-Reply-To: <20250909-gpio-mmio-gpio-conv-part4-v1-0-9f723dc3524a@linaro.org> To: Linus Walleij , Bartosz Golaszewski , Keguang Zhang , Alban Bedel , Doug Berger , Florian Fainelli , Broadcom internal kernel review list , Matthias Brugger , AngeloGioacchino Del Regno , Paul Walmsley , Samuel Holland , Yixun Lan , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4596; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=KmFRStxrtBvgq9SHCuo+p5UvH6qsrW0hcSZujIjU2hM=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBov/A3uBuQUbggrZea4yqPMYEhQc7SR2SyAu4FG dnGFptiCCCJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCaL/wNwAKCRARpy6gFHHX cn7KEAC75xLioRo7Kh1dAfxq+uodLO/+7Wk5UsHsHIvgNKgcWkuWxxBBlb5yTHgZY8lOfw01MAv HLoSw+kRGn25m6kndbzXFcCkeAazbboy8tacIA34T9zLdqqiwNpQ6savUwoWwvQkJCe0Zd1sqyI X0+vuDS5bIpm+F1QnjiLMe0Sbb5PdipzpKDn9Qwvnh9Q1eKdnSW7fzabnl+ZttJSyqO9c77+dlW vo0l5G1dhMiwMY22CWhQs+0Gf2yPiwTZNH2IZggwTy5Na4Y7W6g8ioYaRYaAVsV7JVE+2sagt1b 7Z6NrRm51Mjd01e8i9/OaOH/o3nrWYM3/CETm+sekj8hOtYGtazwGUB8hHTtSy1++BBuRVvn1w5 8rHU8b0ScSiXUkEMSJ+BcGNF15jH3HfKtRCJN3+oO9GO/zHO96i5/v9gIeW/n/B5ivuN9QYHj3H 2A2/MveLQWeuYS6pJTiDY0LW+Ca84OmZDAL7rXXHxhhBR2GGAsU7R+G/J9V54uK7wxEpV29NbAJ ZhSbTRuR8KfbBPHNHz4dMXLnfg3POU4uZ9gTYS4Hj4W2nq7UIAFdcqefi4dcZ4isDmpX37sSQN9 7tu6A1Uoe8feo2JitwhMJoDwuuxnvLFgCKh3IiC+gesr2EEf4/dOHoE2K9kLjL3LpOHzh3r2b96 UGm1jx/g7L4nGcg== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Convert the driver to using the new generic GPIO chip interfaces from linux/gpio/generic.h. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-ath79.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index de4cc12e5e0399abcef61a89c8c91a1b203d20fb..1b2a59ddbec4088c95fb766277b= b94ffff8692b2 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include #include #include @@ -28,7 +29,7 @@ #define AR71XX_GPIO_REG_INT_MASK 0x24 =20 struct ath79_gpio_ctrl { - struct gpio_chip gc; + struct gpio_generic_chip chip; void __iomem *base; raw_spinlock_t lock; unsigned long both_edges; @@ -37,8 +38,9 @@ struct ath79_gpio_ctrl { static struct ath79_gpio_ctrl *irq_data_to_ath79_gpio(struct irq_data *dat= a) { struct gpio_chip *gc =3D irq_data_get_irq_chip_data(data); + struct gpio_generic_chip *gen_gc =3D to_gpio_generic_chip(gc); =20 - return container_of(gc, struct ath79_gpio_ctrl, gc); + return container_of(gen_gc, struct ath79_gpio_ctrl, chip); } =20 static u32 ath79_gpio_read(struct ath79_gpio_ctrl *ctrl, unsigned reg) @@ -72,7 +74,7 @@ static void ath79_gpio_irq_unmask(struct irq_data *data) u32 mask =3D BIT(irqd_to_hwirq(data)); unsigned long flags; =20 - gpiochip_enable_irq(&ctrl->gc, irqd_to_hwirq(data)); + gpiochip_enable_irq(&ctrl->chip.gc, irqd_to_hwirq(data)); raw_spin_lock_irqsave(&ctrl->lock, flags); ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); raw_spin_unlock_irqrestore(&ctrl->lock, flags); @@ -87,7 +89,7 @@ static void ath79_gpio_irq_mask(struct irq_data *data) raw_spin_lock_irqsave(&ctrl->lock, flags); ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); raw_spin_unlock_irqrestore(&ctrl->lock, flags); - gpiochip_disable_irq(&ctrl->gc, irqd_to_hwirq(data)); + gpiochip_disable_irq(&ctrl->chip.gc, irqd_to_hwirq(data)); } =20 static void ath79_gpio_irq_enable(struct irq_data *data) @@ -187,8 +189,9 @@ static void ath79_gpio_irq_handler(struct irq_desc *des= c) { struct gpio_chip *gc =3D irq_desc_get_handler_data(desc); struct irq_chip *irqchip =3D irq_desc_get_chip(desc); + struct gpio_generic_chip *gen_gc =3D to_gpio_generic_chip(gc); struct ath79_gpio_ctrl *ctrl =3D - container_of(gc, struct ath79_gpio_ctrl, gc); + container_of(gen_gc, struct ath79_gpio_ctrl, chip); unsigned long flags, pending; u32 both_edges, state; int irq; @@ -224,6 +227,7 @@ MODULE_DEVICE_TABLE(of, ath79_gpio_of_match); =20 static int ath79_gpio_probe(struct platform_device *pdev) { + struct gpio_generic_chip_config config; struct device *dev =3D &pdev->dev; struct ath79_gpio_ctrl *ctrl; struct gpio_irq_chip *girq; @@ -253,21 +257,26 @@ static int ath79_gpio_probe(struct platform_device *p= dev) return PTR_ERR(ctrl->base); =20 raw_spin_lock_init(&ctrl->lock); - err =3D bgpio_init(&ctrl->gc, dev, 4, - ctrl->base + AR71XX_GPIO_REG_IN, - ctrl->base + AR71XX_GPIO_REG_SET, - ctrl->base + AR71XX_GPIO_REG_CLEAR, - oe_inverted ? NULL : ctrl->base + AR71XX_GPIO_REG_OE, - oe_inverted ? ctrl->base + AR71XX_GPIO_REG_OE : NULL, - 0); + + config =3D (typeof(config)){ + .dev =3D dev, + .sz =3D 4, + .dat =3D ctrl->base + AR71XX_GPIO_REG_IN, + .set =3D ctrl->base + AR71XX_GPIO_REG_SET, + .clr =3D ctrl->base + AR71XX_GPIO_REG_CLEAR, + .dirout =3D oe_inverted ? NULL : ctrl->base + AR71XX_GPIO_REG_OE, + .dirin =3D oe_inverted ? ctrl->base + AR71XX_GPIO_REG_OE : NULL, + }; + + err =3D gpio_generic_chip_init(&ctrl->chip, &config); if (err) { - dev_err(dev, "bgpio_init failed\n"); + dev_err(dev, "failed to initialize generic GPIO chip\n"); return err; } =20 /* Optional interrupt setup */ if (device_property_read_bool(dev, "interrupt-controller")) { - girq =3D &ctrl->gc.irq; + girq =3D &ctrl->chip.gc.irq; gpio_irq_chip_set_chip(girq, &ath79_gpio_irqchip); girq->parent_handler =3D ath79_gpio_irq_handler; girq->num_parents =3D 1; @@ -280,7 +289,7 @@ static int ath79_gpio_probe(struct platform_device *pde= v) girq->handler =3D handle_simple_irq; } =20 - return devm_gpiochip_add_data(dev, &ctrl->gc, ctrl); + return devm_gpiochip_add_data(dev, &ctrl->chip.gc, ctrl); } =20 static struct platform_driver ath79_gpio_driver =3D { --=20 2.48.1