Re: [PATCH 05/12] net-next: mediatek: add switch driver for mt7621

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2016-01-03 at 16:26 +0100, John Crispin wrote:
> This driver is very basic and only provides basic init and irq support.
> The SoC and switch core both have support for a special tag making DSA
> support possible.

trivia:

> diff --git a/drivers/net/ethernet/mediatek/gsw_mt7621.c b/drivers/net/ethernet/mediatek/gsw_mt7621.c
[]
> +static irqreturn_t gsw_interrupt_mt7621(int irq, void *_priv)
> +{
> +	struct fe_priv *priv = (struct fe_priv *)_priv;
> +	struct mt7620_gsw *gsw = (struct mt7620_gsw *)priv->soc->swpriv;
> +	u32 reg, i;
> +
> +	reg = mt7530_mdio_r32(gsw, 0x700c);
> +
> +	for (i = 0; i < 5; i++)
> +		if (reg & BIT(i)) {
> +			unsigned int link;
> +
> +			link = mt7530_mdio_r32(gsw,
> +					       0x3008 + (i * 0x100)) & 0x1;
> +
> +			if (link != priv->link[i]) {
> +				priv->link[i] = link;
> +				if (link)
> +					netdev_info(priv->netdev,
> +						    "port %d link up\n", i);
> +				else
> +					netdev_info(priv->netdev,
> +						    "port %d link down\n", i);
> +			}
> +		}

It's more common to use braces after the for loop.
Perhaps this could be written with a continue; to reduce
indentation and also use a single netdev_info().

	for (i = 0; i < 5; i++) {
		unsigned int link;

		if (!(reg & BIT(i)))
			continue;

		link = mt7530_mdio_r32(gsw, 0x3008 + (i * 0x100)) & 0x1;

		if (link == priv->link[i])
			continue;

		priv->link[i] = link;
		netdev_info(priv->netdev, "port %d link %s\n",
			    i, link ? "up" : "down");
	}






[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux