From 59c5ea6ebdfa11626635f371b8d99ada2fcaf390 Mon Sep 17 00:00:00 2001 From: David S. Miller Date: Sun, 28 Dec 2008 20:15:38 -0800 Subject: net: Fix unused variable warnings in pasemi_mac.c and spider_net.c As reported by Stephen Rothwell: -------------------- Today's linux-next build (powerpc ppc64_defconfig) produced these new warnings: drivers/net/pasemi_mac.c: In function 'pasemi_mac_rx_intr': drivers/net/pasemi_mac.c:957: warning: unused variable 'dev' drivers/net/pasemi_mac.c: In function 'pasemi_mac_poll': drivers/net/pasemi_mac.c:1637: warning: unused variable 'dev' drivers/net/spider_net.c: In function 'spider_net_poll': drivers/net/spider_net.c:1280: warning: unused variable 'netdev' Probably caused by commit 908a7a16b852ffd618a9127be8d62432182d81b4 ("net: Remove unused netdev arg from some NAPI interfaces"). -------------------- Signed-off-by: David S. Miller --- drivers/net/pasemi_mac.c | 2 -- drivers/net/spider_net.c | 1 - 2 files changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c index dcd199045613..5b7a574ce571 100644 --- a/drivers/net/pasemi_mac.c +++ b/drivers/net/pasemi_mac.c @@ -954,7 +954,6 @@ static irqreturn_t pasemi_mac_rx_intr(int irq, void *data) { const struct pasemi_mac_rxring *rxring = data; struct pasemi_mac *mac = rxring->mac; - struct net_device *dev = mac->netdev; const struct pasemi_dmachan *chan = &rxring->chan; unsigned int reg; @@ -1634,7 +1633,6 @@ static void pasemi_mac_set_rx_mode(struct net_device *dev) static int pasemi_mac_poll(struct napi_struct *napi, int budget) { struct pasemi_mac *mac = container_of(napi, struct pasemi_mac, napi); - struct net_device *dev = mac->netdev; int pkts; pasemi_mac_clean_tx(tx_ring(mac)); diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index c5c123d3af57..88d2c67788df 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c @@ -1277,7 +1277,6 @@ bad_desc: static int spider_net_poll(struct napi_struct *napi, int budget) { struct spider_net_card *card = container_of(napi, struct spider_net_card, napi); - struct net_device *netdev = card->netdev; int packets_done = 0; while (packets_done < budget) { -- cgit v1.2.3 From 2d0658d4ef92e4958172c832bd88c961840e599e Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Mon, 29 Dec 2008 18:18:24 -0800 Subject: net: Fix more NAPI interface netdev argument drop fallout. I hit similar build failure due to the change in the netif_rx_reschedule() drivers/net/ehea/ehea_main.c: In function 'ehea_poll': drivers/net/ehea/ehea_main.c:844: warning: passing argument 1 of 'netif_rx_reschedule' from incompatible pointer type drivers/net/ehea/ehea_main.c:844: error: too many arguments to function 'netif_rx_reschedule' make[3]: *** [drivers/net/ehea/ehea_main.o] Error 1 greping through the sources for the changes missed out, we have ./drivers/net/arm/ixp4xx_eth.c:507: netif_rx_reschedule(dev, napi)) { ./drivers/net/arm/ep93xx_eth.c:310: if (more && netif_rx_reschedule(dev, napi)) ./drivers/net/wan/ixp4xx_hss.c:657: netif_rx_reschedule(dev, napi)) { Signed-off-by: Kamalesh Babulal Acked-by: Neil Horman Signed-off-by: David S. Miller --- drivers/net/arm/ep93xx_eth.c | 2 +- drivers/net/arm/ixp4xx_eth.c | 2 +- drivers/net/wan/ixp4xx_hss.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c index 6ecc600c1bcc..3ec20cc18b0c 100644 --- a/drivers/net/arm/ep93xx_eth.c +++ b/drivers/net/arm/ep93xx_eth.c @@ -307,7 +307,7 @@ poll_some_more: } spin_unlock_irq(&ep->rx_lock); - if (more && netif_rx_reschedule(dev, napi)) + if (more && netif_rx_reschedule(napi)) goto poll_some_more; } diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c index 26af411fc428..5fce1d5c1a1a 100644 --- a/drivers/net/arm/ixp4xx_eth.c +++ b/drivers/net/arm/ixp4xx_eth.c @@ -504,7 +504,7 @@ static int eth_poll(struct napi_struct *napi, int budget) netif_rx_complete(napi); qmgr_enable_irq(rxq); if (!qmgr_stat_empty(rxq) && - netif_rx_reschedule(dev, napi)) { + netif_rx_reschedule(napi)) { #if DEBUG_RX printk(KERN_DEBUG "%s: eth_poll" " netif_rx_reschedule successed\n", diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c index 0c6802507a79..2dc241689d37 100644 --- a/drivers/net/wan/ixp4xx_hss.c +++ b/drivers/net/wan/ixp4xx_hss.c @@ -654,7 +654,7 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget) netif_rx_complete(dev, napi); qmgr_enable_irq(rxq); if (!qmgr_stat_empty(rxq) && - netif_rx_reschedule(dev, napi)) { + netif_rx_reschedule(napi)) { #if DEBUG_RX printk(KERN_DEBUG "%s: hss_hdlc_poll" " netif_rx_reschedule succeeded\n", -- cgit v1.2.3 From 36f8b9238373751b684650871fd161546b10116c Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 29 Dec 2008 18:22:43 -0800 Subject: smsc911x: compile fix re netif_rx signature changes Signed-off-by: Alexey Dobriyan Signed-off-by: Steve Glendinning Signed-off-by: David S. Miller --- drivers/net/smsc911x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c index 5e989d884ddd..dc3f1108884d 100644 --- a/drivers/net/smsc911x.c +++ b/drivers/net/smsc911x.c @@ -1484,13 +1484,13 @@ static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id) } if (likely(intsts & inten & INT_STS_RSFL_)) { - if (likely(netif_rx_schedule_prep(dev, &pdata->napi))) { + if (likely(netif_rx_schedule_prep(&pdata->napi))) { /* Disable Rx interrupts */ temp = smsc911x_reg_read(pdata, INT_EN); temp &= (~INT_EN_RSFL_EN_); smsc911x_reg_write(pdata, INT_EN, temp); /* Schedule a NAPI poll */ - __netif_rx_schedule(dev, &pdata->napi); + __netif_rx_schedule(&pdata->napi); } else { SMSC_WARNING(RX_ERR, "netif_rx_schedule_prep failed"); -- cgit v1.2.3 From 7a0a9608e4459afdf2e4a7831c1cbeb41353adf6 Mon Sep 17 00:00:00 2001 From: Kusanagi Kouichi Date: Mon, 29 Dec 2008 18:23:28 -0800 Subject: tun: Fix SIOCSIFHWADDR error. Set proper operations. Signed-off-by: Kusanagi Kouichi Signed-off-by: David S. Miller --- drivers/net/tun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 666c1d98cdaf..69f9a0ec764d 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -343,7 +343,7 @@ static void tun_net_init(struct net_device *dev) break; case TUN_TAP_DEV: - dev->netdev_ops = &tun_netdev_ops; + dev->netdev_ops = &tap_netdev_ops; /* Ethernet TAP Device */ ether_setup(dev); -- cgit v1.2.3 From c8e95c021caa9574350cea6f2b4f91e232e3f3ee Mon Sep 17 00:00:00 2001 From: Huang Weiyi Date: Mon, 29 Dec 2008 18:30:05 -0800 Subject: net: KS8695: removed duplicated #include Removed duplicated include in drivers/net/arm/ks8695net.c. Signed-off-by: Huang Weiyi Signed-off-by: David S. Miller --- drivers/net/arm/ks8695net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c index 592daee9dc28..9ad22d1b00fd 100644 --- a/drivers/net/arm/ks8695net.c +++ b/drivers/net/arm/ks8695net.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From c2b559ed8683ffb5a7bdd9e71b3803b231623c86 Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Mon, 29 Dec 2008 18:38:21 -0800 Subject: mlx4_en: Verify number of RX rings doesn't exceed MAX_RX_RINGS Required in cases were dev->caps.num_comp_vectors > MAX_RX_RINGS. For current values this would happen on machines that have more then 16 cores. Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/mlx4/en_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c index c1c05852a95e..34f3a191fbdf 100644 --- a/drivers/net/mlx4/en_main.c +++ b/drivers/net/mlx4/en_main.c @@ -170,7 +170,8 @@ static void *mlx4_en_add(struct mlx4_dev *dev) mlx4_info(mdev, "Using %d tx rings for port:%d\n", mdev->profile.prof[i].tx_ring_num, i); if (!mdev->profile.prof[i].rx_ring_num) { - mdev->profile.prof[i].rx_ring_num = dev->caps.num_comp_vectors; + mdev->profile.prof[i].rx_ring_num = + min_t(int, dev->caps.num_comp_vectors, MAX_RX_RINGS); mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n", mdev->profile.prof[i].rx_ring_num, i); } else -- cgit v1.2.3 From 2d6a7b7559b47f81c50a1df91910edefff79b9b4 Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Mon, 29 Dec 2008 18:38:54 -0800 Subject: mlx4_en: Always allocate RX ring for each interrupt vector Removed module parameter specifying number of RX rings Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/mlx4/en_main.c | 12 ++++-------- drivers/net/mlx4/en_params.c | 5 ----- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c index 34f3a191fbdf..eda72dd2120f 100644 --- a/drivers/net/mlx4/en_main.c +++ b/drivers/net/mlx4/en_main.c @@ -169,14 +169,10 @@ static void *mlx4_en_add(struct mlx4_dev *dev) mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { mlx4_info(mdev, "Using %d tx rings for port:%d\n", mdev->profile.prof[i].tx_ring_num, i); - if (!mdev->profile.prof[i].rx_ring_num) { - mdev->profile.prof[i].rx_ring_num = - min_t(int, dev->caps.num_comp_vectors, MAX_RX_RINGS); - mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n", - mdev->profile.prof[i].rx_ring_num, i); - } else - mlx4_info(mdev, "Using %d rx rings for port:%d\n", - mdev->profile.prof[i].rx_ring_num, i); + mdev->profile.prof[i].rx_ring_num = + min_t(int, dev->caps.num_comp_vectors, MAX_RX_RINGS); + mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n", + mdev->profile.prof[i].rx_ring_num, i); } /* Create our own workqueue for reset/multicast tasks diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c index 047b37f5a747..6483ae9d45b1 100644 --- a/drivers/net/mlx4/en_params.c +++ b/drivers/net/mlx4/en_params.c @@ -65,9 +65,6 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]." MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." " Per priority bit mask"); -MLX4_EN_PARM_INT(rx_ring_num1, 0, "Number or Rx rings for port 1 (0 = #cores)"); -MLX4_EN_PARM_INT(rx_ring_num2, 0, "Number or Rx rings for port 2 (0 = #cores)"); - MLX4_EN_PARM_INT(tx_ring_size1, MLX4_EN_AUTO_CONF, "Tx ring size for port 1"); MLX4_EN_PARM_INT(tx_ring_size2, MLX4_EN_AUTO_CONF, "Tx ring size for port 2"); MLX4_EN_PARM_INT(rx_ring_size1, MLX4_EN_AUTO_CONF, "Rx ring size for port 1"); @@ -95,8 +92,6 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) params->prof[1].tx_ring_num = 1; params->prof[2].tx_ring_num = 1; } - params->prof[1].rx_ring_num = min_t(int, rx_ring_num1, MAX_RX_RINGS); - params->prof[2].rx_ring_num = min_t(int, rx_ring_num2, MAX_RX_RINGS); if (tx_ring_size1 == MLX4_EN_AUTO_CONF) tx_ring_size1 = MLX4_EN_DEF_TX_RING_SIZE; -- cgit v1.2.3 From 18cc42a3a17d19774b332e933cf34c71b0d3903c Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Mon, 29 Dec 2008 18:39:20 -0800 Subject: mlx4_en: Added "set_ringparam" Ethtool interface implementation Now using Ethtool to determine ring sizes, removed the module parameters that controlled those values. Modifying ring size requires restart of the interface. Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/mlx4/en_netdev.c | 8 ++--- drivers/net/mlx4/en_params.c | 80 ++++++++++++++++++++++++++++---------------- drivers/net/mlx4/mlx4_en.h | 6 ++++ 3 files changed, 61 insertions(+), 33 deletions(-) (limited to 'drivers') diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c index ebada3c7aff2..15bb38d99304 100644 --- a/drivers/net/mlx4/en_netdev.c +++ b/drivers/net/mlx4/en_netdev.c @@ -552,7 +552,7 @@ static void mlx4_en_linkstate(struct work_struct *work) } -static int mlx4_en_start_port(struct net_device *dev) +int mlx4_en_start_port(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; @@ -707,7 +707,7 @@ cq_err: } -static void mlx4_en_stop_port(struct net_device *dev) +void mlx4_en_stop_port(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; @@ -826,7 +826,7 @@ static int mlx4_en_close(struct net_device *dev) return 0; } -static void mlx4_en_free_resources(struct mlx4_en_priv *priv) +void mlx4_en_free_resources(struct mlx4_en_priv *priv) { int i; @@ -845,7 +845,7 @@ static void mlx4_en_free_resources(struct mlx4_en_priv *priv) } } -static int mlx4_en_alloc_resources(struct mlx4_en_priv *priv) +int mlx4_en_alloc_resources(struct mlx4_en_priv *priv) { struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_port_profile *prof = priv->prof; diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c index 6483ae9d45b1..cfeef0f1bacc 100644 --- a/drivers/net/mlx4/en_params.c +++ b/drivers/net/mlx4/en_params.c @@ -65,12 +65,6 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]." MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." " Per priority bit mask"); -MLX4_EN_PARM_INT(tx_ring_size1, MLX4_EN_AUTO_CONF, "Tx ring size for port 1"); -MLX4_EN_PARM_INT(tx_ring_size2, MLX4_EN_AUTO_CONF, "Tx ring size for port 2"); -MLX4_EN_PARM_INT(rx_ring_size1, MLX4_EN_AUTO_CONF, "Rx ring size for port 1"); -MLX4_EN_PARM_INT(rx_ring_size2, MLX4_EN_AUTO_CONF, "Rx ring size for port 2"); - - int mlx4_en_get_profile(struct mlx4_en_dev *mdev) { struct mlx4_en_profile *params = &mdev->profile; @@ -84,6 +78,8 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) params->prof[i].rx_ppp = pfcrx; params->prof[i].tx_pause = 1; params->prof[i].tx_ppp = pfctx; + params->prof[i].tx_ring_size = MLX4_EN_DEF_TX_RING_SIZE; + params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE; } if (pfcrx || pfctx) { params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; @@ -93,29 +89,6 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) params->prof[2].tx_ring_num = 1; } - if (tx_ring_size1 == MLX4_EN_AUTO_CONF) - tx_ring_size1 = MLX4_EN_DEF_TX_RING_SIZE; - params->prof[1].tx_ring_size = - (tx_ring_size1 < MLX4_EN_MIN_TX_SIZE) ? - MLX4_EN_MIN_TX_SIZE : roundup_pow_of_two(tx_ring_size1); - - if (tx_ring_size2 == MLX4_EN_AUTO_CONF) - tx_ring_size2 = MLX4_EN_DEF_TX_RING_SIZE; - params->prof[2].tx_ring_size = - (tx_ring_size2 < MLX4_EN_MIN_TX_SIZE) ? - MLX4_EN_MIN_TX_SIZE : roundup_pow_of_two(tx_ring_size2); - - if (rx_ring_size1 == MLX4_EN_AUTO_CONF) - rx_ring_size1 = MLX4_EN_DEF_RX_RING_SIZE; - params->prof[1].rx_ring_size = - (rx_ring_size1 < MLX4_EN_MIN_RX_SIZE) ? - MLX4_EN_MIN_RX_SIZE : roundup_pow_of_two(rx_ring_size1); - - if (rx_ring_size2 == MLX4_EN_AUTO_CONF) - rx_ring_size2 = MLX4_EN_DEF_RX_RING_SIZE; - params->prof[2].rx_ring_size = - (rx_ring_size2 < MLX4_EN_MIN_RX_SIZE) ? - MLX4_EN_MIN_RX_SIZE : roundup_pow_of_two(rx_ring_size2); return 0; } @@ -412,6 +385,54 @@ static void mlx4_en_get_pauseparam(struct net_device *dev, pause->rx_pause = priv->prof->rx_pause; } +static int mlx4_en_set_ringparam(struct net_device *dev, + struct ethtool_ringparam *param) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + u32 rx_size, tx_size; + int port_up = 0; + int err = 0; + + if (param->rx_jumbo_pending || param->rx_mini_pending) + return -EINVAL; + + rx_size = roundup_pow_of_two(param->rx_pending); + rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE); + tx_size = roundup_pow_of_two(param->tx_pending); + tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); + + if (rx_size == priv->prof->rx_ring_size && + tx_size == priv->prof->tx_ring_size) + return 0; + + mutex_lock(&mdev->state_lock); + if (priv->port_up) { + port_up = 1; + mlx4_en_stop_port(dev); + } + + mlx4_en_free_resources(priv); + + priv->prof->tx_ring_size = tx_size; + priv->prof->rx_ring_size = rx_size; + + err = mlx4_en_alloc_resources(priv); + if (err) { + mlx4_err(mdev, "Failed reallocating port resources\n"); + goto out; + } + if (port_up) { + err = mlx4_en_start_port(dev); + if (err) + mlx4_err(mdev, "Failed starting port\n"); + } + +out: + mutex_unlock(&mdev->state_lock); + return err; +} + static void mlx4_en_get_ringparam(struct net_device *dev, struct ethtool_ringparam *param) { @@ -451,6 +472,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = { .get_pauseparam = mlx4_en_get_pauseparam, .set_pauseparam = mlx4_en_set_pauseparam, .get_ringparam = mlx4_en_get_ringparam, + .set_ringparam = mlx4_en_set_ringparam, .get_flags = ethtool_op_get_flags, .set_flags = ethtool_op_set_flags, }; diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h index e78209768def..2e96c7b2180a 100644 --- a/drivers/net/mlx4/mlx4_en.h +++ b/drivers/net/mlx4/mlx4_en.h @@ -489,6 +489,12 @@ void mlx4_en_destroy_netdev(struct net_device *dev); int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, struct mlx4_en_port_profile *prof); +int mlx4_en_start_port(struct net_device *dev); +void mlx4_en_stop_port(struct net_device *dev); + +void mlx4_en_free_resources(struct mlx4_en_priv *priv); +int mlx4_en_alloc_resources(struct mlx4_en_priv *priv); + int mlx4_en_get_profile(struct mlx4_en_dev *mdev); int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, -- cgit v1.2.3 From 684f4a4c4a69f7226d8c7559c0cdfc7bd388335a Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Mon, 29 Dec 2008 18:42:33 -0800 Subject: EtherExpress16: fix printing timed out status in drivers/net/eexpress.c:558, function unstick_cu() while (!SCB_complete(rsst=scb_status(dev))) { ... if (...) printk(KERN_WARNING "%s: Reset timed out status %04x, retrying...\n", dev->name,rsst); } but this will become while (!((rsst = scb_status(dev) & 0x8000) != 0) ... because of the macro: #define SCB_complete(s) ((s&0x8000)!=0) so rsst can only become either 0x8000 or 0, but in the latter case the loop ends, I think the wrong timed out status is printed. This also cleans up similar macros. Signed-off-by: Roel Kluin Signed-off-by: David S. Miller --- drivers/net/eexpress.h | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'drivers') diff --git a/drivers/net/eexpress.h b/drivers/net/eexpress.h index 707df3fcfe40..dc9c6ea289e9 100644 --- a/drivers/net/eexpress.h +++ b/drivers/net/eexpress.h @@ -68,17 +68,17 @@ */ /* these functions take the SCB status word and test the relevant status bit */ -#define SCB_complete(s) ((s&0x8000)!=0) -#define SCB_rxdframe(s) ((s&0x4000)!=0) -#define SCB_CUdead(s) ((s&0x2000)!=0) -#define SCB_RUdead(s) ((s&0x1000)!=0) -#define SCB_ack(s) (s & 0xf000) +#define SCB_complete(s) (((s) & 0x8000) != 0) +#define SCB_rxdframe(s) (((s) & 0x4000) != 0) +#define SCB_CUdead(s) (((s) & 0x2000) != 0) +#define SCB_RUdead(s) (((s) & 0x1000) != 0) +#define SCB_ack(s) ((s) & 0xf000) /* Command unit status: 0=idle, 1=suspended, 2=active */ -#define SCB_CUstat(s) ((s&0x0300)>>8) +#define SCB_CUstat(s) (((s)&0x0300)>>8) /* Receive unit status: 0=idle, 1=suspended, 2=out of resources, 4=ready */ -#define SCB_RUstat(s) ((s&0x0070)>>4) +#define SCB_RUstat(s) (((s)&0x0070)>>4) /* SCB commands */ #define SCB_CUnop 0x0000 @@ -98,18 +98,18 @@ * Command block defines */ -#define Stat_Done(s) ((s&0x8000)!=0) -#define Stat_Busy(s) ((s&0x4000)!=0) -#define Stat_OK(s) ((s&0x2000)!=0) -#define Stat_Abort(s) ((s&0x1000)!=0) -#define Stat_STFail ((s&0x0800)!=0) -#define Stat_TNoCar(s) ((s&0x0400)!=0) -#define Stat_TNoCTS(s) ((s&0x0200)!=0) -#define Stat_TNoDMA(s) ((s&0x0100)!=0) -#define Stat_TDefer(s) ((s&0x0080)!=0) -#define Stat_TColl(s) ((s&0x0040)!=0) -#define Stat_TXColl(s) ((s&0x0020)!=0) -#define Stat_NoColl(s) (s&0x000f) +#define Stat_Done(s) (((s) & 0x8000) != 0) +#define Stat_Busy(s) (((s) & 0x4000) != 0) +#define Stat_OK(s) (((s) & 0x2000) != 0) +#define Stat_Abort(s) (((s) & 0x1000) != 0) +#define Stat_STFail (((s) & 0x0800) != 0) +#define Stat_TNoCar(s) (((s) & 0x0400) != 0) +#define Stat_TNoCTS(s) (((s) & 0x0200) != 0) +#define Stat_TNoDMA(s) (((s) & 0x0100) != 0) +#define Stat_TDefer(s) (((s) & 0x0080) != 0) +#define Stat_TColl(s) (((s) & 0x0040) != 0) +#define Stat_TXColl(s) (((s) & 0x0020) != 0) +#define Stat_NoColl(s) ((s) & 0x000f) /* Cmd_END will end AFTER the command if this is the first * command block after an SCB_CUstart, but BEFORE the command @@ -136,16 +136,16 @@ * Frame Descriptor (Receive block) defines */ -#define FD_Done(s) ((s&0x8000)!=0) -#define FD_Busy(s) ((s&0x4000)!=0) -#define FD_OK(s) ((s&0x2000)!=0) +#define FD_Done(s) (((s) & 0x8000) != 0) +#define FD_Busy(s) (((s) & 0x4000) != 0) +#define FD_OK(s) (((s) & 0x2000) != 0) -#define FD_CRC(s) ((s&0x0800)!=0) -#define FD_Align(s) ((s&0x0400)!=0) -#define FD_Resrc(s) ((s&0x0200)!=0) -#define FD_DMA(s) ((s&0x0100)!=0) -#define FD_Short(s) ((s&0x0080)!=0) -#define FD_NoEOF(s) ((s&0x0040)!=0) +#define FD_CRC(s) (((s) & 0x0800) != 0) +#define FD_Align(s) (((s) & 0x0400) != 0) +#define FD_Resrc(s) (((s) & 0x0200) != 0) +#define FD_DMA(s) (((s) & 0x0100) != 0) +#define FD_Short(s) (((s) & 0x0080) != 0) +#define FD_NoEOF(s) (((s) & 0x0040) != 0) struct rfd_header { volatile unsigned long flags; -- cgit v1.2.3 From f201a8a4511a4c9953189924df3c880207194b41 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 29 Dec 2008 00:21:07 +0000 Subject: drivers/net/usb: use USB API functions rather than constants This set of patches introduces calls to the following set of functions: usb_endpoint_dir_in(epd) usb_endpoint_dir_out(epd) usb_endpoint_is_bulk_in(epd) usb_endpoint_is_bulk_out(epd) usb_endpoint_is_int_in(epd) usb_endpoint_is_int_out(epd) usb_endpoint_num(epd) usb_endpoint_type(epd) usb_endpoint_xfer_bulk(epd) usb_endpoint_xfer_control(epd) usb_endpoint_xfer_int(epd) usb_endpoint_xfer_isoc(epd) In some cases, introducing one of these functions is not possible, and it just replaces an explicit integer value by one of the following constants: USB_ENDPOINT_XFER_BULK USB_ENDPOINT_XFER_CONTROL USB_ENDPOINT_XFER_INT USB_ENDPOINT_XFER_ISOC In drivers/net/wireless/zd1211rw/zd_usb.c the code: (endpoint->bEndpointAddress & USB_TYPE_MASK) == USB_DIR_OUT is suspicious. If it is intended to use USB_ENDPOINT_DIR_MASK rather than USB_TYPE_MASK, then the whole conditional test could be converted to a call to usb_endpoint_is_bulk_in. An extract of the semantic patch that makes these changes is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r1@ struct usb_endpoint_descriptor *epd; @@ - ((epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\)) == - \(USB_ENDPOINT_XFER_CONTROL\|0\)) + usb_endpoint_xfer_control(epd) @r5@ struct usb_endpoint_descriptor *epd; @@ - ((epd->bEndpointAddress & \(USB_ENDPOINT_DIR_MASK\|0x80\)) == - \(USB_DIR_IN\|0x80\)) + usb_endpoint_dir_in(epd) @inc@ @@ #include @depends on !inc && (r1||r5)@ @@ + #include #include // Signed-off-by: Julia Lawall Signed-off-by: David S. Miller --- drivers/net/usb/hso.c | 2 +- drivers/net/wireless/zd1211rw/zd_usb.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 198ce3cf378a..9f7896a25f1b 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2831,7 +2831,7 @@ static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, for (i = 0; i < iface->desc.bNumEndpoints; i++) { endp = &iface->endpoint[i].desc; if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && - ((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == type)) + (usb_endpoint_type(endp) == type)) return endp; } diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index 04c139666965..b5db57d2fcf5 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c @@ -1065,8 +1065,7 @@ static int eject_installer(struct usb_interface *intf) /* Find bulk out endpoint */ endpoint = &iface_desc->endpoint[1].desc; if ((endpoint->bEndpointAddress & USB_TYPE_MASK) == USB_DIR_OUT && - (endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_BULK) { + usb_endpoint_xfer_bulk(endpoint)) { bulk_out_ep = endpoint->bEndpointAddress; } else { dev_err(&udev->dev, -- cgit v1.2.3