* [PATCH 1/2] net: nps_enet: fix coding style issues
2016-07-13 13:58 [PATCH 0/2] Code style fixes Elad Kanfi
@ 2016-07-13 13:58 ` Elad Kanfi
2016-07-13 13:58 ` [PATCH 2/2] net: nps_enet: code reuse Elad Kanfi
2016-07-14 3:59 ` [PATCH 0/2] Code style fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Elad Kanfi @ 2016-07-13 13:58 UTC (permalink / raw)
To: davem; +Cc: eladkan, linux-kernel, abrodkin, netdev, noamca
From: Elad Kanfi <eladkan@mellanox.com>
Fix following coding style problems :
ERROR: else should follow close brace '}'
+ }
+ else { /* !dst_is_aligned */
WARNING: Missing a blank line after declarations
+ u32 buf = nps_enet_reg_get(priv, NPS_ENET_REG_RX_BUF);
+ put_unaligned_be32(buf, reg);
WARNING: Missing a blank line after declarations
+ u32 buf;
+ ioread32_rep(priv->regs_base + NPS_ENET_REG_RX_BUF, &buf, 1);
CHECK: Blank lines aren't necessary before a close brace '}'
+
+ }
total: 1 errors, 2 warnings, 1 checks, 683 lines checked
Signed-off-by: Elad Kanfi <eladkan@mellanox.com>
---
drivers/net/ethernet/ezchip/nps_enet.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index 06f0317..b182e2a 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -46,16 +46,17 @@ static void nps_enet_read_rx_fifo(struct net_device *ndev,
if (dst_is_aligned) {
ioread32_rep(priv->regs_base + NPS_ENET_REG_RX_BUF, reg, len);
reg += len;
- }
- else { /* !dst_is_aligned */
+ } else { /* !dst_is_aligned */
for (i = 0; i < len; i++, reg++) {
u32 buf = nps_enet_reg_get(priv, NPS_ENET_REG_RX_BUF);
+
put_unaligned_be32(buf, reg);
}
}
/* copy last bytes (if any) */
if (last) {
u32 buf;
+
ioread32_rep(priv->regs_base + NPS_ENET_REG_RX_BUF, &buf, 1);
memcpy((u8 *)reg, &buf, last);
}
@@ -459,7 +460,6 @@ static void nps_enet_set_rx_mode(struct net_device *ndev)
| NPS_ENET_ENABLE << CFG_2_DISK_DA_SHIFT;
ge_mac_cfg_2_value = (ge_mac_cfg_2_value & ~CFG_2_DISK_MC_MASK)
| NPS_ENET_ENABLE << CFG_2_DISK_MC_SHIFT;
-
}
nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, ge_mac_cfg_2_value);
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: nps_enet: code reuse
2016-07-13 13:58 [PATCH 0/2] Code style fixes Elad Kanfi
2016-07-13 13:58 ` [PATCH 1/2] net: nps_enet: fix coding style issues Elad Kanfi
@ 2016-07-13 13:58 ` Elad Kanfi
2016-07-14 3:59 ` [PATCH 0/2] Code style fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Elad Kanfi @ 2016-07-13 13:58 UTC (permalink / raw)
To: davem; +Cc: eladkan, linux-kernel, abrodkin, netdev, noamca
From: Elad Kanfi <eladkan@mellanox.com>
Add inline function that checks if there is a pending tx packet.
Signed-off-by: Elad Kanfi <eladkan@mellanox.com>
---
drivers/net/ethernet/ezchip/nps_enet.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index b182e2a..25faa3d 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -24,6 +24,14 @@
#define DRV_NAME "nps_mgt_enet"
+static inline bool nps_enet_is_tx_pending(struct nps_enet_priv *priv)
+{
+ u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL);
+ u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT;
+
+ return (!tx_ctrl_ct && priv->tx_skb);
+}
+
static void nps_enet_clean_rx_fifo(struct net_device *ndev, u32 frame_len)
{
struct nps_enet_priv *priv = netdev_priv(ndev);
@@ -141,12 +149,11 @@ static void nps_enet_tx_handler(struct net_device *ndev)
{
struct nps_enet_priv *priv = netdev_priv(ndev);
u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL);
- u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT;
u32 tx_ctrl_et = (tx_ctrl_value & TX_CTL_ET_MASK) >> TX_CTL_ET_SHIFT;
u32 tx_ctrl_nt = (tx_ctrl_value & TX_CTL_NT_MASK) >> TX_CTL_NT_SHIFT;
/* Check if we got TX */
- if (!priv->tx_skb || tx_ctrl_ct)
+ if (!nps_enet_is_tx_pending(priv))
return;
/* Ack Tx ctrl register */
@@ -184,9 +191,6 @@ static int nps_enet_poll(struct napi_struct *napi, int budget)
work_done = nps_enet_rx_handler(ndev);
if (work_done < budget) {
u32 buf_int_enable_value = 0;
- u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL);
- u32 tx_ctrl_ct =
- (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT;
napi_complete(napi);
@@ -205,8 +209,7 @@ static int nps_enet_poll(struct napi_struct *napi, int budget)
* the two code lines below will solve this situation by
* re-adding ourselves to the poll list.
*/
-
- if (priv->tx_skb && !tx_ctrl_ct) {
+ if (nps_enet_is_tx_pending(priv)) {
nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0);
napi_reschedule(napi);
}
@@ -231,11 +234,9 @@ static irqreturn_t nps_enet_irq_handler(s32 irq, void *dev_instance)
struct net_device *ndev = dev_instance;
struct nps_enet_priv *priv = netdev_priv(ndev);
u32 rx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_RX_CTL);
- u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL);
- u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT;
u32 rx_ctrl_cr = (rx_ctrl_value & RX_CTL_CR_MASK) >> RX_CTL_CR_SHIFT;
- if ((!tx_ctrl_ct && priv->tx_skb) || rx_ctrl_cr)
+ if (nps_enet_is_tx_pending(priv) || rx_ctrl_cr)
if (likely(napi_schedule_prep(&priv->napi))) {
nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0);
__napi_schedule(&priv->napi);
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Code style fixes
2016-07-13 13:58 [PATCH 0/2] Code style fixes Elad Kanfi
2016-07-13 13:58 ` [PATCH 1/2] net: nps_enet: fix coding style issues Elad Kanfi
2016-07-13 13:58 ` [PATCH 2/2] net: nps_enet: code reuse Elad Kanfi
@ 2016-07-14 3:59 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-14 3:59 UTC (permalink / raw)
To: eladkan; +Cc: linux-kernel, abrodkin, netdev, noamca
From: Elad Kanfi <eladkan@mellanox.com>
Date: Wed, 13 Jul 2016 16:58:05 +0300
> Fix all checkpatch warnings and errors, and reuse code
Series applied to net-next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread