Skip to content

RFC Implement refcounting for OF GPIO chips

Anton Vorontsov linux-devicetree linuxppc-dev lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3of platforms: Move common static initialization to of_node_init()arch/microblaze/kernel/prom.c arch/powerpc/kernel/prom.c arch/powerpc/platforms/iseries/vio.c +6 more+32 -171 reply
2/3of: Introduce safe accessors for node->datadrivers/of/base.c include/linux/of.h+50 -02 replies
3/3of/gpio: Introduce of_put_gpio(), add ref counting for OF GPIO chipsdrivers/of/gpio.c include/linux/of_gpio.h+75 -126 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 0/3] Implement refcounting for OF GPIO chips

Hi all,

OF GPIO infrastructure is using dynamic GPIO bases, so it is possible that of_get_gpio()'s returned GPIO number will be no longer valid, or worse, it may point to an unexpected GPIO controller.

This scenario is possible:

driver A:               driver B:              driver C:
---------               ---------              ---------

gpiochip_add()
gpio = of_get_gpio()
gpiochip_remove()
gpiochip_add()
gpio_request(gpio);
gpio_set_value(gpio);

That is, driver A assumes that it is working with GPIO from driver B, but in practice it may disappear and driver C will take its GPIO base number, so it will provide the same GPIO numbers.

The above situation is hard to trigger, but the issue is there nonetheless, and so needs fixing.

Thanks,

p.s. The patches are based on top of
'[PATCH v2 0/4] OF GPIO integration for I2C/SPI GPIO chips'
http://lkml.org/lkml/2010/2/5/243

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2