- 16 7月, 2018 2 次提交
-
-
由 Bartosz Golaszewski 提交于
It's actually fine to read values of output lines. This was also allowed by the legacy sysfs interface. Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Bartosz Golaszewski 提交于
User space can currently both read and set values of input lines using the character device. This was not allowed by the old sysfs interface nor is it a correct behavior. Check the first descriptor in the set for the OUT flag when asked to set values and return -EPERM if the line is input. Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 13 7月, 2018 2 次提交
-
-
由 Andy Shevchenko 提交于
One line in gpiolib_dbg_show() still fits 80 characters, so, join it to be like that in order to increase readability. Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Andy Shevchenko 提交于
Two out of three calls to ->get_direction (excluding, of course, gpiod_get_direction() itself) are using gpiod_get_direction() and one is still open coded. Replace the latter one to use same API for sake of consistency. Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 09 7月, 2018 3 次提交
-
-
由 Janusz Krzysztofik 提交于
Avoid replication of error code conversion in non-DT GPIO consumers' code by returning -EPROBE_DEFER from gpiod_find() in case a chip identified by its label in a registered lookup table is not ready. See https://lkml.org/lkml/2018/5/30/176 for example case. Suggested-by: NBoris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com> Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Andy Shevchenko 提交于
In case we try to lock GPIO pin as IRQ when something going wrong we print a misleading message. Correct this by checking an error code from ->get_direction() in gpiochip_lock_as_irq() and printing a corresponding message. Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Andy Shevchenko 提交于
For easy grepping on debug purposes join string literals back in the messages. While here, fix couple of small indentation issues. Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 18 6月, 2018 1 次提交
-
-
由 Linus Walleij 提交于
The GPIO (descriptor) API registers a "label" naming what is currently using the GPIO line. Typically this is taken from things like the device tree node, so "reset-gpios" will result in he line being labeled "reset". The technical effect is pretty much zero: the use is for debug and introspection, such as "lsgpio" and debugfs files. However sometimes the user want this cuddly feeling of listing all GPIO lines and seeing exactly what they are for and it gives a very fulfilling sense of control. Especially in the cases when the device tree node doesn't provide a good name, or anonymous GPIO lines assigned just to "gpios" in the device tree because the usage is implicit. For these cases it may be nice to be able to label the line directly and explicitly. Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 07 6月, 2018 1 次提交
-
-
由 Kees Cook 提交于
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL); This patch makes the changes for kmalloc()-family (and kvmalloc()-family) uses. It was done via automatic conversion with manual review for the "CHECKME" non-standard cases noted below, using the following Coccinelle script: // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len * // sizeof *pkey_cache->table, GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // Same pattern, but can't trivially locate the trailing element name, // or variable name. @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; expression SOMETHING, COUNT, ELEMENT; @@ - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP) + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP) Signed-off-by: NKees Cook <keescook@chromium.org>
-
- 24 5月, 2018 1 次提交
-
-
由 Christian Lamparter 提交于
This patch adds the stern warning to the kerneldoc text of both gpiochip_add_pin[group]_range() functions in hope of detering developers from ever using them in their DeviceTree-supported pinctrl drivers in the future. For anyone affected: Please refer to Section 2.1 of Documentation/devicetree/bindings/gpio/gpio.txt on how to bind pinctrl and gpio drivers via the "gpio-ranges" property. Signed-off-by: NChristian Lamparter <chunkeey@gmail.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 23 5月, 2018 1 次提交
-
-
由 Laura Abbott 提交于
The new challenge is to remove VLAs from the kernel (see https://lkml.org/lkml/2018/3/7/621) to eventually turn on -Wvla. Using a kmalloc array is the easy way to fix this but kmalloc is still more expensive than stack allocation. Introduce a fast path with a fixed size stack array to cover most chip with gpios below some fixed amount. The slow path dynamically allocates an array to cover those chips with a large number of gpios. Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: NPhil Reid <preid@electromag.com.au> Reviewed-and-tested-by: NLukas Wunner <lukas@wunner.de> Signed-off-by: NLukas Wunner <lukas@wunner.de> Signed-off-by: NLaura Abbott <labbott@redhat.com> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 16 5月, 2018 2 次提交
-
-
由 Dan Carpenter 提交于
There is a shifter vs vanilla mask bug here. We want to test if 1 << 11 is set but we're testing if 0xb is set. Fixes: 9a6c505f7df1 ("gpiolib: add hogs support for machine code") Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Reviewed-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Bartosz Golaszewski 提交于
Board files constitute a significant part of the users of the legacy GPIO framework. In many cases they only export a line and set its desired value. We could use GPIO hogs for that like we do for DT and ACPI but there's no support for that in machine code. This patch proposes to extend the machine.h API with support for registering hog tables in board files. Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 27 4月, 2018 1 次提交
-
-
由 Uwe Kleine-König 提交于
If gpiod_request() fails the cleanup must not call gpiod_free(). Cc: stable@vger.kernel.org Fixes: 61f922db ("gpio: userspace ABI for reading GPIO line events") Signed-off-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 26 4月, 2018 1 次提交
-
-
由 Timur Tabi 提交于
If the main loop in linehandle_create() encounters an error, it unwinds completely by freeing all previously requested GPIO descriptors. However, if the error occurs in the beginning of the loop before that GPIO is requested, then the exit code attempts to free a null descriptor. If extrachecks is enabled, gpiod_free() triggers a WARN_ON. Instead, keep a separate count of legitimate GPIOs so that only those are freed. Cc: stable@vger.kernel.org Fixes: d7c51b47 ("gpio: userspace ABI for reading/writing GPIO lines") Reviewed-by: NBjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: NTimur Tabi <timur@codeaurora.org> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 27 3月, 2018 3 次提交
-
-
由 Stephen Boyd 提交于
Some qcom platforms make some GPIOs or pins unavailable for use by non-secure operating systems, and thus reading or writing the registers for those pins will cause access control issues. Add support for a DT property to describe the set of GPIOs that are available for use so that higher level OSes are able to know what pins to avoid reading/writing. Non-DT platforms can add support by directly updating the chip->valid_mask. Signed-off-by: NStephen Boyd <sboyd@codeaurora.org> Signed-off-by: NStephen Boyd <swboyd@chromium.org> Tested-by: NTimur Tabi <timur@codeaurora.org> Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Stephen Boyd 提交于
We don't need to clear out these bits when we set them immediately after. Use kmalloc_array() to skip clearing the bits. Suggested-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NStephen Boyd <swboyd@chromium.org> Tested-by: NTimur Tabi <timur@codeaurora.org> Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Stephen Boyd 提交于
We're going to use similar code to allocate and set all the bits in a mask for valid gpios to use. Extract the code from the irqchip version so it can be reused. Signed-off-by: NStephen Boyd <swboyd@chromium.org> Tested-by: NTimur Tabi <timur@codeaurora.org> Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 02 3月, 2018 1 次提交
-
-
由 Wang Dongsheng 提交于
"failed" maybe makes observer confuse when a consumer can not lookup, so change to a friendly information. Signed-off-by: NWang Dongsheng <dongsheng.wang@hxt-semitech.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 12 2月, 2018 1 次提交
-
-
由 Linus Torvalds 提交于
This is the mindless scripted replacement of kernel use of POLL* variables as described by Al, done by this script: for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'` for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done done with de-mangling cleanups yet to come. NOTE! On almost all architectures, the EPOLL* constants have the same values as the POLL* constants do. But they keyword here is "almost". For various bad reasons they aren't the same, and epoll() doesn't actually work quite correctly in some cases due to this on Sparc et al. The next patch from Al will sort out the final differences, and we should be all done. Scripted-by: NAl Viro <viro@zeniv.linux.org.uk> Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
-
- 23 1月, 2018 2 次提交
-
-
由 Linus Walleij 提交于
Add a hardirq handler to the GPIO userspace event loop, making sure to pick up the timestamp there, as close as possible in time relative to the actual event causing the interrupt. Tested with a simple pushbutton GPIO on ux500 and seems to work fine. Cc: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: NFelipe Balbi <felipe.balbi@linux.intel.com> Reported-by: NFelipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Linus Walleij 提交于
The GPIO event descriptor was leaking kernel stack to userspace because we don't zero the variable before use. Ooops. Fix this. Cc: stable@vger.kernel.org Reported-by: NArnd Bergmann <arnd@arndb.de> Reviewed-by: NBartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 17 1月, 2018 2 次提交
-
-
由 Colin Ian King 提交于
The initialized value stored in pointer desc is never read as it is updated in the first executable statement in the function. This is therefore redundant and can be removed. Cleans up clang warning: drivers/gpio/gpiolib.c:3710:20: warning: Value stored to 'desc' during its initialization is never read Signed-off-by: NColin Ian King <colin.king@canonical.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Linus Walleij 提交于
Sometimes a GPIO is fetched with NULL as parent device, and that is just fine. So under these circumstances, avoid using dev_name() to provide a name for the GPIO line. Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 12 1月, 2018 2 次提交
-
-
由 Linus Walleij 提交于
We have been holding back on adding an API for fetching GPIO handles directly from device nodes, strongly preferring to get it from the spawn devices instead. The fwnode interface however already contains an API for doing this, as it is used for opaque device tree nodes or ACPI nodes for getting handles to LEDs and keys that use GPIO: those are specified as one child per LED/key in the device tree and are not individual devices. However regulators present a special problem as they already have helper functions to traverse the device tree from a regulator node and two levels down to fill in data, and as it already traverses GPIO nodes in its own way, and already holds a pointer to each regulators device tree node, it makes most sense to export an API to fetch the GPIO descriptor directly from the node. We only support the devm_* version for now, hopefully no non-devres version will be needed. Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Linus Walleij 提交于
Sometimes a GPIO needs to be taken from a node without a device associated with it. The fwnode accessor does this, let's however break out the DT code for now. Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 10 1月, 2018 2 次提交
-
-
由 Stephen Boyd 提交于
Some pinctrl drivers can use the gpiochip irq valid information to figure out if certain gpios are exposed to the kernel for usage or not. Expose this API so we can use it in the pinmux_ops::request ops. Signed-off-by: NStephen Boyd <sboyd@codeaurora.org> Acked-by: NBjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Geert Uytterhoeven 提交于
Since commit f11a0446 ("i2c: gpio: Enable working over slow can_sleep GPIOs"), probing the i2c RTC connected to an i2c-gpio bus on r8a7740/armadillo fails with: rtc-s35390a 0-0030: error resetting chip rtc-s35390a: probe of 0-0030 failed with error -5 More debug code reveals: i2c i2c-0: master_xfer[0] R, addr=0x30, len=1 i2c i2c-0: NAK from device addr 0x30 msg #0 s35390a_get_reg: ret = -6 Commit 02e47980 ("gpio: Alter semantics of *raw* operations to actually be raw") moved open drain/source handling from gpiod_set_raw_value_commit() to gpiod_set_value(), but forgot to take into account that gpiod_set_value_cansleep() also needs this handling. The i2c protocol mandates that i2c signals are open drain, hence i2c communication fails. Fix this by adding the missing handling to gpiod_set_value_cansleep(), using a new common helper gpiod_set_value_nocheck(). Fixes: 02e47980 ("gpio: Alter semantics of *raw* operations to actually be raw") Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be> [removed underscore syntax, added kerneldoc] Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 09 1月, 2018 1 次提交
-
-
由 Wolfram Sang 提交于
The use of the GPIOF_* flags is deprecated, so don't advertise them here. Document the plain numbers for now until we have a better solution. Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 05 1月, 2018 1 次提交
-
-
由 Linus Walleij 提交于
Some GPIO lines appear named "?" in the lsgpio dump due to their requesting drivers not passing a reasonable label. Most typically this happens if a device tree node just defines gpios = <...> and not foo-gpios = <...>, the former gets named "foo" and the latter gets named "?". However the struct device passed in is always valid so let's just label the GPIO with dev_name() on the device if no proper label was passed. Cc: Reported-by: Jason Kridner <jkridner@beagleboard.org> Reported-by: NJason Kridner <jkridner@beagleboard.org> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 02 1月, 2018 3 次提交
-
-
由 Vladimir Zapolskiy 提交于
The gpiod_set_transitory() function is publicly exported, and it is expected from it to be ready for usage with optional GPIOs on consumer's side. Signed-off-by: NVladimir Zapolskiy <vz@mleia.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Vladimir Zapolskiy 提交于
This non-functional change slightly simplifies the implementation of gpiod_to_chip() function. Signed-off-by: NVladimir Zapolskiy <vz@mleia.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Vladimir Zapolskiy 提交于
The fix restores a proper validation of an input gpio desc, which might be needed to deal with optional GPIOs correctly. Fixes: 02e47980 ("gpio: Alter semantics of *raw* operations to actually be raw") Signed-off-by: NVladimir Zapolskiy <vz@mleia.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 28 12月, 2017 1 次提交
-
-
由 Andrew Lunn 提交于
The IRQ code already has support for lockdep class for the lock mutex in an interrupt descriptor. Extend this to add a second class for the request mutex in the descriptor. Not having a class is resulting in false positive splats in some code paths. Signed-off-by: NAndrew Lunn <andrew@lunn.ch> Signed-off-by: NThomas Gleixner <tglx@linutronix.de> Acked-by: linus.walleij@linaro.org Cc: grygorii.strashko@ti.com Cc: f.fainelli@gmail.com Link: https://lkml.kernel.org/r/1512234664-21555-1-git-send-email-andrew@lunn.ch
-
- 22 12月, 2017 2 次提交
-
-
由 Jonathan Neuschäfer 提交于
Signed-off-by: NJonathan Neuschäfer <j.neuschaefer@gmx.net> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
由 Rasmus Villemoes 提交于
While we do need macros to be able to return from the "calling" function, we can still factor the checks done by the VALIDATE_DESC* macros into a real helper function. This reduces the backslashtitis, avoids duplicating the logic in the two macros and saves about 1K of generated code: $ scripts/bloat-o-meter drivers/gpio/gpiolib.o.{0,1} add/remove: 1/0 grow/shrink: 0/15 up/down: 104/-1281 (-1177) Function old new delta validate_desc - 104 +104 gpiod_set_value 192 135 -57 gpiod_set_raw_value 125 67 -58 gpiod_direction_output 412 351 -61 gpiod_set_value_cansleep 150 70 -80 gpiod_set_raw_value_cansleep 132 52 -80 gpiod_get_raw_value 139 54 -85 gpiod_set_debounce 226 140 -86 gpiod_direction_output_raw 124 38 -86 gpiod_get_value 161 74 -87 gpiod_cansleep 126 39 -87 gpiod_get_raw_value_cansleep 130 39 -91 gpiod_get_value_cansleep 152 59 -93 gpiod_is_active_low 128 33 -95 gpiod_request 299 184 -115 gpiod_direction_input 386 266 -120 Total: Before=25460, After=24283, chg -4.62% Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk> Reviewed-by: NVladimir Zapolskiy <vz@mleia.com> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 21 12月, 2017 1 次提交
-
-
由 Timur Tabi 提交于
This reverts commit 72d32000. We cannot blindly query the direction of all GPIOs when the pins are first registered. The get_direction callback normally triggers a read/write to hardware, but we shouldn't be touching the hardware for an individual GPIO until after it's been properly claimed. Signed-off-by: NTimur Tabi <timur@codeaurora.org> Reviewed-by: NStephen Boyd <sboyd@codeaurora.org> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 20 12月, 2017 1 次提交
-
-
由 Bartosz Golaszewski 提交于
Users often pass a pointer to a static string to gpiochip_add_data() family of functions. Avoid unnecessary memory allocations with the provided helper routine. While at it: use a ternary operator instead of an if else for brevity. Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 03 12月, 2017 1 次提交
-
-
由 Andrew Jeffery 提交于
General support for state persistence is added to gpiolib with the introduction of a new pinconf parameter to propagate the request to hardware. The existing persistence support for sleep is adapted to include hardware support if the GPIO driver provides it. Persistence continues to be enabled by default; in-kernel consumers can opt out, but userspace (currently) does not have a choice. The *_SLEEP_MAY_LOSE_VALUE and *_SLEEP_MAINTAIN_VALUE symbols are renamed, dropping the SLEEP prefix to reflect that the concept is no longer sleep-specific. I feel that renaming to just *_MAY_LOSE_VALUE could initially be misinterpreted, so I've further changed the symbols to *_TRANSITORY and *_PERSISTENT to address this. The sysfs interface is modified only to keep consistency with the chardev interface in enforcing persistence for userspace exports. Signed-off-by: NAndrew Jeffery <andrew@aj.id.au> Reviewed-by: NCharles Keepax <ckeepax@opensource.cirrus.com> Acked-by: NRob Herring <robh@kernel.org> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-
- 30 11月, 2017 1 次提交
-
-
由 Bartosz Golaszewski 提交于
Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If the hardware actually supports enabling both at the same time the electrical result would be disastrous. Suggested-by: NLinus Walleij <linus.walleij@linaro.org> Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
-