From nobody Fri Oct 3 10:12:41 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 5FF961DF270 for ; Wed, 3 Sep 2025 08:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756886432; cv=none; b=JaefjxZkCKW2DlllJibGOvdVSv4YNUKoRvc3fGRjZ2dJ4MGrIHxSGf0Oa08KB/0Przwa1JsM9DFFQioyW7PlZVv0wF9RpURpr8+NgQ2qntoyG5neMQ7XT/FY5Nq/s6zllRJUPegLWdF1Dv+GTyEarlHQcYWdXx5ojB9hJAhNWSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756886432; c=relaxed/simple; bh=3vDdzVPFT4wpbEOIKni3Q53zP4a27+W6novBAExis5c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c1cgBI9MFdFm6BmoCsBWgbZvCp9kkwDm8IqwwgHceTu4cXcGGJhX7UTzr82nD8lZlMNeykla3F5Y/ieR3sOa1wxsmiOBk7Aw6y9UFjsBlb/hJmd/TLLSiiqYm7LvT7nMlZOzAGtJ6T5cx6rxAjuo1v6iWId8pmMkGd1Bcg6bp0M= 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=arHdQBdE; arc=none smtp.client-ip=209.85.128.45 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="arHdQBdE" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-45cb5492350so3371605e9.1 for ; Wed, 03 Sep 2025 01:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1756886429; x=1757491229; 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=vnCK+4GcmtUWl9DLQFGW+1eBeOCL1T5Ocq961UWj+Gc=; b=arHdQBdEuFoUEGufb60EYa8Ix/AMWYDQZA7c0mMO6RlJVBeHBOk8Lq7SddfwaddfK0 JHKgk9S/6k4Nc6G8qdUz1QcYx1AH/aBuJptHCTRdAiqH2lBbI5AHeH5MdF3Zwg9hfv5U tCwQlsgtxWPJIl1RJM1pkBFkNntr/0qDwi0TIBfSs20xx7a/6iiWkBtC9wxN70OZtEvP makPoeHo7iquyjUbluiNtezPBkUWe19WxbdUjQVmCAqEBsRYmVqEKORVnJi0QZN8djIo +/+PjZacyrNB5HAIGgQ4CmEXrB8hrCrhd4g4lIyuF0Yt/sOlDwrNHsIeD4V4Rr+B6Ajw +cCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756886429; x=1757491229; 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=vnCK+4GcmtUWl9DLQFGW+1eBeOCL1T5Ocq961UWj+Gc=; b=BFf+3sgJFbQ6p7g4EjE4YH3uzyLhgtXKYh8o6AzcZ/rnOTxN56+DmtSPUAbbNcXYzP o+2AITp9Qix+vHO9pFs1++i4K9ozKIh6WQP4z8NNsUlBpxOnZDXdzU7YZKx3dzD7WBc6 ee3EYe1e+XPW8Br6l4hk14ul/u6nbJYpjM9saCdYA6C1F6+OmacHWutlscKFeTySyFXU LH3c343H62GyPc7bHMI4ujb/m801BlbVAcqXhdfL1yaNZ4bI4rIN458PKQAYZayOgRXL M31FRHxt4Zxdu1jPFOBpVViZNfcRSgqRreaZhhJr4+kwTSawTj9tSWnGTMi5Q3/7LNK1 F8nw== X-Forwarded-Encrypted: i=1; AJvYcCUevNID6wjl1H6GuOTZIRYhl8zvgBMnB584Mv99a66BU3ZCuHg4WE8MLozTQuRiAe51dM9wSpJEKTDntHY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/31C2eEA63+Z78kFTijOHMUKpyYkBowIG+YMm0Vaxote6GKoI L13P0noW92vjz8JNypZQLfgqyPXxGZwHGqf2UTXSTxCw0iIx/W6URqAiU480OBe4IkDWfhUUuDq TbqzV X-Gm-Gg: ASbGncsrH2wXaIpkWJstTHUZLNWzfCiQRnyOt0NHIVVwQUpjLHhnlXVVCWi+sB+FGE2 LRSX7qPVnM79a/OLsbuelsB2k3Q+xpbH1oJVAzsxEzMwolPlrrSil/iDRik2Zw3R9OBvd9v826b 8rMOuqXVl4fztJjBwZ1NaNw4BsOsTwZVK1HuBuQPKXcavfmXh1p5Q+9wJRpvd2pmz8UvcLYnAi/ N7fDt9V7DPMBJQ5Ya1XCCXE44xa5/in/lJXFaGTscuPzbjwzgNgYp/LELPrVi2dotqSpT/Hz4L9 xo5uL+sRkQD4Cq3v0cfG85XKmLeuDZe9T6+YSgw/lIvXH2IRLqW6mh7ETRrBPtwFhpkp/FPGITR 34ESOfcZ9Gs8Te/HcfkJQhQ1H0Os= X-Google-Smtp-Source: AGHT+IE8VpkQ9cPsjhCBKghShX0Bl86iztiD15845yI63ssB39+OiqSQqOV8L5+iSxUO0uLkiZ8Vkw== X-Received: by 2002:a05:600c:3b1f:b0:458:b7d1:99f9 with SMTP id 5b1f17b1804b1-45b87bf22ecmr114918845e9.11.1756886428337; Wed, 03 Sep 2025 01:00:28 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:2f8b:4799:6bd6:35df]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b83e954b7sm113331635e9.1.2025.09.03.01.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Sep 2025 01:00:27 -0700 (PDT) From: Bartosz Golaszewski Date: Wed, 03 Sep 2025 10:00:11 +0200 Subject: [PATCH 07/12] gpio: tb10x: 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: <20250903-gpio-mmio-gpio-conv-part3-v1-7-ff346509f408@linaro.org> References: <20250903-gpio-mmio-gpio-conv-part3-v1-0-ff346509f408@linaro.org> In-Reply-To: <20250903-gpio-mmio-gpio-conv-part3-v1-0-ff346509f408@linaro.org> To: Linus Walleij , Bartosz Golaszewski , Linus Walleij , Imre Kaloz , James Cowgill , Matt Redfearn , Neil Jones , Nikolaos Pasaloukos Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5920; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=LEfQoq/BGGaE4EFy3J9Er3X0SX0E/ULNzxMEYdtgsLk=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBot/WSJxSeZd8tGawqeqLKQYFSa+dWYjIv4dw6W zAqDihhEeeJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCaLf1kgAKCRARpy6gFHHX cibjD/91jPhdREz7ITpTc4Bx2jp/TVrMaWDc8rjbdLj7Db9CBR3YfOU1BkXTOMjss1kF+cxJRxY /rBQwdz1nHMtjBCIEYK0fpZCSXAe3HEUf4Xgf4WN6eHtD7xlySRfp7FtAEaoAVXEKzYpgvCbPec iMVPgcTDQfOGnDTaCEC7qcn/qHUsAw9AjEN9RP9YYVh3iQNoSAzlG3sGyp27iSqXkCnBmQq/ZZA +Jh0XUm7PUqunAil9Ychwag0TE03hvSGdgICXuVf+hYqLAtqexOyd8jwdwX1va8w7PeeQFHqR5m 1UxnycC034tJ1FgNc/rOxazX9X5xDsstiMRaEEFc7psWaxrG5kXknRGZLSkyMGsqPKN3wjjpqOA bSUhpEaMmfRdZKi3b+h7rZTxY4OJYJNewoKdw2GU6iWoZBZUBl9xrPTSw6MSxFywyuo6Iel8+iq Uofkcg6elIP0YuIbDScyRC8YzH6OCd1iIEDgcf2ev7OcaskvPLlgTEvZ04IPWI0ERmXxS+DayXW S6vByR80LiXFoLpXiGHJbH85u6Qe5kFdcxkBVnc63nXNaK55jp0QYFUO+XHl24G6yBolOJxXQHJ cSOB+qQf6pdOVXorwlrQUXtyVv9Nf1sfnWntJ4WZYyPHlv+45cJawr2kKMMcPH5tgu/gKmjKOOT VZqUiuxejp6XHIQ== 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-tb10x.c | 60 +++++++++++++++++++++++--------------------= ---- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 356d0a82e25f29f60c43801cee6c6803ea7a22c2..f20b6654b865555579bb356a336= 308e23b0e5af6 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c @@ -9,6 +9,7 @@ =20 #include #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include =20 #define TB10X_GPIO_DIR_IN (0x00000000) #define TB10X_GPIO_DIR_OUT (0x00000001) @@ -36,13 +36,13 @@ * @base: register base address * @domain: IRQ domain of GPIO generated interrupts managed by this contro= ller * @irq: Interrupt line of parent interrupt controller - * @gc: gpio_chip structure associated to this GPIO controller + * @chip: Generic GPIO chip structure associated with this GPIO controller */ struct tb10x_gpio { void __iomem *base; struct irq_domain *domain; int irq; - struct gpio_chip gc; + struct gpio_generic_chip chip; }; =20 static inline u32 tb10x_reg_read(struct tb10x_gpio *gpio, unsigned int off= s) @@ -60,16 +60,13 @@ static inline void tb10x_set_bits(struct tb10x_gpio *gp= io, unsigned int offs, u32 mask, u32 val) { u32 r; - unsigned long flags; =20 - raw_spin_lock_irqsave(&gpio->gc.bgpio_lock, flags); + guard(gpio_generic_lock_irqsave)(&gpio->chip); =20 r =3D tb10x_reg_read(gpio, offs); r =3D (r & ~mask) | (val & mask); =20 tb10x_reg_write(gpio, offs, r); - - raw_spin_unlock_irqrestore(&gpio->gc.bgpio_lock, flags); } =20 static int tb10x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) @@ -107,6 +104,7 @@ static irqreturn_t tb10x_gpio_irq_cascade(int irq, void= *data) =20 static int tb10x_gpio_probe(struct platform_device *pdev) { + struct gpio_generic_chip_config config; struct tb10x_gpio *tb10x_gpio; struct device *dev =3D &pdev->dev; struct device_node *np =3D dev->of_node; @@ -127,9 +125,9 @@ static int tb10x_gpio_probe(struct platform_device *pde= v) if (IS_ERR(tb10x_gpio->base)) return PTR_ERR(tb10x_gpio->base); =20 - tb10x_gpio->gc.label =3D + tb10x_gpio->chip.gc.label =3D devm_kasprintf(dev, GFP_KERNEL, "%pOF", pdev->dev.of_node); - if (!tb10x_gpio->gc.label) + if (!tb10x_gpio->chip.gc.label) return -ENOMEM; =20 /* @@ -137,29 +135,30 @@ static int tb10x_gpio_probe(struct platform_device *p= dev) * the lines, no special set or clear registers and a data direction regi= ster * wher 1 means "output". */ - ret =3D bgpio_init(&tb10x_gpio->gc, dev, 4, - tb10x_gpio->base + OFFSET_TO_REG_DATA, - NULL, - NULL, - tb10x_gpio->base + OFFSET_TO_REG_DDR, - NULL, - 0); + config =3D (typeof(config)){ + .dev =3D dev, + .sz =3D 4, + .dat =3D tb10x_gpio->base + OFFSET_TO_REG_DATA, + .dirout =3D tb10x_gpio->base + OFFSET_TO_REG_DDR, + }; + + ret =3D gpio_generic_chip_init(&tb10x_gpio->chip, &config); if (ret) { dev_err(dev, "unable to init generic GPIO\n"); return ret; } - tb10x_gpio->gc.base =3D -1; - tb10x_gpio->gc.parent =3D dev; - tb10x_gpio->gc.owner =3D THIS_MODULE; + tb10x_gpio->chip.gc.base =3D -1; + tb10x_gpio->chip.gc.parent =3D dev; + tb10x_gpio->chip.gc.owner =3D THIS_MODULE; /* - * ngpio is set by bgpio_init() but we override it, this .request() - * callback also overrides the one set up by generic GPIO. + * ngpio is set by gpio_generic_chip_init() but we override it, this + * .request() callback also overrides the one set up by generic GPIO. */ - tb10x_gpio->gc.ngpio =3D ngpio; - tb10x_gpio->gc.request =3D gpiochip_generic_request; - tb10x_gpio->gc.free =3D gpiochip_generic_free; + tb10x_gpio->chip.gc.ngpio =3D ngpio; + tb10x_gpio->chip.gc.request =3D gpiochip_generic_request; + tb10x_gpio->chip.gc.free =3D gpiochip_generic_free; =20 - ret =3D devm_gpiochip_add_data(dev, &tb10x_gpio->gc, tb10x_gpio); + ret =3D devm_gpiochip_add_data(dev, &tb10x_gpio->chip.gc, tb10x_gpio); if (ret < 0) { dev_err(dev, "Could not add gpiochip.\n"); return ret; @@ -174,7 +173,7 @@ static int tb10x_gpio_probe(struct platform_device *pde= v) if (ret < 0) return ret; =20 - tb10x_gpio->gc.to_irq =3D tb10x_gpio_to_irq; + tb10x_gpio->chip.gc.to_irq =3D tb10x_gpio_to_irq; tb10x_gpio->irq =3D ret; =20 ret =3D devm_request_irq(dev, ret, tb10x_gpio_irq_cascade, @@ -183,14 +182,15 @@ static int tb10x_gpio_probe(struct platform_device *p= dev) if (ret !=3D 0) return ret; =20 - tb10x_gpio->domain =3D irq_domain_create_linear(dev_fwnode(dev), tb10x_g= pio->gc.ngpio, + tb10x_gpio->domain =3D irq_domain_create_linear(dev_fwnode(dev), + tb10x_gpio->chip.gc.ngpio, &irq_generic_chip_ops, NULL); if (!tb10x_gpio->domain) { return -ENOMEM; } =20 ret =3D irq_alloc_domain_generic_chips(tb10x_gpio->domain, - tb10x_gpio->gc.ngpio, 1, tb10x_gpio->gc.label, + tb10x_gpio->chip.gc.ngpio, 1, tb10x_gpio->chip.gc.label, handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE, IRQ_GC_INIT_MASK_CACHE); if (ret) @@ -218,9 +218,9 @@ static void tb10x_gpio_remove(struct platform_device *p= dev) { struct tb10x_gpio *tb10x_gpio =3D platform_get_drvdata(pdev); =20 - if (tb10x_gpio->gc.to_irq) { + if (tb10x_gpio->chip.gc.to_irq) { irq_remove_generic_chip(tb10x_gpio->domain->gc->gc[0], - BIT(tb10x_gpio->gc.ngpio) - 1, 0, 0); + BIT(tb10x_gpio->chip.gc.ngpio) - 1, 0, 0); kfree(tb10x_gpio->domain->gc); irq_domain_remove(tb10x_gpio->domain); } --=20 2.48.1