aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-mockup.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-08-31gpio: mockup: remove unused variable gcColin Ian King1-2/+0
The variable gc is assigned but never read and is redundant. Remove it. Cleans up clang warning: drivers/gpio/gpio-mockup.c:169:2: warning: Value stored to 'gc' is never read Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-08-21gpio: mockup: use irq_simBartosz Golaszewski1-70/+7
Shrink the driver by removing the code dealing with dummy interrupts and replacing it with calls to the irq_sim API. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: use devm_kcalloc() where applicableBartosz Golaszewski1-4/+4
When allocating a zeroed array of objects use devm_kcalloc() instead of manually calculating the required size and using devm_kzalloc(). Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: add myself as authorBartosz Golaszewski1-0/+2
Just taking credit for the recent changes and new features. :) Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: improve the error messageBartosz Golaszewski1-2/+3
Indicate the error number and make the message a bit more elaborate. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: don't return magic numbers from probe()Bartosz Golaszewski1-1/+1
When the requested number of GPIO lines is 0, return -EINVAL, not -1 which is -EPERM. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: improve readabilityBartosz Golaszewski1-7/+13
We currently shift bits here and there without actually explaining what we're doing. Add some helper variables with names indicating their purpose to improve the code readability. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: refuse to accept an odd number of GPIO rangesBartosz Golaszewski1-1/+1
Currently we ignore the last odd range value, since each chip is described by two values. Be more strict and require the user to pass an even number of ranges. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: tweak gpio_mockup_event_write()Bartosz Golaszewski1-11/+10
Invert the logic of the irq_enabled check and only access the private data after the input is sanitized. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-06-20gpio: mockup: improve the debugfs input sanitizationBartosz Golaszewski1-12/+7
We're currently only checking the first character of the input to the debugfs event files, so a string like '0sdfdsf' is valid and indicates a falling edge event. Be more strict and only allow '0', '1', '0\n' & '1\n'. While we're at it: move the sanitization code before the irq_enabled check so that we indicate an error on invalid input even if nobody is waiting for events. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-05-29gpio: mockup: support irqmask and irqunmaskBartosz Golaszewski1-6/+20
Even though this is a testing module, be nice and actually implement these functions. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-05-29gpio: mockup: be quiet unless something goes wrongBartosz Golaszewski1-3/+0
When inserting and removing the module repeatedly (e.g. when running the libgpiod test-suite) the kernel log gets clobbered with messages reporting successful creation of dummy gpiochips. Remove this message and only emit logs when something bad happens. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-05-29gpio: mockup: add prefixes to the direction enumBartosz Golaszewski1-4/+4
All internal symbols except for the direction enum follow the same convention and use the gpio_mockup prefix. Add the prefix to the DIR_IN and DIR_OUT definitions as well for consistency across the file. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-05-29gpio: mockup: fix direction valuesBartosz Golaszewski1-2/+2
The comment in linux/gpio/driver.h says: @get_direction: returns direction for signal "offset", 0=out, 1=in We got those switched at some point. Fix the values. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-05-04Merge tag 'gpio-v4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpioLinus Torvalds1-15/+1
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v4.12 kernel cycle. Core changes: - Return NULL from gpiod_get_optional() when GPIOLIB is disabled. This was a much discussed change. It affects use cases where people write drivers that might or might not be using GPIO resources. I have decided that this is the lesser evil right now. - Make gpiod_count() behave consistently across different hardware descriptions. - Fix the syntax around open drain/open source to not infer active high/low semantics. New drivers: - A new single-register fixed-direction framework driver for hardware that have lines controlled by a single register that just work in one direction (out or in), including IRQ support. - Support the Fintek F71889A GPIO SuperIO controller. - Support the National NI 169445 MMIO GPIO. - Support for the X-Gene derivative of the DWC GPIO controller - Support for the Rohm BD9571MWV-M PMIC GPIO controller. - Refactor the Gemini GPIO driver to a generic Faraday FTGPIO driver and replace both the Gemini and the Moxa ART custom drivers with this driver. Driver improvements: - A whole slew of drivers have their spinlocks chaned to raw spinlocks as they provide irqchips, and thus we are progressing on realtime compliance. - Use devm_irq_alloc_descs() in a slew of drivers, getting managed resources. - Support for the embedded PWM controller inside the MVEBU driver. - Debounce, open source and open drain support for the Aspeed driver. - Misc smaller fixes like spelling and syntax and whatnot" * tag 'gpio-v4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (77 commits) gpio: f7188x: Add a missing break gpio: omap: return error if requested debounce time is not possible gpio: Add ROHM BD9571MWV-M PMIC GPIO driver gpio: gpio-wcove: fix GPIO IRQ status mask gpio: DT bindings, move tca9554 from pcf857x to pca953x gpio: move tca9554 from pcf857x to pca953x gpio: arizona: Correct check whether the pin is an input gpio: Add XRA1403 DTS binding documentation dt-bindings: add exar to vendor prefixes list gpio: gpio-wcove: fix irq pending status bit width gpio: dwapb: use dwapb_read instead of readl_relaxed gpio: aspeed: Add open-source and open-drain support gpio: aspeed: Add debounce support gpio: aspeed: dt: Add optional clocks property gpio: aspeed: dt: Fix description alignment in bindings document gpio: mvebu: Add limited PWM support gpio: Use unsigned int for interrupt numbers gpio: f7188x: Add F71889A GPIO support. gpio: core: Decouple open drain/source flag with active low/high gpio: arizona: Correct handling for reading input GPIOs ...
2017-03-15gpio: mockup: use devm_irq_alloc_descs()Bartosz Golaszewski1-15/+1
Use the resource managed variant of irq_alloc_descs(). This allows us to remove gpio_mockup_remove(). Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Reviewed-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-03-06gpio: mockup: return -EFAULT if copy_from_user() failsDan Carpenter1-4/+3
copy_from_user() returns the number of bytes remaining to be copied but we want to return negative error codes on failue. Fixes: 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-02-13gpio: mockup: implement event injecting over debugfsBartosz Golaszewski1-1/+115
Create a debugfs directory for every mockup chip and a single file for every line. Writing (0 or 1) to these files allows the user to inject line events (falling or rising edge respectively). Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-02-13gpio: mockup: add a dummy irqchipBartosz Golaszewski1-0/+79
Setup a dummy irqchip that will allow us to inject line events for testing purposes. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-02-06gpio: mockup: implement naming the linesBartosz Golaszewski1-0/+35
In order to allow testing line lookup by name from user space, add a new boolean parameter that indicates whether we want the lines to be named. The name is created by concatenating the chip name and the line offset value. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-02-06gpio: mockup: code shrinkBartosz Golaszewski1-21/+8
Moving a couple of lines around allows us to shrink the code a bit while keeping the same functionality. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-02-06gpio: mockup: readability tweaksBartosz Golaszewski1-57/+66
The following patch tries to improve the readability of the mockup driver. The driver is called gpio-mockup, so add the same prefix to all functions and structures. Add some newlines and use a temporary pointer in gpio_mockup_add(). Drop the name of the direction enum and rename the enum values to better reflect their purpose. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-12-28gpio: mockup: coding style fixesBartosz Golaszewski1-7/+4
Fix whitespace errors and arrange local variables for better readability. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-12-28gpio: mockup: dynamically allocate memory for chip nameBartosz Golaszewski1-3/+7
Currently the chip name buffer is allocated on the stack and the address of the buffer is passed to the gpio framework. It's invalid after probe() returns, so the sysfs label attribute displays garbage. Use devm_kasprintf() for each string instead. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-12-28gpio: mockup: make pins_name_start staticBartosz Golaszewski1-1/+1
This variable is not used outside this module. Make it static. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-09-26gpio/mockup: add virtual gpio deviceBamvor Jian Zhang1-0/+214
This patch add basic structure of a virtual gpio device(gpio-mockup) for testing gpio subsystem. The tester could manipulate such device through userspace(sysfs or char device) and check the result from debugfs. Currently, it support one or more gpiochip(determined by module parameters with base,ngpio pair). One could test the overlap of different gpiochip and test the direction and/or output values of these chips. Signed-off-by: Kamlakant Patel <kamlakant.patel@broadcom.com> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>