blob: a6bfbe58bc63acb805c582dec7ed9c678b2bb40e [file] [log] [blame]
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +02001/*
2 * GPIO Testing Device Driver
3 *
4 * Copyright (C) 2014 Kamlakant Patel <kamlakant.patel@broadcom.com>
5 * Copyright (C) 2015-2016 Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
Bartosz Golaszewskic60c7f42017-06-09 13:41:31 +02006 * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +02007 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/init.h>
16#include <linux/module.h>
17#include <linux/gpio/driver.h>
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +010018#include <linux/gpio/consumer.h>
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020019#include <linux/platform_device.h>
Bartosz Golaszewski8a68ea02017-02-06 13:10:37 +010020#include <linux/slab.h>
Bartosz Golaszewskie2ff7402017-02-06 15:11:07 +010021#include <linux/interrupt.h>
22#include <linux/irq.h>
Bartosz Golaszewskib4c495f2017-08-14 13:20:56 +020023#include <linux/irq_sim.h>
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +010024#include <linux/debugfs.h>
25#include <linux/uaccess.h>
26
27#include "gpiolib.h"
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020028
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010029#define GPIO_MOCKUP_NAME "gpio-mockup"
Bartosz Golaszewskib9576d02017-11-27 11:48:42 +010030#define GPIO_MOCKUP_MAX_GC 10
Bartosz Golaszewskib6523362017-06-09 13:41:28 +020031/*
32 * We're storing two values per chip: the GPIO base and the number
33 * of GPIO lines.
34 */
35#define GPIO_MOCKUP_MAX_RANGES (GPIO_MOCKUP_MAX_GC * 2)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020036
Bartosz Golaszewskif1bec992017-11-27 11:48:41 +010037#define gpio_mockup_err(...) pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
38
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010039enum {
Bartosz Golaszewskic650c002017-05-25 10:33:39 +020040 GPIO_MOCKUP_DIR_OUT = 0,
41 GPIO_MOCKUP_DIR_IN = 1,
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020042};
43
44/*
45 * struct gpio_pin_status - structure describing a GPIO status
46 * @dir: Configures direction of gpio as "in" or "out", 0=in, 1=out
47 * @value: Configures status of the gpio as 0(low) or 1(high)
48 */
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010049struct gpio_mockup_line_status {
50 int dir;
Bartosz Golaszewski5b7908c2017-11-27 11:48:46 +010051 int value;
Bartosz Golaszewskie2ff7402017-02-06 15:11:07 +010052};
53
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010054struct gpio_mockup_chip {
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020055 struct gpio_chip gc;
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010056 struct gpio_mockup_line_status *lines;
Bartosz Golaszewskib4c495f2017-08-14 13:20:56 +020057 struct irq_sim irqsim;
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +010058 struct dentry *dbg_dir;
59};
60
61struct gpio_mockup_dbgfs_private {
62 struct gpio_mockup_chip *chip;
63 struct gpio_desc *desc;
64 int offset;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020065};
66
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +010067struct gpio_mockup_platform_data {
68 int base;
69 int ngpio;
70 int index;
Bartosz Golaszewskic3196a72017-11-27 11:48:44 +010071 bool named_lines;
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +010072};
73
Bartosz Golaszewskib6523362017-06-09 13:41:28 +020074static int gpio_mockup_ranges[GPIO_MOCKUP_MAX_RANGES];
Bartosz Golaszewskie63a0062017-11-27 11:48:53 +010075static int gpio_mockup_num_ranges;
76module_param_array(gpio_mockup_ranges, int, &gpio_mockup_num_ranges, 0400);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020077
Bartosz Golaszewski8a68ea02017-02-06 13:10:37 +010078static bool gpio_mockup_named_lines;
79module_param_named(gpio_mockup_named_lines,
80 gpio_mockup_named_lines, bool, 0400);
81
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +010082static struct dentry *gpio_mockup_dbg_dir;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020083
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010084static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020085{
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010086 struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020087
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010088 return chip->lines[offset].value;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020089}
90
Bartosz Golaszewski2a9d7422017-11-27 11:48:50 +010091static void gpio_mockup_set(struct gpio_chip *gc,
92 unsigned int offset, int value)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020093{
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010094 struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020095
Bartosz Golaszewskica4091602017-02-06 13:10:35 +010096 chip->lines[offset].value = !!value;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +020097}
98
Bartosz Golaszewskic47bee92017-11-27 11:48:51 +010099static void gpio_mockup_set_multiple(struct gpio_chip *gc,
100 unsigned long *mask, unsigned long *bits)
101{
102 unsigned int bit;
103
104 for_each_set_bit(bit, mask, gc->ngpio)
105 gpio_mockup_set(gc, bit, test_bit(bit, bits));
106
107}
108
Bartosz Golaszewski2a9d7422017-11-27 11:48:50 +0100109static int gpio_mockup_dirout(struct gpio_chip *gc,
110 unsigned int offset, int value)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200111{
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100112 struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200113
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100114 gpio_mockup_set(gc, offset, value);
Bartosz Golaszewskic650c002017-05-25 10:33:39 +0200115 chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100116
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200117 return 0;
118}
119
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100120static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200121{
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100122 struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200123
Bartosz Golaszewskic650c002017-05-25 10:33:39 +0200124 chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100125
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200126 return 0;
127}
128
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100129static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200130{
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100131 struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200132
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100133 return chip->lines[offset].dir;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200134}
135
Bartosz Golaszewskib4c495f2017-08-14 13:20:56 +0200136static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
Bartosz Golaszewskie2ff7402017-02-06 15:11:07 +0100137{
Bartosz Golaszewskic7f5326fb2017-05-25 10:33:41 +0200138 struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
139
Bartosz Golaszewskib4c495f2017-08-14 13:20:56 +0200140 return irq_sim_irqnum(&chip->irqsim, offset);
Bartosz Golaszewskie2ff7402017-02-06 15:11:07 +0100141}
142
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100143static ssize_t gpio_mockup_event_write(struct file *file,
144 const char __user *usr_buf,
145 size_t size, loff_t *ppos)
146{
147 struct gpio_mockup_dbgfs_private *priv;
148 struct gpio_mockup_chip *chip;
149 struct seq_file *sfile;
150 struct gpio_desc *desc;
Bartosz Golaszewski6f9b3e72017-06-09 13:41:25 +0200151 int rv, val;
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100152
Bartosz Golaszewski6f9b3e72017-06-09 13:41:25 +0200153 rv = kstrtoint_from_user(usr_buf, size, 0, &val);
154 if (rv)
155 return rv;
156 if (val != 0 && val != 1)
157 return -EINVAL;
158
Bartosz Golaszewski650b57b2017-06-09 13:41:26 +0200159 sfile = file->private_data;
160 priv = sfile->private;
161 desc = priv->desc;
162 chip = priv->chip;
Bartosz Golaszewskic7f5326fb2017-05-25 10:33:41 +0200163
Bartosz Golaszewskib4c495f2017-08-14 13:20:56 +0200164 gpiod_set_value_cansleep(desc, val);
165 irq_sim_fire(&chip->irqsim, priv->offset);
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100166
167 return size;
168}
169
170static int gpio_mockup_event_open(struct inode *inode, struct file *file)
171{
172 return single_open(file, NULL, inode->i_private);
173}
174
175static const struct file_operations gpio_mockup_event_ops = {
176 .owner = THIS_MODULE,
177 .open = gpio_mockup_event_open,
178 .write = gpio_mockup_event_write,
179 .llseek = no_llseek,
180};
181
182static void gpio_mockup_debugfs_setup(struct device *dev,
183 struct gpio_mockup_chip *chip)
184{
185 struct gpio_mockup_dbgfs_private *priv;
Bartosz Golaszewskica8792a2017-11-27 11:48:45 +0100186 struct dentry *evfile, *link;
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100187 struct gpio_chip *gc;
Bartosz Golaszewskica8792a2017-11-27 11:48:45 +0100188 const char *devname;
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100189 char *name;
190 int i;
191
192 gc = &chip->gc;
Bartosz Golaszewskica8792a2017-11-27 11:48:45 +0100193 devname = dev_name(&gc->gpiodev->dev);
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100194
Bartosz Golaszewskica8792a2017-11-27 11:48:45 +0100195 chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir);
Bartosz Golaszewski46526c12017-11-27 11:48:48 +0100196 if (IS_ERR_OR_NULL(chip->dbg_dir))
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100197 goto err;
198
Bartosz Golaszewskica8792a2017-11-27 11:48:45 +0100199 link = debugfs_create_symlink(gc->label, gpio_mockup_dbg_dir, devname);
Bartosz Golaszewski46526c12017-11-27 11:48:48 +0100200 if (IS_ERR_OR_NULL(link))
Bartosz Golaszewskica8792a2017-11-27 11:48:45 +0100201 goto err;
202
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100203 for (i = 0; i < gc->ngpio; i++) {
204 name = devm_kasprintf(dev, GFP_KERNEL, "%d", i);
205 if (!name)
206 goto err;
207
208 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
209 if (!priv)
210 goto err;
211
212 priv->chip = chip;
213 priv->offset = i;
214 priv->desc = &gc->gpiodev->descs[i];
215
216 evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv,
217 &gpio_mockup_event_ops);
Bartosz Golaszewski46526c12017-11-27 11:48:48 +0100218 if (IS_ERR_OR_NULL(evfile))
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100219 goto err;
220 }
221
222 return;
223
224err:
Bartosz Golaszewski46526c12017-11-27 11:48:48 +0100225 dev_err(dev, "error creating debugfs event files\n");
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100226}
227
Bartosz Golaszewski1cea4732017-11-27 11:48:47 +0100228static int gpio_mockup_name_lines(struct device *dev,
229 struct gpio_mockup_chip *chip)
230{
231 struct gpio_chip *gc = &chip->gc;
232 char **names;
233 int i;
234
235 names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL);
236 if (!names)
237 return -ENOMEM;
238
239 for (i = 0; i < gc->ngpio; i++) {
240 names[i] = devm_kasprintf(dev, GFP_KERNEL,
241 "%s-%d", gc->label, i);
242 if (!names[i])
243 return -ENOMEM;
244 }
245
246 gc->names = (const char *const *)names;
247
248 return 0;
249}
250
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100251static int gpio_mockup_probe(struct platform_device *pdev)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200252{
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100253 struct gpio_mockup_platform_data *pdata;
254 struct gpio_mockup_chip *chip;
Bartosz Golaszewski6d974d32017-11-27 11:48:43 +0100255 struct gpio_chip *gc;
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100256 int rv, base, ngpio;
257 struct device *dev;
258 char *name;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200259
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100260 dev = &pdev->dev;
261 pdata = dev_get_platdata(dev);
262 base = pdata->base;
263 ngpio = pdata->ngpio;
Bartosz Golaszewskib6523362017-06-09 13:41:28 +0200264
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100265 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
266 if (!chip)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200267 return -ENOMEM;
268
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100269 name = devm_kasprintf(dev, GFP_KERNEL, "%s-%c",
270 pdev->name, pdata->index);
271 if (!name)
272 return -ENOMEM;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200273
Bartosz Golaszewski6d974d32017-11-27 11:48:43 +0100274 gc = &chip->gc;
275 gc->base = base;
276 gc->ngpio = ngpio;
277 gc->label = name;
278 gc->owner = THIS_MODULE;
279 gc->parent = dev;
280 gc->get = gpio_mockup_get;
281 gc->set = gpio_mockup_set;
Bartosz Golaszewskic47bee92017-11-27 11:48:51 +0100282 gc->set_multiple = gpio_mockup_set_multiple;
Bartosz Golaszewski6d974d32017-11-27 11:48:43 +0100283 gc->direction_output = gpio_mockup_dirout;
284 gc->direction_input = gpio_mockup_dirin;
285 gc->get_direction = gpio_mockup_get_direction;
286 gc->to_irq = gpio_mockup_to_irq;
287
288 chip->lines = devm_kcalloc(dev, gc->ngpio,
289 sizeof(*chip->lines), GFP_KERNEL);
290 if (!chip->lines)
291 return -ENOMEM;
292
Bartosz Golaszewskic3196a72017-11-27 11:48:44 +0100293 if (pdata->named_lines) {
Bartosz Golaszewski6d974d32017-11-27 11:48:43 +0100294 rv = gpio_mockup_name_lines(dev, chip);
295 if (rv)
296 return rv;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200297 }
298
Bartosz Golaszewski6d974d32017-11-27 11:48:43 +0100299 rv = devm_irq_sim_init(dev, &chip->irqsim, gc->ngpio);
Bartosz Golaszewski1e0dca62017-11-27 11:48:52 +0100300 if (rv < 0)
Bartosz Golaszewski6d974d32017-11-27 11:48:43 +0100301 return rv;
302
303 rv = devm_gpiochip_add_data(dev, &chip->gc, chip);
304 if (rv)
305 return rv;
306
307 if (gpio_mockup_dbg_dir)
308 gpio_mockup_debugfs_setup(dev, chip);
309
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200310 return 0;
311}
312
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100313static struct platform_driver gpio_mockup_driver = {
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200314 .driver = {
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100315 .name = GPIO_MOCKUP_NAME,
Bartosz Golaszewski364ac452016-12-20 12:28:20 +0100316 },
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100317 .probe = gpio_mockup_probe,
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200318};
319
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100320static struct platform_device *gpio_mockup_pdevs[GPIO_MOCKUP_MAX_GC];
321
322static void gpio_mockup_unregister_pdevs(void)
323{
324 struct platform_device *pdev;
325 int i;
326
327 for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) {
328 pdev = gpio_mockup_pdevs[i];
329
330 if (pdev)
331 platform_device_unregister(pdev);
332 }
333}
Bartosz Golaszewskif3b47172017-11-27 11:48:37 +0100334
335static int __init gpio_mockup_init(void)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200336{
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100337 int i, num_chips, err = 0, index = 'A';
338 struct gpio_mockup_platform_data pdata;
339 struct platform_device *pdev;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200340
Bartosz Golaszewskie63a0062017-11-27 11:48:53 +0100341 if ((gpio_mockup_num_ranges < 2) ||
342 (gpio_mockup_num_ranges % 2) ||
343 (gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES))
Bartosz Golaszewski20c35ac2017-11-27 11:48:38 +0100344 return -EINVAL;
345
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100346 /* Each chip is described by two values. */
Bartosz Golaszewskie63a0062017-11-27 11:48:53 +0100347 num_chips = gpio_mockup_num_ranges / 2;
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100348
Bartosz Golaszewskifa869632017-11-27 11:48:49 +0100349 /*
350 * The second value in the <base GPIO - number of GPIOS> pair must
351 * always be greater than 0.
352 */
353 for (i = 0; i < num_chips; i++) {
354 if (gpio_mockup_ranges[i * 2 + 1] < 0)
355 return -EINVAL;
356 }
357
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100358 gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup-event", NULL);
Bartosz Golaszewski46526c12017-11-27 11:48:48 +0100359 if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir))
Bartosz Golaszewskif1bec992017-11-27 11:48:41 +0100360 gpio_mockup_err("error creating debugfs directory\n");
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100361
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100362 err = platform_driver_register(&gpio_mockup_driver);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200363 if (err) {
Bartosz Golaszewskif1bec992017-11-27 11:48:41 +0100364 gpio_mockup_err("error registering platform driver\n");
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200365 return err;
366 }
367
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100368 for (i = 0; i < num_chips; i++) {
369 pdata.index = index++;
370 pdata.base = gpio_mockup_ranges[i * 2];
371 pdata.ngpio = pdata.base < 0
372 ? gpio_mockup_ranges[i * 2 + 1]
373 : gpio_mockup_ranges[i * 2 + 1] - pdata.base;
Bartosz Golaszewskic3196a72017-11-27 11:48:44 +0100374 pdata.named_lines = gpio_mockup_named_lines;
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100375
376 pdev = platform_device_register_resndata(NULL,
377 GPIO_MOCKUP_NAME,
378 i, NULL, 0, &pdata,
379 sizeof(pdata));
380 if (!pdev) {
Bartosz Golaszewskif1bec992017-11-27 11:48:41 +0100381 gpio_mockup_err("error registering device");
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100382 platform_driver_unregister(&gpio_mockup_driver);
383 gpio_mockup_unregister_pdevs();
384 return -ENOMEM;
385 }
386
387 gpio_mockup_pdevs[i] = pdev;
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200388 }
389
390 return 0;
391}
392
Bartosz Golaszewskif3b47172017-11-27 11:48:37 +0100393static void __exit gpio_mockup_exit(void)
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200394{
Bartosz Golaszewski9202ba22017-02-06 15:11:08 +0100395 debugfs_remove_recursive(gpio_mockup_dbg_dir);
Bartosz Golaszewskica4091602017-02-06 13:10:35 +0100396 platform_driver_unregister(&gpio_mockup_driver);
Bartosz Golaszewski8a39f592017-11-27 11:48:40 +0100397 gpio_mockup_unregister_pdevs();
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200398}
399
Bartosz Golaszewskif3b47172017-11-27 11:48:37 +0100400module_init(gpio_mockup_init);
401module_exit(gpio_mockup_exit);
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200402
403MODULE_AUTHOR("Kamlakant Patel <kamlakant.patel@broadcom.com>");
404MODULE_AUTHOR("Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>");
Bartosz Golaszewskic60c7f42017-06-09 13:41:31 +0200405MODULE_AUTHOR("Bartosz Golaszewski <brgl@bgdev.pl>");
Bamvor Jian Zhang0f98dd12016-08-31 11:45:46 +0200406MODULE_DESCRIPTION("GPIO Testing driver");
407MODULE_LICENSE("GPL v2");