GPIO unexport

What should happen whith the GPIO when I unexport an output pin? I did the following:

$ echo 89 > /sys/class/gpio/export

$ echo “out” > /sys/class/gpio/gpio89/direction

$ echo 1 > /sys/class/gpio/gpio89/value

$ echo 89 > /sys/class/gpio/unexport

After the last command I was expecting that the GPIO pin was in high impedance or set to input but the signal remains high. It’s correct?



Hi Daniel,

The GPIO/pinctrl subsystem often does not mandate an explicit behavior, hence a lot of behavior is more or less “happens to be the case like that”, for each SoC a bit different. However, that particular behavior seems not really ideal, and I just found out that since 3.8 there is a callback gpio_disable_free which allows to implement freeing a GPIO properly. I will have a look into that, thanks for pointing it out!

I created a patch which implements the gpio_disable_free callback. With this change, a GPIO pin is explicitly set to Hi-Z when unexporting the pin. You can find the change on our next branch, and it will most likely be part of our next BSP release:

Hi Stefan,

Thanks for the rapid response. I already use toradex_vf_4.1-next kernel so I think that it’s only pull the changes and build the kernel again.