net: fec: only restart or stop the device if it is present and running
Avoid calling fec_restart() or fec_stop() while the device is down
or not present (iow suspended.)
Although the ndo_timeout method will only be called if the device is
present and running, we defer this to a work queue. The work queue
can run independently, and so needs to repeat these checks to ensure
that a restart doesn't occur after the device has been taken down or
detached for suspend. In this case, we call fec_restart() in the
resume path, so nothing is lost.
For fec_set_features, we add a call to fec_restart() in fec_enet_open()
to ensure that the hardware is appropriate programmed when the interface
is opened. fec_set_features() call should not occur while we're
suspended, so we don't have to worry about that case.
The adjust_link needs similar treatment - this also is called from a
work queue, which may be run independently after we have taken the
device down and detached it. In this case, we just mark the link
down and take no further action. We will reset things appropriately
once the device is up and running again, at which point we will receive
another adjust_link callback.
Acked-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>