[PATCH] netfilter: ebtables: use audit_log()

2017-08-07 Thread Geliang Tang
Use audit_log() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/bridge/netfilter/ebtables.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 9c6e619..54c7ef4 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1069,15 +1069,10 @@ static int do_replace_finish(struct net *net, struct 
ebt_replace *repl,
 
 #ifdef CONFIG_AUDIT
if (audit_enabled) {
-   struct audit_buffer *ab;
-
-   ab = audit_log_start(current->audit_context, GFP_KERNEL,
-AUDIT_NETFILTER_CFG);
-   if (ab) {
-   audit_log_format(ab, "table=%s family=%u entries=%u",
-repl->name, AF_BRIDGE, repl->nentries);
-   audit_log_end(ab);
-   }
+   audit_log(current->audit_context, GFP_KERNEL,
+ AUDIT_NETFILTER_CFG,
+ "table=%s family=%u entries=%u",
+ repl->name, AF_BRIDGE, repl->nentries);
}
 #endif
return ret;
-- 
2.9.3



[PATCH] netfilter: xtables: use audit_log()

2017-08-07 Thread Geliang Tang
Use audit_log() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/netfilter/x_tables.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index e164823..c83a3b5 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1192,16 +1192,10 @@ xt_replace_table(struct xt_table *table,
 
 #ifdef CONFIG_AUDIT
if (audit_enabled) {
-   struct audit_buffer *ab;
-
-   ab = audit_log_start(current->audit_context, GFP_KERNEL,
-AUDIT_NETFILTER_CFG);
-   if (ab) {
-   audit_log_format(ab, "table=%s family=%u entries=%u",
-table->name, table->af,
-private->number);
-   audit_log_end(ab);
-   }
+   audit_log(current->audit_context, GFP_KERNEL,
+ AUDIT_NETFILTER_CFG,
+ "table=%s family=%u entries=%u",
+ table->name, table->af, private->number);
}
 #endif
 
-- 
2.9.3



[PATCH] wil6210: use memdup_user

2017-05-06 Thread Geliang Tang
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 5648ebb..5b0f9fc 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -795,15 +795,11 @@ static ssize_t wil_write_file_txmgmt(struct file *file, 
const char __user *buf,
struct wireless_dev *wdev = wil_to_wdev(wil);
struct cfg80211_mgmt_tx_params params;
int rc;
-   void *frame = kmalloc(len, GFP_KERNEL);
+   void *frame;
 
-   if (!frame)
-   return -ENOMEM;
-
-   if (copy_from_user(frame, buf, len)) {
-   kfree(frame);
-   return -EIO;
-   }
+   frame = memdup_user(buf, len);
+   if (IS_ERR(frame))
+   return PTR_ERR(frame);
 
params.buf = frame;
params.len = len;
-- 
2.9.3



[PATCH] net/hippi/rrunner: use memdup_user

2017-05-06 Thread Geliang Tang
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/hippi/rrunner.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index 9b0d614..1ce6239 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1616,17 +1616,14 @@ static int rr_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
return -EPERM;
}
 
-   image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
-   oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
-   if (!image || !oldimage) {
-   error = -ENOMEM;
-   goto wf_out;
-   }
+   image = memdup_user(rq->ifr_data, EEPROM_BYTES);
+   if (IS_ERR(image))
+   return PTR_ERR(image);
 
-   error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
-   if (error) {
-   error = -EFAULT;
-   goto wf_out;
+   oldimage = kmalloc(EEPROM_BYTES, GFP_KERNEL);
+   if (!oldimage) {
+   kfree(image);
+   return -ENOMEM;
}
 
if (rrpriv->fw_running){
-- 
2.9.3



[PATCH] xfrm: use memdup_user

2017-05-06 Thread Geliang Tang
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/xfrm/xfrm_state.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index fc3c5aa..5780cda 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2023,13 +2023,9 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 
__user *optval, int optlen
if (optlen <= 0 || optlen > PAGE_SIZE)
return -EMSGSIZE;
 
-   data = kmalloc(optlen, GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   err = -EFAULT;
-   if (copy_from_user(data, optval, optlen))
-   goto out;
+   data = memdup_user(optval, optlen);
+   if (IS_ERR(data))
+   return PTR_ERR(data);
 
err = -EINVAL;
rcu_read_lock();
@@ -2047,7 +2043,6 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 
__user *optval, int optlen
err = 0;
}
 
-out:
kfree(data);
return err;
 }
-- 
2.9.3



[PATCH] wlcore: use memdup_user

2017-05-06 Thread Geliang Tang
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/wireless/ti/wlcore/debugfs.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/debugfs.c 
b/drivers/net/wireless/ti/wlcore/debugfs.c
index de7e2a5..a2cb408 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.c
+++ b/drivers/net/wireless/ti/wlcore/debugfs.c
@@ -1149,15 +1149,9 @@ static ssize_t dev_mem_write(struct file *file, const 
char __user *user_buf,
part.mem.start = *ppos;
part.mem.size = bytes;
 
-   buf = kmalloc(bytes, GFP_KERNEL);
-   if (!buf)
-   return -ENOMEM;
-
-   ret = copy_from_user(buf, user_buf, bytes);
-   if (ret) {
-   ret = -EFAULT;
-   goto err_out;
-   }
+   buf = memdup_user(user_buf, bytes);
+   if (IS_ERR(buf))
+   return PTR_ERR(buf);
 
mutex_lock(>mutex);
 
@@ -1197,7 +1191,6 @@ static ssize_t dev_mem_write(struct file *file, const 
char __user *user_buf,
if (ret == 0)
*ppos += bytes;
 
-err_out:
kfree(buf);
 
return ((ret == 0) ? bytes : ret);
-- 
2.9.3



[PATCH] yam: use memdup_user

2017-05-06 Thread Geliang Tang
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/hamradio/yam.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index b6891ad..7a7c522 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -976,12 +976,10 @@ static int yam_ioctl(struct net_device *dev, struct ifreq 
*ifr, int cmd)
case SIOCYAMSMCS:
if (netif_running(dev))
return -EINVAL; /* Cannot change this parameter 
when up */
-   if ((ym = kmalloc(sizeof(struct yamdrv_ioctl_mcs), GFP_KERNEL)) 
== NULL)
-   return -ENOBUFS;
-   if (copy_from_user(ym, ifr->ifr_data, sizeof(struct 
yamdrv_ioctl_mcs))) {
-   kfree(ym);
-   return -EFAULT;
-   }
+   ym = memdup_user(ifr->ifr_data,
+sizeof(struct yamdrv_ioctl_mcs));
+   if (IS_ERR(ym))
+   return PTR_ERR(ym);
if (ym->bitrate > YAM_MAXBITRATE) {
kfree(ym);
return -EINVAL;
-- 
2.9.3



[PATCH] xprtrdma: use offset_in_page() macro

2017-04-21 Thread Geliang Tang
Use offset_in_page() macro instead of open-coding.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/sunrpc/xprtrdma/rpc_rdma.c| 4 ++--
 net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index a044be2..429beea 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -540,7 +540,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct 
rpcrdma_req *req,
goto out;
 
page = virt_to_page(xdr->tail[0].iov_base);
-   page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
+   page_base = offset_in_page(xdr->tail[0].iov_base);
 
/* If the content in the page list is an odd length,
 * xdr_write_pages() has added a pad at the beginning
@@ -587,7 +587,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct 
rpcrdma_req *req,
 */
if (xdr->tail[0].iov_len) {
page = virt_to_page(xdr->tail[0].iov_base);
-   page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
+   page_base = offset_in_page(xdr->tail[0].iov_base);
len = xdr->tail[0].iov_len;
 
 map_tail:
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c 
b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index 1736337..60b3f29 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -306,12 +306,11 @@ static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma,
unsigned char *base,
unsigned int len)
 {
-   unsigned long offset = (unsigned long)base & ~PAGE_MASK;
struct ib_device *dev = rdma->sc_cm_id->device;
dma_addr_t dma_addr;
 
dma_addr = ib_dma_map_page(dev, virt_to_page(base),
-  offset, len, DMA_TO_DEVICE);
+  offset_in_page(base), len, DMA_TO_DEVICE);
if (ib_dma_mapping_error(dev, dma_addr))
return -EIO;
 
-- 
2.9.3



[PATCH] net: atheros: atl1: use offset_in_page() macro

2017-04-21 Thread Geliang Tang
Use offset_in_page() macro instead of open-coding.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/atheros/atlx/atl1.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c 
b/drivers/net/ethernet/atheros/atlx/atl1.c
index 022772e..83d2db2 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -1886,7 +1886,7 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter 
*adapter)
buffer_info->skb = skb;
buffer_info->length = (u16) adapter->rx_buffer_len;
page = virt_to_page(skb->data);
-   offset = (unsigned long)skb->data & ~PAGE_MASK;
+   offset = offset_in_page(skb->data);
buffer_info->dma = pci_map_page(pdev, page, offset,
adapter->rx_buffer_len,
PCI_DMA_FROMDEVICE);
@@ -2230,7 +2230,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, 
struct sk_buff *skb,
hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
buffer_info->length = hdr_len;
page = virt_to_page(skb->data);
-   offset = (unsigned long)skb->data & ~PAGE_MASK;
+   offset = offset_in_page(skb->data);
buffer_info->dma = pci_map_page(adapter->pdev, page,
offset, hdr_len,
PCI_DMA_TODEVICE);
@@ -2254,9 +2254,8 @@ static void atl1_tx_map(struct atl1_adapter *adapter, 
struct sk_buff *skb,
data_len -= buffer_info->length;
page = virt_to_page(skb->data +
(hdr_len + i * ATL1_MAX_TX_BUF_LEN));
-   offset = (unsigned long)(skb->data +
-   (hdr_len + i * ATL1_MAX_TX_BUF_LEN)) &
-   ~PAGE_MASK;
+   offset = offset_in_page(skb->data +
+   (hdr_len + i * ATL1_MAX_TX_BUF_LEN));
buffer_info->dma = pci_map_page(adapter->pdev,
page, offset, buffer_info->length,
PCI_DMA_TODEVICE);
@@ -2268,7 +2267,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, 
struct sk_buff *skb,
/* not TSO */
buffer_info->length = buf_len;
page = virt_to_page(skb->data);
-   offset = (unsigned long)skb->data & ~PAGE_MASK;
+   offset = offset_in_page(skb->data);
buffer_info->dma = pci_map_page(adapter->pdev, page,
offset, buf_len, PCI_DMA_TODEVICE);
if (++next_to_use == tpd_ring->count)
-- 
2.9.3



[PATCH] net_sched: use setup_deferrable_timer

2017-03-24 Thread Geliang Tang
Use setup_deferrable_timer() instead of init_timer_deferrable() to
simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/sched/cls_flow.c | 5 ++---
 net/sched/sch_sfq.c  | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 3d6b928..ca193af 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -508,9 +508,8 @@ static int flow_change(struct net *net, struct sk_buff 
*in_skb,
get_random_bytes(>hashrnd, 4);
}
 
-   fnew->perturb_timer.function = flow_perturbation;
-   fnew->perturb_timer.data = (unsigned long)fnew;
-   init_timer_deferrable(>perturb_timer);
+   setup_deferrable_timer(>perturb_timer, flow_perturbation,
+  (unsigned long)fnew);
 
tcf_exts_change(tp, >exts, );
tcf_em_tree_change(tp, >ematches, );
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 9b0911c..332d94b 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -710,9 +710,8 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt)
struct sfq_sched_data *q = qdisc_priv(sch);
int i;
 
-   q->perturb_timer.function = sfq_perturbation;
-   q->perturb_timer.data = (unsigned long)sch;
-   init_timer_deferrable(>perturb_timer);
+   setup_deferrable_timer(>perturb_timer, sfq_perturbation,
+  (unsigned long)sch);
 
for (i = 0; i < SFQ_MAX_DEPTH + 1; i++) {
q->dep[i].next = i + SFQ_MAX_FLOWS;
-- 
2.9.3



[PATCH] isdn: use setup_timer

2017-03-23 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/isdn/divert/isdn_divert.c   |  9 +++--
 drivers/isdn/hardware/eicon/divasi.c|  5 ++---
 drivers/isdn/hardware/mISDN/hfcmulti.c  | 10 --
 drivers/isdn/hardware/mISDN/hfcpci.c|  9 +++--
 drivers/isdn/hardware/mISDN/mISDNipac.c |  5 ++---
 drivers/isdn/hardware/mISDN/mISDNisar.c | 10 --
 drivers/isdn/hardware/mISDN/w6692.c |  5 ++---
 drivers/isdn/hisax/amd7930_fn.c |  4 +---
 drivers/isdn/hisax/arcofi.c |  4 +---
 drivers/isdn/hisax/diva.c   |  5 ++---
 drivers/isdn/hisax/elsa.c   |  4 +---
 drivers/isdn/hisax/fsm.c|  4 +---
 drivers/isdn/hisax/hfc4s8s_l1.c |  5 ++---
 drivers/isdn/hisax/hfc_2bds0.c  |  4 +---
 drivers/isdn/hisax/hfc_pci.c|  8 ++--
 drivers/isdn/hisax/hfc_sx.c |  8 ++--
 drivers/isdn/hisax/hfc_usb.c|  8 ++--
 drivers/isdn/hisax/hfcscard.c   |  4 +---
 drivers/isdn/hisax/icc.c|  4 +---
 drivers/isdn/hisax/ipacx.c  |  4 +---
 drivers/isdn/hisax/isac.c   |  4 +---
 drivers/isdn/hisax/isar.c   | 10 --
 drivers/isdn/hisax/isdnl3.c |  4 +---
 drivers/isdn/hisax/teleint.c|  4 +---
 drivers/isdn/hisax/w6692.c  |  5 ++---
 drivers/isdn/i4l/isdn_ppp.c |  5 ++---
 drivers/isdn/i4l/isdn_tty.c |  5 ++---
 drivers/isdn/mISDN/dsp_core.c   |  4 +---
 drivers/isdn/mISDN/fsm.c|  4 +---
 drivers/isdn/mISDN/l1oip_core.c |  4 +---
 30 files changed, 54 insertions(+), 114 deletions(-)

diff --git a/drivers/isdn/divert/isdn_divert.c 
b/drivers/isdn/divert/isdn_divert.c
index 50749a7..060d357 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -157,10 +157,8 @@ int cf_command(int drvid, int mode,
/* allocate mem for information struct */
if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
return (-ENOMEM); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire, (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own structure */
cs->ics.driver = drvid;
cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
@@ -452,10 +450,9 @@ static int isdn_divert_icall(isdn_ctrl *ic)
return (0); /* no external deflection 
needed */
if (!(cs = kmalloc(sizeof(struct call_struc), 
GFP_ATOMIC)))
return (0); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire,
+   (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own 
structure */
 
cs->ics = *ic; /* copy incoming data */
if (!cs->ics.parm.setup.phone[0]) 
strcpy(cs->ics.parm.setup.phone, "0");
diff --git a/drivers/isdn/hardware/eicon/divasi.c 
b/drivers/isdn/hardware/eicon/divasi.c
index cb88090..c610495 100644
--- a/drivers/isdn/hardware/eicon/divasi.c
+++ b/drivers/isdn/hardware/eicon/divasi.c
@@ -300,9 +300,8 @@ static int um_idi_open_adapter(struct file *file, int 
adapter_nr)
p_os = (diva_um_idi_os_context_t *) diva_um_id_get_os_context(e);
init_waitqueue_head(_os->read_wait);
init_waitqueue_head(_os->close_wait);
-   init_timer(_os->diva_timer_id);
-   p_os->diva_timer_id.function = (void *) diva_um_timer_function;
-   p_os->diva_timer_id.data = (unsigned long) p_os;
+   setup_timer(_os->diva_timer_id, (void *)diva_um_timer_function,
+   (unsigned long)p_os);
p_os->aborted = 0;
p_os->adapter_nr = adapter_nr;
return (1);
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c 
b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 480c2d7..961c07e 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -3878,9 +3878,8 @@ hfcmulti_initmode(struct dchannel *dch)
if (hc->dnum[pt]) {
mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol,
  -1, 0, -1, 0);
-   dch->timer.function = (void *) hfcmulti_dbusy_timer;
-   dch->timer.data = (long) dch;
-   init_timer(>timer);
+

[PATCH] drop_monitor: use setup_timer

2017-03-10 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/core/drop_monitor.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index fb55327..70ccda2 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -412,9 +412,8 @@ static int __init init_net_drop_monitor(void)
for_each_possible_cpu(cpu) {
data = _cpu(dm_cpu_data, cpu);
INIT_WORK(>dm_alert_work, send_dm_alert);
-   init_timer(>send_timer);
-   data->send_timer.data = (unsigned long)data;
-   data->send_timer.function = sched_send_work;
+   setup_timer(>send_timer, sched_send_work,
+   (unsigned long)data);
spin_lock_init(>lock);
reset_per_cpu_data(data);
}
-- 
2.9.3



[PATCH] ambassador: use setup_timer

2017-03-10 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/atm/ambassador.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 4a61079..906705e 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -2267,9 +2267,8 @@ static int amb_probe(struct pci_dev *pci_dev,
dev->atm_dev->ci_range.vpi_bits = NUM_VPI_BITS;
dev->atm_dev->ci_range.vci_bits = NUM_VCI_BITS;
 
-   init_timer(>housekeeping);
-   dev->housekeeping.function = do_housekeeping;
-   dev->housekeeping.data = (unsigned long) dev;
+   setup_timer(>housekeeping, do_housekeeping,
+   (unsigned long)dev);
mod_timer(>housekeeping, jiffies);
 
// enable host interrupts
-- 
2.9.3



Re: [PATCH] net/mlx4: use rb_entry()

2017-01-22 Thread Geliang Tang
On Sun, Jan 22, 2017 at 09:48:39AM +0200, Leon Romanovsky wrote:
> On Fri, Jan 20, 2017 at 10:36:57PM +0800, Geliang Tang wrote:
> > To make the code clearer, use rb_entry() instead of container_of() to
> > deal with rbtree.
> >
> > Signed-off-by: Geliang Tang <geliangt...@gmail.com>
> > ---
> >  drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 8 
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> I don't understand completely the rationale behind this conversion.
> rb_entry == container_of, why do we need another name for it?
> 

There are several *_entry macros which are defined in kernel data
structures, like list_entry, hlist_entry, rb_entry, etc. Each of them is
just another name for container_of. We use different *_entry so that we
could identify the specific type of data structure that we are dealing
with.

-Geliang


[PATCH] net/mlx4: use rb_entry()

2017-01-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c 
b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 1822382..6da6e01 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -236,8 +236,8 @@ static void *res_tracker_lookup(struct rb_root *root, u64 
res_id)
struct rb_node *node = root->rb_node;
 
while (node) {
-   struct res_common *res = container_of(node, struct res_common,
- node);
+   struct res_common *res = rb_entry(node, struct res_common,
+ node);
 
if (res_id < res->res_id)
node = node->rb_left;
@@ -255,8 +255,8 @@ static int res_tracker_insert(struct rb_root *root, struct 
res_common *res)
 
/* Figure out where to put new node */
while (*new) {
-   struct res_common *this = container_of(*new, struct res_common,
-  node);
+   struct res_common *this = rb_entry(*new, struct res_common,
+  node);
 
parent = *new;
if (res->res_id < this->res_id)
-- 
2.9.3



[PATCH] 6lowpan: use rb_entry()

2017-01-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/6lowpan/nhc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/6lowpan/nhc.c b/net/6lowpan/nhc.c
index 7008d53..4fa2fdd 100644
--- a/net/6lowpan/nhc.c
+++ b/net/6lowpan/nhc.c
@@ -27,8 +27,8 @@ static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
 
/* Figure out where to put new node */
while (*new) {
-   struct lowpan_nhc *this = container_of(*new, struct lowpan_nhc,
-  node);
+   struct lowpan_nhc *this = rb_entry(*new, struct lowpan_nhc,
+  node);
int result, len_dif, len;
 
len_dif = nhc->idlen - this->idlen;
@@ -69,8 +69,8 @@ static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct 
sk_buff *skb)
const u8 *nhcid_skb_ptr = skb->data;
 
while (node) {
-   struct lowpan_nhc *nhc = container_of(node, struct lowpan_nhc,
- node);
+   struct lowpan_nhc *nhc = rb_entry(node, struct lowpan_nhc,
+ node);
u8 nhcid_skb_ptr_masked[LOWPAN_NHC_MAX_ID_LEN];
int result, i;
 
-- 
2.9.3



[PATCH] sock: use hlist_entry_safe

2017-01-20 Thread Geliang Tang
Use hlist_entry_safe() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 include/net/sock.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 4077ec4..c4e1caf1 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -544,8 +544,7 @@ static inline struct sock *sk_nulls_head(const struct 
hlist_nulls_head *head)
 
 static inline struct sock *sk_next(const struct sock *sk)
 {
-   return sk->sk_node.next ?
-   hlist_entry(sk->sk_node.next, struct sock, sk_node) : NULL;
+   return hlist_entry_safe(sk->sk_node.next, struct sock, sk_node);
 }
 
 static inline struct sock *sk_nulls_next(const struct sock *sk)
-- 
2.9.3



[PATCH] net_sched: sch_fq: use rb_entry()

2016-12-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/sched/sch_fq.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index 86309a3..a4f738a 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -136,7 +136,7 @@ static void fq_flow_set_throttled(struct fq_sched_data *q, 
struct fq_flow *f)
struct fq_flow *aux;
 
parent = *p;
-   aux = container_of(parent, struct fq_flow, rate_node);
+   aux = rb_entry(parent, struct fq_flow, rate_node);
if (f->time_next_packet >= aux->time_next_packet)
p = >rb_right;
else
@@ -188,7 +188,7 @@ static void fq_gc(struct fq_sched_data *q,
while (*p) {
parent = *p;
 
-   f = container_of(parent, struct fq_flow, fq_node);
+   f = rb_entry(parent, struct fq_flow, fq_node);
if (f->sk == sk)
break;
 
@@ -256,7 +256,7 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, 
struct fq_sched_data *q)
while (*p) {
parent = *p;
 
-   f = container_of(parent, struct fq_flow, fq_node);
+   f = rb_entry(parent, struct fq_flow, fq_node);
if (f->sk == sk) {
/* socket might have been reallocated, so check
 * if its sk_hash is the same.
@@ -424,7 +424,7 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 
now)
 
q->time_next_delayed_flow = ~0ULL;
while ((p = rb_first(>delayed)) != NULL) {
-   struct fq_flow *f = container_of(p, struct fq_flow, rate_node);
+   struct fq_flow *f = rb_entry(p, struct fq_flow, rate_node);
 
if (f->time_next_packet > now) {
q->time_next_delayed_flow = f->time_next_packet;
@@ -563,7 +563,7 @@ static void fq_reset(struct Qdisc *sch)
for (idx = 0; idx < (1U << q->fq_trees_log); idx++) {
root = >fq_root[idx];
while ((p = rb_first(root)) != NULL) {
-   f = container_of(p, struct fq_flow, fq_node);
+   f = rb_entry(p, struct fq_flow, fq_node);
rb_erase(p, root);
 
fq_flow_purge(f);
@@ -593,7 +593,7 @@ static void fq_rehash(struct fq_sched_data *q,
oroot = _array[idx];
while ((op = rb_first(oroot)) != NULL) {
rb_erase(op, oroot);
-   of = container_of(op, struct fq_flow, fq_node);
+   of = rb_entry(op, struct fq_flow, fq_node);
if (fq_gc_candidate(of)) {
fcnt++;
kmem_cache_free(fq_flow_cachep, of);
@@ -606,7 +606,7 @@ static void fq_rehash(struct fq_sched_data *q,
while (*np) {
parent = *np;
 
-   nf = container_of(parent, struct fq_flow, 
fq_node);
+   nf = rb_entry(parent, struct fq_flow, fq_node);
BUG_ON(nf->sk == of->sk);
 
if (nf->sk > of->sk)
-- 
2.9.3



[PATCH] net/mlx5: use rb_entry()

2016-12-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
index 3b026c1..7431f63 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
@@ -75,7 +75,7 @@ static void mlx5_fc_stats_insert(struct rb_root *root, struct 
mlx5_fc *counter)
struct rb_node *parent = NULL;
 
while (*new) {
-   struct mlx5_fc *this = container_of(*new, struct mlx5_fc, node);
+   struct mlx5_fc *this = rb_entry(*new, struct mlx5_fc, node);
int result = counter->id - this->id;
 
parent = *new;
-- 
2.9.3



[PATCH] RDS: use rb_entry()

2016-12-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/rds/rdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 4c93bad..ea96114 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -135,7 +135,7 @@ void rds_rdma_drop_keys(struct rds_sock *rs)
/* Release any MRs associated with this socket */
spin_lock_irqsave(>rs_rdma_lock, flags);
while ((node = rb_first(>rs_rdma_keys))) {
-   mr = container_of(node, struct rds_mr, r_rb_node);
+   mr = rb_entry(node, struct rds_mr, r_rb_node);
if (mr->r_trans == rs->rs_transport)
mr->r_invalidate = 0;
rb_erase(>r_rb_node, >rs_rdma_keys);
-- 
2.9.3



[PATCH] netfilter: xt_connlimit: use rb_entry()

2016-12-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/netfilter/xt_connlimit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
index 2aff2b7..660b61d 100644
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -218,7 +218,7 @@ count_tree(struct net *net, struct rb_root *root,
int diff;
bool addit;
 
-   rbconn = container_of(*rbnode, struct xt_connlimit_rb, node);
+   rbconn = rb_entry(*rbnode, struct xt_connlimit_rb, node);
 
parent = *rbnode;
diff = same_source_net(addr, mask, >addr, family);
@@ -398,7 +398,7 @@ static void destroy_tree(struct rb_root *r)
struct rb_node *node;
 
while ((node = rb_first(r)) != NULL) {
-   rbconn = container_of(node, struct xt_connlimit_rb, node);
+   rbconn = rb_entry(node, struct xt_connlimit_rb, node);
 
rb_erase(node, r);
 
-- 
2.9.3



[PATCH] net_sched: sch_netem: use rb_entry()

2016-12-20 Thread Geliang Tang
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 net/sched/sch_netem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 9f7b380..b7e4097 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -152,7 +152,7 @@ struct netem_skb_cb {
 
 static struct sk_buff *netem_rb_to_skb(struct rb_node *rb)
 {
-   return container_of(rb, struct sk_buff, rbnode);
+   return rb_entry(rb, struct sk_buff, rbnode);
 }
 
 static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
-- 
2.9.3



[PATCH] net/mlx5: drop duplicate header delay.h

2016-11-24 Thread Geliang Tang
Drop duplicate header delay.h from mlx5/core/main.c.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index f28df33..d7a55eb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -46,7 +46,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #ifdef CONFIG_RFS_ACCEL
 #include 
-- 
2.9.3



[PATCH] ath5k: drop duplicate header vmalloc.h

2016-11-24 Thread Geliang Tang
Drop duplicate header vmalloc.h from ath5k/debug.c.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/wireless/ath/ath5k/debug.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath5k/debug.c 
b/drivers/net/wireless/ath/ath5k/debug.c
index 4f8d9ed..d068df5 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -66,7 +66,6 @@
 
 #include 
 #include 
-#include 
 #include "debug.h"
 #include "ath5k.h"
 #include "reg.h"
-- 
2.9.3



[PATCH] ibmvnic: drop duplicate header seq_file.h

2016-11-24 Thread Geliang Tang
Drop duplicate header seq_file.h from ibmvnic.c.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
index 1e486d1..c125966 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -74,7 +74,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "ibmvnic.h"
-- 
2.9.3



[PATCH] net: ieee802154: drop duplicate header delay.h

2016-11-24 Thread Geliang Tang
Drop duplicate header delay.h from adf7242.c.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ieee802154/adf7242.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
index 4ff4c7d..3e4c8b2 100644
--- a/drivers/net/ieee802154/adf7242.c
+++ b/drivers/net/ieee802154/adf7242.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.9.3



[PATCH] dwc_eth_qos: drop duplicate headers

2016-11-23 Thread Geliang Tang
Drop duplicate headers types.h and delay.h from dwc_eth_qos.c.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/synopsys/dwc_eth_qos.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c 
b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 7053301..acce385 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -33,7 +33,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -43,7 +42,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.9.3



[PATCH] drivers: net: davinci_mdio: use builtin_platform_driver

2016-11-23 Thread Geliang Tang
Use builtin_platform_driver() helper to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@gmail.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c 
b/drivers/net/ethernet/ti/davinci_mdio.c
index 33df340..b3f0a12 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -536,11 +536,7 @@ static struct platform_driver davinci_mdio_driver = {
.remove = davinci_mdio_remove,
 };
 
-static int __init davinci_mdio_init(void)
-{
-   return platform_driver_register(_mdio_driver);
-}
-device_initcall(davinci_mdio_init);
+builtin_platform_driver(davinci_mdio_driver);
 
 static void __exit davinci_mdio_exit(void)
 {
-- 
2.9.3



[PATCH 3/3] libceph: use KMEM_CACHE macro

2016-03-12 Thread Geliang Tang
Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/ceph/messenger.c  | 10 ++
 net/ceph/osd_client.c |  5 +
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 9382619..32c997e 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -235,18 +235,12 @@ static struct workqueue_struct *ceph_msgr_wq;
 static int ceph_msgr_slab_init(void)
 {
BUG_ON(ceph_msg_cache);
-   ceph_msg_cache = kmem_cache_create("ceph_msg",
-   sizeof (struct ceph_msg),
-   __alignof__(struct ceph_msg), 0, NULL);
-
+   ceph_msg_cache = KMEM_CACHE(ceph_msg, 0);
if (!ceph_msg_cache)
return -ENOMEM;
 
BUG_ON(ceph_msg_data_cache);
-   ceph_msg_data_cache = kmem_cache_create("ceph_msg_data",
-   sizeof (struct ceph_msg_data),
-   __alignof__(struct ceph_msg_data),
-   0, NULL);
+   ceph_msg_data_cache = KMEM_CACHE(ceph_msg_data, 0);
if (ceph_msg_data_cache)
return 0;
 
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 5bc0537..7558855 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2783,10 +2783,7 @@ EXPORT_SYMBOL(ceph_osdc_writepages);
 int ceph_osdc_setup(void)
 {
BUG_ON(ceph_osd_request_cache);
-   ceph_osd_request_cache = kmem_cache_create("ceph_osd_request",
-   sizeof (struct ceph_osd_request),
-   __alignof__(struct ceph_osd_request),
-   0, NULL);
+   ceph_osd_request_cache = KMEM_CACHE(ceph_osd_request, 0);
 
return ceph_osd_request_cache ? 0 : -ENOMEM;
 }
-- 
2.5.0




[PATCH 2/6] wlcore: use to_delayed_work

2016-01-01 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/ti/wlcore/main.c | 10 +-
 drivers/net/wireless/ti/wlcore/ps.c   |  2 +-
 drivers/net/wireless/ti/wlcore/scan.c |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/main.c 
b/drivers/net/wireless/ti/wlcore/main.c
index ec7f6af..5c12caa 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -244,7 +244,7 @@ static void wl12xx_tx_watchdog_work(struct work_struct 
*work)
struct delayed_work *dwork;
struct wl1271 *wl;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wl = container_of(dwork, struct wl1271, tx_watchdog_work);
 
mutex_lock(>mutex);
@@ -2085,7 +2085,7 @@ static void wlcore_channel_switch_work(struct work_struct 
*work)
struct wl12xx_vif *wlvif;
int ret;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wlvif = container_of(dwork, struct wl12xx_vif, channel_switch_work);
wl = wlvif->wl;
 
@@ -2121,7 +2121,7 @@ static void wlcore_connection_loss_work(struct 
work_struct *work)
struct ieee80211_vif *vif;
struct wl12xx_vif *wlvif;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wlvif = container_of(dwork, struct wl12xx_vif, connection_loss_work);
wl = wlvif->wl;
 
@@ -2150,7 +2150,7 @@ static void wlcore_pending_auth_complete_work(struct 
work_struct *work)
unsigned long time_spare;
int ret;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wlvif = container_of(dwork, struct wl12xx_vif,
 pending_auth_complete_work);
wl = wlvif->wl;
@@ -5660,7 +5660,7 @@ static void wlcore_roc_complete_work(struct work_struct 
*work)
struct wl1271 *wl;
int ret;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wl = container_of(dwork, struct wl1271, roc_complete_work);
 
ret = wlcore_roc_completed(wl);
diff --git a/drivers/net/wireless/ti/wlcore/ps.c 
b/drivers/net/wireless/ti/wlcore/ps.c
index 4cd316e..d4420da 100644
--- a/drivers/net/wireless/ti/wlcore/ps.c
+++ b/drivers/net/wireless/ti/wlcore/ps.c
@@ -38,7 +38,7 @@ void wl1271_elp_work(struct work_struct *work)
struct wl12xx_vif *wlvif;
int ret;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wl = container_of(dwork, struct wl1271, elp_work);
 
wl1271_debug(DEBUG_PSM, "elp work");
diff --git a/drivers/net/wireless/ti/wlcore/scan.c 
b/drivers/net/wireless/ti/wlcore/scan.c
index 1e3d51c..a384f3f 100644
--- a/drivers/net/wireless/ti/wlcore/scan.c
+++ b/drivers/net/wireless/ti/wlcore/scan.c
@@ -38,7 +38,7 @@ void wl1271_scan_complete_work(struct work_struct *work)
struct wl12xx_vif *wlvif;
int ret;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wl = container_of(dwork, struct wl1271, scan_complete_work);
 
wl1271_debug(DEBUG_SCAN, "Scanning complete");
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] ipw2x00: use to_pci_dev()

2016-01-01 Thread Geliang Tang
Use to_pci_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
This patch is against net-next tree.

Changes in v2:
 - fix wrong title.
---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c 
b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index 36818c7..121294f 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -3514,7 +3514,7 @@ static void ipw2100_msg_free(struct ipw2100_priv *priv)
 static ssize_t show_pci(struct device *d, struct device_attribute *attr,
char *buf)
 {
-   struct pci_dev *pci_dev = container_of(d, struct pci_dev, dev);
+   struct pci_dev *pci_dev = to_pci_dev(d);
char *out = buf;
int i, j;
u32 val;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] rtlwifi: use to_delayed_work

2016-01-01 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 4544752..d37ce16 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2873,7 +2873,7 @@ value to host byte ordering.*/
(ppsc->cur_ps_level |= _ps_flg)
 
 #define container_of_dwork_rtl(x, y, z) \
-   container_of(container_of(x, struct delayed_work, work), y, z)
+   container_of(to_delayed_work(x), y, z)
 
 #define FILL_OCTET_STRING(_os, _octet, _len)   \
(_os).octet = (u8 *)(_octet);   \
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] tilepro: use to_delayed_work

2016-01-01 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/ethernet/tile/tilepro.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/tile/tilepro.c 
b/drivers/net/ethernet/tile/tilepro.c
index 6f0a449..298e059 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -1349,8 +1349,7 @@ static int tile_net_open_inner(struct net_device *dev)
  */
 static void tile_net_open_retry(struct work_struct *w)
 {
-   struct delayed_work *dw =
-   container_of(w, struct delayed_work, work);
+   struct delayed_work *dw = to_delayed_work(w);
 
struct tile_net_priv *priv =
container_of(dw, struct tile_net_priv, retry_work);
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] mwifiex: use to_delayed_work

2016-01-01 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/marvell/mwifiex/11h.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/11h.c 
b/drivers/net/wireless/marvell/mwifiex/11h.c
index 71a1b58..81c60d0 100644
--- a/drivers/net/wireless/marvell/mwifiex/11h.c
+++ b/drivers/net/wireless/marvell/mwifiex/11h.c
@@ -123,8 +123,7 @@ void mwifiex_11h_process_join(struct mwifiex_private *priv, 
u8 **buffer,
 void mwifiex_dfs_cac_work_queue(struct work_struct *work)
 {
struct cfg80211_chan_def chandef;
-   struct delayed_work *delayed_work =
-   container_of(work, struct delayed_work, work);
+   struct delayed_work *delayed_work = to_delayed_work(work);
struct mwifiex_private *priv =
container_of(delayed_work, struct mwifiex_private,
 dfs_cac_work);
@@ -289,8 +288,7 @@ int mwifiex_11h_handle_radar_detected(struct 
mwifiex_private *priv,
 void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work)
 {
struct mwifiex_uap_bss_param *bss_cfg;
-   struct delayed_work *delayed_work =
-   container_of(work, struct delayed_work, work);
+   struct delayed_work *delayed_work = to_delayed_work(work);
struct mwifiex_private *priv =
container_of(delayed_work, struct mwifiex_private,
 dfs_chan_sw_work);
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] cfg80211/mac80211: use to_delayed_work

2016-01-01 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/mac80211/mlme.c | 3 +--
 net/wireless/mlme.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 1c342e2..ea70917 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1638,8 +1638,7 @@ void ieee80211_dynamic_ps_timer(unsigned long data)
 
 void ieee80211_dfs_cac_timer_work(struct work_struct *work)
 {
-   struct delayed_work *delayed_work =
-   container_of(work, struct delayed_work, work);
+   struct delayed_work *delayed_work = to_delayed_work(work);
struct ieee80211_sub_if_data *sdata =
container_of(delayed_work, struct ieee80211_sub_if_data,
 dfs_cac_timer_work);
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index fb44fa3..4fccf52 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -721,7 +721,7 @@ void cfg80211_dfs_channels_update_work(struct work_struct 
*work)
unsigned long timeout, next_time = 0;
int bandid, i;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
rdev = container_of(delayed_work, struct cfg80211_registered_device,
dfs_update_channels_wk);
wiphy = >wiphy;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] wl1251: use to_delayed_work

2016-01-01 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/ti/wl1251/ps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ti/wl1251/ps.c 
b/drivers/net/wireless/ti/wl1251/ps.c
index b9e27b9..fa01b0a 100644
--- a/drivers/net/wireless/ti/wl1251/ps.c
+++ b/drivers/net/wireless/ti/wl1251/ps.c
@@ -32,7 +32,7 @@ void wl1251_elp_work(struct work_struct *work)
struct delayed_work *dwork;
struct wl1251 *wl;
 
-   dwork = container_of(work, struct delayed_work, work);
+   dwork = to_delayed_work(work);
wl = container_of(dwork, struct wl1251, elp_work);
 
wl1251_debug(DEBUG_PSM, "elp work");
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] batman-adv: use to_delayed_work

2015-12-28 Thread Geliang Tang
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/batman-adv/bridge_loop_avoidance.c | 2 +-
 net/batman-adv/distributed-arp-table.c | 2 +-
 net/batman-adv/network-coding.c| 2 +-
 net/batman-adv/originator.c| 2 +-
 net/batman-adv/send.c  | 4 ++--
 net/batman-adv/translation-table.c | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index 99dcae3..4f47c82 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1183,7 +1183,7 @@ static void batadv_bla_periodic_work(struct work_struct 
*work)
struct batadv_hard_iface *primary_if;
int i;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
priv_bla = container_of(delayed_work, struct batadv_priv_bla, work);
bat_priv = container_of(priv_bla, struct batadv_priv, bla);
primary_if = batadv_primary_if_get_selected(bat_priv);
diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index a49c705..64facfc 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -138,7 +138,7 @@ static void batadv_dat_purge(struct work_struct *work)
struct batadv_priv_dat *priv_dat;
struct batadv_priv *bat_priv;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
priv_dat = container_of(delayed_work, struct batadv_priv_dat, work);
bat_priv = container_of(priv_dat, struct batadv_priv, dat);
 
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index f5276be..a5ffe20 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -700,7 +700,7 @@ static void batadv_nc_worker(struct work_struct *work)
struct batadv_priv *bat_priv;
unsigned long timeout;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
priv_nc = container_of(delayed_work, struct batadv_priv_nc, work);
bat_priv = container_of(priv_nc, struct batadv_priv, nc);
 
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 3c782a33..0eb5d01 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -1232,7 +1232,7 @@ static void batadv_purge_orig(struct work_struct *work)
struct delayed_work *delayed_work;
struct batadv_priv *bat_priv;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
_batadv_purge_orig(bat_priv);
queue_delayed_work(batadv_event_workqueue,
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index f664324..848ce65 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -506,7 +506,7 @@ static void batadv_send_outstanding_bcast_packet(struct 
work_struct *work)
struct net_device *soft_iface;
struct batadv_priv *bat_priv;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
forw_packet = container_of(delayed_work, struct batadv_forw_packet,
   delayed_work);
soft_iface = forw_packet->if_incoming->soft_iface;
@@ -559,7 +559,7 @@ void batadv_send_outstanding_bat_ogm_packet(struct 
work_struct *work)
struct batadv_forw_packet *forw_packet;
struct batadv_priv *bat_priv;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
forw_packet = container_of(delayed_work, struct batadv_forw_packet,
   delayed_work);
bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface);
diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index ec67def..ed6fcc7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3157,7 +3157,7 @@ static void batadv_tt_purge(struct work_struct *work)
struct batadv_priv_tt *priv_tt;
struct batadv_priv *bat_priv;
 
-   delayed_work = container_of(work, struct delayed_work, work);
+   delayed_work = to_delayed_work(work);
priv_tt = container_of(delayed_work, struct batadv_priv_tt, work);
bat_priv = container_of(priv_tt, struct batadv_priv, tt);
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/9] ssb: use to_pci_dev()

2015-12-27 Thread Geliang Tang
Use to_pci_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/ssb/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index 0f28c08..67428f4 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -1130,7 +1130,7 @@ static ssize_t ssb_pci_attr_sprom_show(struct device 
*pcidev,
   struct device_attribute *attr,
   char *buf)
 {
-   struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev);
+   struct pci_dev *pdev = to_pci_dev(pcidev);
struct ssb_bus *bus;
 
bus = ssb_pci_dev_to_bus(pdev);
@@ -1144,7 +1144,7 @@ static ssize_t ssb_pci_attr_sprom_store(struct device 
*pcidev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev);
+   struct pci_dev *pdev = to_pci_dev(pcidev);
struct ssb_bus *bus;
 
bus = ssb_pci_dev_to_bus(pdev);
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] atm: solos-pci: use to_pci_dev()

2015-12-27 Thread Geliang Tang
Use to_pci_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/atm/solos-pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 0c2b4ba0..6ac2b2b 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -525,7 +525,7 @@ struct geos_gpio_attr {
 static ssize_t geos_gpio_store(struct device *dev, struct device_attribute 
*attr,
   const char *buf, size_t count)
 {
-   struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+   struct pci_dev *pdev = to_pci_dev(dev);
struct geos_gpio_attr *gattr = container_of(attr, struct 
geos_gpio_attr, attr);
struct solos_card *card = pci_get_drvdata(pdev);
uint32_t data32;
@@ -551,7 +551,7 @@ static ssize_t geos_gpio_store(struct device *dev, struct 
device_attribute *attr
 static ssize_t geos_gpio_show(struct device *dev, struct device_attribute 
*attr,
  char *buf)
 {
-   struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+   struct pci_dev *pdev = to_pci_dev(dev);
struct geos_gpio_attr *gattr = container_of(attr, struct 
geos_gpio_attr, attr);
struct solos_card *card = pci_get_drvdata(pdev);
uint32_t data32;
@@ -565,7 +565,7 @@ static ssize_t geos_gpio_show(struct device *dev, struct 
device_attribute *attr,
 static ssize_t hardware_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+   struct pci_dev *pdev = to_pci_dev(dev);
struct geos_gpio_attr *gattr = container_of(attr, struct 
geos_gpio_attr, attr);
struct solos_card *card = pci_get_drvdata(pdev);
uint32_t data32;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/9] ipw2x00: sdhci-pci: use to_pci_dev()

2015-12-27 Thread Geliang Tang
Use to_pci_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c 
b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index 36818c7..121294f 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -3514,7 +3514,7 @@ static void ipw2100_msg_free(struct ipw2100_priv *priv)
 static ssize_t show_pci(struct device *d, struct device_attribute *attr,
char *buf)
 {
-   struct pci_dev *pci_dev = container_of(d, struct pci_dev, dev);
+   struct pci_dev *pci_dev = to_pci_dev(d);
char *out = buf;
int i, j;
u32 val;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/10] net: hns: use to_platform_device()

2015-12-27 Thread Geliang Tang
On Sun, Dec 27, 2015 at 03:23:30PM +0200, Andy Shevchenko wrote:
> On Sun, Dec 27, 2015 at 3:15 PM, Geliang Tang <geliangt...@163.com> wrote:
> > Use to_platform_device() instead of open-coding it.
> >
> > Signed-off-by: Geliang Tang <geliangt...@163.com>
> > ---
> >  drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c 
> > b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
> > index 8c30cec..d2263c7 100644
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
> > @@ -499,8 +499,7 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
> > int base_irq_idx = hns_rcb_get_base_irq_idx(rcb_common);
> > struct device_node *np = rcb_common->dsaf_dev->dev->of_node;
> > struct platform_device *pdev =
> > -   container_of(rcb_common->dsaf_dev->dev,
> > -struct platform_device, dev);
> > +   to_platform_device(rcb_common->dsaf_dev->dev);
> 
> Can it be one line after all? Please, check this for all your patches
> of such kind.
> 

Thanks for your review.

It's over 80 characters in one line:

 WARNING: line over 80 characters
 #22: FILE: drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c:501:
 +  struct platform_device *pdev = 
to_platform_device(rcb_common->dsaf_dev->dev);

 total: 0 errors, 1 warnings, 0 checks, 10 lines checked

Geliang

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/10] net: hns: use to_platform_device()

2015-12-27 Thread Geliang Tang
Use to_platform_device() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
index 8c30cec..d2263c7 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
@@ -499,8 +499,7 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
int base_irq_idx = hns_rcb_get_base_irq_idx(rcb_common);
struct device_node *np = rcb_common->dsaf_dev->dev->of_node;
struct platform_device *pdev =
-   container_of(rcb_common->dsaf_dev->dev,
-struct platform_device, dev);
+   to_platform_device(rcb_common->dsaf_dev->dev);
bool is_ver1 = AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver);
 
for (i = 0; i < ring_num; i++) {
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] bridge: use kobj_to_dev instead of to_dev

2015-12-23 Thread Geliang Tang
kobj_to_dev has been defined in linux/device.h, so I replace to_dev
with it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/bridge/br_sysfs_br.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 8365bd5..6b80914 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -22,7 +22,6 @@
 
 #include "br_private.h"
 
-#define to_dev(obj)container_of(obj, struct device, kobj)
 #define to_bridge(cd)  ((struct net_bridge *)netdev_priv(to_net_dev(cd)))
 
 /*
@@ -814,7 +813,7 @@ static ssize_t brforward_read(struct file *filp, struct 
kobject *kobj,
  struct bin_attribute *bin_attr,
  char *buf, loff_t off, size_t count)
 {
-   struct device *dev = to_dev(kobj);
+   struct device *dev = kobj_to_dev(kobj);
struct net_bridge *br = to_bridge(dev);
int n;
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] bonding: drop unused to_dev macro in bond_sysfs.c

2015-12-23 Thread Geliang Tang
to_dev is not used anymore so drop it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/bonding/bond_sysfs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index f4ae720..313dbac 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -42,7 +42,6 @@
 
 #include 
 
-#define to_dev(obj)container_of(obj, struct device, kobj)
 #define to_bond(cd)((struct bonding *)(netdev_priv(to_net_dev(cd
 
 /* "show" function for the bond_masters attribute.
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net-sysfs: use to_net_dev in net_namespace()

2015-12-22 Thread Geliang Tang
Use to_net_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/core/net-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index bca8c35..b6c8a66 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1453,8 +1453,8 @@ static void netdev_release(struct device *d)
 
 static const void *net_namespace(struct device *d)
 {
-   struct net_device *dev;
-   dev = container_of(d, struct net_device, dev);
+   struct net_device *dev = to_net_dev(d);
+
return dev_net(dev);
 }
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/14 v2] ipv4, ipv6: use list_for_each_entry*

2015-12-19 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
Changes in v2:
 - bugfix for inet6_register_protosw in v1.
---
 net/ipv4/af_inet.c| 11 ---
 net/ipv4/tcp_output.c |  6 ++
 net/ipv6/addrconf.c   |  8 +++-
 net/ipv6/af_inet6.c   | 19 +--
 4 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 11c4ca1..eedf814 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1028,10 +1028,8 @@ static struct inet_protosw inetsw_array[] =
 
 void inet_register_protosw(struct inet_protosw *p)
 {
-   struct list_head *lh;
-   struct inet_protosw *answer;
+   struct inet_protosw *answer, *last_perm;
int protocol = p->protocol;
-   struct list_head *last_perm;
 
spin_lock_bh(_lock);
 
@@ -1040,14 +1038,13 @@ void inet_register_protosw(struct inet_protosw *p)
 
/* If we are trying to override a permanent protocol, bail. */
last_perm = [p->type];
-   list_for_each(lh, [p->type]) {
-   answer = list_entry(lh, struct inet_protosw, list);
+   list_for_each_entry(answer, [p->type], list) {
/* Check only the non-wild match. */
if ((INET_PROTOSW_PERMANENT & answer->flags) == 0)
break;
if (protocol == answer->protocol)
goto out_permanent;
-   last_perm = lh;
+   last_perm = answer;
}
 
/* Add the new entry after the last permanent entry if any, so that
@@ -1056,7 +1053,7 @@ void inet_register_protosw(struct inet_protosw *p)
 * non-permanent entry.  This means that when we remove this entry, the
 * system automatically returns to the old behavior.
 */
-   list_add_rcu(>list, last_perm);
+   list_add_rcu(>list, _perm->list);
 out:
spin_unlock_bh(_lock);
 
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index a800cee..8810694 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -751,16 +751,14 @@ static void tcp_tasklet_func(unsigned long data)
struct tsq_tasklet *tsq = (struct tsq_tasklet *)data;
LIST_HEAD(list);
unsigned long flags;
-   struct list_head *q, *n;
-   struct tcp_sock *tp;
+   struct tcp_sock *tp, *n;
struct sock *sk;
 
local_irq_save(flags);
list_splice_init(>head, );
local_irq_restore(flags);
 
-   list_for_each_safe(q, n, ) {
-   tp = list_entry(q, struct tcp_sock, tsq_node);
+   list_for_each_entry_safe(tp, n, , tsq_node) {
list_del(>tsq_node);
 
sk = (struct sock *)tp;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7082fb7..e293647 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -865,21 +865,19 @@ void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
 static void
 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
 {
-   struct list_head *p;
+   struct inet6_ifaddr *ifa;
int ifp_scope = ipv6_addr_src_scope(>addr);
 
/*
 * Each device address list is sorted in order of scope -
 * global before linklocal.
 */
-   list_for_each(p, >addr_list) {
-   struct inet6_ifaddr *ifa
-   = list_entry(p, struct inet6_ifaddr, if_list);
+   list_for_each_entry(ifa, >addr_list, if_list) {
if (ifp_scope >= ipv6_addr_src_scope(>addr))
break;
}
 
-   list_add_tail(>if_list, p);
+   list_add_tail(>if_list, >if_list);
 }
 
 static u32 inet6_addr_hash(const struct in6_addr *addr)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 8ec0df7..437a500 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -568,9 +568,7 @@ static const struct net_proto_family inet6_family_ops = {
 
 int inet6_register_protosw(struct inet_protosw *p)
 {
-   struct list_head *lh;
-   struct inet_protosw *answer;
-   struct list_head *last_perm;
+   struct inet_protosw *answer, *last_perm;
int protocol = p->protocol;
int ret;
 
@@ -581,23 +579,16 @@ int inet6_register_protosw(struct inet_protosw *p)
goto out_illegal;
 
/* If we are trying to override a permanent protocol, bail. */
-   answer = NULL;
ret = -EPERM;
last_perm = [p->type];
-   list_for_each(lh, [p->type]) {
-   answer = list_entry(lh, struct inet_protosw, list);
-
+   list_for_each_entry(answer, [p->type], list) {
/* Check only the non-wild match. */
if (INET_PROTOSW_PERMANENT & answer->flags) {
if (protocol == answer->protocol)
-   break;
-   last_perm = 

[PATCH 11/14] openvswitch: use list_for_each_entry

2015-12-18 Thread Geliang Tang
Use list_for_each_entry() instead of list_for_each() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/openvswitch/flow_table.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index d073fff..9b5999ba 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -651,11 +651,9 @@ static bool mask_equal(const struct sw_flow_mask *a,
 static struct sw_flow_mask *flow_mask_find(const struct flow_table *tbl,
   const struct sw_flow_mask *mask)
 {
-   struct list_head *ml;
+   struct sw_flow_mask *m;
 
-   list_for_each(ml, >mask_list) {
-   struct sw_flow_mask *m;
-   m = container_of(ml, struct sw_flow_mask, list);
+   list_for_each_entry(m, >mask_list, list) {
if (mask_equal(mask, m))
return m;
}
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/14] sunrpc: use list_for_each_entry_safe

2015-12-18 Thread Geliang Tang
Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/sunrpc/svc_xprt.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index a6cbb21..fe4f628 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -904,8 +904,7 @@ out:
 static void svc_age_temp_xprts(unsigned long closure)
 {
struct svc_serv *serv = (struct svc_serv *)closure;
-   struct svc_xprt *xprt;
-   struct list_head *le, *next;
+   struct svc_xprt *xprt, *next;
 
dprintk("svc_age_temp_xprts\n");
 
@@ -916,9 +915,7 @@ static void svc_age_temp_xprts(unsigned long closure)
return;
}
 
-   list_for_each_safe(le, next, >sv_tempsocks) {
-   xprt = list_entry(le, struct svc_xprt, xpt_list);
-
+   list_for_each_entry_safe(xprt, next, >sv_tempsocks, xpt_list) {
/* First time through, just mark it OLD. Second time
 * through, close it. */
if (!test_and_set_bit(XPT_OLD, >xpt_flags))
@@ -926,7 +923,7 @@ static void svc_age_temp_xprts(unsigned long closure)
if (atomic_read(>xpt_ref.refcount) > 1 ||
test_bit(XPT_BUSY, >xpt_flags))
continue;
-   list_del_init(le);
+   list_del_init(>xpt_list);
set_bit(XPT_CLOSE, >xpt_flags);
dprintk("queuing xprt %p for closing\n", xprt);
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/14] ipv4, ipv6: use list_for_each_entry*

2015-12-18 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/ipv4/af_inet.c| 6 ++
 net/ipv4/tcp_output.c | 6 ++
 net/ipv6/addrconf.c   | 8 +++-
 net/ipv6/af_inet6.c   | 7 ++-
 4 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 11c4ca1..bb11ec1 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1028,7 +1028,6 @@ static struct inet_protosw inetsw_array[] =
 
 void inet_register_protosw(struct inet_protosw *p)
 {
-   struct list_head *lh;
struct inet_protosw *answer;
int protocol = p->protocol;
struct list_head *last_perm;
@@ -1040,14 +1039,13 @@ void inet_register_protosw(struct inet_protosw *p)
 
/* If we are trying to override a permanent protocol, bail. */
last_perm = [p->type];
-   list_for_each(lh, [p->type]) {
-   answer = list_entry(lh, struct inet_protosw, list);
+   list_for_each_entry(answer, [p->type], list) {
/* Check only the non-wild match. */
if ((INET_PROTOSW_PERMANENT & answer->flags) == 0)
break;
if (protocol == answer->protocol)
goto out_permanent;
-   last_perm = lh;
+   last_perm = >list;
}
 
/* Add the new entry after the last permanent entry if any, so that
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index a800cee..8810694 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -751,16 +751,14 @@ static void tcp_tasklet_func(unsigned long data)
struct tsq_tasklet *tsq = (struct tsq_tasklet *)data;
LIST_HEAD(list);
unsigned long flags;
-   struct list_head *q, *n;
-   struct tcp_sock *tp;
+   struct tcp_sock *tp, *n;
struct sock *sk;
 
local_irq_save(flags);
list_splice_init(>head, );
local_irq_restore(flags);
 
-   list_for_each_safe(q, n, ) {
-   tp = list_entry(q, struct tcp_sock, tsq_node);
+   list_for_each_entry_safe(tp, n, , tsq_node) {
list_del(>tsq_node);
 
sk = (struct sock *)tp;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7082fb7..e293647 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -865,21 +865,19 @@ void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
 static void
 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
 {
-   struct list_head *p;
+   struct inet6_ifaddr *ifa;
int ifp_scope = ipv6_addr_src_scope(>addr);
 
/*
 * Each device address list is sorted in order of scope -
 * global before linklocal.
 */
-   list_for_each(p, >addr_list) {
-   struct inet6_ifaddr *ifa
-   = list_entry(p, struct inet6_ifaddr, if_list);
+   list_for_each_entry(ifa, >addr_list, if_list) {
if (ifp_scope >= ipv6_addr_src_scope(>addr))
break;
}
 
-   list_add_tail(>if_list, p);
+   list_add_tail(>if_list, >if_list);
 }
 
 static u32 inet6_addr_hash(const struct in6_addr *addr)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 8ec0df7..a4fb172 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -568,7 +568,6 @@ static const struct net_proto_family inet6_family_ops = {
 
 int inet6_register_protosw(struct inet_protosw *p)
 {
-   struct list_head *lh;
struct inet_protosw *answer;
struct list_head *last_perm;
int protocol = p->protocol;
@@ -584,14 +583,12 @@ int inet6_register_protosw(struct inet_protosw *p)
answer = NULL;
ret = -EPERM;
last_perm = [p->type];
-   list_for_each(lh, [p->type]) {
-   answer = list_entry(lh, struct inet_protosw, list);
-
+   list_for_each_entry(answer, [p->type], list) {
/* Check only the non-wild match. */
if (INET_PROTOSW_PERMANENT & answer->flags) {
if (protocol == answer->protocol)
break;
-   last_perm = lh;
+   last_perm = >list;
}
 
answer = NULL;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/14] Bluetooth: use list_for_each_entry*

2015-12-18 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/bluetooth/af_bluetooth.c | 12 ++--
 net/bluetooth/cmtp/capi.c|  8 ++--
 net/bluetooth/hci_core.c |  8 +++-
 net/bluetooth/rfcomm/core.c  | 46 ++--
 4 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index cb4e8d4..955eda9 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -174,13 +174,13 @@ EXPORT_SYMBOL(bt_accept_unlink);
 
 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
 {
-   struct list_head *p, *n;
+   struct bt_sock *s, *n;
struct sock *sk;
 
BT_DBG("parent %p", parent);
 
-   list_for_each_safe(p, n, _sk(parent)->accept_q) {
-   sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
+   list_for_each_entry_safe(s, n, _sk(parent)->accept_q, accept_q) {
+   sk = (struct sock *)s;
 
lock_sock(sk);
 
@@ -388,11 +388,11 @@ EXPORT_SYMBOL(bt_sock_stream_recvmsg);
 
 static inline unsigned int bt_accept_poll(struct sock *parent)
 {
-   struct list_head *p, *n;
+   struct bt_sock *s, *n;
struct sock *sk;
 
-   list_for_each_safe(p, n, _sk(parent)->accept_q) {
-   sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
+   list_for_each_entry_safe(s, n, _sk(parent)->accept_q, accept_q) {
+   sk = (struct sock *)s;
if (sk->sk_state == BT_CONNECTED ||
(test_bit(BT_SK_DEFER_SETUP, _sk(parent)->flags) &&
 sk->sk_state == BT_CONNECT2))
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 9a503387..46ac686 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -100,10 +100,8 @@ static void cmtp_application_del(struct cmtp_session 
*session, struct cmtp_appli
 static struct cmtp_application *cmtp_application_get(struct cmtp_session 
*session, int pattern, __u16 value)
 {
struct cmtp_application *app;
-   struct list_head *p;
 
-   list_for_each(p, >applications) {
-   app = list_entry(p, struct cmtp_application, list);
+   list_for_each_entry(app, >applications, list) {
switch (pattern) {
case CMTP_MSGNUM:
if (app->msgnum == value)
@@ -511,14 +509,12 @@ static int cmtp_proc_show(struct seq_file *m, void *v)
struct capi_ctr *ctrl = m->private;
struct cmtp_session *session = ctrl->driverdata;
struct cmtp_application *app;
-   struct list_head *p;
 
seq_printf(m, "%s\n\n", cmtp_procinfo(ctrl));
seq_printf(m, "addr %s\n", session->name);
seq_printf(m, "ctrl %d\n", session->num);
 
-   list_for_each(p, >applications) {
-   app = list_entry(p, struct cmtp_application, list);
+   list_for_each_entry(app, >applications, list) {
seq_printf(m, "appl %d -> %d\n", app->appl, app->mapping);
}
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9fb443a..47bcef7 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2713,12 +2713,10 @@ struct bdaddr_list *hci_bdaddr_list_lookup(struct 
list_head *bdaddr_list,
 
 void hci_bdaddr_list_clear(struct list_head *bdaddr_list)
 {
-   struct list_head *p, *n;
+   struct bdaddr_list *b, *n;
 
-   list_for_each_safe(p, n, bdaddr_list) {
-   struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list);
-
-   list_del(p);
+   list_for_each_entry_safe(b, n, bdaddr_list, list) {
+   list_del(>list);
kfree(b);
}
 }
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 29709fb..f7eb02f 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -692,11 +692,9 @@ static struct rfcomm_session *rfcomm_session_del(struct 
rfcomm_session *s)
 
 static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
 {
-   struct rfcomm_session *s;
-   struct list_head *p, *n;
+   struct rfcomm_session *s, *n;
struct l2cap_chan *chan;
-   list_for_each_safe(p, n, _list) {
-   s = list_entry(p, struct rfcomm_session, list);
+   list_for_each_entry_safe(s, n, _list, list) {
chan = l2cap_pi(s->sock->sk)->chan;
 
if ((!bacmp(src, BDADDR_ANY) || !bacmp(>src, src)) &&
@@ -709,16 +707,14 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t 
*src, bdaddr_t *dst)
 static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s,
  

[PATCH 14/14] net: pktgen: use list_for_each_entry_safe

2015-12-18 Thread Geliang Tang
Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/core/pktgen.c | 26 --
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 2be1444..1d8cffb 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3293,14 +3293,11 @@ static void pktgen_stop(struct pktgen_thread *t)
  */
 static void pktgen_rem_one_if(struct pktgen_thread *t)
 {
-   struct list_head *q, *n;
-   struct pktgen_dev *cur;
+   struct pktgen_dev *cur, *n;
 
func_enter();
 
-   list_for_each_safe(q, n, >if_list) {
-   cur = list_entry(q, struct pktgen_dev, list);
-
+   list_for_each_entry_safe(cur, n, >if_list, list) {
if (!cur->removal_mark)
continue;
 
@@ -3315,16 +3312,13 @@ static void pktgen_rem_one_if(struct pktgen_thread *t)
 
 static void pktgen_rem_all_ifs(struct pktgen_thread *t)
 {
-   struct list_head *q, *n;
-   struct pktgen_dev *cur;
+   struct pktgen_dev *cur, *n;
 
func_enter();
 
/* Remove all devices, free mem */
 
-   list_for_each_safe(q, n, >if_list) {
-   cur = list_entry(q, struct pktgen_dev, list);
-
+   list_for_each_entry_safe(cur, n, >if_list, list) {
kfree_skb(cur->skb);
cur->skb = NULL;
 
@@ -3771,12 +3765,10 @@ static int __net_init pktgen_create_thread(int cpu, 
struct pktgen_net *pn)
 static void _rem_dev_from_if_list(struct pktgen_thread *t,
  struct pktgen_dev *pkt_dev)
 {
-   struct list_head *q, *n;
-   struct pktgen_dev *p;
+   struct pktgen_dev *p, *n;
 
if_lock(t);
-   list_for_each_safe(q, n, >if_list) {
-   p = list_entry(q, struct pktgen_dev, list);
+   list_for_each_entry_safe(p, n, >if_list, list) {
if (p == pkt_dev)
list_del_rcu(>list);
}
@@ -3866,8 +3858,7 @@ remove:
 static void __net_exit pg_net_exit(struct net *net)
 {
struct pktgen_net *pn = net_generic(net, pg_net_id);
-   struct pktgen_thread *t;
-   struct list_head *q, *n;
+   struct pktgen_thread *t, *n;
LIST_HEAD(list);
 
/* Stop all interfaces & threads */
@@ -3877,8 +3868,7 @@ static void __net_exit pg_net_exit(struct net *net)
list_splice_init(>pktgen_threads, );
mutex_unlock(_thread_lock);
 
-   list_for_each_safe(q, n, ) {
-   t = list_entry(q, struct pktgen_thread, th_list);
+   list_for_each_entry_safe(t, n, , th_list) {
list_del(>th_list);
kthread_stop(t->tsk);
put_task_struct(t->tsk);
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/14] x25: use list_for_each_entry*

2015-12-18 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/x25/x25_forward.c | 20 ++--
 net/x25/x25_link.c| 23 ++-
 net/x25/x25_route.c   | 29 +++--
 3 files changed, 19 insertions(+), 53 deletions(-)

diff --git a/net/x25/x25_forward.c b/net/x25/x25_forward.c
index cf561f1..4394eb6 100644
--- a/net/x25/x25_forward.c
+++ b/net/x25/x25_forward.c
@@ -24,7 +24,6 @@ int x25_forward_call(struct x25_address *dest_addr, struct 
x25_neigh *from,
 {
struct x25_route *rt;
struct x25_neigh *neigh_new = NULL;
-   struct list_head *entry;
struct x25_forward *x25_frwd, *new_frwd;
struct sk_buff *skbn;
short same_lci = 0;
@@ -51,8 +50,7 @@ int x25_forward_call(struct x25_address *dest_addr, struct 
x25_neigh *from,
 * established LCI? It shouldn't happen, just in case..
 */
read_lock_bh(_forward_list_lock);
-   list_for_each(entry, _forward_list) {
-   x25_frwd = list_entry(entry, struct x25_forward, node);
+   list_for_each_entry(x25_frwd, _forward_list, node) {
if (x25_frwd->lci == lci) {
pr_warn("call request for lci which is already 
registered!, transmitting but not registering new pair\n");
same_lci = 1;
@@ -97,15 +95,13 @@ out_no_route:
 int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) {
 
struct x25_forward *frwd;
-   struct list_head *entry;
struct net_device *peer = NULL;
struct x25_neigh *nb;
struct sk_buff *skbn;
int rc = 0;
 
read_lock_bh(_forward_list_lock);
-   list_for_each(entry, _forward_list) {
-   frwd = list_entry(entry, struct x25_forward, node);
+   list_for_each_entry(frwd, _forward_list, node) {
if (frwd->lci == lci) {
/* The call is established, either side can send */
if (from->dev == frwd->dev1) {
@@ -136,13 +132,11 @@ out:
 
 void x25_clear_forward_by_lci(unsigned int lci)
 {
-   struct x25_forward *fwd;
-   struct list_head *entry, *tmp;
+   struct x25_forward *fwd, *tmp;
 
write_lock_bh(_forward_list_lock);
 
-   list_for_each_safe(entry, tmp, _forward_list) {
-   fwd = list_entry(entry, struct x25_forward, node);
+   list_for_each_entry_safe(fwd, tmp, _forward_list, node) {
if (fwd->lci == lci) {
list_del(>node);
kfree(fwd);
@@ -154,13 +148,11 @@ void x25_clear_forward_by_lci(unsigned int lci)
 
 void x25_clear_forward_by_dev(struct net_device *dev)
 {
-   struct x25_forward *fwd;
-   struct list_head *entry, *tmp;
+   struct x25_forward *fwd, *tmp;
 
write_lock_bh(_forward_list_lock);
 
-   list_for_each_safe(entry, tmp, _forward_list) {
-   fwd = list_entry(entry, struct x25_forward, node);
+   list_for_each_entry_safe(fwd, tmp, _forward_list, node) {
if ((fwd->dev1 == dev) || (fwd->dev2 == dev)){
list_del(>node);
kfree(fwd);
diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c
index fd5ffb2..61cc8a2 100644
--- a/net/x25/x25_link.c
+++ b/net/x25/x25_link.c
@@ -296,14 +296,11 @@ static void __x25_remove_neigh(struct x25_neigh *nb)
  */
 void x25_link_device_down(struct net_device *dev)
 {
-   struct x25_neigh *nb;
-   struct list_head *entry, *tmp;
+   struct x25_neigh *nb, *tmp;
 
write_lock_bh(_neigh_list_lock);
 
-   list_for_each_safe(entry, tmp, _neigh_list) {
-   nb = list_entry(entry, struct x25_neigh, node);
-
+   list_for_each_entry_safe(nb, tmp, _neigh_list, node) {
if (nb->dev == dev) {
__x25_remove_neigh(nb);
dev_put(dev);
@@ -319,12 +316,9 @@ void x25_link_device_down(struct net_device *dev)
 struct x25_neigh *x25_get_neigh(struct net_device *dev)
 {
struct x25_neigh *nb, *use = NULL;
-   struct list_head *entry;
 
read_lock_bh(_neigh_list_lock);
-   list_for_each(entry, _neigh_list) {
-   nb = list_entry(entry, struct x25_neigh, node);
-
+   list_for_each_entry(nb, _neigh_list, node) {
if (nb->dev == dev) {
use = nb;
break;
@@ -394,18 +388,13 @@ out_dev_put:
  */
 void __exit x25_link_free(void)
 {
-   struct x25_neigh *nb;
-   struct list_head *entry, *tmp;
+   struct x25_neigh *nb, *tmp;
 
write_lock_bh(_neigh_list_lock);
 
-   list_for_each_safe(entry, tmp, _neigh_list) {
-   struct net_device *dev;
-
-   nb = list_entry(entry, struct x25_neigh, node);
-   dev = nb->dev;
+  

[PATCH 08/14] caif: use list_for_each_entry_safe

2015-12-18 Thread Geliang Tang
Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/caif/chnl_net.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 67a4a36..d3db77c 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -140,13 +140,10 @@ static int delete_device(struct chnl_net *dev)
 
 static void close_work(struct work_struct *work)
 {
-   struct chnl_net *dev = NULL;
-   struct list_head *list_node;
-   struct list_head *_tmp;
+   struct chnl_net *dev = NULL, *tmp;
 
rtnl_lock();
-   list_for_each_safe(list_node, _tmp, _net_list) {
-   dev = list_entry(list_node, struct chnl_net, list_field);
+   list_for_each_entry_safe(dev, tmp, _net_list, list_field) {
if (dev->state == CAIF_SHUTDOWN)
dev_close(dev->netdev);
}
@@ -535,14 +532,11 @@ static int __init chnl_init_module(void)
 
 static void __exit chnl_exit_module(void)
 {
-   struct chnl_net *dev = NULL;
-   struct list_head *list_node;
-   struct list_head *_tmp;
+   struct chnl_net *dev = NULL, *tmp;
rtnl_link_unregister(_link_ops);
rtnl_lock();
-   list_for_each_safe(list_node, _tmp, _net_list) {
-   dev = list_entry(list_node, struct chnl_net, list_field);
-   list_del(list_node);
+   list_for_each_entry_safe(dev, tmp, _net_list, list_field) {
+   list_del(>list_field);
delete_device(dev);
}
rtnl_unlock();
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/14] lapb: use list_for_each_entry

2015-12-18 Thread Geliang Tang
Use list_for_each_entry() instead of list_for_each() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/lapb/lapb_iface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index fc60d9d..49abba7 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -86,11 +86,9 @@ static void __lapb_insert_cb(struct lapb_cb *lapb)
 
 static struct lapb_cb *__lapb_devtostruct(struct net_device *dev)
 {
-   struct list_head *entry;
struct lapb_cb *lapb, *use = NULL;
 
-   list_for_each(entry, _list) {
-   lapb = list_entry(entry, struct lapb_cb, node);
+   list_for_each_entry(lapb, _list, node) {
if (lapb->dev == dev) {
use = lapb;
break;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/14] net: sched: use list_for_each_entry

2015-12-18 Thread Geliang Tang
Use list_for_each_entry() instead of list_for_each() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/sched/sch_htb.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 15ccd7f..5f7aa74 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -948,10 +948,9 @@ static unsigned int htb_drop(struct Qdisc *sch)
int prio;
 
for (prio = TC_HTB_NUMPRIO - 1; prio >= 0; prio--) {
-   struct list_head *p;
-   list_for_each(p, q->drops + prio) {
-   struct htb_class *cl = list_entry(p, struct htb_class,
- un.leaf.drop_list);
+   struct htb_class *cl;
+
+   list_for_each_entry(cl, q->drops + prio, un.leaf.drop_list) {
unsigned int len;
if (cl->un.leaf.q->ops->drop &&
(len = cl->un.leaf.q->ops->drop(cl->un.leaf.q))) {
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/14] net: dsa: use list_for_each_entry

2015-12-18 Thread Geliang Tang
Use list_for_each_entry() instead of list_for_each() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/dsa/dsa.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 208d1b2..2ab4a19 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -53,19 +53,14 @@ EXPORT_SYMBOL_GPL(unregister_switch_driver);
 static struct dsa_switch_driver *
 dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name)
 {
-   struct dsa_switch_driver *ret;
-   struct list_head *list;
+   struct dsa_switch_driver *ret, *drv;
char *name;
 
ret = NULL;
name = NULL;
 
mutex_lock(_switch_drivers_mutex);
-   list_for_each(list, _switch_drivers) {
-   struct dsa_switch_driver *drv;
-
-   drv = list_entry(list, struct dsa_switch_driver, list);
-
+   list_for_each_entry(drv, _switch_drivers, list) {
name = drv->probe(host_dev, sw_addr);
if (name != NULL) {
ret = drv;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/14] batman-adv: use list_for_each_entry_safe

2015-12-18 Thread Geliang Tang
Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/batman-adv/icmp_socket.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index bcabb5e..841239c 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -104,25 +104,21 @@ static int batadv_socket_open(struct inode *inode, struct 
file *file)
 
 static int batadv_socket_release(struct inode *inode, struct file *file)
 {
-   struct batadv_socket_client *socket_client = file->private_data;
-   struct batadv_socket_packet *socket_packet;
-   struct list_head *list_pos, *list_pos_tmp;
+   struct batadv_socket_client *client = file->private_data;
+   struct batadv_socket_packet *packet, *tmp;
 
-   spin_lock_bh(_client->lock);
+   spin_lock_bh(>lock);
 
/* for all packets in the queue ... */
-   list_for_each_safe(list_pos, list_pos_tmp, _client->queue_list) {
-   socket_packet = list_entry(list_pos,
-  struct batadv_socket_packet, list);
-
-   list_del(list_pos);
-   kfree(socket_packet);
+   list_for_each_entry_safe(packet, tmp, >queue_list, list) {
+   list_del(>list);
+   kfree(packet);
}
 
-   batadv_socket_client_hash[socket_client->index] = NULL;
-   spin_unlock_bh(_client->lock);
+   batadv_socket_client_hash[client->index] = NULL;
+   spin_unlock_bh(>lock);
 
-   kfree(socket_client);
+   kfree(client);
module_put(THIS_MODULE);
 
return 0;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/14] libceph: use list_for_each_entry_safe

2015-12-18 Thread Geliang Tang
Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/ceph/messenger.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 9981039..c664b7f 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -3361,9 +3361,8 @@ static void ceph_msg_free(struct ceph_msg *m)
 static void ceph_msg_release(struct kref *kref)
 {
struct ceph_msg *m = container_of(kref, struct ceph_msg, kref);
-   LIST_HEAD(data);
-   struct list_head *links;
-   struct list_head *next;
+   LIST_HEAD(head);
+   struct ceph_msg_data *data, *next;
 
dout("%s %p\n", __func__, m);
WARN_ON(!list_empty(>list_head));
@@ -3376,12 +3375,9 @@ static void ceph_msg_release(struct kref *kref)
m->middle = NULL;
}
 
-   list_splice_init(>data, );
-   list_for_each_safe(links, next, ) {
-   struct ceph_msg_data *data;
-
-   data = list_entry(links, struct ceph_msg_data, links);
-   list_del_init(links);
+   list_splice_init(>data, );
+   list_for_each_entry_safe(data, next, , links) {
+   list_del_init(>links);
ceph_msg_data_destroy(data);
}
m->data_length = 0;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/14] atm: use list_for_each_entry

2015-12-18 Thread Geliang Tang
Use list_for_each_entry() instead of list_for_each() to simplify
the code.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/atm/ioctl.c | 5 ++---
 net/atm/resources.c | 8 ++--
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index bbd3b63..9feb293 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -53,7 +53,7 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,
struct sock *sk = sock->sk;
struct atm_vcc *vcc;
int error;
-   struct list_head *pos;
+   struct atm_ioctl *ic;
void __user *argp = (void __user *)arg;
 
vcc = ATM_SD(sock);
@@ -163,8 +163,7 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int 
cmd,
error = -ENOIOCTLCMD;
 
mutex_lock(_mutex);
-   list_for_each(pos, _list) {
-   struct atm_ioctl *ic = list_entry(pos, struct atm_ioctl, list);
+   list_for_each_entry(ic, _list, list) {
if (try_module_get(ic->owner)) {
error = ic->ioctl(sock, cmd, arg);
module_put(ic->owner);
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 0447d5d..413d919 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -51,10 +51,8 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
 static struct atm_dev *__atm_dev_lookup(int number)
 {
struct atm_dev *dev;
-   struct list_head *p;
 
-   list_for_each(p, _devs) {
-   dev = list_entry(p, struct atm_dev, dev_list);
+   list_for_each_entry(dev, _devs, dev_list) {
if (dev->number == number) {
atm_dev_hold(dev);
return dev;
@@ -238,10 +236,8 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int 
compat)
return -ENOMEM;
}
tmp_p = tmp_buf;
-   list_for_each(p, _devs) {
-   dev = list_entry(p, struct atm_dev, dev_list);
+   list_for_each_entry(dev, _devs, dev_list)
*tmp_p++ = dev->number;
-   }
mutex_unlock(_dev_mutex);
error = ((copy_to_user(buf, tmp_buf, size)) ||
 put_user(size, iobuf_len))
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] livepatch: use list_is_first()

2015-12-10 Thread Geliang Tang
For better readability, use list_is_first() instead of open-coded.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 kernel/livepatch/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index bc2c85c..be64106 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -479,7 +479,7 @@ static int __klp_enable_patch(struct klp_patch *patch)
return -EINVAL;
 
/* enforce stacking: only the first disabled patch can be enabled */
-   if (patch->list.prev != _patches &&
+   if (!list_is_first(>list, _patches) &&
list_prev_entry(patch, list)->state == KLP_DISABLED)
return -EBUSY;
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] elevator: use list_is_{first,last}

2015-12-10 Thread Geliang Tang
For better readability, use list_is_{first,last}() instead of open-coded.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 block/noop-iosched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/noop-iosched.c b/block/noop-iosched.c
index a163c48..d44326e 100644
--- a/block/noop-iosched.c
+++ b/block/noop-iosched.c
@@ -44,7 +44,7 @@ noop_former_request(struct request_queue *q, struct request 
*rq)
 {
struct noop_data *nd = q->elevator->elevator_data;
 
-   if (rq->queuelist.prev == >queue)
+   if (list_is_first(>queuelist, >queue))
return NULL;
return list_prev_entry(rq, queuelist);
 }
@@ -54,7 +54,7 @@ noop_latter_request(struct request_queue *q, struct request 
*rq)
 {
struct noop_data *nd = q->elevator->elevator_data;
 
-   if (rq->queuelist.next == >queue)
+   if (list_is_last(>queuelist, >queue))
return NULL;
return list_next_entry(rq, queuelist);
 }
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] netfilter: ipset: use list_is_first()

2015-12-10 Thread Geliang Tang
For better readability, use list_is_first() instead of open-coded.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/netfilter/ipset/ip_set_list_set.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/ipset/ip_set_list_set.c 
b/net/netfilter/ipset/ip_set_list_set.c
index bbede95..9d757d6 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -288,7 +288,7 @@ list_set_uadd(struct ip_set *set, void *value, const struct 
ip_set_ext *ext,
n = list_next_entry(next, list);
} else {
/* Insert before prev element */
-   if (prev->list.prev != >members)
+   if (!list_is_first(>list, >members))
n = list_prev_entry(prev, list);
}
/* Can we replace a timed out entry? */
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] list: introduce list_is_first()

2015-12-10 Thread Geliang Tang
We already have list_is_last(), it makes sense to also add
list_is_first() for consistency. This list utility function
to check for first element in a list.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 include/linux/list.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/list.h b/include/linux/list.h
index 5356f4d..2c43ef4 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -170,6 +170,17 @@ static inline void list_move_tail(struct list_head *list,
 }
 
 /**
+ * list_is_first - tests whether @list is the first entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_first(const struct list_head *list,
+   const struct list_head *head)
+{
+   return list->prev == head;
+}
+
+/**
  * list_is_last - tests whether @list is the last entry in list @head
  * @list: the entry to test
  * @head: the head of the list
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] iwlwifi: fix a problematic usage of WARN_ON_ONCE()

2015-11-25 Thread Geliang Tang
WARN_ON_ONCE() takes a condition rather than a format string. This
patch converted WARN_ON_ONCE() to WARN_ONCE() instead.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index d1ad103..58d7bee 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -1827,7 +1827,7 @@ static int rs_switch_to_column(struct iwl_mvm *mvm,
rate->type = lq_sta->is_vht ? LQ_VHT_MIMO2 : LQ_HT_MIMO2;
rate_mask = lq_sta->active_mimo2_rate;
} else {
-   WARN_ON_ONCE("Bad column mode");
+   WARN_ONCE(1, "Bad column mode");
}
 
if (column->mode != RS_LEGACY) {
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pcnet32: fix a logic error with pci_set_dma_mask

2015-11-23 Thread Geliang Tang
On Wed, Oct 21, 2015 at 09:01:26PM -0700, Don Fry wrote:
> On Mon, 2015-10-12 at 05:38 -0700, David Miller wrote:
> > From: Geliang Tang <geliangt...@163.com>
> > Date: Fri,  9 Oct 2015 03:45:39 -0700
> > 
> > > pcnet32 can't work on my machine recently. It says "architecture
> > > does not support 32bit PCI busmaster DMA". There is a logic error
> > > in it: pci_set_dma_mask() return 0 means return successfully.
> > > 
> > > Signed-off-by: Geliang Tang <geliangt...@163.com>
> > 
> > This driver doesn't call pci_set_dma_mask() in any of my tree(s).
> I failed.  My system with pcnet32 boards was down with a dead power
> supply and a visual review was not good enough.  I missed that
> pci_dma_supported returns 1 on success and pci_set_dma_mask returns 0 on
> success.  The original patch needs to have the ! removed as Geliang Tang
> points out.
> 
> Acked-by:  Don Fry <pcne...@frontier.com>

Hi:

It has been a month since I submitted this patch. I'm wondering is it
still valid and wether it will be applied? 

A recent commit targeting at the same problem (commit 1a47de6 various:
fix pci_set_dma_mask return value checking) has been applied. But my
commit, which I reported and submitted earlier, hasn't been applied. I'd
like to know if there's anything wrong with it? 

Thank you!

- Geliang Tang

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] libceph: use list_next_entry instead of list_entry_next

2015-11-16 Thread Geliang Tang
list_next_entry has been defined in list.h, so I replace list_entry_next
with it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 net/ceph/messenger.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 9981039..b1d1489 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -23,9 +23,6 @@
 #include 
 #include 
 
-#define list_entry_next(pos, member)   \
-   list_entry(pos->member.next, typeof(*pos), member)
-
 /*
  * Ceph uses the messenger to exchange ceph_msg messages with other
  * hosts in the system.  The messenger provides ordered and reliable
@@ -1042,7 +1039,7 @@ static bool ceph_msg_data_pagelist_advance(struct 
ceph_msg_data_cursor *cursor,
/* Move on to the next page */
 
BUG_ON(list_is_last(>page->lru, >head));
-   cursor->page = list_entry_next(cursor->page, lru);
+   cursor->page = list_next_entry(cursor->page, lru);
cursor->last_piece = cursor->resid <= PAGE_SIZE;
 
return true;
@@ -1166,7 +1163,7 @@ static bool ceph_msg_data_advance(struct 
ceph_msg_data_cursor *cursor,
if (!cursor->resid && cursor->total_resid) {
WARN_ON(!cursor->last_piece);
BUG_ON(list_is_last(>data->links, cursor->data_head));
-   cursor->data = list_entry_next(cursor->data, links);
+   cursor->data = list_next_entry(cursor->data, links);
__ceph_msg_data_cursor_init(cursor);
new_piece = true;
}
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/9] net: fix trivial typos

2015-10-18 Thread Geliang Tang
s/regsiter/register/

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/ethernet/amd/amd8111e.h   | 2 +-
 drivers/net/ethernet/atheros/atl1c/atl1c_hw.c | 2 +-
 drivers/net/ethernet/intel/igb/e1000_phy.c| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/amd8111e.h 
b/drivers/net/ethernet/amd/amd8111e.h
index 7cdb185..d5e2b71 100644
--- a/drivers/net/ethernet/amd/amd8111e.h
+++ b/drivers/net/ethernet/amd/amd8111e.h
@@ -48,7 +48,7 @@ eg., if the value 10011010b is written into the least 
significant byte of a comm
 /* 32 bit registers */
 
 #define  ASF_STAT  0x00/* ASF status register */
-#define CHIPID 0x04/* Chip ID regsiter */
+#define CHIPID 0x04/* Chip ID register */
 #defineMIB_DATA0x10/* MIB data register */
 #define MIB_ADDR   0x14/* MIB address register */
 #define STAT0  0x30/* Status0 register */
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c 
b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
index a8b80c5..73efdb0 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
@@ -307,7 +307,7 @@ void atl1c_start_phy_polling(struct atl1c_hw *hw, u16 
clk_sel)
 
 /*
  * atl1c_read_phy_core
- * core function to read register in PHY via MDIO control regsiter.
+ * core function to read register in PHY via MDIO control register.
  * ext: extension register (see IEEE 802.3)
  * dev: device address (see IEEE 802.3 DEVAD, PRTAD is fixed to 0)
  * reg: reg to read
diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c 
b/drivers/net/ethernet/intel/igb/e1000_phy.c
index 23ec28f..ffc3a14 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
@@ -123,7 +123,7 @@ out:
  *  @offset: register offset to be read
  *  @data: pointer to the read data
  *
- *  Reads the MDI control regsiter in the PHY at offset and stores the
+ *  Reads the MDI control register in the PHY at offset and stores the
  *  information read to data.
  **/
 s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pcnet32: fix a logic error with pci_set_dma_mask

2015-10-13 Thread Geliang Tang
On Mon, Oct 12, 2015 at 05:38:14AM -0700, David Miller wrote:
> From: Geliang Tang <geliangt...@163.com>
> Date: Fri,  9 Oct 2015 03:45:39 -0700
> 
> > pcnet32 can't work on my machine recently. It says "architecture
> > does not support 32bit PCI busmaster DMA". There is a logic error
> > in it: pci_set_dma_mask() return 0 means return successfully.
> > 
> > Signed-off-by: Geliang Tang <geliangt...@163.com>
> 
> This driver doesn't call pci_set_dma_mask() in any of my tree(s).

This patch is against linux-next tree. It was introduced by commit
9c034d4 'pcnet32: use pci_set_dma_mask insted of pci_dma_supported'.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] mISDN: use kstrdup() in dsp_pipeline_build

2015-10-12 Thread Geliang Tang
Use kstrdup instead of strlen-kmalloc-strcpy. Remove unneeded NULL
test, it will be tested inside kstrdup. Remove 0 length string test,
it has been tested in the caller of dsp_pipeline_build.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
Changes in v2:
  - Remove unneeded NULL test.
---
 drivers/isdn/mISDN/dsp_pipeline.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/isdn/mISDN/dsp_pipeline.c 
b/drivers/isdn/mISDN/dsp_pipeline.c
index 8b1a66c..e72b4e7 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -235,7 +235,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
 
 int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
 {
-   int len, incomplete = 0, found = 0;
+   int incomplete = 0, found = 0;
char *dup, *tok, *name, *args;
struct dsp_element_entry *entry, *n;
struct dsp_pipeline_entry *pipeline_entry;
@@ -247,17 +247,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, 
const char *cfg)
if (!list_empty(>list))
_dsp_pipeline_destroy(pipeline);
 
-   if (!cfg)
-   return 0;
-
-   len = strlen(cfg);
-   if (!len)
-   return 0;
-
-   dup = kmalloc(len + 1, GFP_ATOMIC);
+   dup = kstrdup(cfg, GFP_ATOMIC);
if (!dup)
return 0;
-   strcpy(dup, cfg);
while ((tok = strsep(, "|"))) {
if (!strlen(tok))
continue;
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mISDN: use kstrdup() in dsp_pipeline_build

2015-10-10 Thread Geliang Tang
Use kstrdup instead of strlen-kmalloc-strcpy.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/isdn/mISDN/dsp_pipeline.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/isdn/mISDN/dsp_pipeline.c 
b/drivers/isdn/mISDN/dsp_pipeline.c
index 8b1a66c..c60722d 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -235,7 +235,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
 
 int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
 {
-   int len, incomplete = 0, found = 0;
+   int incomplete = 0, found = 0;
char *dup, *tok, *name, *args;
struct dsp_element_entry *entry, *n;
struct dsp_pipeline_entry *pipeline_entry;
@@ -250,14 +250,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, 
const char *cfg)
if (!cfg)
return 0;
 
-   len = strlen(cfg);
-   if (!len)
-   return 0;
-
-   dup = kmalloc(len + 1, GFP_ATOMIC);
+   dup = kstrdup(cfg, GFP_ATOMIC);
if (!dup)
return 0;
-   strcpy(dup, cfg);
while ((tok = strsep(, "|"))) {
if (!strlen(tok))
continue;
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pcnet32: fix a logic error with pci_set_dma_mask

2015-10-09 Thread Geliang Tang
pcnet32 can't work on my machine recently. It says "architecture
does not support 32bit PCI busmaster DMA". There is a logic error
in it: pci_set_dma_mask() return 0 means return successfully.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/ethernet/amd/pcnet32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/pcnet32.c 
b/drivers/net/ethernet/amd/pcnet32.c
index e2afabf..2d9d216 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -1500,7 +1500,7 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return -ENODEV;
}
 
-   if (!pci_set_dma_mask(pdev, PCNET32_DMA_MASK)) {
+   if (pci_set_dma_mask(pdev, PCNET32_DMA_MASK)) {
if (pcnet32_debug & NETIF_MSG_PROBE)
pr_err("architecture does not support 32bit PCI 
busmaster DMA\n");
return -ENODEV;
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] ath6kl: drop unlikely behind WARN_ON()

2015-10-05 Thread Geliang Tang
WARN_ON() already contain an unlikely compiler flag. Drop it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
Changes in v2:
 - change subject prefix to ath6kl.
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c 
b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index a511ef3..fe38fc4 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -2217,7 +2217,7 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct 
cfg80211_wowlan *wow)
 
/* enter / leave wow suspend on first vif always */
first_vif = ath6kl_vif_first(ar);
-   if (WARN_ON(unlikely(!first_vif)) ||
+   if (WARN_ON(!first_vif) ||
!ath6kl_cfg80211_ready(first_vif))
return -EIO;
 
@@ -2297,7 +2297,7 @@ static int ath6kl_wow_resume(struct ath6kl *ar)
int ret;
 
vif = ath6kl_vif_first(ar);
-   if (WARN_ON(unlikely(!vif)) ||
+   if (WARN_ON(!vif) ||
!ath6kl_cfg80211_ready(vif))
return -EIO;
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mwifiex: fix a comment typo

2015-10-04 Thread Geliang Tang
Just fix a typo in the code comment.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/mwifiex/cfg80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mwifiex/cfg80211.c 
b/drivers/net/wireless/mwifiex/cfg80211.c
index 30cbafb..b7ac45f 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -2374,7 +2374,7 @@ mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct 
net_device *dev)
  * CFG802.11 operation handler for scan request.
  *
  * This function issues a scan request to the firmware based upon
- * the user specified scan configuration. On successfull completion,
+ * the user specified scan configuration. On successful completion,
  * it also informs the results.
  */
 static int
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cfg80211: drop unlikely behind WARN_ON()

2015-10-04 Thread Geliang Tang
WARN_ON() already contain an unlikely compiler flag. Drop it.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c 
b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index a511ef3..fe38fc4 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -2217,7 +2217,7 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct 
cfg80211_wowlan *wow)
 
/* enter / leave wow suspend on first vif always */
first_vif = ath6kl_vif_first(ar);
-   if (WARN_ON(unlikely(!first_vif)) ||
+   if (WARN_ON(!first_vif) ||
!ath6kl_cfg80211_ready(first_vif))
return -EIO;
 
@@ -2297,7 +2297,7 @@ static int ath6kl_wow_resume(struct ath6kl *ar)
int ret;
 
vif = ath6kl_vif_first(ar);
-   if (WARN_ON(unlikely(!vif)) ||
+   if (WARN_ON(!vif) ||
!ath6kl_cfg80211_ready(vif))
return -EIO;
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] amd-xgbe: fix potential memory leak in xgbe-debugfs

2015-09-30 Thread Geliang Tang
Added kfree() to avoid the memory leak when debugfs_create_dir() fails.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
index 2c063b6..66137ff 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
@@ -330,6 +330,7 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL);
if (!pdata->xgbe_debugfs) {
netdev_err(pdata->netdev, "debugfs_create_dir failed\n");
+   kfree(buf);
return;
}
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net: macb: fix two typos

2015-09-29 Thread Geliang Tang
Just fix two typos in code comments.

Signed-off-by: Geliang Tang <geliangt...@163.com>
---
 drivers/net/ethernet/cadence/macb.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index 6e1faea..866b128 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -267,9 +267,9 @@
 #define MACB_BEX_SIZE  1
 #define MACB_RM9200_BNQ_OFFSET 4 /* AT91RM9200 only */
 #define MACB_RM9200_BNQ_SIZE   1 /* AT91RM9200 only */
-#define MACB_COMP_OFFSET   5 /* Trnasmit complete */
+#define MACB_COMP_OFFSET   5 /* Transmit complete */
 #define MACB_COMP_SIZE 1
-#define MACB_UND_OFFSET6 /* Trnasmit under run */
+#define MACB_UND_OFFSET6 /* Transmit under run */
 #define MACB_UND_SIZE  1
 
 /* Bitfields in RSR */
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libceph: use kvfree() in ceph_put_page_vector()

2015-06-01 Thread Geliang Tang
Use kvfree() instead of open-coding it.

Signed-off-by: Geliang Tang geliangt...@163.com
---
 net/ceph/pagevec.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c
index 096d914..d4f5f22 100644
--- a/net/ceph/pagevec.c
+++ b/net/ceph/pagevec.c
@@ -51,10 +51,7 @@ void ceph_put_page_vector(struct page **pages, int 
num_pages, bool dirty)
set_page_dirty_lock(pages[i]);
put_page(pages[i]);
}
-   if (is_vmalloc_addr(pages))
-   vfree(pages);
-   else
-   kfree(pages);
+   kvfree(pages);
 }
 EXPORT_SYMBOL(ceph_put_page_vector);
 
-- 
2.3.4


--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html