linux/drivers/gpio
Arnd Bergmann 287980e49f remove lots of IS_ERR_VALUE abuses
Most users of IS_ERR_VALUE() in the kernel are wrong, as they
pass an 'int' into a function that takes an 'unsigned long'
argument. This happens to work because the type is sign-extended
on 64-bit architectures before it gets converted into an
unsigned type.

However, anything that passes an 'unsigned short' or 'unsigned int'
argument into IS_ERR_VALUE() is guaranteed to be broken, as are
8-bit integers and types that are wider than 'unsigned long'.

Andrzej Hajda has already fixed a lot of the worst abusers that
were causing actual bugs, but it would be nice to prevent any
users that are not passing 'unsigned long' arguments.

This patch changes all users of IS_ERR_VALUE() that I could find
on 32-bit ARM randconfig builds and x86 allmodconfig. For the
moment, this doesn't change the definition of IS_ERR_VALUE()
because there are probably still architecture specific users
elsewhere.

Almost all the warnings I got are for files that are better off
using 'if (err)' or 'if (err < 0)'.
The only legitimate user I could find that we get a warning for
is the (32-bit only) freescale fman driver, so I did not remove
the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
For 9pfs, I just worked around one user whose calling conventions
are so obscure that I did not dare change the behavior.

I was using this definition for testing:

 #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
       unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

which ends up making all 16-bit or wider types work correctly with
the most plausible interpretation of what IS_ERR_VALUE() was supposed
to return according to its users, but also causes a compile-time
warning for any users that do not pass an 'unsigned long' argument.

I suggested this approach earlier this year, but back then we ended
up deciding to just fix the users that are obviously broken. After
the initial warning that caused me to get involved in the discussion
(fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
asked me to send the whole thing again.

[ Updated the 9p parts as per Al Viro  - Linus ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.org/lkml/2016/1/7/363
Link: https://lkml.org/lkml/2016/5/27/486
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-05-27 15:26:11 -07:00
..
Kconfig driver core update for 4.7-rc1 2016-05-20 21:26:15 -07:00
Makefile gpio: rename gpio-generic.c into gpio-mmio.c 2016-04-29 16:14:32 +02:00
devres.c
gpio-74x164.c
gpio-74xx-mmio.c
gpio-104-dio-48e.c gpio: 104-dio-48e: Utilize the ISA bus driver 2016-05-02 09:32:04 -07:00
gpio-104-idi-48.c gpio: 104-idi-48: Utilize the ISA bus driver 2016-05-02 09:32:04 -07:00
gpio-104-idio-16.c gpio: 104-idio-16: Utilize the ISA bus driver 2016-05-02 09:32:04 -07:00
gpio-adnp.c
gpio-adp5520.c
gpio-adp5588.c
gpio-altera.c
gpio-amd8111.c
gpio-amdpt.c
gpio-arizona.c
gpio-ath79.c
gpio-bcm-kona.c
gpio-brcmstb.c gpio: brcmstb: Return proper error if bank width is invalid 2016-04-15 10:09:48 +02:00
gpio-bt8xx.c
gpio-clps711x.c
gpio-crystalcove.c
gpio-cs5535.c
gpio-da9052.c
gpio-da9055.c
gpio-davinci.c
gpio-dln2.c
gpio-dwapb.c gpio: dwapb: Add ACPI device ID for DWAPB GPIO controller on X-Gene platforms 2016-05-11 11:32:39 +02:00
gpio-em.c
gpio-ep93xx.c
gpio-etraxfs.c
gpio-f7188x.c gpio: f7188x: fix edit mistake 2016-04-18 13:32:20 +02:00
gpio-ge.c
gpio-grgpio.c
gpio-ich.c
gpio-intel-mid.c
gpio-iop.c
gpio-it87.c
gpio-janz-ttl.c
gpio-kempld.c
gpio-ks8695.c
gpio-loongson.c
gpio-loongson1.c
gpio-lp3943.c
gpio-lpc18xx.c
gpio-lpc32xx.c
gpio-lynxpoint.c
gpio-max730x.c
gpio-max732x.c
gpio-max7300.c
gpio-max7301.c
gpio-mb86s7x.c
gpio-mc9s08dz60.c
gpio-mc33880.c
gpio-mcp23s08.c
gpio-menz127.c This is the bulk of GPIO changes for kernel cycle v4.7: 2016-05-17 17:39:42 -07:00
gpio-ml-ioh.c
gpio-mm-lantiq.c
gpio-mmio.c gpio: rename gpio-generic.c into gpio-mmio.c 2016-04-29 16:14:32 +02:00
gpio-moxart.c
gpio-mpc8xxx.c
gpio-mpc5200.c
gpio-msic.c
gpio-mvebu.c
gpio-mxc.c
gpio-mxs.c
gpio-octeon.c
gpio-omap.c gpio: omap: fix irq triggering in smart-idle wakeup mode 2016-04-26 15:56:47 +02:00
gpio-palmas.c
gpio-pca953x.c This is the bulk of GPIO changes for kernel cycle v4.7: 2016-05-17 17:39:42 -07:00
gpio-pcf857x.c
gpio-pch.c
gpio-pisosr.c
gpio-pl061.c gpio: pl061: implement .get_direction() 2016-04-28 14:36:37 +02:00
gpio-pxa.c
gpio-rc5t583.c
gpio-rcar.c This is the bulk of GPIO changes for kernel cycle v4.7: 2016-05-17 17:39:42 -07:00
gpio-rdc321x.c
gpio-sa1100.c
gpio-sch.c
gpio-sch311x.c
gpio-sodaville.c gpio: sodaville: make it explicitly non-modular 2016-05-11 13:46:49 +02:00
gpio-spear-spics.c
gpio-sta2x11.c
gpio-stmpe.c gpio: stmpe: make it explicitly non-modular 2016-05-11 13:48:03 +02:00
gpio-stp-xway.c
gpio-sx150x.c gpio: sx150x: use the new open drain callback 2016-04-14 14:03:26 +02:00
gpio-syscon.c
gpio-tb10x.c
gpio-tc3589x.c
gpio-tegra.c gpio: tegra: Implement gpio_get_direction callback 2016-04-30 13:15:10 +02:00
gpio-timberdale.c gpio: timberdale: make it explicitly non-modular 2016-05-11 13:49:11 +02:00
gpio-tpic2810.c
gpio-tps6586x.c
gpio-tps65086.c
gpio-tps65218.c
gpio-tps65910.c
gpio-tps65912.c
gpio-ts4800.c
gpio-ts5500.c
gpio-twl4030.c
gpio-twl6040.c
gpio-tz1090-pdc.c
gpio-tz1090.c
gpio-ucb1400.c
gpio-vf610.c
gpio-viperboard.c
gpio-vr41xx.c
gpio-vx855.c gpio: vx855: use the new open drain callback 2016-04-14 14:03:28 +02:00
gpio-wm831x.c gpio: wm831x: use the new open drain callback 2016-04-14 14:03:28 +02:00
gpio-wm8350.c
gpio-wm8994.c gpio: wm8994: use the new open drain callback 2016-04-14 14:03:29 +02:00
gpio-ws16c48.c gpio: ws16c48: Utilize the ISA bus driver 2016-05-02 09:32:04 -07:00
gpio-xgene-sb.c
gpio-xgene.c This is the bulk of GPIO changes for kernel cycle v4.7: 2016-05-17 17:39:42 -07:00
gpio-xilinx.c
gpio-xlp.c remove lots of IS_ERR_VALUE abuses 2016-05-27 15:26:11 -07:00
gpio-xtensa.c
gpio-zevio.c gpio: zevio: make it explicitly non-modular 2016-05-11 13:50:01 +02:00
gpio-zx.c
gpio-zynq.c
gpiolib-acpi.c gpiolib-acpi: Duplicate con_id string when adding it to the crs lookup list 2016-04-30 13:51:59 +02:00
gpiolib-legacy.c
gpiolib-of.c gpio: of: make it possible to name GPIO lines 2016-05-10 13:43:48 +02:00
gpiolib-sysfs.c
gpiolib.c This is the bulk of GPIO changes for kernel cycle v4.7: 2016-05-17 17:39:42 -07:00
gpiolib.h gpio: move gpiod_set_array_value_priv() 2016-04-26 10:51:36 +02:00