diff options
author | Nimrod Andy <B38611@freescale.com> | 2014-10-12 22:53:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-14 12:53:37 -0400 |
commit | 5bc26726ada73264c0fd7b93ccbe7d9e78b2b2d2 (patch) | |
tree | c537b4ff0ae35446eb08ea1f36284d6888241d28 /drivers/net | |
parent | c53fed07a03d8b2a2e3bdaba87768211fa55806c (diff) |
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: Fabio Estevam <festevam@gmail.com>
Suggested-by: Christopher Li <sparse@chrisli.org>
Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/freescale/fec_main.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 87975b5dda94..7a8209e73199 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c | |||
@@ -2912,20 +2912,12 @@ static void fec_poll_controller(struct net_device *dev) | |||
2912 | #endif | 2912 | #endif |
2913 | 2913 | ||
2914 | #define FEATURES_NEED_QUIESCE NETIF_F_RXCSUM | 2914 | #define FEATURES_NEED_QUIESCE NETIF_F_RXCSUM |
2915 | 2915 | static inline void fec_enet_set_netdev_features(struct net_device *netdev, | |
2916 | static int fec_set_features(struct net_device *netdev, | ||
2917 | netdev_features_t features) | 2916 | netdev_features_t features) |
2918 | { | 2917 | { |
2919 | struct fec_enet_private *fep = netdev_priv(netdev); | 2918 | struct fec_enet_private *fep = netdev_priv(netdev); |
2920 | netdev_features_t changed = features ^ netdev->features; | 2919 | netdev_features_t changed = features ^ netdev->features; |
2921 | 2920 | ||
2922 | /* Quiesce the device if necessary */ | ||
2923 | if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) { | ||
2924 | napi_disable(&fep->napi); | ||
2925 | netif_tx_lock_bh(netdev); | ||
2926 | fec_stop(netdev); | ||
2927 | } | ||
2928 | |||
2929 | netdev->features = features; | 2921 | netdev->features = features; |
2930 | 2922 | ||
2931 | /* Receive checksum has been changed */ | 2923 | /* Receive checksum has been changed */ |
@@ -2935,13 +2927,25 @@ static int fec_set_features(struct net_device *netdev, | |||
2935 | else | 2927 | else |
2936 | fep->csum_flags &= ~FLAG_RX_CSUM_ENABLED; | 2928 | fep->csum_flags &= ~FLAG_RX_CSUM_ENABLED; |
2937 | } | 2929 | } |
2930 | } | ||
2931 | |||
2932 | static int fec_set_features(struct net_device *netdev, | ||
2933 | netdev_features_t features) | ||
2934 | { | ||
2935 | struct fec_enet_private *fep = netdev_priv(netdev); | ||
2936 | netdev_features_t changed = features ^ netdev->features; | ||
2938 | 2937 | ||
2939 | /* Resume the device after updates */ | ||
2940 | if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) { | 2938 | if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) { |
2939 | napi_disable(&fep->napi); | ||
2940 | netif_tx_lock_bh(netdev); | ||
2941 | fec_stop(netdev); | ||
2942 | fec_enet_set_netdev_features(netdev, features); | ||
2941 | fec_restart(netdev); | 2943 | fec_restart(netdev); |
2942 | netif_tx_wake_all_queues(netdev); | 2944 | netif_tx_wake_all_queues(netdev); |
2943 | netif_tx_unlock_bh(netdev); | 2945 | netif_tx_unlock_bh(netdev); |
2944 | napi_enable(&fep->napi); | 2946 | napi_enable(&fep->napi); |
2947 | } else { | ||
2948 | fec_enet_set_netdev_features(netdev, features); | ||
2945 | } | 2949 | } |
2946 | 2950 | ||
2947 | return 0; | 2951 | return 0; |