2021-01-14 18:00:24

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 1/3] tty: hvcs: Drop unnecessary if block

If hvcs_probe() succeeded dev_set_drvdata() is called with a non-NULL
value, and if hvcs_probe() failed hvcs_remove() isn't called.

So there is no way dev_get_drvdata() can return NULL in hvcs_remove() and
the check can just go away.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/tty/hvc/hvcs.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 509d1042825a..3e0461285c34 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -825,9 +825,6 @@ static int hvcs_remove(struct vio_dev *dev)
unsigned long flags;
struct tty_struct *tty;

- if (!hvcsd)
- return -ENODEV;
-
/* By this time the vty-server won't be getting any more interrupts */

spin_lock_irqsave(&hvcsd->lock, flags);
--
2.29.2


2021-01-15 08:48:59

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 1/3] tty: hvcs: Drop unnecessary if block

On 14. 01. 21, 18:57, Uwe Kleine-König wrote:
> If hvcs_probe() succeeded dev_set_drvdata() is called with a non-NULL
> value, and if hvcs_probe() failed hvcs_remove() isn't called.
>
> So there is no way dev_get_drvdata() can return NULL in hvcs_remove() and
> the check can just go away.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>

Reviewed-by: Jiri Slaby <[email protected]>

> ---
> drivers/tty/hvc/hvcs.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
> index 509d1042825a..3e0461285c34 100644
> --- a/drivers/tty/hvc/hvcs.c
> +++ b/drivers/tty/hvc/hvcs.c
> @@ -825,9 +825,6 @@ static int hvcs_remove(struct vio_dev *dev)
> unsigned long flags;
> struct tty_struct *tty;
>
> - if (!hvcsd)
> - return -ENODEV;
> -
> /* By this time the vty-server won't be getting any more interrupts */
>
> spin_lock_irqsave(&hvcsd->lock, flags);
>


--
js

2021-01-20 17:22:30

by Tyrel Datwyler

[permalink] [raw]
Subject: Re: [PATCH 1/3] tty: hvcs: Drop unnecessary if block

On 1/14/21 9:57 AM, Uwe Kleine-König wrote:
> If hvcs_probe() succeeded dev_set_drvdata() is called with a non-NULL
> value, and if hvcs_probe() failed hvcs_remove() isn't called.
>
> So there is no way dev_get_drvdata() can return NULL in hvcs_remove() and
> the check can just go away.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>

Reviewed-by: Tyrel Datwyler <[email protected]>

> ---
> drivers/tty/hvc/hvcs.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
> index 509d1042825a..3e0461285c34 100644
> --- a/drivers/tty/hvc/hvcs.c
> +++ b/drivers/tty/hvc/hvcs.c
> @@ -825,9 +825,6 @@ static int hvcs_remove(struct vio_dev *dev)
> unsigned long flags;
> struct tty_struct *tty;
>
> - if (!hvcsd)
> - return -ENODEV;
> -
> /* By this time the vty-server won't be getting any more interrupts */
>
> spin_lock_irqsave(&hvcsd->lock, flags);
>