From nobody Sat Jun 20 14:14:06 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 76BF921A95D for ; Tue, 14 Apr 2026 10:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776162237; cv=none; b=Xzp5ZERRKXo1lNzSQhbo1TD5Q6bVzmSoJVNt69MyhCv8qLmfcSaXbCaQaZiyA3mJEC0WSDufV+/aPUHlR6djH5MWTtMr0nt8BmjaUYpqnARMTmyN59J5V+CPcuJHCO6diAw/28HpT8j80GT6G9hoZYV/nCraVnxwPYYxY0RL6b4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776162237; c=relaxed/simple; bh=kXxYyFY2N/cEQFJ8qJDkGUJKJ4FyU6QZbTb+jig8aIo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=I6mwgdMVuswG79dLNZL6noZFXPrMISI4n8HYJJcInyUNYKGtbWqna5W9HI2bpRGMc1g2VWlYoO5O5nDzFfZTQZ4xCELbIFyVFB1UwuM3DMx+VxPaRo0zP1YW6gqDuyCilYegIUS1L/cHwttmBx0ubU4gzX3yB1s7PPPfbggvs8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=crimson.net.eu.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=crimson.net.eu.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-43d03db7f87so3314274f8f.3 for ; Tue, 14 Apr 2026 03:23:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776162229; x=1776767029; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=agEPNcn5UfOsWzLW0MOgaJUmP7o4DXe8RlSLgKzjHg4=; b=rCHYV/x/5HzeoTsbHlBrZEHAFX/nIWl+403G/ILNV/JkIbBKwEXGeLmqZQ7whUbVGa KL72D6vpG4zS55hs0NNjQAoYV8Xi9x1zwwEow8ZUgrkpMRIuD0PVOy6xxk4+LlX1qqvI 3pQ7Gvw/8iTUS8j7q1Ygh6TrBaf7aAzW1pY9TU4u+exKFxRJv2ACAJK533YvXBVaA+sF 44yCW7Z/mMGh8veq25GfHJtGnA/HIYDcXdzS8abAW/r0cpyt0bsvtRy77E7oDbfe/63E 5/hXHjBuxHFIaw9HjabvwXSoSgMNWat3neTbdqW+nNyA8uc8Tl5USkUqJTQ5lAxViF5z nDEw== X-Forwarded-Encrypted: i=1; AFNElJ/D/k7Ux/fbsdWCPbGUPyKUPruZNLqSfSAt67FkDhhqjMNlSe95RQcqh0vsk1Bn2/YmYbteQTGIyvcdhWY=@vger.kernel.org X-Gm-Message-State: AOJu0YzSRGVZZi4K+yaR2FyoLBW2+ertsYHNGCYVp4W2Ik59ILeRf+3e EpfHvzjFe5531EuJSzqbJRxVsBVMJ0l06+ifnJD4DXv/AA013KBL34SK X-Gm-Gg: AeBDievIOn5hRCOl0ytKxc2ZEzL1EbeX8+YLsDLU7lCxK4phHOv323udafDr0Cw2VLq Y/nr4Aim+Irv0d3jPphSj5lj+VgHmmdZAyzz/LlZcixnt8m4iTIcTXwFHp92DL1kX1aGLJhX4fw /7fqplZlrYhITKKGGuxvMLZHwd9INVaxkM8xOcm34Y/U9ad0Q/t+SUCg1dsfzFGvle+T7NePaEb U/MnACMNNVJ4g1fy6JRLhefr6jxkVAs5xTZbjS0QFPfNZf4ix90YH6Cyf+tKAQ6PxbMIasZ3qPA YWmWesR6KDksfRiwa8uRt6EgYFSk6uFaJGRAWVc/kYQBW4oMleC1EmPqQwg30Yo0tMtmlohNrN7 jGaOBCVfrCkRsZXR8NDUPi9WyF9zhX/b2vIBNuMflodVfXTu+WS15tI3Zz3SfYLn6QurCD1TyPr bSGgqMUREOGSxi3l496hb5/rW6rHKV45SKiy3CrtC702+3uj4qF0obz4HHGkIO4WWQz+UqPnpwP No5e5UOyNphrmiQFxYixsvwIFRICR43zBF208rGO3cHJxXYcXNMCZhI2y2QNPWajCUMuLo= X-Received: by 2002:a5d:5d83:0:b0:43b:40ef:5d1a with SMTP id ffacd0b85a97d-43d642552e7mr23917731f8f.5.1776162228496; Tue, 14 Apr 2026 03:23:48 -0700 (PDT) Received: from localhost.localdomain (host-79-18-131-221.retail.telecomitalia.it. [79.18.131.221]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d750f0ca9sm21461453f8f.37.2026.04.14.03.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2026 03:23:48 -0700 (PDT) From: deep@crimson.net.eu.org To: Krzysztof Kozlowski Cc: Linus Walleij , Bartosz Golaszewski , netdev@vger.kernel.org, linux-nfc@lists.01.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Kenet Jovan Sokoli Subject: [PATCH] nfc: s3fwrn5: switch to GPIO descriptor API Date: Tue, 14 Apr 2026 12:22:57 +0200 Message-ID: <20260414102257.365421-1-deep@crimson.net.eu.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kenet Jovan Sokoli I am working on cleaning up some legacy GPIO usage in the NFC subsystem. This patch converts the s3fwrn5 driver to use the modern descriptor based GPIO API instead of the old integer based one. Specifically: - I changed the gpio_en and gpio_fw_wake types to struct gpio_desc. - Replaced the manual DT parsing with devm_gpiod_get() in the probe functions. - Updated the calls in phy_common.c to use gpiod_set_value(). This also allowed me to remove the s3fwrn5_i2c_parse_dt and s3fwrn82_uart_parse_dt functions as they are no longer needed with the new API. Signed-off-by: Kenet Jovan Sokoli --- I have verified that this patch builds successfully with "make M=3Ddrivers/= nfc/s3fwrn5" "scripts/checkpatch.pl" with no errors or warnings. This is very complicated stuff, but I am learning a lot by doing these clea= nup works. I really hope I can contribute as much as possible to this environment, lit= tle by little. --- drivers/nfc/s3fwrn5/i2c.c | 58 ++++++-------------------------- drivers/nfc/s3fwrn5/phy_common.c | 12 +++---- drivers/nfc/s3fwrn5/phy_common.h | 5 +-- drivers/nfc/s3fwrn5/uart.c | 43 ++++++----------------- 4 files changed, 31 insertions(+), 87 deletions(-) diff --git a/drivers/nfc/s3fwrn5/i2c.c b/drivers/nfc/s3fwrn5/i2c.c index 110d086cfe5b..a629fbcd3237 100644 --- a/drivers/nfc/s3fwrn5/i2c.c +++ b/drivers/nfc/s3fwrn5/i2c.c @@ -8,9 +8,8 @@ =20 #include #include -#include +#include #include -#include #include #include =20 @@ -146,37 +145,6 @@ static irqreturn_t s3fwrn5_i2c_irq_thread_fn(int irq, = void *phy_id) return IRQ_HANDLED; } =20 -static int s3fwrn5_i2c_parse_dt(struct i2c_client *client) -{ - struct s3fwrn5_i2c_phy *phy =3D i2c_get_clientdata(client); - struct device_node *np =3D client->dev.of_node; - - if (!np) - return -ENODEV; - - phy->common.gpio_en =3D of_get_named_gpio(np, "en-gpios", 0); - if (!gpio_is_valid(phy->common.gpio_en)) { - /* Support also deprecated property */ - phy->common.gpio_en =3D of_get_named_gpio(np, - "s3fwrn5,en-gpios", - 0); - if (!gpio_is_valid(phy->common.gpio_en)) - return -ENODEV; - } - - phy->common.gpio_fw_wake =3D of_get_named_gpio(np, "wake-gpios", 0); - if (!gpio_is_valid(phy->common.gpio_fw_wake)) { - /* Support also deprecated property */ - phy->common.gpio_fw_wake =3D of_get_named_gpio(np, - "s3fwrn5,fw-gpios", - 0); - if (!gpio_is_valid(phy->common.gpio_fw_wake)) - return -ENODEV; - } - - return 0; -} - static int s3fwrn5_i2c_probe(struct i2c_client *client) { struct s3fwrn5_i2c_phy *phy; @@ -193,21 +161,17 @@ static int s3fwrn5_i2c_probe(struct i2c_client *clien= t) phy->i2c_dev =3D client; i2c_set_clientdata(client, phy); =20 - ret =3D s3fwrn5_i2c_parse_dt(client); - if (ret < 0) - return ret; - - ret =3D devm_gpio_request_one(&phy->i2c_dev->dev, phy->common.gpio_en, - GPIOF_OUT_INIT_HIGH, "s3fwrn5_en"); - if (ret < 0) - return ret; - - ret =3D devm_gpio_request_one(&phy->i2c_dev->dev, - phy->common.gpio_fw_wake, - GPIOF_OUT_INIT_LOW, "s3fwrn5_fw_wake"); - if (ret < 0) - return ret; + phy->common.gpio_en =3D devm_gpiod_get(&client->dev, "en", GPIOD_OUT_HIGH= ); + if (IS_ERR(phy->common.gpio_en)) { + return dev_err_probe(&client->dev, PTR_ERR(phy->common.gpio_en), + "Failed to get EN gpio\n"); + } =20 + phy->common.gpio_fw_wake =3D devm_gpiod_get(&client->dev, "wake", GPIOD_O= UT_LOW); + if (IS_ERR(phy->common.gpio_fw_wake)) { + return dev_err_probe(&client->dev, PTR_ERR(phy->common.gpio_fw_wake), + "Failed to get WAKE gpio\n"); + } /* * S3FWRN5 depends on a clock input ("XI" pin) to function properly. * Depending on the hardware configuration this could be an always-on diff --git a/drivers/nfc/s3fwrn5/phy_common.c b/drivers/nfc/s3fwrn5/phy_com= mon.c index deb2c039f0fd..e802b4e609c8 100644 --- a/drivers/nfc/s3fwrn5/phy_common.c +++ b/drivers/nfc/s3fwrn5/phy_common.c @@ -8,7 +8,7 @@ * Bongsu Jeon */ =20 -#include +#include #include #include =20 @@ -19,7 +19,7 @@ void s3fwrn5_phy_set_wake(void *phy_id, bool wake) struct phy_common *phy =3D phy_id; =20 mutex_lock(&phy->mutex); - gpio_set_value(phy->gpio_fw_wake, wake); + gpiod_set_value(phy->gpio_fw_wake, wake); if (wake) msleep(S3FWRN5_EN_WAIT_TIME); mutex_unlock(&phy->mutex); @@ -33,14 +33,14 @@ bool s3fwrn5_phy_power_ctrl(struct phy_common *phy, enu= m s3fwrn5_mode mode) =20 phy->mode =3D mode; =20 - gpio_set_value(phy->gpio_en, 1); - gpio_set_value(phy->gpio_fw_wake, 0); + gpiod_set_value(phy->gpio_en, 1); + gpiod_set_value(phy->gpio_fw_wake, 0); if (mode =3D=3D S3FWRN5_MODE_FW) - gpio_set_value(phy->gpio_fw_wake, 1); + gpiod_set_value(phy->gpio_fw_wake, 1); =20 if (mode !=3D S3FWRN5_MODE_COLD) { msleep(S3FWRN5_EN_WAIT_TIME); - gpio_set_value(phy->gpio_en, 0); + gpiod_set_value(phy->gpio_en, 0); msleep(S3FWRN5_EN_WAIT_TIME); } =20 diff --git a/drivers/nfc/s3fwrn5/phy_common.h b/drivers/nfc/s3fwrn5/phy_com= mon.h index 9cef25436bf9..10210a8fd755 100644 --- a/drivers/nfc/s3fwrn5/phy_common.h +++ b/drivers/nfc/s3fwrn5/phy_common.h @@ -13,6 +13,7 @@ =20 #include #include +#include =20 #include "s3fwrn5.h" =20 @@ -21,8 +22,8 @@ struct phy_common { struct nci_dev *ndev; =20 - int gpio_en; - int gpio_fw_wake; + struct gpio_desc *gpio_en; + struct gpio_desc *gpio_fw_wake; =20 struct mutex mutex; =20 diff --git a/drivers/nfc/s3fwrn5/uart.c b/drivers/nfc/s3fwrn5/uart.c index 4ee481bd7e96..5a7c7741a881 100644 --- a/drivers/nfc/s3fwrn5/uart.c +++ b/drivers/nfc/s3fwrn5/uart.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include =20 #include "phy_common.h" =20 @@ -92,25 +91,6 @@ static const struct of_device_id s3fwrn82_uart_of_match[= ] =3D { }; MODULE_DEVICE_TABLE(of, s3fwrn82_uart_of_match); =20 -static int s3fwrn82_uart_parse_dt(struct serdev_device *serdev) -{ - struct s3fwrn82_uart_phy *phy =3D serdev_device_get_drvdata(serdev); - struct device_node *np =3D serdev->dev.of_node; - - if (!np) - return -ENODEV; - - phy->common.gpio_en =3D of_get_named_gpio(np, "en-gpios", 0); - if (!gpio_is_valid(phy->common.gpio_en)) - return -ENODEV; - - phy->common.gpio_fw_wake =3D of_get_named_gpio(np, "wake-gpios", 0); - if (!gpio_is_valid(phy->common.gpio_fw_wake)) - return -ENODEV; - - return 0; -} - static int s3fwrn82_uart_probe(struct serdev_device *serdev) { struct s3fwrn82_uart_phy *phy; @@ -144,20 +124,19 @@ static int s3fwrn82_uart_probe(struct serdev_device *= serdev) =20 serdev_device_set_flow_control(serdev, false); =20 - ret =3D s3fwrn82_uart_parse_dt(serdev); - if (ret < 0) - goto err_serdev; - - ret =3D devm_gpio_request_one(&phy->ser_dev->dev, phy->common.gpio_en, - GPIOF_OUT_INIT_HIGH, "s3fwrn82_en"); - if (ret < 0) + phy->common.gpio_en =3D devm_gpiod_get(&serdev->dev, "en", GPIOD_OUT_HIGH= ); + if (IS_ERR(phy->common.gpio_en)) { + ret =3D dev_err_probe(&serdev->dev, PTR_ERR(phy->common.gpio_en), + "failed to get en gpio\n"); goto err_serdev; + } =20 - ret =3D devm_gpio_request_one(&phy->ser_dev->dev, - phy->common.gpio_fw_wake, - GPIOF_OUT_INIT_LOW, "s3fwrn82_fw_wake"); - if (ret < 0) + phy->common.gpio_fw_wake =3D devm_gpiod_get(&serdev->dev, "wake", GPIOD_O= UT_LOW); + if (IS_ERR(phy->common.gpio_fw_wake)) { + ret =3D dev_err_probe(&serdev->dev, PTR_ERR(phy->common.gpio_fw_wake), + "failed to get wake gpio\n"); goto err_serdev; + } =20 ret =3D s3fwrn5_probe(&phy->common.ndev, phy, &phy->ser_dev->dev, &uart_phy_ops); --=20 2.43.0