1
0
Fork 0
alistair23-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: Propagate all errors in devm_get_gpiod_from_child() 2016-02-25 10:04:25 +01:00
gpio-74x164.c gpio: 74x164: add dt support for nxp's 74x594 2016-03-31 10:25:51 +02:00
gpio-74xx-mmio.c gpio: 74xx-mmio: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:19:42 +05:30
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: adnp: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:19:46 +05:30
gpio-adp5520.c gpio: adp5520: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:34:06 +05:30
gpio-adp5588.c gpio: adp5588: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:34:24 +05:30
gpio-altera.c gpio: gpio-altera: Remove gpiochip on probe failure. 2016-01-27 10:50:22 +01:00
gpio-amd8111.c gpio: amd8111: Use devm_request_region 2016-02-16 00:19:52 +01:00
gpio-amdpt.c gpio: amdpt: Add a new ACPI HID 2016-03-30 10:38:51 +02:00
gpio-arizona.c gpio: arizona: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:34:29 +05:30
gpio-ath79.c gpio: ath79: Check valid gpio count for both DT and non-DT cases 2016-02-25 15:20:43 +01:00
gpio-bcm-kona.c gpio: bcm-kona: make explicitly non-modular 2016-03-31 12:01:15 +02:00
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: bt8xx: use gpiochip data pointer 2016-01-05 11:21:03 +01:00
gpio-clps711x.c gpio: clps711x: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:27 +05:30
gpio-crystalcove.c gpio: crystalcove: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:27 +05:30
gpio-cs5535.c gpio: cs5535: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:28 +05:30
gpio-da9052.c gpio: da9052: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:29 +05:30
gpio-da9055.c gpio: da9055: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:29 +05:30
gpio-davinci.c Merge branch 'devel' into for-next 2016-02-22 13:47:49 +01:00
gpio-dln2.c gpio: dln2: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:30 +05:30
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: em: use gpiochip data pointer 2016-01-05 11:21:05 +01:00
gpio-ep93xx.c gpio: ep93xx: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:30 +05:30
gpio-etraxfs.c gpio: generic: factor into gpio_chip struct 2016-01-05 11:21:00 +01:00
gpio-f7188x.c gpio: f7188x: fix edit mistake 2016-04-18 13:32:20 +02:00
gpio-ge.c gpio: ge: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:31 +05:30
gpio-grgpio.c gpio: generic: factor into gpio_chip struct 2016-01-05 11:21:00 +01:00
gpio-ich.c gpio: ich: Use devm_request_region 2016-02-16 00:19:53 +01:00
gpio-intel-mid.c gpio: intel-mid: use gpiochip data pointer 2016-01-05 11:21:05 +01:00
gpio-iop.c gpio: iop: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:32 +05:30
gpio-it87.c gpio: gpio-it87: Add support for IT8620 and IT8628 2016-03-31 11:59:43 +02:00
gpio-janz-ttl.c gpio: janz-ttl: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:33 +05:30
gpio-kempld.c gpio: kempld: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:34 +05:30
gpio-ks8695.c gpio: ks8695: remove irq_to_gpio function 2016-02-19 00:20:30 +01:00
gpio-loongson.c gpio: convert remaining users to gpiochip_add_data() 2016-01-05 11:21:20 +01:00
gpio-loongson1.c gpio: Loongson1: add Loongson1 GPIO driver 2016-04-09 20:14:35 +02:00
gpio-lp3943.c Revert "gpio: lp3943: Drop pin_used and lp3943_gpio_request/lp3943_gpio_free" 2016-03-09 22:00:27 +07:00
gpio-lpc18xx.c gpio: lpc18xx: use gpiochip data pointer 2016-01-05 11:21:06 +01:00
gpio-lpc32xx.c gpio: lpc32xx: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:35 +05:30
gpio-lynxpoint.c gpio: lynxpoint: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:35 +05:30
gpio-max730x.c gpio: max730x: use gpiochip data pointer 2016-01-05 11:21:07 +01:00
gpio-max732x.c gpio: max732x: use gpiochip data pointer 2016-01-05 11:21:07 +01:00
gpio-max7300.c gpio: Drop owner assignment from i2c_driver 2015-11-30 09:31:00 +01:00
gpio-max7301.c spi: Drop owner assignment from spi_drivers 2015-10-28 10:30:17 +09:00
gpio-mb86s7x.c gpio: mb86s7x: make explicitly non-modular 2016-03-31 15:00:28 +02:00
gpio-mc9s08dz60.c gpio: mc9s08dz60: make explicitly non-modular 2016-03-31 15:02:09 +02:00
gpio-mc33880.c gpio: mc33880: use gpiochip data pointer 2016-01-05 11:21:07 +01:00
gpio-mcp23s08.c gpio: mcp23s08: Add support for level triggered interrupts 2016-03-31 10:41:50 +02:00
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: ml-ioh: use gpiochip data pointer 2016-01-05 11:21:08 +01:00
gpio-mm-lantiq.c gpio: mm-lantiq: Do not use gpiochip_get_data() in ltq_mm_save_regs() 2016-01-13 10:21:06 +01:00
gpio-mmio.c gpio: rename gpio-generic.c into gpio-mmio.c 2016-04-29 16:14:32 +02:00
gpio-moxart.c gpio: moxart: make explicitly non-modular 2016-03-31 15:03:13 +02:00
gpio-mpc8xxx.c gpio: mpc8xxx: Slightly update the code for better readability 2016-03-09 10:44:13 +07:00
gpio-mpc5200.c gpio: Include linux/gpio.h instead of asm/gpio.h 2016-02-16 00:20:03 +01:00
gpio-msic.c gpio: msic: use gpiochip data pointer 2016-01-05 11:21:09 +01:00
gpio-mvebu.c gpio: mvebu: make explicitly non-modular 2016-03-31 15:05:44 +02:00
gpio-mxc.c gpio: mxc: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:37 +05:30
gpio-mxs.c gpio: generic: factor into gpio_chip struct 2016-01-05 11:21:00 +01:00
gpio-octeon.c gpio: octeon: Constify octeon_gpio_match table 2016-03-30 10:38:51 +02:00
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: palmas: make explicitly non-modular 2016-04-05 17:02:36 +02:00
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: pcf857x: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:39 +05:30
gpio-pch.c gpio: pch: Optimize pch_gpio_get() 2016-01-05 15:46:34 +01:00
gpio-pisosr.c gpio: pisosr: Use gpiod_set_value_cansleep in pisosr_gpio_refresh() 2016-02-25 15:20:46 +01:00
gpio-pl061.c gpio: pl061: implement .get_direction() 2016-04-28 14:36:37 +02:00
gpio-pxa.c gpio: pxa: fix legacy non pinctrl aware builds 2016-04-08 10:10:08 +02:00
gpio-rc5t583.c gpio: rc5t583: make explicitly non-modular 2016-04-05 17:02:35 +02:00
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: rdc321x: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:41 +05:30
gpio-sa1100.c gpio: convert remaining users to gpiochip_add_data() 2016-01-05 11:21:20 +01:00
gpio-sch.c gpio: sch: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:41 +05:30
gpio-sch311x.c gpio: sch311x: Use devm_request_region 2016-02-16 00:19:53 +01:00
gpio-sodaville.c gpio: sodaville: make it explicitly non-modular 2016-05-11 13:46:49 +02:00
gpio-spear-spics.c gpio: spear-spics: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:42 +05:30
gpio-sta2x11.c gpio: sta2x11: make explicitly non-modular 2016-03-31 15:07:40 +02:00
gpio-stmpe.c gpio: stmpe: make it explicitly non-modular 2016-05-11 13:48:03 +02:00
gpio-stp-xway.c gpio: stp-xway: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:43 +05:30
gpio-sx150x.c gpio: sx150x: use the new open drain callback 2016-04-14 14:03:26 +02:00
gpio-syscon.c gpio: syscon: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:44 +05:30
gpio-tb10x.c gpio: tb10x: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:44 +05:30
gpio-tc3589x.c gpio: tc3589x: make explicitly non-modular 2016-04-05 17:02:35 +02:00
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: tpic2810: Make sure cached buffer has consistent status with h/w status 2016-03-31 15:14:37 +02:00
gpio-tps6586x.c gpio: tps6586x: make explicitly non-modular 2016-04-05 17:02:37 +02:00
gpio-tps65086.c gpio: tps65086: Add GPO driver for the TPS65086 PMIC 2016-03-16 08:50:33 +00:00
gpio-tps65218.c gpio: tps65218: use the new open drain callback 2016-04-14 14:03:25 +02:00
gpio-tps65910.c gpio: tps65910: make explicitly non-modular 2016-04-05 17:02:37 +02:00
gpio-tps65912.c gpio: tps65912: fix bad merge 2016-03-09 22:02:52 +07:00
gpio-ts4800.c gpio: ts4800: Drop redundant code to set already initialized gpio_chip fields 2016-02-25 15:20:44 +01:00
gpio-ts5500.c gpio: ts5500: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:49 +05:30
gpio-twl4030.c gpio: twl4030: use gpiochip data pointer 2016-01-05 11:21:16 +01:00
gpio-twl6040.c gpio: twl6040: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:50 +05:30
gpio-tz1090-pdc.c gpio: tz1090-pdc: use gpiochip data pointer 2016-01-05 11:21:16 +01:00
gpio-tz1090.c gpio: tz1090: use gpiochip data pointer 2016-01-05 11:21:16 +01:00
gpio-ucb1400.c gpio: ucb1400: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:50 +05:30
gpio-vf610.c gpio: vf610: use gpiochip data pointer 2016-01-05 11:21:17 +01:00
gpio-viperboard.c gpio: viperboard: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:51 +05:30
gpio-vr41xx.c gpio: convert remaining users to gpiochip_add_data() 2016-01-05 11:21:20 +01:00
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: wm8350: Use devm_gpiochip_add_data() for gpio registration 2016-02-23 20:35:52 +05:30
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-sb: Use irq_domain_free_irqs_common() 2016-03-31 10:22:53 +02:00
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: xilinx: Do not use gpiochip_get_data() in xgpio_save_regs() 2016-01-07 10:06:56 +01:00
gpio-xlp.c remove lots of IS_ERR_VALUE abuses 2016-05-27 15:26:11 -07:00
gpio-xtensa.c gpio: convert remaining users to gpiochip_add_data() 2016-01-05 11:21:20 +01:00
gpio-zevio.c gpio: zevio: make it explicitly non-modular 2016-05-11 13:50:01 +02:00
gpio-zx.c gpio: zx: make explicitly non-modular 2016-03-31 15:10:25 +02:00
gpio-zynq.c gpio: zynq: Fix the error path 2016-04-09 20:14:36 +02:00
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: Split GPIO flags parsing and GPIO configuration 2015-10-16 22:46:46 +02:00
gpiolib-of.c gpio: of: make it possible to name GPIO lines 2016-05-10 13:43:48 +02:00
gpiolib-sysfs.c gpio: fix abi regression in sysfs 2016-02-25 16:08:45 +01:00
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