[1/3] usb: typec: drop check because i2c_unregister_device() is NULL safe

Message ID 20230922080421.35145-2-wsa+renesas@sang-engineering.com
State New
Headers
Series treewide: drop check because i2c_unregister_device() is NULL safe |

Commit Message

Wolfram Sang Sept. 22, 2023, 8:04 a.m. UTC
  No need to check the argument of i2c_unregister_device() because the
function itself does it.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Build tested only. Please apply to your tree.

 drivers/usb/typec/anx7411.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Kieran Bingham Sept. 22, 2023, 11:50 a.m. UTC | #1
Quoting Wolfram Sang (2023-09-22 09:04:18)
> No need to check the argument of i2c_unregister_device() because the
> function itself does it.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

And this is the same pattern here so:

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
> Build tested only. Please apply to your tree.
> 
>  drivers/usb/typec/anx7411.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
> index 221604f933a4..b12a07edc71b 100644
> --- a/drivers/usb/typec/anx7411.c
> +++ b/drivers/usb/typec/anx7411.c
> @@ -1550,8 +1550,7 @@ static void anx7411_i2c_remove(struct i2c_client *client)
>         if (plat->workqueue)
>                 destroy_workqueue(plat->workqueue);
>  
> -       if (plat->spi_client)
> -               i2c_unregister_device(plat->spi_client);
> +       i2c_unregister_device(plat->spi_client);
>  
>         if (plat->typec.role_sw)
>                 usb_role_switch_put(plat->typec.role_sw);
> -- 
> 2.30.2
>
  
Geert Uytterhoeven Sept. 25, 2023, 7:44 a.m. UTC | #2
On Fri, Sep 22, 2023 at 12:44 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> No need to check the argument of i2c_unregister_device() because the
> function itself does it.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
  

Patch

diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index 221604f933a4..b12a07edc71b 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -1550,8 +1550,7 @@  static void anx7411_i2c_remove(struct i2c_client *client)
 	if (plat->workqueue)
 		destroy_workqueue(plat->workqueue);
 
-	if (plat->spi_client)
-		i2c_unregister_device(plat->spi_client);
+	i2c_unregister_device(plat->spi_client);
 
 	if (plat->typec.role_sw)
 		usb_role_switch_put(plat->typec.role_sw);