Commit 5bc26726 authored by Nimrod Andy's avatar Nimrod Andy Committed by David S. Miller

net: fec: Fix sparse warnings with different lock contexts for basic block

reproduce:
make  ARCH=arm C=1 2>fec.txt drivers/net/ethernet/freescale/fec_main.o
cat fec.txt

sparse warnings:
drivers/net/ethernet/freescale/fec_main.c:2916:12: warning: context imbalance
in 'fec_set_features' - different lock contexts for basic block

Christopher Li suggest to change as below:
	if (need_lock) {
		lock();
		do_something_real();
		unlock();
	} else {
		do_something_real();
	}
Reported-by: default avatarFabio Estevam <festevam@gmail.com>
Suggested-by: default avatarChristopher Li <sparse@chrisli.org>
Signed-off-by: default avatarFugang Duan <B38611@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c53fed07
...@@ -2912,20 +2912,12 @@ static void fec_poll_controller(struct net_device *dev) ...@@ -2912,20 +2912,12 @@ static void fec_poll_controller(struct net_device *dev)
#endif #endif
#define FEATURES_NEED_QUIESCE NETIF_F_RXCSUM #define FEATURES_NEED_QUIESCE NETIF_F_RXCSUM
static inline void fec_enet_set_netdev_features(struct net_device *netdev,
static int fec_set_features(struct net_device *netdev,
netdev_features_t features) netdev_features_t features)
{ {
struct fec_enet_private *fep = netdev_priv(netdev); struct fec_enet_private *fep = netdev_priv(netdev);
netdev_features_t changed = features ^ netdev->features; netdev_features_t changed = features ^ netdev->features;
/* Quiesce the device if necessary */
if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) {
napi_disable(&fep->napi);
netif_tx_lock_bh(netdev);
fec_stop(netdev);
}
netdev->features = features; netdev->features = features;
/* Receive checksum has been changed */ /* Receive checksum has been changed */
...@@ -2935,13 +2927,25 @@ static int fec_set_features(struct net_device *netdev, ...@@ -2935,13 +2927,25 @@ static int fec_set_features(struct net_device *netdev,
else else
fep->csum_flags &= ~FLAG_RX_CSUM_ENABLED; fep->csum_flags &= ~FLAG_RX_CSUM_ENABLED;
} }
}
static int fec_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct fec_enet_private *fep = netdev_priv(netdev);
netdev_features_t changed = features ^ netdev->features;
/* Resume the device after updates */
if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) { if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) {
napi_disable(&fep->napi);
netif_tx_lock_bh(netdev);
fec_stop(netdev);
fec_enet_set_netdev_features(netdev, features);
fec_restart(netdev); fec_restart(netdev);
netif_tx_wake_all_queues(netdev); netif_tx_wake_all_queues(netdev);
netif_tx_unlock_bh(netdev); netif_tx_unlock_bh(netdev);
napi_enable(&fep->napi); napi_enable(&fep->napi);
} else {
fec_enet_set_netdev_features(netdev, features);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment