summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-mockup.c
diff options
context:
space:
mode:
authorVincent Whitchurch <vincent.whitchurch@axis.com>2020-10-29 09:17:20 +0100
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2020-10-29 10:39:09 +0100
commit43ddebdd096638ef8cd2ec41d6acca3400069171 (patch)
tree1bc632851884017cdad0c05a8156247dc3dc2314 /drivers/gpio/gpio-mockup.c
parentdt-bindings: gpio: pca953x: Add support for the NXP PCAL9554B/C (diff)
downloadlinux-43ddebdd096638ef8cd2ec41d6acca3400069171.tar.xz
linux-43ddebdd096638ef8cd2ec41d6acca3400069171.zip
gpio: mockup: Allow probing from device tree
Allow the mockup driver to be probed via the device tree without any module parameters, allowing it to be used to configure and test higher level drivers like the leds-gpio driver and corresponding userspace before actual hardware is available. Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Diffstat (limited to 'drivers/gpio/gpio-mockup.c')
-rw-r--r--drivers/gpio/gpio-mockup.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 67ed4f238d43..28b757d34046 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -15,6 +15,7 @@
#include <linux/irq.h>
#include <linux/irq_sim.h>
#include <linux/irqdomain.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/property.h>
@@ -460,9 +461,16 @@ static int gpio_mockup_probe(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id gpio_mockup_of_match[] = {
+ { .compatible = "gpio-mockup", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, gpio_mockup_of_match);
+
static struct platform_driver gpio_mockup_driver = {
.driver = {
.name = "gpio-mockup",
+ .of_match_table = gpio_mockup_of_match,
},
.probe = gpio_mockup_probe,
};
@@ -556,8 +564,7 @@ static int __init gpio_mockup_init(void)
{
int i, num_chips, err;
- if ((gpio_mockup_num_ranges < 2) ||
- (gpio_mockup_num_ranges % 2) ||
+ if ((gpio_mockup_num_ranges % 2) ||
(gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES))
return -EINVAL;