]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: mockup: rework device probing
authorBartosz Golaszewski <brgl@bgdev.pl>
Mon, 27 Nov 2017 10:48:40 +0000 (11:48 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 2 Dec 2017 21:42:24 +0000 (22:42 +0100)
commit6a89252e9800c600216c167daf0c3561c69e6834
treebfa4ca299fdb1d2d79e7c585743f79649c069fc3
parenta9e2021c4cfa0fd1b298cb4f37bec70f080b90d2
gpio: mockup: rework device probing

We currently create a single platform device in init and then parse
the configuration passed to us via module parameters in probe() before
creating GPIO chips and registering them with the gpiolib framework.

The relation between platform devices and mockup chips should be 1:1.

Create a separate platform device for each mockup chip using convenient
helpers (platform_device_register_resndata()). Pass a platform data
structure to probe() in which the configuration (GPIO base, number of
lines, chip index) extracted from the module params is stored. Make
probe() create a single mockup chip for every platform device.

This approach has several advantages:
- we only parse the module parameters in init() and can bail out before
  attaching any device if the input is invalid (currently we would
  have to examine kernel logs),
- we'll get notified by the device framework about errors in probe()
  for specific chips,
- probe() gets simplified and only does what it's supposed to.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mockup.c