* [PATCH] gpio: Remove impossible checks on container_of() result
@ 2017-01-09 19:47 Stephen Boyd
2017-01-11 15:02 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Boyd @ 2017-01-09 19:47 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot; +Cc: linux-kernel, linux-gpio
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>
---
drivers/gpio/gpiolib.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 86bf3b84ada5..4864408364ef 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -982,7 +982,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;
@@ -1001,8 +1001,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;
}
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: Remove impossible checks on container_of() result
2017-01-09 19:47 [PATCH] gpio: Remove impossible checks on container_of() result Stephen Boyd
@ 2017-01-11 15:02 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2017-01-11 15:02 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Alexandre Courbot, linux-kernel, linux-gpio
On Mon, Jan 9, 2017 at 8:47 PM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> 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>
Good point.
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-11 15:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 19:47 [PATCH] gpio: Remove impossible checks on container_of() result Stephen Boyd
2017-01-11 15:02 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.