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)
commit06863620edfeadbe9e0ea5eb01dd94ce07f37549
treef480b288a7b532bc0ddc30a49bc094f232f0abc9
parentd90f36851d6595136b461773846b76e0c45e3e0c
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