net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered
authorGrygorii Strashko <grygorii.strashko@ti.com>
Thu, 24 Dec 2020 16:24:05 +0000 (18:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jan 2021 19:18:11 +0000 (20:18 +0100)
commit44dc29d44b842ff7761f24ab129f0a5a70982bb5
treee3b9db71e1b303e9e12b0d8809b7db9c9397823a
parente4535dbb721d0346f6a7ee6b6cbaf517cb96dbcb
net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered

[ Upstream commit 4614792eebcbf81c60ad3604c1aeeb2b0899cea4 ]

The CPTS driver registers PTP PHC clock when first netif is going up and
unregister it when all netif are down. Now ethtool will show:
 - PTP PHC clock index 0 after boot until first netif is up;
 - the last assigned PTP PHC clock index even if PTP PHC clock is not
registered any more after all netifs are down.

This patch ensures that -1 is returned by ethtool when PTP PHC clock is not
registered any more.

Fixes: 8a2c9a5ab4b9 ("net: ethernet: ti: cpts: rework initialization/deinitialization")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://lore.kernel.org/r/20201224162405.28032-1-grygorii.strashko@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/ti/cpts.c