Skip to content
  • Johan Hovold's avatar
    gpio: sysfs: use per-gpio locking · 6ffcb797
    Johan Hovold authored
    
    
    Add a per-gpio mutex to serialise attribute operations rather than use
    one global mutex for all gpios and chips.
    
    Having a single global lock for all gpios in a system adds unnecessary
    latency to the sysfs interface, and especially when having gpio
    controllers connected over slow buses.
    
    Now that the global gpio-sysfs interrupt table is gone and with per-gpio
    data in place, we can easily switch to using a more fine-grained locking
    scheme.
    
    Keep the global mutex to serialise the global (class) operations of gpio
    export and unexport and chip removal.
    
    Also document the locking assumptions made.
    
    Note that this is also needed to fix a race between gpiod_export and
    gpiod_unexport.
    
    Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
    Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    6ffcb797