[PATCH] rfkill: gpio: initialize GPIOs according to default-blocked
From: jiegu
Date: Mon Nov 16 2026 - 22:21:31 EST
From: gujie <jie.gu@xxxxxxxxxxxxxxxxxxxxxxx>
When default-blocked is present, rfkill_gpio_probe() initializes the
software state to blocked but configures the GPIOs to the unblocked
level.
rfkill_init_sw_state() does not invoke the set_block callback and marks
the state as persistent, so registration does not normally synchronize
the GPIOs. The radio can therefore remain enabled while rfkill reports
it as blocked, until userspace toggles the state.
Initialize both GPIOs using !blocked, matching the existing set_block
callback and the initial software state. Preserve the existing behavior
when default-blocked is absent.
Signed-off-by: gujie <jie.gu@xxxxxxxxxxxxxxxxxxxxxxx>
---
net/rfkill/rfkill-gpio.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index cf2dcec6ce5a..e1248a6f7711 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -98,6 +98,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
const char *name_property;
const char *type_property;
struct gpio_desc *gpio;
+ bool blocked;
int ret;
if (dmi_check_system(rfkill_gpio_deny_table))
@@ -148,11 +149,13 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
return -EINVAL;
}
- ret = gpiod_direction_output(rfkill->reset_gpio, true);
+ blocked = device_property_present(&pdev->dev, "default-blocked");
+
+ ret = gpiod_direction_output(rfkill->reset_gpio, !blocked);
if (ret)
return ret;
- ret = gpiod_direction_output(rfkill->shutdown_gpio, true);
+ ret = gpiod_direction_output(rfkill->shutdown_gpio, !blocked);
if (ret)
return ret;
@@ -162,7 +165,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
if (!rfkill->rfkill_dev)
return -ENOMEM;
- if (device_property_present(&pdev->dev, "default-blocked"))
+ if (blocked)
rfkill_init_sw_state(rfkill->rfkill_dev, true);
ret = rfkill_register(rfkill->rfkill_dev);
--
2.34.1