Subject: Re: [PATCH RFC 02/10] mlx4_en: Device initialization

From: Ben Hutchings <[email-masked]>
Date: Mon, 14 Jul 2008 17:48:32 +0100

Yevgeny Petrilin wrote:
[...]
> +static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr)
> +{
> +	struct mlx4_en_dev *mdev = endev_ptr;
> +	int p;
> +
> +	down(&mdev->state_sem);
> +	mdev->state = DEVICE_DOWN;
> +	up(&mdev->state_sem);
> +
> +	for (p = 1; p <= MLX4_MAX_PORTS; ++p)
> +		if (mdev->pndev[p])
> +			mlx4_en_destroy_netdev(mdev->pndev[p]);
[...]
> +static void *mlx4_en_add(struct mlx4_dev *dev)
> +{
[...]
> +	/* Create a netdev for each port */
> +	mlx4_foreach_port(i, mdev->ports_map) {
> +		mlx4_info(mdev, "Activating port:%d\n", i);
> +		if (mlx4_en_init_netdev(mdev, i, &mdev->profile.prof[i])) {
> +			mdev->pndev[i] = NULL;
> +			goto err_free_netdev;
> +		}
> +	}
> +	return mdev;
> +
> +
> +err_free_netdev:
> +	for (i = 0; i < dev->caps.num_ports; i++) {
> +		if (mdev->pndev[i])
> +			mlx4_en_destroy_netdev(mdev->pndev[i]);
> +	}
[...]

These three loops need to loop over the same set of devices, so why are they
written completely differently?

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.