[PATCH v2 04/11] regulator: bq257xx: Make OTG enable GPIO really optional

Alexey Charkov posted 11 patches 1 month ago
There is a newer version of this series
[PATCH v2 04/11] regulator: bq257xx: Make OTG enable GPIO really optional
Posted by Alexey Charkov 1 month ago
The bindings describe the OTG enable GPIO as optional, but the driver
gets upset if it's not provided in the device tree.

Make the driver accept the absence of the GPIO, and just use register
writes to handle OTG mode in that case, skipping the error message for
-ENOENT.

Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
 drivers/regulator/bq257xx-regulator.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/regulator/bq257xx-regulator.c b/drivers/regulator/bq257xx-regulator.c
index 674dae6109e9..0bb58ab4b8d4 100644
--- a/drivers/regulator/bq257xx-regulator.c
+++ b/drivers/regulator/bq257xx-regulator.c
@@ -126,6 +126,12 @@ static void bq257xx_reg_dt_parse_gpio(struct platform_device *pdev)
 	of_node_put(subchild);
 
 	if (IS_ERR(pdata->otg_en_gpio)) {
+		if (PTR_ERR(pdata->otg_en_gpio) == -ENOENT) {
+			/* No GPIO, will only use register writes for OTG */
+			pdata->otg_en_gpio = NULL;
+			return;
+		}
+
 		dev_err(&pdev->dev, "Error getting enable gpio: %ld\n",
 			PTR_ERR(pdata->otg_en_gpio));
 		return;

-- 
2.52.0
Re: [PATCH v2 04/11] regulator: bq257xx: Make OTG enable GPIO really optional
Posted by Mark Brown 1 month ago
On Fri, Mar 06, 2026 at 06:33:04PM +0400, Alexey Charkov wrote:
> The bindings describe the OTG enable GPIO as optional, but the driver
> gets upset if it's not provided in the device tree.
> 
> Make the driver accept the absence of the GPIO, and just use register
> writes to handle OTG mode in that case, skipping the error message for
> -ENOENT.

Acked-by: Mark Brown <broonie@kernel.org>