Skip to content

Commit

Permalink
gpio: Remove impossible checks on container_of() result
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Boyd authored and Linus Walleij committed Jan 11, 2017
1 parent e567c35 commit fb50574
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit fb50574

Please sign in to comment.