Subject: Re: [PATCH net-next 1/4] net: dsa: Pass a port to get_tag_protocol()

From: Andrew Lunn <[email-masked]>
Date: Sat, 11 Nov 2017 16:41:11 +0100

On Fri, Nov 10, 2017 at 03:22:52PM -0800, Florian Fainelli wrote:
> A number of drivers want to check whether the configured CPU port is a
> possible configuration for enabling tagging, pass down the CPU port
> number so they verify that.
> 
> -static bool b53_can_enable_brcm_tags(struct dsa_switch *ds)
> +static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port)
>  {
> -	unsigned int brcm_tag_mask;
> -	unsigned int i;
> -
>  	/* Broadcom switches will accept enabling Broadcom tags on the
>  	 * following ports: 5, 7 and 8, any other port is not supported
>  	 */
> -	brcm_tag_mask = BIT(B53_CPU_PORT_25) | BIT(7) | BIT(B53_CPU_PORT);
> -
> -	for (i = 0; i < ds->num_ports; i++) {
> -		if (dsa_is_cpu_port(ds, i)) {
> -			if (!(BIT(i) & brcm_tag_mask)) {
> -				dev_warn(ds->dev,
> -					 "Port %d is not Broadcom tag capable\n",
> -					 i);
> -				return false;
> -			}
> -		}
> +	switch (port) {
> +	case B53_CPU_PORT_25:
> +	case 7:
> +	case B53_CPU_PORT:
> +		return true;
>  	}
>  
> -	return true;
> +	dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", port);
> +	return false;
>  }

Hi Florian

This looks a lot better than the previous implementation.

Reviewed-by: Andrew Lunn <[email-masked]>

    Andrew