Get a GPIO descriptor with devm_gpiod_get
devm_gpiod_get() looks up a named GPIO from the device tree, sets its direction and initial level, and releases it on unbind; use it instead of gpio numbers.
The old integer GPIO API is gone from new drivers. The descriptor API finds a line by a connection name taken from the firmware description, so a driver does not hard-code pin numbers. This example is for Linux 6.12.
struct gpio_desc *reset;
reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(reset))
return dev_err_probe(&pdev->dev, PTR_ERR(reset),
"cannot get the reset line\n");
usleep_range(1000, 2000);
gpiod_set_value(reset, 0); /* release the reset */demo 10000000.demo: cannot get the reset lineThe text is what you get if the device tree has no reset-gpios property: the lookup returns -ENOENT, which dev_err_probe() reports. The third argument sets the direction and the initial value in one step, which avoids a glitch on the line between the request and the first write.
The values are logical, not physical. If the property carries GPIO_ACTIVE_LOW, GPIOD_OUT_HIGH drives the pin low, so assert and release read the same way in code on every board. That is the main reason to use this API over raw numbers. The flags are GPIOD_IN, GPIOD_OUT_LOW and GPIOD_OUT_HIGH. See the GPIO consumer guide.