Re: [PATCH net-next v4 5/9] net: dsa: microchip: ksz9477: Add Wake on Magic Packet support

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

 



> @@ -155,6 +158,14 @@ int ksz9477_set_wol(struct ksz_device *dev, int port,
>  	if (ret)
>  		return ret;
>  
> +	if (wol->wolopts & WAKE_MAGIC) {
> +		ret = ksz_switch_macaddr_get(dev->ds, port, NULL);
> +		if (ret)
> +			return ret;
> +
> +		pme_ctrl |= PME_WOL_MAGICPKT;
> +	}

There is no matching ksz_switch_macaddr_put() here when the user turns
WAKE_MAGIC off. Ideally you need to keep track of the WoL state per
port, and when the user disables it, release the MAC address.

> +
>  	if (wol->wolopts & WAKE_PHY)
>  		pme_ctrl |= PME_WOL_LINKUP | PME_WOL_ENERGY;
>  
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 3f7c86e545a7..4601aaca5179 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -3569,6 +3569,7 @@ static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
>  				    const unsigned char *addr)
>  {
>  	struct dsa_port *dp = dsa_to_port(ds, port);
> +	struct ethtool_wolinfo wol;
>  
>  	if (dp->hsr_dev) {
>  		dev_err(ds->dev,
> @@ -3577,6 +3578,14 @@ static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
>  		return -EBUSY;
>  	}
>  
> +	ksz_get_wol(ds, dp->index, &wol);
> +	if (wol.wolopts & WAKE_MAGIC) {
> +		dev_err(ds->dev,
> +			"Cannot change MAC address on port %d with active Wake on Magic Packet\n",
> +			port);

This is not really an error, as in something went wrong. Its just a
hardware restriction. So dev_warn() would be better, or nothing at all
in the logs.

   Andrew




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux