1
0
Fork 0
Commit Graph

721788 Commits (a0d65009411c620a9e7140d6a83b9d5aeb8f1801)

Author SHA1 Message Date
Maciej S. Szmigiero a0d6500941 gpio: winbond: Add driver
This commit adds GPIO driver for Winbond Super I/Os.

Currently, only W83627UHG model (also known as Nuvoton NCT6627UD)
is supported but in the future a support for other Winbond models,
too, can be added to the driver.

A module parameter "gpios" sets a bitmask of GPIO ports to enable
(bit 0 is GPIO1, bit 1 is GPIO2, etc.).

One should be careful which ports one tinkers with since some
might be managed by the firmware (for functions like powering on and
off, sleeping, BIOS recovery, etc.) and some of GPIO port pins are
physically shared with other devices included in the Super I/O chip.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-09 14:51:00 +01:00
Linus Walleij c858233902 gpio: of: Support SPI nonstandard GPIO properties
Before it was clearly established that all GPIO properties in the
device tree shall be named "foo-gpios" (with the deprecated variant
"foo-gpio" for single lines) we unfortunately merged a few bindings
which named the lines "gpio-foo" instead.

This is most prominent in the GPIO SPI driver in Linux which names
the lines "gpio-sck", "gpio-mosi" and "gpio-miso".

As we want to switch the GPIO SPI driver to using descriptors, we
need devm_gpiod_get() to return something reasonable when looking
up these in the device tree.

Put in a special #ifdef:ed kludge to do this special lookup only
for the SPI case and gets compiled out if we're not enabling SPI.
If we have more oddly defined legacy GPIOs like this, they can be
handled in a similar manner.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-08 17:29:25 +01:00
Linus Walleij 24e78079bf gpio: label descriptors using the device name
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: Jason Kridner <jkridner@beagleboard.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-05 09:25:42 +01:00
Linus Walleij 088413bc0b gpio: omap: Give unique labels to each GPIO bank/chip
As we need to add GPIO lookup tables to the OMAP platforms, we
need to reference each GPIO chip with a unique label. Use the GPIO
base to name each chip, "gpio-0-31", "gpio-32-63" etc.

Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Santosh Shilimkar <ssantosh@kernel.org>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-03 08:46:08 +01:00
Vladimir Zapolskiy 156dd39219 gpiolib: add desc validation to gpiod_set_transitory()
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: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-02 09:39:17 +01:00
Vladimir Zapolskiy dd3b9a4408 gpiolib: remove a redundant check in gpiod_to_chip()
This non-functional change slightly simplifies the implementation
of gpiod_to_chip() function.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-02 09:33:07 +01:00
Vladimir Zapolskiy 30322bcf82 gpiolib: don't dereference a desc before validation
The fix restores a proper validation of an input gpio desc, which
might be needed to deal with optional GPIOs correctly.

Fixes: 02e479808b ("gpio: Alter semantics of *raw* operations to actually be raw")
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-02 09:31:20 +01:00
Vasyl Gomonovych fe13862c9c gpio: fix aspeed_gpio_banks array size check
The test should be >= ARRAY_SIZE() instead of > ARRAY_SIZE().

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-28 13:53:06 +01:00
Linus Walleij bd8ed930af Revert "pinctrl: qcom: disable GPIO groups with no pins"
This reverts commit 93ebe8636b.

After discussion and review of the v11 patchset, a new approach
was found so that this patch is not needed.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-28 13:32:53 +01:00
Jonathan Neuschäfer 689fd02e81 gpiolib: Fix typo in comment ("piochip_add_data")
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 23:55:16 +01:00
Rasmus Villemoes a746a23218 gpio: reduce descriptor validation code size
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: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 23:09:51 +01:00
Joel Stanley 1696784eb7 tools/gpio: Fix build error with musl libc
The GPIO tools build fails when using a buildroot toolchain that uses musl
as it's C library:

arm-broomstick-linux-musleabi-gcc -Wp,-MD,./.gpio-event-mon.o.d \
 -Wp,-MT,gpio-event-mon.o -O2 -Wall -g -D_GNU_SOURCE \
 -Iinclude -D"BUILD_STR(s)=#s" -c -o gpio-event-mon.o gpio-event-mon.c
gpio-event-mon.c:30:6: error: unknown type name ‘u_int32_t’; did you mean ‘uint32_t’?
      u_int32_t handleflags,
      ^~~~~~~~~
      uint32_t

The glibc headers installed on my laptop include sys/types.h in
unistd.h, but it appears that musl does not.

Fixes: 97f69747d8 ("tools/gpio: add the gpio-event-mon tool")
Cc: stable@vger.kernel.org
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 13:51:01 +01:00
Timur Tabi 93ebe8636b pinctrl: qcom: disable GPIO groups with no pins
pinctrl-msm only accepts an array of GPIOs from 0 to n-1, and it expects
each group to support have only one pin (npins == 1).

We can support "sparse" GPIO maps if we allow for some groups to have zero
pins (npins == 0).  These pins are "hidden" from the rest of the driver
and gpiolib.

Access to unavailable GPIOs is blocked via a request callback.  If the
requested GPIO is unavailable, -EACCES is returned, which prevents
further access to that GPIO.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 13:04:35 +01:00
Timur Tabi 1ca2a92b2a Revert "gpio: set up initial state from .get_direction()"
This reverts commit 72d3200061.

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: Timur Tabi <timur@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 13:03:41 +01:00
Geert Uytterhoeven caa92ee84b dt-bindings: gpio: rcar: Correct SoC family name for R8A7778
R8A7778 is R-Car (not R-Mobile) M1.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-21 10:52:41 +01:00
Pravin Shedge 76bc7f1876 drivers: gpio: remove duplicate includes
These duplicate includes have been found with scripts/checkincludes.pl
but they have been removed manually to avoid removing false positives.

Signed-off-by: Pravin Shedge <pravin.shedge4linux@gmail.com>
Acked-by: Gregory Fong <gregory.0xf0@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 13:08:10 +01:00
Jonathan Neuschäfer 92e70b83c0 tools/gpio: Don't use u_int32_t
u_int32_t is a non-standard version of uint32_t, that was apparently
introduced by BSD. Use uint32_t from stdint.h instead.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 10:36:30 +01:00
Christophe Leroy 1efba35afa gpio: sysfs: avoid using kstrtol() in 'value' attribute write
A 'perf record' on an app continuously writing in the 'value'
attribute show that most of the time is spent in kstrtol()

--17.99%--value_store
          |
          |--10.17%--kstrtoint
          |          |
          |          |--8.82%--kstrtoll
          |
          |--2.50%--gpiod_set_value_cansleep
          |
          |--1.82%--u16_gpio_set
          |
          |--1.46%--value_store

The normal case is to write 0 or 1 in the attribute, therefore
this patch avoids the call to kstrtol() in the most common cases

Then 'perf record' shows

--7.21%--value_store
          |
          |--2.69%--u16_gpio_set
          |
          |--1.47%--value_store
          |
          |--1.08%--gpiod_set_value_cansleep
          |
          |--0.60%--mutex_lock
          |
           --0.58%--mutex_unlock

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 10:34:58 +01:00
Christophe Leroy 7a94b88cb7 gpio: sysfs: don't use sprintf() for 'value' attribute
A bench with 'perf record' shows that most of time spent in value_show()
is spent in sprintf()

--42.41%--sysfs_kf_read
          |
          |--39.73%--dev_attr_show
          |          |
          |          |--38.23%--value_show
          |          |          |
          |          |          |--29.22%--sprintf
          |          |          |
          |          |          |--2.94%--gpiod_get_value_cansleep
          |          |          |

value_show() only returns "0\n" or "1\n", therefore the use of
sprintf() can be avoided

With this patch we get the following result with 'perf record'

--13.89%--sysfs_kf_read
          |
          |--10.72%--dev_attr_show
          |          |
          |          |--9.44%--value_show
          |          |          |
          |          |          |--4.61%--gpiod_get_value_cansleep

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 10:34:01 +01:00
Christophe Leroy 9295c01253 gpio: sysfs: correct error handling on 'value' attribute read.
'value' attribute is supposed to only return 0 or 1 according to
the documentation.
With today's implementation, if gpiod_get_value_cansleep() fails
the printed 'value' is a negative value.

This patch ensures that an error is returned on read instead.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 10:33:21 +01:00
Christophe Leroy 7fda9100bb gpio: sysfs: change 'value' attribute to prealloc
The GPIO 'value' attribute is time critical. A small bench with
'perf record' on the app below shows that 80% of the time spent in
sysfs_kf_seq_show() is spent in memset() for zeroising the buffer.

|--67.48%--sysfs_kf_seq_show
|          |
|          |--54.40%--memset
|          |
|          |--11.49%--dev_attr_show
|          |          |
|          |          |--10.06%--value_show
|          |          |          |
|          |          |          |--4.75%--sprintf
|          |          |          |          |

This patch changes the attribute type to prealloc, eliminating the
need to zeroise the buffer at each read. 'perf record' gives the
following result.

|--42.41%--sysfs_kf_read
|          |
|          |--39.73%--dev_attr_show
|          |          |
|          |          |--38.23%--value_show
|          |          |          |
|          |          |          |--29.22%--sprintf
|          |          |          |          |

Test done with the following small app:

int main(int argc, char **argv)
{
	int fd = open(argv[1], O_RDONLY);

	for (;;) {
		int buf[512];

		read(fd, buf, 512);
		lseek(fd, 0, SEEK_SET);
	}
	exit(0);
}

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 10:28:05 +01:00
Bartosz Golaszewski fcf273e580 gpiolib: use kstrdup_const() for gpio_device label
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: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 09:16:39 +01:00
Bartosz Golaszewski 3b469b0a13 gpiolib: constify label in gpio_device
This string is never modified. Make it const.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-20 09:01:50 +01:00
Bartosz Golaszewski c4b54e138a gpio: mockup: fix a return value check
The return value of platform_device_register_resndata() on error is
an error code converted to pointer with ERR_PTR(), not NULL.

Check the return value correctly.

Fixes: 8a39f597bc ("gpio: mockup: rework device probing")
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-08 15:34:15 +01:00
Linus Walleij e0fc62a655 w1: w1-gpio: Convert to use GPIO descriptors
The w1 master driver includes a complete open drain emulation
reimplementation among other things.

This converts the driver and all board files using it to use
GPIO descriptors associated with the device to look up the
GPIO wire, as well ass the optional pull-up GPIO line.

When probed from the device tree, the driver will just pick
descriptors and use them right off. For the two board files
in the kernel, we add descriptor lookups so we do not need
to keep any old platform data handling around for the GPIO
lines.

As the platform data is also a state container for this driver,
we augment it to contain the GPIO descriptors.

w1_gpio_write_bit_dir() and w1_gpio_write_bit_val() are gone
since this pair was a reimplementation of open drain emulation
which is now handled by gpiolib.

The special "linux,open-drain" flag is a bit of mishap here:
it has the same semantic as the same flags in I2C: it means
that something in the platform is setting up the line as
open drain behind our back. We handle this the same way as
in I2C.

To drive the pull-up, we need to bypass open drain emulation
in gpiolib for the line, and this is done by driving it high
using gpiod_set_raw_value() which has been augmented to have
the semantic of overriding the open drain emulation.

We also augment the documentation to reflect the way to pass
GPIO descriptors from the machine.

Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-08 15:32:53 +01:00
Linus Walleij 110e2a38c8 Merge branch 'ib-move-axp209' into devel 2017-12-07 10:09:55 +01:00
Quentin Schulz e1190083b8 pinctrl: axp209: add support for AXP813 GPIOs
The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
regulator.

Moreover, the status bit of the GPIOs when in input mode is not offset
by 4 unlike the AXP209.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:08:12 +01:00
Quentin Schulz a0a4b4c242 pinctrl: axp209: add programmable ADC muxing value
To prepare for patches that will add support for a new PMIC that has a
different GPIO adc muxing value, add an adc_mux within axp20x_pctl
structure and use it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:07:45 +01:00
Quentin Schulz 48e706fbc5 pinctrl: axp209: add programmable gpio_status_offset
To prepare for patches that will add support for a new PMIC that has a
different GPIO input status register, add a gpio_status_offset within
axp20x_pctl structure and use it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:07:19 +01:00
Quentin Schulz d242e60c7d pinctrl: axp209: rename everything from gpio to pctl
This driver used to do only GPIO features of the GPIOs in X-Powers
AXP20X. Now that we have migrated everything to the pinctrl subsystem
and added pinctrl features, rename everything related to pinctrl from
gpio to pctl to ease the understanding of differences between GPIO
and pinctrl features.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:06:57 +01:00
Quentin Schulz f17aea430f dt-bindings: gpio: gpio-axp209: add pinctrl features
The X-Powers AXP209 has 3 GPIOs. GPIO0/1 can each act either as a GPIO,
an ADC or a LDO regulator. GPIO2 can only act as a GPIO.

This adds the pinctrl features to the driver so GPIO0/1 can be used as
ADC or LDO regulator.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:06:24 +01:00
Quentin Schulz 23f75d7dfa pinctrl: axp209: add pinctrl features
The X-Powers AXP209 has 3 GPIOs. GPIO0/1 can each act either as a GPIO,
an ADC or a LDO regulator. GPIO2 can only act as a GPIO.

This adds the pinctrl features to the driver so GPIO0/1 can be used as
ADC or LDO regulator.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:05:58 +01:00
Quentin Schulz 449317a8b4 pinctrl: move gpio-axp209 to pinctrl
To prepare the driver for the upcoming pinctrl features, move the GPIO
driver AXP209 from GPIO to pinctrl subsystem.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:05:30 +01:00
Quentin Schulz 3cac991e33 gpio: axp209: switch unsigned variables to unsigned int
Checkpatch complains with the following message:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Let's make it happy by switching over to unsigned int.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-07 10:04:09 +01:00
Arvind Yadav 4070a53496 gpio: ftgpio010: Fix platform_get_irq's error checking
The platform_get_irq() function returns negative if an error occurs.
zero or positive number on success. platform_get_irq() error checking
for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:35 +01:00
Andrew Jeffery 1b43d26985 gpio: aspeed: Add support for reset tolerance
Use the new pinconf parameter for state persistence to expose the
associated capability of the Aspeed GPIO controller.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:34 +01:00
Andrew Jeffery e10f72bf4b gpio: gpiolib: Generalise state persistence beyond sleep
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: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:34 +01:00
Colin Ian King e2843cb6cd gpio: gpio-stmpe: make various char arrays static const, shrinks object size
Don't populate the read-only arrays edge_det_values, rise_values and
fall_values on the stack but instead make them static and constify them.
Makes the object code smaller by over 240 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
   9525	   2520	    192	  12237	   2fcd	drivers/gpio/gpio-stmpe.o

After:
   text	   data	    bss	    dec	    hex	filename
   9025	   2776	    192	  11993	   2ed9	drivers/gpio/gpio-stmpe.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:33 +01:00
Adam Borowski deb2e713ba gpio: it87: fix mojibake in module metadata
It had twice-encoded Unicode.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:32 +01:00
Bartosz Golaszewski 7965f5df85 MAINTAINERS: add myself as reviewer for gpio-mockup
The user space libgpiod project is now tightly coupled with the
gpio-mockup module, so let me know when any changes to it are being
proposed.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:32 +01:00
Bartosz Golaszewski cd9835f1c6 gpio: mockup: add helpers for accessing the gpio ranges
In order to avoid repeating the calculations on every access - add
helpers for gpio base and ngpio components of the ranges array.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:31 +01:00
Bartosz Golaszewski e63a006f70 gpio: mockup: rename gpio_mockup_params_nr to gpio_mockup_num_ranges
This variable holds the number of mockup GPIO ranges so rename it
accordingly.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:31 +01:00
Bartosz Golaszewski 1e0dca677b gpio: mockup: modify the return value check for devm_irq_sim_init()
As discussed with Marc Zyngier: irq_sim_init() and its devres variant
should return the base of the allocated interrupt range on success
rather than 0. This will be modified later - first, change the way
users handle the return value of these routines.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:30 +01:00
Bartosz Golaszewski c47bee95f6 gpio: mockup: implement gpio_mockup_set_multiple()
Implement the set_multiple() callback and register it with the gpiolib
framework. This is only meant to also test the internal kernel API.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:30 +01:00
Bartosz Golaszewski 2a9d742c26 gpio: mockup: tweak line breaks
Minor readability tweak: prefer breaking the lines in a way where the
second part is longer than the first.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:29 +01:00
Bartosz Golaszewski fa86963a75 gpio: mockup: verify that ngpio > 0
Improve the module params sanitization: bail out from init if the user
tries to pass a non-positive number of GPIO lines for any mockup chip.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:28 +01:00
Bartosz Golaszewski 46526c15ca gpio: mockup: fix debugfs handling
The debugfs routines returning pointers can return NULL or error codes
embedded with ERR_PTR(). Check the return values with IS_ERR_OR_NULL().

While we're at it: make the error message more specific so it's not
confused with the one emitted when the top-level gpio-mockup debugfs
directory creation fails.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:28 +01:00
Bartosz Golaszewski 1cea4734f9 gpio: mockup: group code by logic
Keep GPIO chip callbacks, event trigger callbacks and mockup chip
setup code visibly separated. We're mostly good - just need to move
the line naming routine below.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:28 +01:00
Bartosz Golaszewski 5b7908c024 gpio: mockup: change the type of value field in line state struct
GPIO values are universally represented as integers. Change the type
of the variable storing the current line value to int for consistency.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:27 +01:00
Bartosz Golaszewski ca8792af40 gpio: mockup: extend the debugfs layout
Currently each chip has a dedicated directory in debugfs for event
triggers. We use the chip's label for the directory name, but the user
can't really associate these directories with chip names without
parsing the relevant sysfs entries.

Use chip names for directory names. For backward compatibility: create
links pointing to the actual directories named using the chip labels.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-12-02 22:42:27 +01:00