]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
gpio: Remove impossible checks on container_of() result
authorStephen Boyd <sboyd@codeaurora.org>
Mon, 9 Jan 2017 19:47:44 +0000 (11:47 -0800)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 11 Jan 2017 15:01:27 +0000 (16:01 +0100)
container_of() does pointer math on the pointer that's passed in.
If it were to return a NULL pointer the value passed in would
need to be perfectly offset from 0 to make that so. Remove these
checks because they don't make sense.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c

index 7f51c9bf55330c786db6e36adc0b2578e2e4418a..c76fa4ffb59c2103c361110762331a9c02b0b162 100644 (file)
@@ -983,7 +983,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *filp)
                                              struct gpio_device, chrdev);
 
        /* Fail on open if the backing gpiochip is gone */
-       if (!gdev || !gdev->chip)
+       if (!gdev->chip)
                return -ENODEV;
        get_device(&gdev->dev);
        filp->private_data = gdev;
@@ -1002,8 +1002,6 @@ static int gpio_chrdev_release(struct inode *inode, struct file *filp)
        struct gpio_device *gdev = container_of(inode->i_cdev,
                                              struct gpio_device, chrdev);
 
-       if (!gdev)
-               return -ENODEV;
        put_device(&gdev->dev);
        return 0;
 }