- 21 9月, 2022 1 次提交
-
-
由 Meng Li 提交于
When running gpio test on nxp-ls1028 platform with below command gpiomon --num-events=3 --rising-edge gpiochip1 25 There will be a warning trace as below: Call trace: free_irq+0x204/0x360 lineevent_free+0x64/0x70 gpio_ioctl+0x598/0x6a0 __arm64_sys_ioctl+0xb4/0x100 invoke_syscall+0x5c/0x130 ...... el0t_64_sync+0x1a0/0x1a4 The reason of this issue is that calling request_threaded_irq() function failed, and then lineevent_free() is invoked to release the resource. Since the lineevent_state::irq was already set, so the subsequent invocation of free_irq() would trigger the above warning call trace. To fix this issue, set the lineevent_state::irq after the IRQ register successfully. Fixes: 46824272 ("gpiolib: cdev: refactor lineevent cleanup into lineevent_free") Cc: stable@vger.kernel.org Signed-off-by: NMeng Li <Meng.Li@windriver.com> Reviewed-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
- 19 7月, 2022 6 次提交
-
-
由 Kent Gibson 提交于
The majority of builds do not include HTE, so compile out hte functionality unless CONFIG_HTE is selected. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
由 Kent Gibson 提交于
Combine the polarity_change flag, struct line eflags, and hte enable flag into a single flag variable. The combination of these flags describes the configuration state of the edge detector, so formalize and clarify that by combining them into a single variable, edflags, in struct line. The edflags is a subset of the GPIO_V2_LINE_FLAGsb relevant to the edge detector, and is also a superset of the eflags it replaces. The eflags name is still used to describe the subset of edflags corresponding to the rising/falling edge flags where edflags is masked down to that subset. This consolidation reduces the number of variables being passed, simplifies state comparisons, and provides a more extensible foundation should additional edge sources be integrated in the future. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
由 Kent Gibson 提交于
Reorganise line event identification code to reduce code duplication, and replace if-else initializers with a helper function to improve readability. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Kent Gibson 提交于
Improve readability by replacing if-else chains with switch statements. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
由 Kent Gibson 提交于
Improve readability by using the GPIO_V2_LINE_FLAG_EDGE_BOTH instead of combining the rising and falling edge flags. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Acked-by: NDipen Patel <dipenp@nvidia.com> Tested-by: NDipen Patel <dipenp@nvidia.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
由 Kent Gibson 提交于
The edge detector is only ever started after the line desc has been determined, so move edge_detector_stop() inside the line desc check, and merge the two checked regions into one. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Acked-by: NDipen Patel <dipenp@nvidia.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
- 07 7月, 2022 1 次提交
-
-
由 Kent Gibson 提交于
Fix a kernel NULL pointer dereference reported by gpio kselftests. linereq_free() can be called as part of the cleanup of a failed request, at which time the desc for a line may not have been determined, so it is unsafe to dereference without a check. Add a check prior to dereferencing the line desc. Fixes: 2068339a ("gpiolib: cdev: Add hardware timestamp clock type") Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
- 17 6月, 2022 1 次提交
-
-
由 Andy Shevchenko 提交于
Kernel doc validator is not happy: gpiolib-cdev.c:487: warning: Function parameter or member 'hdesc' not described in 'line' gpiolib-cdev.c:487: warning: Function parameter or member 'raw_level' not described in 'line' gpiolib-cdev.c:487: warning: Function parameter or member 'total_discard_seq' not described in 'line' gpiolib-cdev.c:487: warning: Function parameter or member 'last_seqno' not described in 'line' Describe above mentioned parameters. Fixes: 2068339a ("gpiolib: cdev: Add hardware timestamp clock type") Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: NDipen Patel <dipenp@nvidia.com> Acked-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NThierry Reding <treding@nvidia.com>
-
- 04 5月, 2022 1 次提交
-
-
由 Dipen Patel 提交于
This patch adds new clock type for the GPIO controller which can timestamp gpio lines in using hardware means. To expose such functionalities to the userspace, code has been added where during line create or set config API calls, it checks for new clock type and if requested, calls HTE API. During line change event, the HTE subsystem pushes timestamp data to userspace through gpiolib-cdev. Signed-off-by: NDipen Patel <dipenp@nvidia.com> Acked-by: NLinus Walleij <linus.walleij@linaro.org> Reported-by: Nkernel test robot <lkp@intel.com> Reported-by: NDan Carpenter <dan.carpenter@oracle.com> Signed-off-by: NThierry Reding <treding@nvidia.com>
-
- 05 4月, 2022 1 次提交
-
-
由 Andy Shevchenko 提交于
In the snippets like the following if (...) return / goto / break / continue ...; else ... the 'else' is redundant. Get rid of it. In case of IOCTLs use switch-case pattern that seems the usual in such cases. While at it, clarify necessity of else in gpiod_direction_output() by attaching else if to the closing curly brace on a previous line. Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
- 08 2月, 2022 1 次提交
-
-
由 Andy Shevchenko 提交于
Currently it's possible that character device interface may return the error codes which are not supposed to be seen by user space. In this case it's EPROBE_DEFER. Wrap it to return -ENODEV instead as sysfs does. Fixes: d7c51b47 ("gpio: userspace ABI for reading/writing GPIO lines") Fixes: 61f922db ("gpio: userspace ABI for reading GPIO line events") Fixes: 3c0d9c63 ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL") Reported-by: NSuresh Balakrishnan <suresh.balakrishnan@intel.com> Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
-
- 22 6月, 2021 1 次提交
-
-
由 Gabriel Knezek 提交于
When userspace requests a GPIO v1 line info changed event, lineinfo_watch_read() populates and returns the gpioline_info_changed structure. It contains 5 words of padding at the end which are not initialized before being returned to userspace. Zero the structure in gpio_v2_line_info_change_to_v1() before populating its contents. Fixes: aad95584 ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL") Signed-off-by: NGabriel Knezek <gabeknez@linux.microsoft.com> Reviewed-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 27 1月, 2021 1 次提交
-
-
由 Kent Gibson 提交于
When set_config changes a line from input to output debounce is implicitly disabled, as debounce makes no sense for outputs, but the debounce period is not being cleared and is still reported in the line info. So clear the debounce period when the debouncer is stopped in edge_detector_stop(). Fixes: 65cff704 ("gpiolib: cdev: support setting debounce") Cc: stable@vger.kernel.org Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 03 1月, 2021 1 次提交
-
-
由 Kent Gibson 提交于
The kernel test robot reports the following warning in [1]: drivers/gpio/gpiolib-cdev.c: In function 'gpio_ioctl': >>drivers/gpio/gpiolib-cdev.c:1437:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=] Refactor gpio_ioctl() to handle each ioctl in its own helper function and so reduce the variables stored on the stack to those explicitly required to service the ioctl at hand. The lineinfo_get_v1() helper handles both the GPIO_GET_LINEINFO_IOCTL and GPIO_GET_LINEINFO_WATCH_IOCTL, as per the corresponding v2 implementation - lineinfo_get(). [1] https://lore.kernel.org/lkml/202012270910.VW3qc1ER-lkp@intel.com/ Fixes: aad95584 ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL") Reported-by: Nkernel test robot <lkp@intel.com> Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 09 12月, 2020 1 次提交
-
-
由 Marc Zyngier 提交于
When reporting the state of a GPIO to userspace, we never check for the actual validity of the line, meaning we report invalid lines as being usable. A subsequent request will fail though, which is an inconsistent behaviour from a userspace perspective. Instead, let's check for the validity of the line and report it as used if it is invalid. This allows a tool such as gpioinfo to report something sensible: gpiochip3 - 4 lines: line 0: unnamed unused input active-high line 1: unnamed kernel input active-high [used] line 2: unnamed kernel input active-high [used] line 3: unnamed unused input active-high In this example, lines 1 and 2 are invalid, and cannot be used by userspace. Signed-off-by: NMarc Zyngier <maz@kernel.org> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20201204164739.781812-2-maz@kernel.orgSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 06 12月, 2020 1 次提交
-
-
由 Kent Gibson 提交于
Using CLOCK_REALTIME as the source for event timestamps is crucial for some specific applications, particularly those requiring timetamps relative to a PTP clock, so provide an option to switch the event timestamp source from the default CLOCK_MONOTONIC to CLOCK_REALTIME. Note that CLOCK_REALTIME was the default source clock for GPIO until Linux 5.7 when it was changed to CLOCK_MONOTONIC due to issues with the shifting of the realtime clock. Providing this option maintains the CLOCK_MONOTONIC as the default, while also providing a path forward for those dependent on the pre-5.7 behaviour. Suggested-by: NJack Winch <sunt.un.morcov@gmail.com> Signed-off-by: NKent Gibson <warthog618@gmail.com> Link: https://lore.kernel.org/r/20201014231158.34117-2-warthog618@gmail.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 30 10月, 2020 1 次提交
-
-
由 Kent Gibson 提交于
Add GPIO_V2_LINE_FLAG_EDGE_BOTH macro and use it in edge_irq_thread() to improve readability of edge handling cases. Suggested-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 28 10月, 2020 1 次提交
-
-
由 Andy Shevchenko 提交于
Use the new compat_need_64bit_alignment_fixup() helper to avoid ugly ifdeffery in IOCTL compatibility code. Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: NKent Gibson <warthog618@gmail.com> Depends-on: 527c4125 ("compat: add a compat_need_64bit_alignment_fixup() helper") Link: https://lore.kernel.org/r/20201014103315.82662-1-andriy.shevchenko@linux.intel.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 26 10月, 2020 1 次提交
-
-
由 Kent Gibson 提交于
The line.eflags field is shared so document this fact and highlight it throughout using READ_ONCE() and WRITE_ONCE() accessors. Also use a local copy of the eflags in edge_irq_thread() to ensure consistent control flow even if eflags changes. This is only a defensive measure as edge_irq_thread() is currently disabled when the eflags are changed. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 09 10月, 2020 1 次提交
-
-
由 Kent Gibson 提交于
Use kstrndup() to copy line labels from the userspace provided char array, rather than ensuring the char array contains a null terminator and using kstrdup(). Note that the length provided to kstrndup() still assumes that the char array does contain a null terminator, so the maximum string length is one less than the array. This is consistent with the previous behaviour. Suggested-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: NKent Gibson <warthog618@gmail.com> Link: https://lore.kernel.org/r/20201005070246.20927-1-warthog618@gmail.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 07 10月, 2020 1 次提交
-
-
由 Andy Shevchenko 提交于
It appears that UML (arch/um) has no compat.h header defined and hence can't compile a recently provided piece of code in GPIO library. Disable compat ->read() code in UML case to avoid compilation errors. While at it, use pattern which is already being used in the kernel elsewhere. Fixes: 5ad284ab ("gpiolib: Fix line event handling in syscall compatible mode") Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20201005131044.87276-1-andriy.shevchenko@linux.intel.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 30 9月, 2020 8 次提交
-
-
由 Kent Gibson 提交于
Add support for setting debounce on a line via the GPIO uAPI. Where debounce is not supported by hardware, a software debounce is provided. The implementation of the software debouncer waits for the line to be stable for the debounce period before determining if a level change, and a corresponding edge event, has occurred. This provides maximum protection against glitches, but also introduces a debounce_period latency to edge events. The software debouncer is integrated with the edge detection as it utilises the line interrupt, and integration is simpler than getting the two to interwork. Where software debounce AND edge detection is required, the debouncer provides both. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Add support for the GPIO_V2_LINE_SET_VALUES_IOCTL. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Add support for GPIO_V2_LINE_SET_CONFIG_IOCTL, the uAPI v2 line set config ioctl. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Add support for edge detection to lines requested using GPIO_V2_GET_LINE_IOCTL. The edge_detector implementation is based on the v1 lineevent implementation. Unlike the v1 implementation, an overflow of the event buffer results in discarding older events, rather than the most recent, so the final event in a burst will correspond to the current state of the line. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Add support for GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL. The core of this change is the event kfifo switching to contain struct gpioline_info_changed_v2, instead of v1 as v2 is richer. The two uAPI versions are mostly independent - other than where they both provide line info changes via reads on the chip fd. As the info change structs differ between v1 and v2, the infowatch implementation tracks which version of the infowatch ioctl, either GPIO_GET_LINEINFO_WATCH_IOCTL or GPIO_V2_GET_LINEINFO_WATCH_IOCTL, initiates the initial watch and returns the corresponding info change struct to the read. The version supported on that fd locks to that version on the first watch request, so subsequent watches from that process must use the same uAPI version. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Add support for requesting lines using the GPIO_V2_GET_LINE_IOCTL, and returning their current values using GPIO_V2_LINE_GET_VALUES_IOCTL. The struct linereq implementation is based on the v1 struct linehandle implementation. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Replace usage of strncpy() with strscpy() to remove -Wstringop-truncation warnings. The structures being populated are zeroed, to prevent stack leakage as they are returned to userspace, so strscpy() performs the equivalent function without the warnings. Reported-by: Nkernel test robot <lkp@intel.com> Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Set the value of the line info offset in gpio_desc_to_lineinfo(), rather than relying on it being passed in the info. This makes the function behave as you would expect from the name - it generates the line info corresponding to a given GPIO desc. Signed-off-by: NKent Gibson <warthog618@gmail.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 17 9月, 2020 1 次提交
-
-
由 Andy Shevchenko 提交于
The introduced line event handling ABI in the commit 61f922db ("gpio: userspace ABI for reading GPIO line events") missed the fact that 64-bit kernel may serve for 32-bit applications. In such case the very first check in the lineevent_read() will fail due to alignment differences. To workaround this introduce lineevent_get_size() helper which returns actual size of the structure in user space. Fixes: 61f922db ("gpio: userspace ABI for reading GPIO line events") Suggested-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: NArnd Bergmann <arnd@arndb.de> Tested-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
- 12 7月, 2020 9 次提交
-
-
由 Kent Gibson 提交于
Consolidate the cleanup of lineevents, currently duplicated in lineevent_create and lineevent_release, into a helper function lineevent_free. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Consolidate the cleanup of linehandles, currently duplicated in linehandle_create and linehandle_release, into a helper function linehandle_free. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Remove recalculation of offset from desc, where desc itself was calculated from offset. There is no benefit from the desc -> hwgpio conversion in this context. The only implicit benefit of the offset -> desc -> hwgpio is the range check in the offset -> desc, but where desc is required you still get that, and where desc isn't required it is simpler to perform the range check directly. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Merge separate usage of test_bit/set_bit into test_and_set_bit to remove the possibility of a race between the test and set. Similarly test_bit and clear_bit. In the existing code it is possible for two threads to race past the test_bit and then set or clear the watch bit, and neither return EBUSY. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Rename priv to cdev to improve readability. The name "priv" indicates that the object is pointed to by file->private_data, not what the object is actually is. As it is always used to point to a struct gpio_chardev_data, renaming it to cdev is more appropriate. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Replace usage of atomic_notifier_call_chain with blocking_notifier_call_chain as the notifier function, lineinfo_changed_notify, calls gpio_desc_to_lineinfo, which calls pinctrl_gpio_can_use_line, which can sleep. The chain isn't being called from an atomic context so the the blocking notifier is a suitable substitute. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Remove pointless decrement of variable, and associated comment. While i is used subsequently, it is re-initialized so this decrement serves no purpose. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Rename numdescs to num_descs to be more consistent with the naming of other counters and improve readability. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-
由 Kent Gibson 提交于
Rename 'filep' and 'filp' to 'file' to be consistent with other use and improve readability. Signed-off-by: NKent Gibson <warthog618@gmail.com> Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
-