Thank you for your response! All clear! -----Original Message----- From: Linus Walleij <linus.walleij@xxxxxxxxxx> Sent: Friday, September 2, 2022 5:55 PM To: Asmaa Mnebhi <asmaa@xxxxxxxxxx> Cc: andy.shevchenko@xxxxxxxxx; bgolaszewski@xxxxxxxxxxxx; linux-gpio@xxxxxxxxxxxxxxx; linux-acpi@xxxxxxxxxxxxxxx Subject: Re: [PATCH v1 1/1] Add driver for Mellanox BlueField-3 GPIO controller Importance: High On Fri, Sep 2, 2022 at 5:55 PM Asmaa Mnebhi <asmaa@xxxxxxxxxx> wrote: > During testing, I use the sysfs to change the gpio value as follows: > Cd /sys/class/gpio > echo 480 > export > When I do the export, I see that gpiochip_generic_request is being called which calls .gpio_request_enable = mlxbf_gpio_request_enable. Yes but don't use the deprecated sysfs to test GPIO, use libgpiod https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ > Is this how it also works in other driver? Or am I missing something? The gpio_chip usually works as a front end for pin control. > I wanted to disallow muxing from user space. If you ask for a GPIO then it will be muxed in if you implement .gpio_request_enable(). If you want to make it impossible to use certain gpios alter .valid_mask. If you don't want people to use the sysfs ABI (which by the way requires you to first select the "CONFIG_EXPERT" option) then do not compile it into the kernel. It is a big risk to use it in any case, so just don't. If you use the character device (which is enabled by default), you can set permissions on /dev/gpiochipN such that only privileged users can access it, just like you protect any other block/character device. > I would like that to be controlled by the ACPI table only. I don't know if it is possible to restrict GPIOs to just be used from ACPI. > For example, use devm_gpio_request from some other driver if needed. If you only want other kernel consumers to use GPIOs, the disable the sysfs ABI, and also disable the character device, then only the kernel can use GPIOs. Yours, Linus Walleij