gpio: cdev: don't access gdev->chip if it's not needed
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 24 Jan 2024 16:21:16 +0000 (17:21 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 12 Feb 2024 09:51:10 +0000 (10:51 +0100)
The variable holding the number of GPIO lines is duplicated in GPIO
device so read it instead of unnecessarily dereferencing the chip
pointer.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/gpio/gpiolib-cdev.c

index 8e37e3befa084080d8f455ec82b29f34d7a8781f..e993c6a7215af4f4d888e923ce8a195b648b93e5 100644 (file)
@@ -2701,7 +2701,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)
        if (!cdev)
                return -ENODEV;
 
-       cdev->watched_lines = bitmap_zalloc(gdev->chip->ngpio, GFP_KERNEL);
+       cdev->watched_lines = bitmap_zalloc(gdev->ngpio, GFP_KERNEL);
        if (!cdev->watched_lines)
                goto out_free_cdev;