2022-06-08 12:31:24

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 net-next 3/5] ptp_ocp: drop duplicate NULL check in ptp_ocp_detach()

Since platform_device_unregister() is NULL-aware, we don't need to duplicate
this check. Remove it and fold the rest of the code.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/ptp/ptp_ocp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 926add7be9a2..4e237f806085 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -3701,10 +3701,8 @@ ptp_ocp_detach(struct ptp_ocp *bp)
serial8250_unregister_port(bp->mac_port);
if (bp->nmea_port != -1)
serial8250_unregister_port(bp->nmea_port);
- if (bp->spi_flash)
- platform_device_unregister(bp->spi_flash);
- if (bp->i2c_ctrl)
- platform_device_unregister(bp->i2c_ctrl);
+ platform_device_unregister(bp->spi_flash);
+ platform_device_unregister(bp->i2c_ctrl);
if (bp->i2c_clk)
clk_hw_unregister_fixed_rate(bp->i2c_clk);
if (bp->n_irqs)
--
2.35.1


2022-06-08 22:30:16

by Vadim Fedorenko

[permalink] [raw]
Subject: Re: [PATCH v1 net-next 3/5] ptp_ocp: drop duplicate NULL check in ptp_ocp_detach()

On 08.06.2022 13:03, Andy Shevchenko wrote:
> Since platform_device_unregister() is NULL-aware, we don't need to duplicate
> this check. Remove it and fold the rest of the code.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Acked-by: Vadim Fedorenko <[email protected]>
> ---
> drivers/ptp/ptp_ocp.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 926add7be9a2..4e237f806085 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -3701,10 +3701,8 @@ ptp_ocp_detach(struct ptp_ocp *bp)
> serial8250_unregister_port(bp->mac_port);
> if (bp->nmea_port != -1)
> serial8250_unregister_port(bp->nmea_port);
> - if (bp->spi_flash)
> - platform_device_unregister(bp->spi_flash);
> - if (bp->i2c_ctrl)
> - platform_device_unregister(bp->i2c_ctrl);
> + platform_device_unregister(bp->spi_flash);
> + platform_device_unregister(bp->i2c_ctrl);
> if (bp->i2c_clk)
> clk_hw_unregister_fixed_rate(bp->i2c_clk);
> if (bp->n_irqs)