]> git.baikalelectronics.ru Git - kernel.git/commit
gpiolib: convert the type of hwnum to unsigned int in gpiochip_get_desc()
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 24 Dec 2019 12:06:59 +0000 (13:06 +0100)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 7 Jan 2020 11:03:28 +0000 (12:03 +0100)
commitb69fa38e5ad5214271d655e99b6f236ad01db213
treef480b288a7b532bc0ddc30a49bc094f232f0abc9
parenta5ed00cf1ff66570307a9ed03e584920c7773187
gpiolib: convert the type of hwnum to unsigned int in gpiochip_get_desc()

gpiochip_get_desc() takes a u16 hwnum, but it turns out most users don't
respect that and usually pass an unsigned int. Since implicit casting to
a smaller type is dangerous - let's change the type of hwnum to unsigned
int in gpiochip_get_desc() and in gpiochip_request_own_desc() where the
size of hwnum is not respected either and who's a user of the former.

This is safe as we then check the hwnum against the number of lines
before proceeding in gpiochip_get_desc().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c
drivers/gpio/gpiolib.h
include/linux/gpio/driver.h