Re: [PATCH 1/4] staging: octeon: factor out device removal into a helper
From: Dan Carpenter
Date: Mon Jun 29 2026 - 03:32:04 EST
On Sun, Jun 28, 2026 at 12:31:24PM +0530, Prashant Rahul wrote:
> Factor out the common device removal sequence into a helper in
> preparation for adding cleanup to the probe error path.
>
> Signed-off-by: Prashant Rahul <prashantrahul23@xxxxxxxxx>
> ---
> drivers/staging/octeon/ethernet.c | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
> index f3fa221f452e2..e07c6911b8252 100644
> --- a/drivers/staging/octeon/ethernet.c
> +++ b/drivers/staging/octeon/ethernet.c
> @@ -104,6 +104,21 @@ struct net_device *cvm_oct_device[TOTAL_NUMBER_OF_PORTS];
>
> u64 cvm_oct_tx_poll_interval;
>
> +static inline void cvm_oct_remove_device(int port)
> +{
> + if (cvm_oct_device[port]) {
> + struct net_device *dev = cvm_oct_device[port];
> + struct octeon_ethernet *priv = netdev_priv(dev);
> +
> + cancel_delayed_work_sync(&priv->port_periodic_work);
> +
> + cvm_oct_tx_shutdown_dev(dev);
> + unregister_netdev(dev);
> + free_netdev(dev);
> + cvm_oct_device[port] = NULL;
> + }
> +}
> +
> static void cvm_oct_rx_refill_worker(struct work_struct *work)
> {
> struct octeon_ethernet_platform *plat = container_of(work,
> @@ -949,17 +964,7 @@ static void cvm_oct_remove(struct platform_device *pdev)
>
> /* Free the ethernet devices */
> for (port = 0; port < TOTAL_NUMBER_OF_PORTS; port++) {
> - if (cvm_oct_device[port]) {
> - struct net_device *dev = cvm_oct_device[port];
> - struct octeon_ethernet *priv = netdev_priv(dev);
> -
> - cancel_delayed_work_sync(&priv->port_periodic_work);
> -
> - cvm_oct_tx_shutdown_dev(dev);
> - unregister_netdev(dev);
> - free_netdev(dev);
> - cvm_oct_device[port] = NULL;
> - }
> + cvm_oct_remove_device(port);
> }
Delete the curly braces as well.
regards,
dan carpenter