[PATCH v3] arm64/crypto: Accelerated CRC T10 DIF computation

2016-11-22 Thread YueHaibing
This is the ARM64 CRC T10 DIF transform accelerated with the ARMv8
NEON instruction.The config CRYPTO_CRCT10DIF_NEON should be turned
on to enable the feature.The crc_t10dif crypto library function will
use this faster algorithm when crct10dif_neon module is loaded.

Tcrypt benchmark results:

HIP06  (mode=320 sec=2)

The ratio of bytes/sec crct10dif-neon Vs. crct10dif-generic:

TEST  neon  generic 
ratio
  16 byte blocks,   16 bytes per update,   1 updates214506112   
171095400   1.25
  64 byte blocks,   16 bytes per update,   4 updates139385312   
119036352   1.17
  64 byte blocks,   64 bytes per update,   1 updates671523712   
198945344   3.38
 256 byte blocks,   16 bytes per update,  16 updates157674880   
125146752   1.26
 256 byte blocks,   64 bytes per update,   4 updates491888128   
175764096   2.80
 256 byte blocks,  256 bytes per update,   1 updates2123298176  
206995200   10.26
1024 byte blocks,   16 bytes per update,  64 updates161243136   
126460416   1.28
1024 byte blocks,  256 bytes per update,   4 updates1643020800  
200027136   8.21
1024 byte blocks, 1024 bytes per update,   1 updates4238239232  
209106432   20.27
2048 byte blocks,   16 bytes per update, 128 updates162079744   
126953472   1.28
2048 byte blocks,  256 bytes per update,   8 updates1693587456  
200867840   8.43
2048 byte blocks, 1024 bytes per update,   2 updates3424323584  
206330880   16.60
2048 byte blocks, 2048 bytes per update,   1 updates5228207104  
208620544   25.06
4096 byte blocks,   16 bytes per update, 256 updates162304000   
126894080   1.28
4096 byte blocks,  256 bytes per update,  16 updates1731862528  
201197568   8.61
4096 byte blocks, 1024 bytes per update,   4 updates3668625408  
207003648   17.72
4096 byte blocks, 4096 bytes per update,   1 updates5551239168  
209127424   26.54
8192 byte blocks,   16 bytes per update, 512 updates162779136   
126984192   1.28
8192 byte blocks,  256 bytes per update,  32 updates1753702400  
201420800   8.71
8192 byte blocks, 1024 bytes per update,   8 updates3760918528  
207351808   18.14
8192 byte blocks, 4096 bytes per update,   2 updates5483655168  
208928768   26.25
8192 byte blocks, 8192 bytes per update,   1 updates5623377920  
209108992   26.89

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
Signed-off-by: YangShengkai <yangsheng...@huawei.com>
Signed-off-by: Ding Tianhong <dingtianh...@huawei.com>
Signed-off-by: Hanjun Guo <hanjun@linaro.org>

---
 arch/arm64/crypto/Kconfig |   5 +
 arch/arm64/crypto/Makefile|   4 +
 arch/arm64/crypto/crct10dif-neon-asm_64.S | 751 ++
 arch/arm64/crypto/crct10dif-neon_glue.c   | 115 +
 4 files changed, 875 insertions(+)
 create mode 100644 arch/arm64/crypto/crct10dif-neon-asm_64.S
 create mode 100644 arch/arm64/crypto/crct10dif-neon_glue.c

diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig
index 2cf32e9..2e450bf 100644
--- a/arch/arm64/crypto/Kconfig
+++ b/arch/arm64/crypto/Kconfig
@@ -23,6 +23,11 @@ config CRYPTO_GHASH_ARM64_CE
depends on ARM64 && KERNEL_MODE_NEON
select CRYPTO_HASH
 
+config CRYPTO_CRCT10DIF_NEON
+   tristate "CRCT10DIF hardware acceleration using NEON instructions"
+   depends on ARM64 && KERNEL_MODE_NEON
+   select CRYPTO_HASH
+
 config CRYPTO_AES_ARM64_CE
tristate "AES core cipher using ARMv8 Crypto Extensions"
depends on ARM64 && KERNEL_MODE_NEON
diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile
index abb79b3..6c9ff2c 100644
--- a/arch/arm64/crypto/Makefile
+++ b/arch/arm64/crypto/Makefile
@@ -29,6 +29,10 @@ aes-ce-blk-y := aes-glue-ce.o aes-ce.o
 obj-$(CONFIG_CRYPTO_AES_ARM64_NEON_BLK) += aes-neon-blk.o
 aes-neon-blk-y := aes-glue-neon.o aes-neon.o
 
+obj-$(CONFIG_CRYPTO_CRCT10DIF_NEON) += crct10dif-neon.o
+crct10dif-neon-y := crct10dif-neon-asm_64.o crct10dif-neon_glue.o
+AFLAGS_crct10dif-neon-asm_64.o := -march=armv8-a+crypto
+
 AFLAGS_aes-ce.o:= -DINTERLEAVE=4
 AFLAGS_aes-neon.o  := -DINTERLEAVE=4
 
diff --git a/arch/arm64/crypto/crct10dif-neon-asm_64.S 
b/arch/arm64/crypto/crct10dif-neon-asm_64.S
new file mode 100644
index 000..2ae3033
--- /dev/null
+++ b/arch/arm64/crypto/crct10dif-neon-asm_64.S
@@ -0,0 +1,751 @@
+/*
+ * Copyright (c) 2016-2017 Hisilicon Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 

[PATCH] ptp_pch: use helpers function for converting between ns and timespec

2018-04-27 Thread YueHaibing
use ns_to_timespec64() and timespec64_to_ns() instead of open coding

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/ptp/ptp_pch.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c
index b328517..78ccf93 100644
--- a/drivers/ptp/ptp_pch.c
+++ b/drivers/ptp/ptp_pch.c
@@ -452,7 +452,6 @@ static int ptp_pch_adjtime(struct ptp_clock_info *ptp, s64 
delta)
 static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
u64 ns;
-   u32 remainder;
unsigned long flags;
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
struct pch_ts_regs __iomem *regs = pch_dev->regs;
@@ -461,8 +460,7 @@ static int ptp_pch_gettime(struct ptp_clock_info *ptp, 
struct timespec64 *ts)
ns = pch_systime_read(regs);
spin_unlock_irqrestore(_dev->register_lock, flags);
 
-   ts->tv_sec = div_u64_rem(ns, 10, );
-   ts->tv_nsec = remainder;
+   *ts = ns_to_timespec64(ns);
return 0;
 }
 
@@ -474,8 +472,7 @@ static int ptp_pch_settime(struct ptp_clock_info *ptp,
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
struct pch_ts_regs __iomem *regs = pch_dev->regs;
 
-   ns = ts->tv_sec * 10ULL;
-   ns += ts->tv_nsec;
+   ns = timespec64_to_ns(ts);
 
spin_lock_irqsave(_dev->register_lock, flags);
pch_systime_write(regs, ns);
-- 
2.7.0




[PATCH net-next] libcxgb,cxgb4: use __skb_put_zero to simplfy code

2018-04-27 Thread YueHaibing
use helper __skb_put_zero to replace the pattern of __skb_put() && memset()

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c |  3 +--
 drivers/net/ethernet/chelsio/cxgb4/srq.c  |  3 +--
 drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h | 15 +--
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index db92f18..aae9802 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -64,8 +64,7 @@ static int set_tcb_field(struct adapter *adap, struct 
filter_entry *f,
if (!skb)
return -ENOMEM;
 
-   req = (struct cpl_set_tcb_field *)__skb_put(skb, sizeof(*req));
-   memset(req, 0, sizeof(*req));
+   req = (struct cpl_set_tcb_field *)__skb_put_zero(skb, sizeof(*req));
INIT_TP_WR_CPL(req, CPL_SET_TCB_FIELD, ftid);
req->reply_ctrl = htons(REPLY_CHAN_V(0) |
QUEUENO_V(adap->sge.fw_evtq.abs_id) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/srq.c 
b/drivers/net/ethernet/chelsio/cxgb4/srq.c
index 6228a57..82b70a5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/srq.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/srq.c
@@ -84,8 +84,7 @@ int cxgb4_get_srq_entry(struct net_device *dev,
if (!skb)
return -ENOMEM;
req = (struct cpl_srq_table_req *)
-   __skb_put(skb, sizeof(*req));
-   memset(req, 0, sizeof(*req));
+   __skb_put_zero(skb, sizeof(*req));
INIT_TP_WR(req, 0);
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SRQ_TABLE_REQ,
  TID_TID_V(srq_idx) |
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h 
b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
index 4b5aacc..240ba9d 100644
--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
@@ -90,8 +90,7 @@ cxgb_mk_tid_release(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan)
 {
struct cpl_tid_release *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_TID_RELEASE, tid));
@@ -104,8 +103,7 @@ cxgb_mk_close_con_req(struct sk_buff *skb, u32 len, u32 
tid, u16 chan,
 {
struct cpl_close_con_req *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_CLOSE_CON_REQ, tid));
@@ -119,8 +117,7 @@ cxgb_mk_abort_req(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan,
 {
struct cpl_abort_req *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_ABORT_REQ, tid));
@@ -134,8 +131,7 @@ cxgb_mk_abort_rpl(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan)
 {
struct cpl_abort_rpl *rpl;
 
-   rpl = __skb_put(skb, len);
-   memset(rpl, 0, len);
+   rpl = __skb_put_zero(skb, len);
 
INIT_TP_WR(rpl, tid);
OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_ABORT_RPL, tid));
@@ -149,8 +145,7 @@ cxgb_mk_rx_data_ack(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan,
 {
struct cpl_rx_data_ack *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_RX_DATA_ACK, tid));
-- 
2.7.0




[PATCH] IB/cxgb4: use skb_put_zero()/__skb_put_zero

2018-04-28 Thread YueHaibing
Use the recently introduced helper to replace the pattern of
skb_put_zero/__skb_put() && memset().

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/infiniband/hw/cxgb4/qp.c| 9 +++--
 drivers/infiniband/sw/rxe/rxe_net.c | 4 +---
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index de77b60..2dc9499 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1297,8 +1297,7 @@ static void post_terminate(struct c4iw_qp *qhp, struct 
t4_cqe *err_cqe,
 
set_wr_txq(skb, CPL_PRIORITY_DATA, qhp->ep->txq_idx);
 
-   wqe = __skb_put(skb, sizeof(*wqe));
-   memset(wqe, 0, sizeof *wqe);
+   wqe = __skb_put_zero(skb, sizeof(*wqe));
wqe->op_compl = cpu_to_be32(FW_WR_OP_V(FW_RI_INIT_WR));
wqe->flowid_len16 = cpu_to_be32(
FW_WR_FLOWID_V(qhp->ep->hwtid) |
@@ -1421,8 +1420,7 @@ static int rdma_fini(struct c4iw_dev *rhp, struct c4iw_qp 
*qhp,
 
set_wr_txq(skb, CPL_PRIORITY_DATA, ep->txq_idx);
 
-   wqe = __skb_put(skb, sizeof(*wqe));
-   memset(wqe, 0, sizeof *wqe);
+   wqe = __skb_put_zero(skb, sizeof(*wqe));
wqe->op_compl = cpu_to_be32(
FW_WR_OP_V(FW_RI_INIT_WR) |
FW_WR_COMPL_F);
@@ -1487,8 +1485,7 @@ static int rdma_init(struct c4iw_dev *rhp, struct c4iw_qp 
*qhp)
}
set_wr_txq(skb, CPL_PRIORITY_DATA, qhp->ep->txq_idx);
 
-   wqe = __skb_put(skb, sizeof(*wqe));
-   memset(wqe, 0, sizeof *wqe);
+   wqe = __skb_put_zero(skb, sizeof(*wqe));
wqe->op_compl = cpu_to_be32(
FW_WR_OP_V(FW_RI_INIT_WR) |
FW_WR_COMPL_F);
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c 
b/drivers/infiniband/sw/rxe/rxe_net.c
index 9da6e37..95dcd10 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -562,11 +562,9 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, 
struct rxe_av *av,
 
pkt->rxe= rxe;
pkt->port_num   = port_num;
-   pkt->hdr= skb_put(skb, paylen);
+   pkt->hdr= skb_put_zero(skb, paylen);
pkt->mask   |= RXE_GRH_MASK;
 
-   memset(pkt->hdr, 0, paylen);
-
dev_put(ndev);
return skb;
 }
-- 
2.7.0




[PATCH net-next] can: dev: use skb_put_zero to simplfy code

2018-04-28 Thread YueHaibing
use helper skb_put_zero to replace the pattern of skb_put() && memset()

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/can/dev.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index b177956..d8140a9 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -649,8 +649,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, 
struct can_frame **cf)
can_skb_prv(skb)->ifindex = dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;
 
-   *cf = skb_put(skb, sizeof(struct can_frame));
-   memset(*cf, 0, sizeof(struct can_frame));
+   *cf = skb_put_zero(skb, sizeof(struct can_frame));
 
return skb;
 }
@@ -678,8 +677,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
can_skb_prv(skb)->ifindex = dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;
 
-   *cfd = skb_put(skb, sizeof(struct canfd_frame));
-   memset(*cfd, 0, sizeof(struct canfd_frame));
+   *cfd = skb_put_zero(skb, sizeof(struct canfd_frame));
 
return skb;
 }
-- 
2.7.0




[PATCH net-next] net: stmmac: Remove useless test before clk_disable_unprepare

2018-05-16 Thread YueHaibing
clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 13133b3..f08625a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1104,30 +1104,20 @@ static int gmac_clk_enable(struct rk_priv_data 
*bsp_priv, bool enable)
} else {
if (bsp_priv->clk_enabled) {
if (phy_iface == PHY_INTERFACE_MODE_RMII) {
-   if (!IS_ERR(bsp_priv->mac_clk_rx))
-   clk_disable_unprepare(
-   bsp_priv->mac_clk_rx);
+   clk_disable_unprepare(bsp_priv->mac_clk_rx);
 
-   if (!IS_ERR(bsp_priv->clk_mac_ref))
-   clk_disable_unprepare(
-   bsp_priv->clk_mac_ref);
+   clk_disable_unprepare(bsp_priv->clk_mac_ref);
 
-   if (!IS_ERR(bsp_priv->clk_mac_refout))
-   clk_disable_unprepare(
-   bsp_priv->clk_mac_refout);
+   clk_disable_unprepare(bsp_priv->clk_mac_refout);
}
 
-   if (!IS_ERR(bsp_priv->clk_phy))
-   clk_disable_unprepare(bsp_priv->clk_phy);
+   clk_disable_unprepare(bsp_priv->clk_phy);
 
-   if (!IS_ERR(bsp_priv->aclk_mac))
-   clk_disable_unprepare(bsp_priv->aclk_mac);
+   clk_disable_unprepare(bsp_priv->aclk_mac);
 
-   if (!IS_ERR(bsp_priv->pclk_mac))
-   clk_disable_unprepare(bsp_priv->pclk_mac);
+   clk_disable_unprepare(bsp_priv->pclk_mac);
 
-   if (!IS_ERR(bsp_priv->mac_clk_tx))
-   clk_disable_unprepare(bsp_priv->mac_clk_tx);
+   clk_disable_unprepare(bsp_priv->mac_clk_tx);
/**
 * if (!IS_ERR(bsp_priv->clk_mac))
 *  clk_disable_unprepare(bsp_priv->clk_mac);
-- 
2.7.0




[PATCH net-next] net: ethoc: Remove useless test before clk_disable_unprepare

2018-05-16 Thread YueHaibing
clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/ethoc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 8bb0db9..00a5727 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1246,8 +1246,7 @@ static int ethoc_probe(struct platform_device *pdev)
mdiobus_unregister(priv->mdio);
mdiobus_free(priv->mdio);
 free2:
-   if (priv->clk)
-   clk_disable_unprepare(priv->clk);
+   clk_disable_unprepare(priv->clk);
 free:
free_netdev(netdev);
 out:
@@ -1271,8 +1270,7 @@ static int ethoc_remove(struct platform_device *pdev)
mdiobus_unregister(priv->mdio);
mdiobus_free(priv->mdio);
}
-   if (priv->clk)
-   clk_disable_unprepare(priv->clk);
+   clk_disable_unprepare(priv->clk);
unregister_netdev(netdev);
free_netdev(netdev);
}
-- 
2.7.0




Re: [PATCH] bpf: check NULL for sk_to_full_sk()

2018-05-21 Thread YueHaibing
On 2018/5/21 23:17, Eric Dumazet wrote:
> 
> 
> On 05/21/2018 12:55 AM, YueHaibing wrote:
>> like commit df39a9f106d5 ("bpf: check NULL for sk_to_full_sk() return 
>> value"),
>> we should check sk_to_full_sk return value against NULL.
>>
>> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
>> ---
>>  include/linux/bpf-cgroup.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
>> index 30d15e6..fd3fbeb 100644
>> --- a/include/linux/bpf-cgroup.h
>> +++ b/include/linux/bpf-cgroup.h
>> @@ -91,7 +91,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 
>> major, u32 minor,
>>  int __ret = 0; \
>>  if (cgroup_bpf_enabled && sk && sk == skb->sk) {   \
>>  typeof(sk) __sk = sk_to_full_sk(sk);   \
>> -if (sk_fullsock(__sk)) \
>> +if (__sk && sk_fullsock(__sk)) \
>>  __ret = __cgroup_bpf_run_filter_skb(__sk, skb, \
>>BPF_CGROUP_INET_EGRESS); \
>>  }  \
>>
> 
> Why is this needed ???

BPF_CGROUP_RUN_PROG_INET_EGRESS is called in ip_output

I just misunderstood, sorry for noise.
> 
> 



[PATCH] netfilter: uapi: includes linux/types.h

2018-05-23 Thread YueHaibing
gcc-7.3.0 report following warning:
./usr/include/linux/netfilter/nf_osf.h:27: found __[us]{8,16,32,64} type 
without #include 

includes linux/types.h to fix it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 include/uapi/linux/netfilter/nf_osf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/netfilter/nf_osf.h 
b/include/uapi/linux/netfilter/nf_osf.h
index 45376ea..d1dbe00 100644
--- a/include/uapi/linux/netfilter/nf_osf.h
+++ b/include/uapi/linux/netfilter/nf_osf.h
@@ -1,6 +1,8 @@
 #ifndef _NF_OSF_H
 #define _NF_OSF_H
 
+#include 
+
 #define MAXGENRELEN32
 
 #define NF_OSF_GENRE   (1 << 0)
-- 
2.7.0




[PATCH net-next] bpfilter: fix a build err

2018-05-25 Thread YueHaibing
gcc-7.3.0 report following err:

  HOSTCC  net/bpfilter/main.o
In file included from net/bpfilter/main.c:9:0:
./include/uapi/linux/bpf.h:12:10: fatal error: linux/bpf_common.h: No such file 
or directory
 #include 

remove it by adding a include path.
Fixes: d2ba09c17a06 ("net: add skeleton of bpfilter kernel module")

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 net/bpfilter/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index 2af752c..3f3cb87 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -5,7 +5,7 @@
 
 hostprogs-y := bpfilter_umh
 bpfilter_umh-objs := main.o
-HOSTCFLAGS += -I. -Itools/include/
+HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
 ifeq ($(CONFIG_BPFILTER_UMH), y)
 # builtin bpfilter_umh should be compiled with -static
 # since rootfs isn't mounted at the time of __init
-- 
2.7.0




Re: [PATCH net-next] bpfilter: fix a build err

2018-05-25 Thread YueHaibing
On 2018/5/26 0:19, Alexei Starovoitov wrote:
> On Fri, May 25, 2018 at 06:17:57PM +0800, YueHaibing wrote:
>> gcc-7.3.0 report following err:
>>
>>   HOSTCC  net/bpfilter/main.o
>> In file included from net/bpfilter/main.c:9:0:
>> ./include/uapi/linux/bpf.h:12:10: fatal error: linux/bpf_common.h: No such 
>> file or directory
>>  #include 
>>
>> remove it by adding a include path.
>> Fixes: d2ba09c17a06 ("net: add skeleton of bpfilter kernel module")
>>
>> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
>> ---
>>  net/bpfilter/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
>> index 2af752c..3f3cb87 100644
>> --- a/net/bpfilter/Makefile
>> +++ b/net/bpfilter/Makefile
>> @@ -5,7 +5,7 @@
>>  
>>  hostprogs-y := bpfilter_umh
>>  bpfilter_umh-objs := main.o
>> -HOSTCFLAGS += -I. -Itools/include/
>> +HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
> 
> Strangely I don't see this error with gcc 7.3
> I've tried this patch and it doesn't hurt,
> but before it gets applied could you please try
> the top two patches from this tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/?h=ipt_bpf
> in your environment?
> These two patches add the actual meat of bpfilter and I'd like
> to make sure the build setup is good for everyone before
> we proceed too far.

after applied these two patches on net-next, the err still here:
 bpfilter: rough bpfilter codegen example hack
 bpfilter: add iptable get/set parsing

  HOSTCC  net/bpfilter/main.o
In file included from net/bpfilter/main.c:13:0:
./include/uapi/linux/bpf.h:12:10: fatal error: linux/bpf_common.h: No such file 
or directory
 #include 
  ^~~~
compilation terminated.
make[2]: *** [net/bpfilter/main.o] Error 1
make[1]: *** [net/bpfilter] Error 2
make: *** [net] Error 2

Also I compile your tree, error is same

my gcc version info as follow:
[root@localhost net-next]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/yuehb/gcc-7.3.0-tools/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-7.3.0/configure --enable-checking=release 
--enable-languages=c,c++
--disable-multilib --prefix=/home/yuehb/gcc-7.3.0-tools
Thread model: posix
gcc version 7.3.0 (GCC)

> 
> 
> .
> 



[PATCH net-next] net: remove unnecessary genlmsg_cancel() calls

2018-05-26 Thread YueHaibing
the message be freed immediately, no need to trim it
back to the previous size.

Inspired by commit 7a9b3ec1e19f ("nl80211: remove unnecessary genlmsg_cancel() 
calls")

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/team/team.c   |  2 --
 drivers/net/wireless/mac80211_hwsim.c |  1 -
 net/core/devlink.c|  4 
 net/ipv6/seg6.c   |  1 -
 net/ncsi/ncsi-netlink.c   |  1 -
 net/nfc/netlink.c | 17 -
 6 files changed, 26 deletions(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index e6730a0..267dcc9 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2426,7 +2426,6 @@ static int team_nl_send_options_get(struct team *team, 
u32 portid, u32 seq,
 nla_put_failure:
err = -EMSGSIZE;
 errout:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
@@ -2720,7 +2719,6 @@ static int team_nl_send_port_list_get(struct team *team, 
u32 portid, u32 seq,
 nla_put_failure:
err = -EMSGSIZE;
 errout:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index c26469b..38e1135 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2514,7 +2514,6 @@ static void hwsim_mcast_new_radio(int id, struct 
genl_info *info,
return;
 
 out_err:
-   genlmsg_cancel(mcast_skb, data);
nlmsg_free(mcast_skb);
 }
 
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 475246b..f75ee02 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1826,7 +1826,6 @@ static int devlink_dpipe_tables_fill(struct genl_info 
*info,
 nla_put_failure:
err = -EMSGSIZE;
 err_table_put:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
@@ -2032,7 +2031,6 @@ int devlink_dpipe_entry_ctx_prepare(struct 
devlink_dpipe_dump_ctx *dump_ctx)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(dump_ctx->skb, dump_ctx->hdr);
nlmsg_free(dump_ctx->skb);
return -EMSGSIZE;
 }
@@ -2249,7 +2247,6 @@ static int devlink_dpipe_headers_fill(struct genl_info 
*info,
 nla_put_failure:
err = -EMSGSIZE;
 err_table_put:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
@@ -2551,7 +2548,6 @@ static int devlink_resource_fill(struct genl_info *info,
err = -EMSGSIZE;
 err_resource_put:
 err_skb_send_alloc:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index 7f5621d..0fdf2a5 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -226,7 +226,6 @@ static int seg6_genl_get_tunsrc(struct sk_buff *skb, struct 
genl_info *info)
 
 nla_put_failure:
rcu_read_unlock();
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -ENOMEM;
diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
index b09ef77..99f4c22 100644
--- a/net/ncsi/ncsi-netlink.c
+++ b/net/ncsi/ncsi-netlink.c
@@ -201,7 +201,6 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct 
genl_info *info)
return genlmsg_reply(skb, info);
 
 err:
-   genlmsg_cancel(skb, hdr);
kfree_skb(skb);
return rc;
 }
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index f018eaf..376181c 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -206,7 +206,6 @@ int nfc_genl_targets_found(struct nfc_dev *dev)
return genlmsg_multicast(_genl_family, msg, 0, 0, GFP_ATOMIC);
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -237,7 +236,6 @@ int nfc_genl_target_lost(struct nfc_dev *dev, u32 
target_idx)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -269,7 +267,6 @@ int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -299,7 +296,6 @@ int nfc_genl_tm_deactivated(struct nfc_dev *dev)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -340,7 +336,6 @@ int nfc_genl_device_added(struct nfc_dev *dev)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -370,7 +365,6 @@ int nfc_genl_device_removed(struct nfc_dev *dev)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -434,8 +428,6 @@ int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct 
hlist_head *sdres_list)
return genlmsg_multicast(_genl_family, msg, 0, 0, GFP_AT

Re: [PATCH net-next] cxgb4: Check for kvzalloc allocation failure

2018-05-24 Thread YueHaibing
On 2018/5/24 23:07, David Miller wrote:
> From: YueHaibing <yuehaib...@huawei.com>
> Date: Tue, 22 May 2018 15:07:18 +0800
> 
>> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
>> b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> index 130d1ee..019cffe 100644
>> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> @@ -4135,6 +4135,10 @@ static int adap_init0(struct adapter *adap)
>>   * card
>>   */
>>  card_fw = kvzalloc(sizeof(*card_fw), GFP_KERNEL);
>> +if (!card_fw) {
>> +ret = -ENOMEM;
>> +goto bye;
>> +}
>>  
> 
> On error, this leaks fw_info.

Hi David,

I checked fw_info is an element of fw_info_array,there all members of struct 
fw_info no need free.

It likes this :

static struct fw_info fw_info_array[] = {
{
.chip = CHELSIO_T4,
.fs_name = FW4_CFNAME,
.fw_mod_name = FW4_FNAME,
.fw_hdr = {
.chip = FW_HDR_CHIP_T4,
.fw_ver = __cpu_to_be32(FW_VERSION(T4)),
.intfver_nic = FW_INTFVER(T4, NIC),
.intfver_vnic = FW_INTFVER(T4, VNIC),
.intfver_ri = FW_INTFVER(T4, RI),
.intfver_iscsi = FW_INTFVER(T4, ISCSI),
.intfver_fcoe = FW_INTFVER(T4, FCOE),
},
}, {


Am I missing something?
> 
> .
> 



[PATCH net-next] net: fec: remove stale comment

2018-05-24 Thread YueHaibing
This comment is outdated as fec_ptp_ioctl has been replaced by 
fec_ptp_set/fec_ptp_get 
since commit 1d5244d0e43b ("fec: Implement the SIOCGHWTSTAMP ioctl")

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/freescale/fec_ptp.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c 
b/drivers/net/ethernet/freescale/fec_ptp.c
index f814397..d438ef8 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -466,12 +466,6 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
return -EOPNOTSUPP;
 }
 
-/**
- * fec_ptp_hwtstamp_ioctl - control hardware time stamping
- * @ndev: pointer to net_device
- * @ifreq: ioctl data
- * @cmd: particular ioctl requested
- */
 int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr)
 {
struct fec_enet_private *fep = netdev_priv(ndev);
-- 
2.7.0




[PATCH net-next] vmxnet3: Replace msleep(1) with usleep_range()

2018-05-16 Thread YueHaibing
As documented in Documentation/timers/timers-howto.txt,
replace msleep(1) with usleep_range().

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 6 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 9ebe2a6..2234a33 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2945,7 +2945,7 @@ vmxnet3_close(struct net_device *netdev)
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
vmxnet3_quiesce_dev(adapter);
 
@@ -2995,7 +2995,7 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
if (netif_running(netdev)) {
vmxnet3_quiesce_dev(adapter);
@@ -3567,7 +3567,7 @@ static void vmxnet3_shutdown_device(struct pci_dev *pdev)
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
if (test_and_set_bit(VMXNET3_STATE_BIT_QUIESCED,
 >state)) {
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c 
b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 2ff2731..559db05 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -600,7 +600,7 @@ vmxnet3_set_ringparam(struct net_device *netdev,
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
if (netif_running(netdev)) {
vmxnet3_quiesce_dev(adapter);
-- 
2.7.0




[PATCH] bpf: check NULL for sk_to_full_sk()

2018-05-21 Thread YueHaibing
like commit df39a9f106d5 ("bpf: check NULL for sk_to_full_sk() return value"),
we should check sk_to_full_sk return value against NULL.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 include/linux/bpf-cgroup.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 30d15e6..fd3fbeb 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -91,7 +91,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 
major, u32 minor,
int __ret = 0; \
if (cgroup_bpf_enabled && sk && sk == skb->sk) {   \
typeof(sk) __sk = sk_to_full_sk(sk);   \
-   if (sk_fullsock(__sk)) \
+   if (__sk && sk_fullsock(__sk)) \
__ret = __cgroup_bpf_run_filter_skb(__sk, skb, \
  BPF_CGROUP_INET_EGRESS); \
}  \
-- 
2.7.0




[PATCH net-next] cxgb4: Check for kvzalloc allocation failure

2018-05-22 Thread YueHaibing
t4_prep_fw doesn't check for card_fw pointer before store the read data,
which could lead to a NULL pointer dereference if kvzalloc failed.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 130d1ee..019cffe 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4135,6 +4135,10 @@ static int adap_init0(struct adapter *adap)
 * card
 */
card_fw = kvzalloc(sizeof(*card_fw), GFP_KERNEL);
+   if (!card_fw) {
+   ret = -ENOMEM;
+   goto bye;
+   }
 
/* Get FW from from /lib/firmware/ */
ret = request_firmware(, fw_info->fw_mod_name,
-- 
2.7.0




[PATCH net] net: qcom/emac: Add missing of_node_put()

2018-06-11 Thread YueHaibing
Add missing of_node_put() call for device node returned by
of_parse_phandle().

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c 
b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index e78e5db..c694e34 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -384,6 +384,7 @@ int emac_sgmii_config(struct platform_device *pdev, struct 
emac_adapter *adpt)
}
 
sgmii_pdev = of_find_device_by_node(np);
+   of_node_put(np);
if (!sgmii_pdev) {
dev_err(>dev, "invalid internal-phy property\n");
return -ENODEV;
-- 
2.7.0




[PATCH bpf-next] bpf: hide the unused 'off' variable

2018-05-28 Thread YueHaibing
The local variable is only used while CONFIG_IPV6 enabled

net/core/filter.c: In function ‘sk_msg_convert_ctx_access’:
net/core/filter.c:6489:6: warning: unused variable ‘off’ [-Wunused-variable]
  int off;
  ^
This puts it into #ifdef.

Fixes: 303def35f64e ("bpf: allow sk_msg programs to read sock fields")
Signed-off-by: YueHaibing 
---
 net/core/filter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 24e6ce8..0ce93ed 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -6486,7 +6486,9 @@ static u32 sk_msg_convert_ctx_access(enum bpf_access_type 
type,
 struct bpf_prog *prog, u32 *target_size)
 {
struct bpf_insn *insn = insn_buf;
+#if IS_ENABLED(CONFIG_IPV6)
int off;
+#endif
 
switch (si->off) {
case offsetof(struct sk_msg_md, data):
-- 
2.7.0




[PATCH net-next] net: qcom/emac: fix unused variable

2018-05-29 Thread YueHaibing
When CONFIG_ACPI isn't set, variable qdf2400_ops/qdf2432_ops isn't used.
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c:284:25: warning: ‘qdf2400_ops’ 
defined but not used [-Wunused-variable]
 static struct sgmii_ops qdf2400_ops = {
 ^~~
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c:276:25: warning: ‘qdf2432_ops’ 
defined but not used [-Wunused-variable]
 static struct sgmii_ops qdf2432_ops = {
 ^~~

Move the declaration and functions inside the CONFIG_ACPI ifdef 
to fix the warning.
Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c 
b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index 562420b..15609cb 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -108,6 +108,7 @@ static void emac_sgmii_link_init(struct emac_adapter *adpt)
writel(val, phy->base + EMAC_SGMII_PHY_AUTONEG_CFG2);
 }
 
+#ifdef CONFIG_ACPI
 static int emac_sgmii_irq_clear(struct emac_adapter *adpt, u8 irq_bits)
 {
struct emac_sgmii *phy = >phy;
@@ -291,7 +292,6 @@ static struct sgmii_ops qdf2400_ops = {
 
 static int emac_sgmii_acpi_match(struct device *dev, void *data)
 {
-#ifdef CONFIG_ACPI
static const struct acpi_device_id match_table[] = {
{
.id = "QCOM8071",
@@ -327,10 +327,16 @@ static int emac_sgmii_acpi_match(struct device *dev, void 
*data)
return 1;
}
}
-#endif
 
return 0;
 }
+#else
+static int emac_sgmii_acpi_match(struct device *dev, void *data)
+{
+   return 0;
+}
+
+#endif
 
 static const struct of_device_id emac_sgmii_dt_match[] = {
{
-- 
2.7.0




[PATCH] IB/hns: Use zeroing memory allocator instead of allocator/memset

2018-06-03 Thread YueHaibing
Use dma_zalloc_coherent for allocating zeroed memory and
remove unnecessary memset function.

Signed-off-by: YueHaibing 
---
 drivers/infiniband/hw/hns/hns_roce_alloc.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c 
b/drivers/infiniband/hw/hns/hns_roce_alloc.c
index a40ec93..46f65f9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
+++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
@@ -197,7 +197,8 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 
size, u32 max_direct,
buf->npages = 1 << order;
buf->page_shift = page_shift;
/* MTT PA must be recorded in 4k alignment, t is 4k aligned */
-   buf->direct.buf = dma_alloc_coherent(dev, size, , GFP_KERNEL);
+   buf->direct.buf = dma_zalloc_coherent(dev,
+ size, , GFP_KERNEL);
if (!buf->direct.buf)
return -ENOMEM;
 
@@ -207,8 +208,6 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 
size, u32 max_direct,
--buf->page_shift;
buf->npages *= 2;
}
-
-   memset(buf->direct.buf, 0, size);
} else {
buf->nbufs = (size + page_size - 1) / page_size;
buf->npages = buf->nbufs;
@@ -220,7 +219,7 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 
size, u32 max_direct,
return -ENOMEM;
 
for (i = 0; i < buf->nbufs; ++i) {
-   buf->page_list[i].buf = dma_alloc_coherent(dev,
+   buf->page_list[i].buf = dma_zalloc_coherent(dev,
  page_size, ,
  GFP_KERNEL);
 
@@ -228,7 +227,6 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 
size, u32 max_direct,
goto err_free;
 
buf->page_list[i].map = t;
-   memset(buf->page_list[i].buf, 0, page_size);
}
}
 
-- 
2.7.0




[PATCH] ath10k: use dma_zalloc_coherent instead of allocator/memset

2018-06-04 Thread YueHaibing
Use dma_zalloc_coherent instead of dma_alloc_coherent
followed by memset 0.

Signed-off-by: YueHaibing 
---
 drivers/net/wireless/ath/ath10k/wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index f97ab79..72db3bd 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -5018,13 +5018,11 @@ static int ath10k_wmi_alloc_chunk(struct ath10k *ar, 
u32 req_id,
void *vaddr;
 
pool_size = num_units * round_up(unit_len, 4);
-   vaddr = dma_alloc_coherent(ar->dev, pool_size, , GFP_KERNEL);
+   vaddr = dma_zalloc_coherent(ar->dev, pool_size, , GFP_KERNEL);
 
if (!vaddr)
return -ENOMEM;
 
-   memset(vaddr, 0, pool_size);
-
ar->wmi.mem_chunks[idx].vaddr = vaddr;
ar->wmi.mem_chunks[idx].paddr = paddr;
ar->wmi.mem_chunks[idx].len = pool_size;
-- 
2.7.0




[PATCH net-next] net: fddi: fix a possible null-ptr-deref

2018-06-05 Thread YueHaibing
bp->SharedMemAddr is set to NULL while bp->SharedMemSize less than 0,
then memset will trigger null-ptr-deref.

Fix it use pci_zalloc_consistent when bp->SharedMemSize is greater than 0.

Signed-off-by: YueHaibing 
---
 drivers/net/fddi/skfp/skfddi.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fddi/skfp/skfddi.c b/drivers/net/fddi/skfp/skfddi.c
index 2414f1d..90164e0 100644
--- a/drivers/net/fddi/skfp/skfddi.c
+++ b/drivers/net/fddi/skfp/skfddi.c
@@ -407,23 +407,21 @@ static  int skfp_driver_init(struct net_device *dev)
if (bp->SharedMemSize > 0) {
bp->SharedMemSize += 16;// for descriptor alignment
 
-   bp->SharedMemAddr = pci_alloc_consistent(>pdev,
-bp->SharedMemSize,
->SharedMemDMA);
+   bp->SharedMemAddr = pci_zalloc_consistent(>pdev,
+ bp->SharedMemSize,
+ >SharedMemDMA);
if (!bp->SharedMemAddr) {
printk("could not allocate mem for ");
printk("hardware module: %ld byte\n",
   bp->SharedMemSize);
goto fail;
}
-   bp->SharedMemHeap = 0;  // Nothing used yet.
 
} else {
bp->SharedMemAddr = NULL;
-   bp->SharedMemHeap = 0;
}   // SharedMemSize > 0
 
-   memset(bp->SharedMemAddr, 0, bp->SharedMemSize);
+   bp->SharedMemHeap = 0;
 
card_stop(smc); // Reset adapter.
 
-- 
2.7.0




Re: [PATCH net-next 0/6] use pci_zalloc_consistent

2018-06-05 Thread YueHaibing
On 2018/6/5 20:46, Andy Shevchenko wrote:
> On Tue, Jun 5, 2018 at 3:49 PM, Christoph Hellwig  wrote:
>> On Tue, Jun 05, 2018 at 03:39:16PM +0300, Andy Shevchenko wrote:
>>> On Tue, Jun 5, 2018 at 3:28 PM, YueHaibing  wrote:
>>>>
>>>
>>> Hmm... Is PCI case anyhow special or it's a simple wrapper on top of
>>> dma.*alloc() ?
>>
>> All drivers should move from pci_dma* to dma_* eventually.  Converting
>> from one flavor of deprecated to another is completely pointless.
> 
> Exactly my impression. Thanks, Christoph for clarification.
> 
> YueHaibing, care to follow what Christoph said and change your series
> accordingly?

ok, will send v2
> 



[PATCH] iommu/io-pgtable-arm: Use for_each_set_bit to simplify code

2018-04-25 Thread YueHaibing
We can use for_each_set_bit() to simplify code slightly in the
ARM io-pgtable self tests while unmapping.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/iommu/io-pgtable-arm-v7s.c | 5 +
 drivers/iommu/io-pgtable-arm.c | 5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/io-pgtable-arm-v7s.c 
b/drivers/iommu/io-pgtable-arm-v7s.c
index 10e4a3d..50e3a9f 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -898,8 +898,7 @@ static int __init arm_v7s_do_selftests(void)
 
/* Full unmap */
iova = 0;
-   i = find_first_bit(_bitmap, BITS_PER_LONG);
-   while (i != BITS_PER_LONG) {
+   for_each_set_bit(i, _bitmap, BITS_PER_LONG) {
size = 1UL << i;
 
if (ops->unmap(ops, iova, size) != size)
@@ -916,8 +915,6 @@ static int __init arm_v7s_do_selftests(void)
return __FAIL(ops);
 
iova += SZ_16M;
-   i++;
-   i = find_next_bit(_bitmap, BITS_PER_LONG, i);
}
 
free_io_pgtable_ops(ops);
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 39c2a05..4ffdd88 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -1120,8 +1120,7 @@ static int __init arm_lpae_run_tests(struct 
io_pgtable_cfg *cfg)
 
/* Full unmap */
iova = 0;
-   j = find_first_bit(>pgsize_bitmap, BITS_PER_LONG);
-   while (j != BITS_PER_LONG) {
+   for_each_set_bit(j, >pgsize_bitmap, BITS_PER_LONG) {
size = 1UL << j;
 
if (ops->unmap(ops, iova, size) != size)
@@ -1138,8 +1137,6 @@ static int __init arm_lpae_run_tests(struct 
io_pgtable_cfg *cfg)
return __FAIL(ops, i);
 
iova += SZ_1G;
-   j++;
-   j = find_next_bit(>pgsize_bitmap, BITS_PER_LONG, 
j);
}
 
free_io_pgtable_ops(ops);
-- 
2.7.0




[PATCH] ARM: dmabounce: remove unnecessary NULL check before dma_pool_destroy

2018-08-03 Thread YueHaibing
dma_pool_destroy will do NULL check,thus the check before
the call is not needed.

Signed-off-by: YueHaibing 
---
 arch/arm/common/dmabounce.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 9a92de6..dcdd80c 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -569,10 +569,8 @@ void dmabounce_unregister_dev(struct device *dev)
BUG();
}
 
-   if (device_info->small.pool)
-   dma_pool_destroy(device_info->small.pool);
-   if (device_info->large.pool)
-   dma_pool_destroy(device_info->large.pool);
+   dma_pool_destroy(device_info->small.pool);
+   dma_pool_destroy(device_info->large.pool);
 
 #ifdef STATS
if (device_info->attr_res == 0)
-- 
2.7.0




[PATCH] um: NULL check before kfree is not needed

2018-08-03 Thread YueHaibing
kfree(NULL) is safe,so this removes NULL check before freeing the mem

Signed-off-by: YueHaibing 
---
 arch/um/drivers/vector_kern.c | 15 +--
 arch/um/drivers/vector_user.c |  6 ++
 arch/um/kernel/irq.c  |  3 +--
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 50ee3bb..c84133c 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1118,16 +1118,11 @@ static int vector_net_close(struct net_device *dev)
os_close_file(vp->fds->tx_fd);
vp->fds->tx_fd = -1;
}
-   if (vp->bpf != NULL)
-   kfree(vp->bpf);
-   if (vp->fds->remote_addr != NULL)
-   kfree(vp->fds->remote_addr);
-   if (vp->transport_data != NULL)
-   kfree(vp->transport_data);
-   if (vp->header_rxbuffer != NULL)
-   kfree(vp->header_rxbuffer);
-   if (vp->header_txbuffer != NULL)
-   kfree(vp->header_txbuffer);
+   kfree(vp->bpf);
+   kfree(vp->fds->remote_addr);
+   kfree(vp->transport_data);
+   kfree(vp->header_rxbuffer);
+   kfree(vp->header_txbuffer);
if (vp->rx_queue != NULL)
destroy_queue(vp->rx_queue);
if (vp->tx_queue != NULL)
diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
index 4d6a78e..3d8cdbd 100644
--- a/arch/um/drivers/vector_user.c
+++ b/arch/um/drivers/vector_user.c
@@ -267,8 +267,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist 
*ifspec)
os_close_file(rxfd);
if (txfd >= 0)
os_close_file(txfd);
-   if (result != NULL)
-   kfree(result);
+   kfree(result);
return NULL;
 }
 
@@ -434,8 +433,7 @@ static struct vector_fds *user_init_socket_fds(struct 
arglist *ifspec, int id)
if (fd >= 0)
os_close_file(fd);
if (result != NULL) {
-   if (result->remote_addr != NULL)
-   kfree(result->remote_addr);
+   kfree(result->remote_addr);
kfree(result);
}
return NULL;
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 6b7f382..8360fa3 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -244,8 +244,7 @@ static void garbage_collect_irq_entries(void)
to_free = NULL;
}
walk = walk->next;
-   if (to_free != NULL)
-   kfree(to_free);
+   kfree(to_free);
}
 }
 
-- 
2.7.0




Re: [PATCH 03/10] atmel: hide unused procfs helpers

2018-07-27 Thread YueHaibing
On 2018/7/27 17:24, Kalle Valo wrote:
> (fixing top posting)
> 
> YueHaibing  writes:
> 
>> On 2018/7/13 14:46, YueHaibing wrote:
>>> When CONFIG_PROC_FS isn't set, gcc warning this:
>>>
>>> drivers/net/wireless/atmel/atmel.c:1402:12: warning: ‘atmel_proc_show’ 
>>> defined but not used [-Wunused-function]
>>>  static int atmel_proc_show(struct seq_file *m, void *v)
>>>     ^
>>> fix this by adding #ifdef around it.
>>>
>>> Signed-off-by: YueHaibing 
>>
>> pls ignore this,my bad.
> 
> Why should I drop this? Does the patch have something wrong which I'm
> missing?

No,the patch is ok,just because I find this issue has a fix patch from Randy.

> 
> I'm asking because I prefer this over Randy's version:
> 
> https://patchwork.kernel.org/patch/10512913/
> 



[PATCH] pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state

2018-07-31 Thread YueHaibing
fixes following Smatch static check warning:

 drivers/pinctrl/berlin/berlin.c:237 berlin_pinctrl_build_state()
 warn: passing devm_ allocated variable to kfree. 'pctrl->functions'

As we will be calling krealloc() on pointer 'pctrl->functions', which means
kfree() will be called in there, devm_kzalloc() shouldn't be used with
the allocation in the first place.  Fix the warning by calling kcalloc()
and managing the free procedure in error path on our own.

Fixes: 3de68d331c24 ("pinctrl: berlin: add the core pinctrl driver for Marvell 
Berlin SoCs")
Signed-off-by: YueHaibing 
---
 drivers/pinctrl/berlin/berlin.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index d6d183e..db2afb2 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -216,10 +216,8 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
}
 
/* we will reallocate later */
-   pctrl->functions = devm_kcalloc(>dev,
-   max_functions,
-   sizeof(*pctrl->functions),
-   GFP_KERNEL);
+   pctrl->functions = kcalloc(max_functions,
+  sizeof(*pctrl->functions), GFP_KERNEL);
if (!pctrl->functions)
return -ENOMEM;
 
@@ -257,8 +255,10 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
function++;
}
 
-   if (!found)
+   if (!found) {
+   kfree(function);
return -EINVAL;
+   }
 
if (!function->groups) {
function->groups =
@@ -267,8 +267,10 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
 sizeof(char *),
 GFP_KERNEL);
 
-   if (!function->groups)
+   if (!function->groups) {
+   kfree(function);
return -ENOMEM;
+   }
}
 
groups = function->groups;
-- 
2.7.0




Re: [PATCH v2] pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state

2018-07-31 Thread YueHaibing
Sorry, I send a wrong patch, pls ignore this.

On 2018/8/1 13:02, YueHaibing wrote:
> fixes following Smatch static check warning:
> 
>  drivers/pinctrl/berlin/berlin.c:237 berlin_pinctrl_build_state()
>  warn: passing devm_ allocated variable to kfree. 'pctrl->functions'
> 
> As we will be calling krealloc() on pointer 'pctrl->functions', which means
> kfree() will be called in there, devm_kzalloc() shouldn't be used with
> the allocation in the first place.  Fix the warning by calling kcalloc()
> and managing the free procedure in error path on our own.
> 
> Fixes: 3de68d331c24 ("pinctrl: berlin: add the core pinctrl driver for 
> Marvell Berlin SoCs")
> Signed-off-by: YueHaibing 
> ---
> v2: free pctrl->functions instead of function as Jisheng Zhang suggested
> ---
>  drivers/pinctrl/berlin/berlin.c | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
> index d6d183e..b5903ff 100644
> --- a/drivers/pinctrl/berlin/berlin.c
> +++ b/drivers/pinctrl/berlin/berlin.c
> @@ -216,10 +216,8 @@ static int berlin_pinctrl_build_state(struct 
> platform_device *pdev)
>   }
>  
>   /* we will reallocate later */
> - pctrl->functions = devm_kcalloc(>dev,
> - max_functions,
> - sizeof(*pctrl->functions),
> - GFP_KERNEL);
> + pctrl->functions = kcalloc(max_functions,
> +sizeof(*pctrl->functions), GFP_KERNEL);
>   if (!pctrl->functions)
>   return -ENOMEM;
>  
> @@ -257,8 +255,10 @@ static int berlin_pinctrl_build_state(struct 
> platform_device *pdev)
>   function++;
>   }
>  
> - if (!found)
> + if (!found) {
> + kfree( );
>   return -EINVAL;
> + }
>  
>   if (!function->groups) {
>   function->groups =
> @@ -267,8 +267,10 @@ static int berlin_pinctrl_build_state(struct 
> platform_device *pdev)
>sizeof(char *),
>GFP_KERNEL);
>  
> - if (!function->groups)
> + if (!function->groups) {
> + kfree(pctrl->functions);
>   return -ENOMEM;
> + }
>   }
>  
>   groups = function->groups;
> 



Re: [PATCH] pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state

2018-07-31 Thread YueHaibing
On 2018/8/1 10:36, Jisheng Zhang wrote:
> Hi,
> 
> On Tue, 31 Jul 2018 22:25:01 +0800 YueHaibing wrote:
> 
>> fixes following Smatch static check warning:
>>
>>  drivers/pinctrl/berlin/berlin.c:237 berlin_pinctrl_build_state()
>>  warn: passing devm_ allocated variable to kfree. 'pctrl->functions'
>>
>> As we will be calling krealloc() on pointer 'pctrl->functions', which means
>> kfree() will be called in there, devm_kzalloc() shouldn't be used with
>> the allocation in the first place.  Fix the warning by calling kcalloc()
>> and managing the free procedure in error path on our own.
> 
> Good catch. Comments below.
> 
>>
>> Fixes: 3de68d331c24 ("pinctrl: berlin: add the core pinctrl driver for 
>> Marvell Berlin SoCs")
>> Signed-off-by: YueHaibing 
>> ---
>>  drivers/pinctrl/berlin/berlin.c | 14 --
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/pinctrl/berlin/berlin.c 
>> b/drivers/pinctrl/berlin/berlin.c
>> index d6d183e..db2afb2 100644
>> --- a/drivers/pinctrl/berlin/berlin.c
>> +++ b/drivers/pinctrl/berlin/berlin.c
>> @@ -216,10 +216,8 @@ static int berlin_pinctrl_build_state(struct 
>> platform_device *pdev)
>>  }
>>  
>>  /* we will reallocate later */
>> -pctrl->functions = devm_kcalloc(>dev,
>> -max_functions,
>> -sizeof(*pctrl->functions),
>> -GFP_KERNEL);
>> +pctrl->functions = kcalloc(max_functions,
>> +   sizeof(*pctrl->functions), GFP_KERNEL);
>>  if (!pctrl->functions)
>>  return -ENOMEM;
>>  
>> @@ -257,8 +255,10 @@ static int berlin_pinctrl_build_state(struct 
>> platform_device *pdev)
>>  function++;
>>  }
>>  
>> -if (!found)
>> +if (!found) {
>> +kfree(function);
> 
> is it enough to just free one function? I think we need to free functions.

Yep, should free 'pctrl->functions', Thanks!

Will send v2.

> 
>>  return -EINVAL;
>> +}
>>  
>>  if (!function->groups) {
>>  function->groups =
>> @@ -267,8 +267,10 @@ static int berlin_pinctrl_build_state(struct 
>> platform_device *pdev)
>>   sizeof(char *),
>>   GFP_KERNEL);
>>  
>> -if (!function->groups)
>> +if (!function->groups) {
>> +kfree(function);
> 
> ditto
> 
>>  return -ENOMEM;
>> +}
>>  }
>>  
>>  groups = function->groups;
> 
> 
> 



[PATCH v2] pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state

2018-07-31 Thread YueHaibing
fixes following Smatch static check warning:

 drivers/pinctrl/berlin/berlin.c:237 berlin_pinctrl_build_state()
 warn: passing devm_ allocated variable to kfree. 'pctrl->functions'

As we will be calling krealloc() on pointer 'pctrl->functions', which means
kfree() will be called in there, devm_kzalloc() shouldn't be used with
the allocation in the first place.  Fix the warning by calling kcalloc()
and managing the free procedure in error path on our own.

Fixes: 3de68d331c24 ("pinctrl: berlin: add the core pinctrl driver for Marvell 
Berlin SoCs")
Signed-off-by: YueHaibing 
---
v2: free pctrl->functions instead of function as Jisheng Zhang suggested
---
 drivers/pinctrl/berlin/berlin.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index d6d183e..b5903ff 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -216,10 +216,8 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
}
 
/* we will reallocate later */
-   pctrl->functions = devm_kcalloc(>dev,
-   max_functions,
-   sizeof(*pctrl->functions),
-   GFP_KERNEL);
+   pctrl->functions = kcalloc(max_functions,
+  sizeof(*pctrl->functions), GFP_KERNEL);
if (!pctrl->functions)
return -ENOMEM;
 
@@ -257,8 +255,10 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
function++;
}
 
-   if (!found)
+   if (!found) {
+   kfree( );
return -EINVAL;
+   }
 
if (!function->groups) {
function->groups =
@@ -267,8 +267,10 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
 sizeof(char *),
 GFP_KERNEL);
 
-   if (!function->groups)
+   if (!function->groups) {
+   kfree(pctrl->functions);
return -ENOMEM;
+   }
}
 
groups = function->groups;
-- 
2.7.0




[PATCH v3] pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state

2018-07-31 Thread YueHaibing
fixes following Smatch static check warning:

 drivers/pinctrl/berlin/berlin.c:237 berlin_pinctrl_build_state()
 warn: passing devm_ allocated variable to kfree. 'pctrl->functions'

As we will be calling krealloc() on pointer 'pctrl->functions', which means
kfree() will be called in there, devm_kzalloc() shouldn't be used with
the allocation in the first place.  Fix the warning by calling kcalloc()
and managing the free procedure in error path on our own.

Fixes: 3de68d331c24 ("pinctrl: berlin: add the core pinctrl driver for Marvell 
Berlin SoCs")
Signed-off-by: YueHaibing 
---
v2: free pctrl->functions instead of function as Jisheng Zhang suggested
v3: v2 I send a wrong patch,this is the correct patch.
---
 drivers/pinctrl/berlin/berlin.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index d6d183e..b5903ff 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -216,10 +216,8 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
}
 
/* we will reallocate later */
-   pctrl->functions = devm_kcalloc(>dev,
-   max_functions,
-   sizeof(*pctrl->functions),
-   GFP_KERNEL);
+   pctrl->functions = kcalloc(max_functions,
+  sizeof(*pctrl->functions), GFP_KERNEL);
if (!pctrl->functions)
return -ENOMEM;
 
@@ -257,8 +255,10 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
function++;
}
 
-   if (!found)
+   if (!found) {
+   kfree(pctrl->functions);
return -EINVAL;
+   }
 
if (!function->groups) {
function->groups =
@@ -267,8 +267,10 @@ static int berlin_pinctrl_build_state(struct 
platform_device *pdev)
 sizeof(char *),
 GFP_KERNEL);
 
-   if (!function->groups)
+   if (!function->groups) {
+   kfree(pctrl->functions);
return -ENOMEM;
+   }
}
 
groups = function->groups;
-- 
2.7.0




[PATCH] nds32: add NULL entry to the end of_device_id array

2018-08-06 Thread YueHaibing
Make sure of_device_id tables are NULL terminated.
Found by coccinelle spatch "misc/of_table.cocci"

Signed-off-by: YueHaibing 
---
 arch/nds32/kernel/atl2c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/nds32/kernel/atl2c.c b/arch/nds32/kernel/atl2c.c
index 0c6d031..0c5386e 100644
--- a/arch/nds32/kernel/atl2c.c
+++ b/arch/nds32/kernel/atl2c.c
@@ -9,7 +9,8 @@
 
 void __iomem *atl2c_base;
 static const struct of_device_id atl2c_ids[] __initconst = {
-   {.compatible = "andestech,atl2c",}
+   {.compatible = "andestech,atl2c",},
+   {}
 };
 
 static int __init atl2c_of_init(void)
-- 
2.7.0




[PATCH] kernel: remove duplicated include from sys.c

2018-08-21 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 kernel/sys.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 45dc552..d0281b5 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -71,9 +71,6 @@
 #include 
 #include 
 
-/* Hardening for Spectre-v1 */
-#include 
-
 #include "uid16.h"
 
 #ifndef SET_UNALIGN_CTL
-- 
2.7.0




Re: [PATCH v2] ARM: dma-mapping: always clear allocated buffers

2018-08-21 Thread YueHaibing


Russell, will you pick this patch?

On 2018/7/25 15:13, YueHaibing wrote:
> +CC  Christoph Hellwig 
> 
> On 2018/7/25 15:07, YueHaibing wrote:
>> Sean Wang reported dma_zalloc_coherent doesn't work as expect on his
>> armv7,the allocated mem is not zeroed.The reason is __alloc_from_pool
>> doesn't honor __GFP_ZERO.
>>
>> As commit 6829e274a623 ("arm64: dma-mapping: always clear allocated buffers")
>> has pointed out,buffers allocated by dma_alloc_coherent() are always zeroed
>> on most architectures. some drivers rely on this 'feature'. Allocated buffer
>> might be also exposed to userspace with dma_mmap() call,so clearing it is
>> desired from security point of view to avoid exposing random memory to 
>> userspace.
>>
>> This patch unifies dma_alloc_coherent() behavior on ARM architecture with 
>> other
>> implementations by unconditionally zeroing allocated buffer.Also to fix
>> dma_zalloc_coherent behavior.
>>
>> Reported-by: Sean Wang 
>> Signed-off-by: YueHaibing 
>> Reviewed-by: zhong jiang 
>> ---
>> v2: reference more argument from arm64 commit as Christoph suggested
>> ---
>>  arch/arm/mm/dma-mapping.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>> index 6656647..cf5882f 100644
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -564,6 +564,7 @@ static void *__alloc_from_pool(size_t size, struct page 
>> **ret_page)
>>  
>>  *ret_page = phys_to_page(phys);
>>  ptr = (void *)val;
>> +memset(ptr, 0, size);
>>  }
>>  
>>  return ptr;
>>



[PATCH] x86: use PTR_ERR_OR_ZERO to fix ptr_ret.cocci warning

2018-07-20 Thread YueHaibing
ptr_ret.cocci warnings:
  arch/x86/kernel/pcspeaker.c:12:8-14: WARNING: PTR_ERR_OR_ZERO can be used

use PTR_ERR_OR_ZERO rather than an open-code version to fix this.

Signed-off-by: YueHaibing 
---
 arch/x86/kernel/pcspeaker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/pcspeaker.c b/arch/x86/kernel/pcspeaker.c
index da5190a..4a710ff 100644
--- a/arch/x86/kernel/pcspeaker.c
+++ b/arch/x86/kernel/pcspeaker.c
@@ -9,6 +9,6 @@ static __init int add_pcspkr(void)
 
pd = platform_device_register_simple("pcspkr", -1, NULL, 0);
 
-   return IS_ERR(pd) ? PTR_ERR(pd) : 0;
+   return PTR_ERR_OR_ZERO(pd);
 }
 device_initcall(add_pcspkr);
-- 
2.7.0




Re: [PATCH] ARM: dma-mapping: always clear allocated buffers

2018-07-24 Thread YueHaibing
On 2018/7/25 2:09, Christoph Hellwig wrote:
> On Tue, Jul 24, 2018 at 10:04:35PM +0800, YueHaibing wrote:
>> Sean Wang report dma_zalloc_coherent doesn't work as expect on his
>> armv7,the allocated mem is not zeroed.The reason is __alloc_from_pool
>> doesn't honor __GFP_ZERO.
> 
> Please explain the "why" a little more.  All the explanations are in
> the referenced arm64 commit and should be mentioned here as well.

ok, will send v2.

> 
> .
> 



[PATCH v2] ARM: dma-mapping: always clear allocated buffers

2018-07-25 Thread YueHaibing
Sean Wang reported dma_zalloc_coherent doesn't work as expect on his
armv7,the allocated mem is not zeroed.The reason is __alloc_from_pool
doesn't honor __GFP_ZERO.

As commit 6829e274a623 ("arm64: dma-mapping: always clear allocated buffers")
has pointed out,buffers allocated by dma_alloc_coherent() are always zeroed
on most architectures. some drivers rely on this 'feature'. Allocated buffer
might be also exposed to userspace with dma_mmap() call,so clearing it is
desired from security point of view to avoid exposing random memory to 
userspace.

This patch unifies dma_alloc_coherent() behavior on ARM architecture with other
implementations by unconditionally zeroing allocated buffer.Also to fix
dma_zalloc_coherent behavior.

Reported-by: Sean Wang 
Signed-off-by: YueHaibing 
Reviewed-by: zhong jiang 
---
v2: reference more argument from arm64 commit as Christoph suggested
---
 arch/arm/mm/dma-mapping.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 6656647..cf5882f 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -564,6 +564,7 @@ static void *__alloc_from_pool(size_t size, struct page 
**ret_page)
 
*ret_page = phys_to_page(phys);
ptr = (void *)val;
+   memset(ptr, 0, size);
}
 
return ptr;
-- 
2.7.0




Re: [PATCH v2] ARM: dma-mapping: always clear allocated buffers

2018-07-25 Thread YueHaibing
+CC  Christoph Hellwig 

On 2018/7/25 15:07, YueHaibing wrote:
> Sean Wang reported dma_zalloc_coherent doesn't work as expect on his
> armv7,the allocated mem is not zeroed.The reason is __alloc_from_pool
> doesn't honor __GFP_ZERO.
> 
> As commit 6829e274a623 ("arm64: dma-mapping: always clear allocated buffers")
> has pointed out,buffers allocated by dma_alloc_coherent() are always zeroed
> on most architectures. some drivers rely on this 'feature'. Allocated buffer
> might be also exposed to userspace with dma_mmap() call,so clearing it is
> desired from security point of view to avoid exposing random memory to 
> userspace.
> 
> This patch unifies dma_alloc_coherent() behavior on ARM architecture with 
> other
> implementations by unconditionally zeroing allocated buffer.Also to fix
> dma_zalloc_coherent behavior.
> 
> Reported-by: Sean Wang 
> Signed-off-by: YueHaibing 
> Reviewed-by: zhong jiang 
> ---
> v2: reference more argument from arm64 commit as Christoph suggested
> ---
>  arch/arm/mm/dma-mapping.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 6656647..cf5882f 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -564,6 +564,7 @@ static void *__alloc_from_pool(size_t size, struct page 
> **ret_page)
>  
>   *ret_page = phys_to_page(phys);
>   ptr = (void *)val;
> + memset(ptr, 0, size);
>   }
>  
>   return ptr;
> 



[PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning

2018-07-25 Thread YueHaibing
Fix a static code checker warning:

  net/xfrm/xfrm_policy.c:1836 xfrm_resolve_and_create_bundle() warn: passing 
zero to 'ERR_PTR'

xfrm_tmpl_resolve return 0 just means no xdst found, return NULL
instead of passing zero to ERR_PTR.

Fixes: d809ec895505 ("xfrm: do not assume that template resolving always 
returns xfrms")
Signed-off-by: YueHaibing 
---
 net/xfrm/xfrm_policy.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5f48251..4adbeb2 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1831,7 +1831,10 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy 
**pols, int num_pols,
/* Try to instantiate a bundle */
err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family);
if (err <= 0) {
-   if (err != 0 && err != -EAGAIN)
+   if (err == 0)
+   return NULL;
+
+   if (err != -EAGAIN)
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
return ERR_PTR(err);
}
-- 
2.7.0




[PATCH net-next] tipc: add missing dev_put() on error in tipc_enable_l2_media

2018-07-25 Thread YueHaibing
when tipc_own_id failed to obtain node identity,dev_put should
be call before return -EINVAL.

Fixes: 682cd3cf946b ("tipc: confgiure and apply UDP bearer MTU on running 
links")
Signed-off-by: YueHaibing 
---
 net/tipc/bearer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index fd6d8f1..418f03d 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -395,6 +395,7 @@ int tipc_enable_l2_media(struct net *net, struct 
tipc_bearer *b,
tipc_net_init(net, node_id, 0);
}
if (!tipc_own_id(net)) {
+   dev_put(dev);
pr_warn("Failed to obtain node identity\n");
return -EINVAL;
}
-- 
2.7.0




Re: [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac

2018-07-25 Thread YueHaibing
On 2018/7/25 5:48, Michael Chan wrote:
> On Tue, Jul 24, 2018 at 9:01 AM, Vasundhara Volam
>  wrote:
>> On Tue, Jul 24, 2018 at 1:01 PM, Michael Chan  
>> wrote:
>>>
>>> On Mon, Jul 23, 2018 at 10:24 PM, YueHaibing  wrote:
>>>> Based on the comments,req->l2addr must match the VF MAC address
>>>> if firmware spec >= 1.2.2, mac_ok can be true.
>>>>
>>>> Signed-off-by: YueHaibing 
>>>> ---
>>>>  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-
>>>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 
>>>> b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> index a649108..7925964 100644
>>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> @@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, 
>>>> struct bnxt_vf_info *vf)
>>>> if (ether_addr_equal((const u8 *)req->l2_addr, 
>>>> vf->mac_addr))
>>>> mac_ok = true;
>>>> } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
>>>> -   if (ether_addr_equal((const u8 *)req->l2_addr, 
>>>> vf->vf_mac_addr))
>>>> +   if (ether_addr_equal((const u8 *)req->l2_addr, 
>>>> vf->vf_mac_addr) &&
>>>> +   bp->hwrm_spec_code >= 0x10202)
>>>> mac_ok = true;
>>>
>>> I'm not sure if this is correct.  If firmware spec < 0x10202, the VF
>>> MAC address is not forwarded to the PF and so it doesn't have to match
>>> and mac_ok should still be true.  I think we are missing that
>>> condition with this patch.
>>>
>>> I need to let my colleague Vasundhara comment on this.  She is more
>>> familiar with this logic.
>> Yes Michael, you are right. Also, the plain else condition is to cover
>> a special case to allow VF to modify
>> it's own MAC when PF has not assigned a valid MAC address and HWRM
>> spec code > 0x10202.
> 
> We should combine the "else if" and "else" below into a plain else and
> add some comments to explain the conditions.

Thank you for clarification.

I will send a new patch for this.

> 
>>>
>>>> -   } else if (bp->hwrm_spec_code < 0x10202) {
>>>> -   mac_ok = true;
>>>> -   } else {
>>>> -   mac_ok = true;
>>>> }
>>>> if (mac_ok)
>>>> return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
>>>> --
>>>> 2.7.0
>>>>
>>>>
> 
> .
> 



[PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche

2018-07-25 Thread YueHaibing
The else-if branch and else branch set mac_ok to true similarly,
so combine the two into single else branch.

Aslo add comments to explain the two conditions, which
from Michael Chan and Vasundhara Volam.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index a649108..f560845 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -956,9 +956,13 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, 
struct bnxt_vf_info *vf)
} else if (is_valid_ether_addr(vf->vf_mac_addr)) {
if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
mac_ok = true;
-   } else if (bp->hwrm_spec_code < 0x10202) {
-   mac_ok = true;
} else {
+   /* There are two cases:
+* 1.If firmware spec < 0x10202,VF MAC address is not forwarded
+*   to the PF and so it doesn't have to match
+* 2.Allow VF to modify it's own MAC when PF has not assigned a
+*   valid MAC address and firmware spec >= 0x10202
+*/
mac_ok = true;
}
if (mac_ok)
-- 
2.7.0




[PATCH] cpufreq: qcom-kryo: add NULL entry to the end of_device_id array

2018-07-23 Thread YueHaibing
Make sure of_device_id tables are NULL terminated
Found by coccinelle spatch "misc/of_table.cocci"

Signed-off-by: YueHaibing 
---
 drivers/cpufreq/qcom-cpufreq-kryo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c 
b/drivers/cpufreq/qcom-cpufreq-kryo.c
index 29389ac..efc9a7a 100644
--- a/drivers/cpufreq/qcom-cpufreq-kryo.c
+++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
@@ -183,6 +183,7 @@ static struct platform_driver qcom_cpufreq_kryo_driver = {
 static const struct of_device_id qcom_cpufreq_kryo_match_list[] __initconst = {
{ .compatible = "qcom,apq8096", },
{ .compatible = "qcom,msm8996", },
+   {}
 };
 
 /*
-- 
2.7.0




[PATCH] x86: Use PTR_ERR_OR_ZERO

2018-07-19 Thread YueHaibing
Replace IS_ERR/PTR_ERR

Signed-off-by: YueHaibing 
---
 arch/x86/kernel/pcspeaker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/pcspeaker.c b/arch/x86/kernel/pcspeaker.c
index da5190a..4a710ff 100644
--- a/arch/x86/kernel/pcspeaker.c
+++ b/arch/x86/kernel/pcspeaker.c
@@ -9,6 +9,6 @@ static __init int add_pcspkr(void)
 
pd = platform_device_register_simple("pcspkr", -1, NULL, 0);
 
-   return IS_ERR(pd) ? PTR_ERR(pd) : 0;
+   return PTR_ERR_OR_ZERO(pd);
 }
 device_initcall(add_pcspkr);
-- 
2.7.0




[PATCH] ARM: dma-mapping: always clear allocated buffers

2018-07-24 Thread YueHaibing
Sean Wang report dma_zalloc_coherent doesn't work as expect on his
armv7,the allocated mem is not zeroed.The reason is __alloc_from_pool
doesn't honor __GFP_ZERO.

Like commit 6829e274a623 ("arm64: dma-mapping: always clear allocated buffers")
does,always clear allocated buffers to fix this.

Reported-by: Sean Wang 
Signed-off-by: YueHaibing 
Reviewed-by: zhong jiang 
---
 arch/arm/mm/dma-mapping.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 6656647..cf5882f 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -564,6 +564,7 @@ static void *__alloc_from_pool(size_t size, struct page 
**ret_page)
 
*ret_page = phys_to_page(phys);
ptr = (void *)val;
+   memset(ptr, 0, size);
}
 
return ptr;
-- 
2.7.0




[PATCH rdma-next] RDMA/qedr: remove set but not used variable 'ctx'

2018-08-31 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/infiniband/hw/qedr/verbs.c: In function 'qedr_create_srq':
drivers/infiniband/hw/qedr/verbs.c:1450:24: warning:
 variable 'ctx' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/infiniband/hw/qedr/verbs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/infiniband/hw/qedr/verbs.c 
b/drivers/infiniband/hw/qedr/verbs.c
index 8cc3df2..9d4d165 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -1447,7 +1447,6 @@ struct ib_srq *qedr_create_srq(struct ib_pd *ibpd,
u64 pbl_base_addr, phy_prod_pair_addr;
struct ib_ucontext *ib_ctx = NULL;
struct qedr_srq_hwq_info *hw_srq;
-   struct qedr_ucontext *ctx = NULL;
u32 page_cnt, page_size;
struct qedr_srq *srq;
int rc = 0;
@@ -1473,7 +1472,6 @@ struct ib_srq *qedr_create_srq(struct ib_pd *ibpd,
 
if (udata && ibpd->uobject && ibpd->uobject->context) {
ib_ctx = ibpd->uobject->context;
-   ctx = get_qedr_ucontext(ib_ctx);
 
if (ib_copy_from_udata(, udata, sizeof(ureq))) {
DP_ERR(dev,



[PATCH -next] interconnect: Remove set but not used variable 'p'

2018-09-06 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/interconnect/core.c: In function 'icc_set':
drivers/interconnect/core.c:350:23: warning:
 variable 'p' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/interconnect/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index 2740f1a..8b1ba1a 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -347,7 +347,6 @@ struct icc_path *of_icc_get(struct device *dev, const char 
*name)
 int icc_set(struct icc_path *path, u32 avg_bw, u32 peak_bw)
 {
struct icc_node *node;
-   struct icc_provider *p;
size_t i;
int ret;
 
@@ -358,7 +357,6 @@ int icc_set(struct icc_path *path, u32 avg_bw, u32 peak_bw)
 
for (i = 0; i < path->num_nodes; i++) {
node = path->reqs[i].node;
-   p = node->provider;
 
/* update the consumer request for this path */
path->reqs[i].avg_bw = avg_bw;



[PATCH -next] interconnect: qcom: fix return value of qnoc_probe

2018-09-06 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/interconnect/qcom/msm8916.c: In function 'qnoc_probe':
drivers/interconnect/qcom/msm8916.c:439:7: warning:
 variable 'ret' set but not used [-Wunused-but-set-variable]

if icc_node_create failed, err code 'ret' will be returned,
so it cannot be a local variable in for-loop.

Fixes: 8d9300299a40 ("interconnect: qcom: Add msm8916 interconnect provider 
driver")
Signed-off-by: YueHaibing 
---
 drivers/interconnect/qcom/msm8916.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/interconnect/qcom/msm8916.c 
b/drivers/interconnect/qcom/msm8916.c
index 74145f4..0e33fdf 100644
--- a/drivers/interconnect/qcom/msm8916.c
+++ b/drivers/interconnect/qcom/msm8916.c
@@ -436,7 +436,6 @@ static int qnoc_probe(struct platform_device *pdev)
}
 
for (i = 0; i < num_nodes; i++) {
-   int ret;
size_t j;
 
node = icc_node_create(qnodes[i]->id);



[PATCH -next] drm: Remove set but not used variable 'config'

2018-09-11 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/drm_plane.c: In function 'drm_mode_getplane_res':
drivers/gpu/drm/drm_plane.c:475:26: warning:
 variable 'config' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/gpu/drm/drm_plane.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 36bf3fe..4a72c68 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -472,7 +472,6 @@ int drm_mode_getplane_res(struct drm_device *dev, void 
*data,
  struct drm_file *file_priv)
 {
struct drm_mode_get_plane_res *plane_resp = data;
-   struct drm_mode_config *config;
struct drm_plane *plane;
uint32_t __user *plane_ptr;
int count = 0;
@@ -480,7 +479,6 @@ int drm_mode_getplane_res(struct drm_device *dev, void 
*data,
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
 
-   config = >mode_config;
plane_ptr = u64_to_user_ptr(plane_resp->plane_id_ptr);
 
/*



[PATCH] ACPI: button: hide unused procfs helpers

2018-07-13 Thread YueHaibing
When CONFIG_PROC_FS isn't set, gcc warning this:

drivers/acpi/button.c:255:12: warning: ‘acpi_button_state_seq_show’ defined but 
not used [-Wunused-function]
 static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
^
fix this by adding #ifdef around it.

Signed-off-by: YueHaibing 
---
 drivers/acpi/button.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 2345a5e..8538e25 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -252,6 +252,7 @@ static int acpi_lid_notify_state(struct acpi_device 
*device, int state)
return ret;
 }
 
+#ifdef CONFIG_PROC_FS
 static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
 {
struct acpi_device *device = seq->private;
@@ -262,6 +263,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, 
void *offset)
   state < 0 ? "unsupported" : (state ? "open" : "closed"));
return 0;
 }
+#endif
 
 static int acpi_button_add_fs(struct acpi_device *device)
 {
-- 
2.7.0




[PATCH] staging/rtl8192u: hide unused procfs helpers

2018-07-13 Thread YueHaibing
When CONFIG_PROC_FS isn't set, gcc warning this:

drivers/staging/rtl8192u/r8192U_core.c:508:12: warning: ‘proc_get_stats_ap’ 
defined but not used [-Wunused-function]
 static int proc_get_stats_ap(struct seq_file *m, void *v)
^
drivers/staging/rtl8192u/r8192U_core.c:527:12: warning: ‘proc_get_registers’ 
defined but not used [-Wunused-function]
 static int proc_get_registers(struct seq_file *m, void *v)
^
drivers/staging/rtl8192u/r8192U_core.c:568:12: warning: ‘proc_get_stats_tx’ 
defined but not used [-Wunused-function]
 static int proc_get_stats_tx(struct seq_file *m, void *v)
^
drivers/staging/rtl8192u/r8192U_core.c:627:12: warning: ‘proc_get_stats_rx’ 
defined but not used [-Wunused-function]
 static int proc_get_stats_rx(struct seq_file *m, void *v)
^
fix this by adding #ifdef around them.

Signed-off-by: YueHaibing 
---
 drivers/staging/rtl8192u/r8192U_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
b/drivers/staging/rtl8192u/r8192U_core.c
index 8b17400..b9724d9 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -505,6 +505,7 @@ static void watch_dog_timer_callback(struct timer_list *t);
 
 static struct proc_dir_entry *rtl8192_proc;
 
+#ifdef CONFIG_PROC_FS
 static int proc_get_stats_ap(struct seq_file *m, void *v)
 {
struct net_device *dev = m->private;
@@ -639,6 +640,7 @@ static int proc_get_stats_rx(struct seq_file *m, void *v)
 
return 0;
 }
+#endif
 
 static void rtl8192_proc_module_init(void)
 {
-- 
2.7.0




Re: [PATCH] connector: hide unused procfs helpers

2018-07-13 Thread YueHaibing
pls ignore this,my bad.

On 2018/7/13 15:11, YueHaibing wrote:
> When CONFIG_PROC_FS isn't set, gcc warning this:
> 
> drivers/connector/connector.c:242:12: warning: ‘cn_proc_show’ defined but not 
> used [-Wunused-function]
>  static int cn_proc_show(struct seq_file *m, void *v)
> ^
> fix this by adding #ifdef around it.
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/connector/connector.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
> index e718b8c..e2636d4 100644
> --- a/drivers/connector/connector.c
> +++ b/drivers/connector/connector.c
> @@ -239,6 +239,7 @@ void cn_del_callback(struct cb_id *id)
>  }
>  EXPORT_SYMBOL_GPL(cn_del_callback);
>  
> +#ifdef CONFIG_PROC_FS
>  static int cn_proc_show(struct seq_file *m, void *v)
>  {
>   struct cn_queue_dev *dev = cdev.cbdev;
> @@ -259,6 +260,7 @@ static int cn_proc_show(struct seq_file *m, void *v)
>  
>   return 0;
>  }
> +#endif
>  
>  static struct cn_dev cdev = {
>   .input   = cn_rx_skb,
> 



Re: [PATCH] staging/rtl8192u: hide unused procfs helpers

2018-07-13 Thread YueHaibing
Pls ignore this, there has a fix.

[PATCH] staging/rtl8192u: fix defined but not used build warnings

On 2018/7/13 16:01, YueHaibing wrote:
> When CONFIG_PROC_FS isn't set, gcc warning this:
> 
> drivers/staging/rtl8192u/r8192U_core.c:508:12: warning: ‘proc_get_stats_ap’ 
> defined but not used [-Wunused-function]
>  static int proc_get_stats_ap(struct seq_file *m, void *v)
> ^
> drivers/staging/rtl8192u/r8192U_core.c:527:12: warning: ‘proc_get_registers’ 
> defined but not used [-Wunused-function]
>  static int proc_get_registers(struct seq_file *m, void *v)
> ^
> drivers/staging/rtl8192u/r8192U_core.c:568:12: warning: ‘proc_get_stats_tx’ 
> defined but not used [-Wunused-function]
>  static int proc_get_stats_tx(struct seq_file *m, void *v)
> ^
> drivers/staging/rtl8192u/r8192U_core.c:627:12: warning: ‘proc_get_stats_rx’ 
> defined but not used [-Wunused-function]
>  static int proc_get_stats_rx(struct seq_file *m, void *v)
> ^
> fix this by adding #ifdef around them.
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
> b/drivers/staging/rtl8192u/r8192U_core.c
> index 8b17400..b9724d9 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -505,6 +505,7 @@ static void watch_dog_timer_callback(struct timer_list 
> *t);
>  
>  static struct proc_dir_entry *rtl8192_proc;
>  
> +#ifdef CONFIG_PROC_FS
>  static int proc_get_stats_ap(struct seq_file *m, void *v)
>  {
>   struct net_device *dev = m->private;
> @@ -639,6 +640,7 @@ static int proc_get_stats_rx(struct seq_file *m, void *v)
>  
>   return 0;
>  }
> +#endif
>  
>  static void rtl8192_proc_module_init(void)
>  {
> 



Re: [PATCH] ACPI: button: hide unused procfs helpers

2018-07-13 Thread YueHaibing
sorry for noise,there has a fix:

[PATCH] acpi/button.c: fix defined but not used warning
https://lkml.org/lkml/2018/7/11/231

On 2018/7/13 15:19, YueHaibing wrote:
> When CONFIG_PROC_FS isn't set, gcc warning this:
> 
> drivers/acpi/button.c:255:12: warning: ‘acpi_button_state_seq_show’ defined 
> but not used [-Wunused-function]
>  static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
> ^
> fix this by adding #ifdef around it.
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/acpi/button.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index 2345a5e..8538e25 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -252,6 +252,7 @@ static int acpi_lid_notify_state(struct acpi_device 
> *device, int state)
>   return ret;
>  }
>  
> +#ifdef CONFIG_PROC_FS
>  static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
>  {
>   struct acpi_device *device = seq->private;
> @@ -262,6 +263,7 @@ static int acpi_button_state_seq_show(struct seq_file 
> *seq, void *offset)
>  state < 0 ? "unsupported" : (state ? "open" : "closed"));
>   return 0;
>  }
> +#endif
>  
>  static int acpi_button_add_fs(struct acpi_device *device)
>  {
> 



[PATCH -next] staging: mt7621-pci: Use PTR_ERR_OR_ZERO in mt7621_pcie_parse_dt()

2018-09-11 Thread YueHaibing
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Signed-off-by: YueHaibing 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index ba1f117..d2cb910 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -396,10 +396,7 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
}
 
pcie->base = devm_ioremap_resource(dev, );
-   if (IS_ERR(pcie->base))
-   return PTR_ERR(pcie->base);
-
-   return 0;
+   return PTR_ERR_OR_ZERO(pcie->base);
 }
 
 static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie,





[PATCH] powerpc/xics: add missing of_node_put() in error path

2018-04-25 Thread YueHaibing
The device node obtained with of_find_compatible_node() should be
released by calling of_node_put().  But it was not released when
of_get_property() failed.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 arch/powerpc/sysdev/xics/xics-common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/sysdev/xics/xics-common.c 
b/arch/powerpc/sysdev/xics/xics-common.c
index 77e864d..e54a9e6 100644
--- a/arch/powerpc/sysdev/xics/xics-common.c
+++ b/arch/powerpc/sysdev/xics/xics-common.c
@@ -448,7 +448,10 @@ static void __init xics_get_server_size(void)
return;
isize = of_get_property(np, "ibm,interrupt-server#-size", NULL);
if (!isize)
+   {
+   of_node_put(np);
return;
+   }
xics_interrupt_server_size = be32_to_cpu(*isize);
of_node_put(np);
 }
-- 
2.7.0




Re: [PATCH] irqchip/gic-v3: check kasprintf() for failures

2018-04-24 Thread YueHaibing

On 2018/4/24 15:21, Marc Zyngier wrote:
> On Tue, 24 Apr 2018 08:10:36 +0100,
> YueHaibing wrote:
>>
>> We should just return -ENOMEM here if the allocation fails,
>> otherwise it may cause a panic.
> 
> Can you explain how? From what I can see, node_name is only used as a
> parameter to pr_err/pr_info, which will perfectly deal with it by
> printing "(null)", and not causing a panic. Am I missing something?
> 
You are right

I just misunderstood,sorry for noise.

>>
>> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
>> ---
>>  drivers/irqchip/irq-gic-v3-its-pci-msi.c  | 3 +++
>>  drivers/irqchip/irq-gic-v3-its-platform-msi.c | 3 +++
>>  2 files changed, 6 insertions(+)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c 
>> b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>> index 25a98de..ef3911f 100644
>> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>> @@ -160,6 +160,9 @@ its_pci_msi_parse_madt(struct acpi_subtable_header 
>> *header,
>>  its_entry = (struct acpi_madt_generic_translator *)header;
>>  node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
>>(long)its_entry->base_address);
>> +if(!node_name)
> 
> Missing space.
> 
>> +return -ENOMEM;
>> +
>>  dom_handle = iort_find_domain_token(its_entry->translation_id);
>>  if (!dom_handle) {
>>  pr_err("%s: Unable to locate ITS domain handle\n", node_name);
>> diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c 
>> b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
>> index 8881a05..b676fb4 100644
>> --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c
>> +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
>> @@ -126,6 +126,9 @@ its_pmsi_parse_madt(struct acpi_subtable_header *header,
>>  its_entry = (struct acpi_madt_generic_translator *)header;
>>  node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
>>(long)its_entry->base_address);
>> +if(!node_name)
>> +return -ENOMEM;
>> +
>>  domain_handle = iort_find_domain_token(its_entry->translation_id);
>>  if (!domain_handle) {
>>  pr_err("%s: Unable to locate ITS domain handle\n", node_name);
>> -- 
>> 2.7.0
>>
>>
> 
> Thanks,
> 
>   M.
> 



[PATCH] irqchip/gic-v3: check kasprintf() for failures

2018-04-24 Thread YueHaibing
We should just return -ENOMEM here if the allocation fails,
otherwise it may cause a panic.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/irqchip/irq-gic-v3-its-pci-msi.c  | 3 +++
 drivers/irqchip/irq-gic-v3-its-platform-msi.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c 
b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
index 25a98de..ef3911f 100644
--- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
@@ -160,6 +160,9 @@ its_pci_msi_parse_madt(struct acpi_subtable_header *header,
its_entry = (struct acpi_madt_generic_translator *)header;
node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
  (long)its_entry->base_address);
+   if(!node_name)
+   return -ENOMEM;
+
dom_handle = iort_find_domain_token(its_entry->translation_id);
if (!dom_handle) {
pr_err("%s: Unable to locate ITS domain handle\n", node_name);
diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c 
b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
index 8881a05..b676fb4 100644
--- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
@@ -126,6 +126,9 @@ its_pmsi_parse_madt(struct acpi_subtable_header *header,
its_entry = (struct acpi_madt_generic_translator *)header;
node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
  (long)its_entry->base_address);
+   if(!node_name)
+   return -ENOMEM;
+
domain_handle = iort_find_domain_token(its_entry->translation_id);
if (!domain_handle) {
pr_err("%s: Unable to locate ITS domain handle\n", node_name);
-- 
2.7.0




Re: [PATCH] lib/string.c: fix a typo in comment: 'iff' -->'if'

2018-06-28 Thread YueHaibing



On 2018/6/29 11:35, Randy Dunlap wrote:
> On 06/28/2018 08:33 PM, YueHaibing wrote:
>> Signed-off-by: YueHaibing 
>> ---
>>  lib/string.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Hi,
> 
> This isn't a typo.  "iff" means "if and only if".

ok, my poor english, thank you.

> 
>> diff --git a/lib/string.c b/lib/string.c
>> index 2c0900a..23ed944 100644
>> --- a/lib/string.c
>> +++ b/lib/string.c
>> @@ -609,7 +609,7 @@ EXPORT_SYMBOL(strsep);
>>   * @s1: one string
>>   * @s2: another string
>>   *
>> - * This routine returns true iff two strings are equal, treating both
>> + * This routine returns true if two strings are equal, treating both
>>   * NUL and newline-then-NUL as equivalent string terminations.  It's
>>   * geared for use with sysfs input strings, which generally terminate
>>   * with newlines but are compared against values without newlines.
>>
> 
> 



[PATCH] lib/string.c: fix a typo in comment: 'iff' -->'if'

2018-06-28 Thread YueHaibing
Signed-off-by: YueHaibing 
---
 lib/string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/string.c b/lib/string.c
index 2c0900a..23ed944 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -609,7 +609,7 @@ EXPORT_SYMBOL(strsep);
  * @s1: one string
  * @s2: another string
  *
- * This routine returns true iff two strings are equal, treating both
+ * This routine returns true if two strings are equal, treating both
  * NUL and newline-then-NUL as equivalent string terminations.  It's
  * geared for use with sysfs input strings, which generally terminate
  * with newlines but are compared against values without newlines.
-- 
2.7.0




[PATCH -next] misc: mic: scif: remove set but not used variables 'src_dma_addr, dst_dma_addr'

2018-10-11 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/misc/mic/scif/scif_dma.c: In function 'scif_rma_list_dma_copy_wrapper':
drivers/misc/mic/scif/scif_dma.c:1558:27: warning:
 variable 'dst_dma_addr' set but not used [-Wunused-but-set-variable]

drivers/misc/mic/scif/scif_dma.c:1558:13: warning:
 variable 'src_dma_addr' set but not used [-Wunused-but-set-variable]

They never used since introduction in
commit 7cc31cd27752 ("misc: mic: SCIF DMA and CPU copy interface")

Signed-off-by: YueHaibing 
---
 drivers/misc/mic/scif/scif_dma.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/misc/mic/scif/scif_dma.c b/drivers/misc/mic/scif/scif_dma.c
index 03af8b5..2babbac 100644
--- a/drivers/misc/mic/scif/scif_dma.c
+++ b/drivers/misc/mic/scif/scif_dma.c
@@ -1555,7 +1555,6 @@ static int scif_rma_list_dma_copy_wrapper(struct 
scif_endpt *epd,
u8 *temp = NULL;
bool src_local = true;
struct scif_dma_comp_cb *comp_cb;
-   dma_addr_t src_dma_addr, dst_dma_addr;
int err;
 
if (is_dma_copy_aligned(chan->device, 1, 1, 1))
@@ -1569,8 +1568,6 @@ static int scif_rma_list_dma_copy_wrapper(struct 
scif_endpt *epd,
 
if (work->loopback)
return scif_rma_list_cpu_copy(work);
-   src_dma_addr = __scif_off_to_dma_addr(work->src_window, src_offset);
-   dst_dma_addr = __scif_off_to_dma_addr(work->dst_window, dst_offset);
src_local = work->src_window->type == SCIF_WINDOW_SELF;
 
/* Allocate dma_completion cb */



[PATCH -next] x86/cpu: Drop pointless static qualifier in punit_dev_state_show()

2018-10-12 Thread YueHaibing
There is no need to have the 'struct dentry *dev_state' variable static
since new value always be assigned before use it.

Signed-off-by: YueHaibing 
---
 arch/x86/platform/atom/punit_atom_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/platform/atom/punit_atom_debug.c 
b/arch/x86/platform/atom/punit_atom_debug.c
index 41dae0f..6cb6076 100644
--- a/arch/x86/platform/atom/punit_atom_debug.c
+++ b/arch/x86/platform/atom/punit_atom_debug.c
@@ -115,7 +115,7 @@ static int punit_dev_state_show(struct seq_file *seq_file, 
void *unused)
 
 static int punit_dbgfs_register(struct punit_device *punit_device)
 {
-   static struct dentry *dev_state;
+   struct dentry *dev_state;
 
punit_dbg_file = debugfs_create_dir("punit_atom", NULL);
if (!punit_dbg_file)





[PATCH -next] nds32: Remove duplicated include from pm.c

2018-10-29 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 arch/nds32/kernel/pm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/nds32/kernel/pm.c b/arch/nds32/kernel/pm.c
index 6989560..ffa8040 100644
--- a/arch/nds32/kernel/pm.c
+++ b/arch/nds32/kernel/pm.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 







[PATCH -next] edac: i82975x: remove set but not used variable 'dtype'

2018-10-31 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/edac/i82975x_edac.c:378:16: warning:
 variable ‘dtype’ set but not used [-Wunused-but-set-variable]

It never used since introduction in commit
084a4fccef39 ("edac: move dimm properties to struct dimm_info")

Signed-off-by: YueHaibing 
---
 drivers/edac/i82975x_edac.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
index 892815e..ae0d8fa 100644
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -375,7 +375,6 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
u32 cumul_size, nr_pages;
int index, chan;
struct dimm_info *dimm;
-   enum dev_type dtype;
 
last_cumul_size = 0;
 
@@ -413,7 +412,6 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
 *   [0-7] for single-channel; i.e. csrow->nr_channels = 1
 *   [0-3] for dual-channel; i.e. csrow->nr_channels = 2
 */
-   dtype = i82975x_dram_type(mch_window, index);
for (chan = 0; chan < csrow->nr_channels; chan++) {
dimm = mci->csrows[index]->channels[chan]->dimm;
 
-- 
2.7.0




[PATCH -next] firewire: net: remove set but not used variable 'guid'

2018-10-31 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/firewire/net.c:488:9: warning:
 variable ‘guid’ set but not used [-Wunused-but-set-variable]

It not used anymore after commit 6752c8db8e0c ("firewire net, ipv4 arp:
 Extend hardware address and remove driver-level packet inspection.")

Signed-off-by: YueHaibing 
---
 drivers/firewire/net.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 82ba110..5dcb991 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -485,7 +485,6 @@ static int fwnet_finish_incoming_packet(struct net_device 
*net,
 {
struct fwnet_device *dev;
int status;
-   __be64 guid;
 
switch (ether_type) {
case ETH_P_ARP:
@@ -507,7 +506,6 @@ static int fwnet_finish_incoming_packet(struct net_device 
*net,
 * Parse the encapsulation header. This actually does the job of
 * converting to an ethernet-like pseudo frame header.
 */
-   guid = cpu_to_be64(dev->card->guid);
if (dev_hard_header(skb, net, ether_type,
   is_broadcast ? net->broadcast : net->dev_addr,
   NULL, skb->len) >= 0) {
-- 
2.7.0




[PATCH -next] sgi-xp: drop pointless static qualifier in xpc_setup_msg_structures_uv

2018-10-26 Thread YueHaibing
There is no need to have the 'enum xp_retval ret' variable static since
new value always be assigned before use it.

Signed-off-by: YueHaibing 
---
 drivers/misc/sgi-xp/xpc_uv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 0441abe..0323bfe 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -1151,7 +1151,7 @@ struct uv_IO_APIC_route_entry {
 static enum xp_retval
 xpc_setup_msg_structures_uv(struct xpc_channel *ch)
 {
-   static enum xp_retval ret;
+   enum xp_retval ret;
struct xpc_channel_uv *ch_uv = >sn.uv;
 
DBUG_ON(ch->flags & XPC_C_SETUP);





Re: [PATCH -next] edac: i82975x: remove set but not used variable 'dtype'

2018-11-06 Thread YueHaibing
On 2018/11/7 2:05, Borislav Petkov wrote:
> On Thu, Nov 01, 2018 at 10:26:04AM +0800, YueHaibing wrote:
>> Fixes gcc '-Wunused-but-set-variable' warning:
>>
>> drivers/edac/i82975x_edac.c:378:16: warning:
>>  variable ‘dtype’ set but not used [-Wunused-but-set-variable]
>>
>> It never used since introduction in commit
>> 084a4fccef39 ("edac: move dimm properties to struct dimm_info")
>>
>> Signed-off-by: YueHaibing 
>> ---
>>  drivers/edac/i82975x_edac.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
>> index 892815e..ae0d8fa 100644
>> --- a/drivers/edac/i82975x_edac.c
>> +++ b/drivers/edac/i82975x_edac.c
>> @@ -375,7 +375,6 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
>>  u32 cumul_size, nr_pages;
>>  int index, chan;
>>  struct dimm_info *dimm;
>> -enum dev_type dtype;
>>  
>>  last_cumul_size = 0;
>>  
>> @@ -413,7 +412,6 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
>>   *   [0-7] for single-channel; i.e. csrow->nr_channels = 1
>>   *   [0-3] for dual-channel; i.e. csrow->nr_channels = 2
>>   */
>> -dtype = i82975x_dram_type(mch_window, index);
> 
> Please get rid of that silly function too and move the comment and the
> assignment to the single place where it is done:
> 
> /*
>  * ECC is possible on i92975x ONLY with DEV_X8
>  */
> dimm->dtype = DEV_X8;
> 

OK, will send v2.

> 
> Thx.
> 



[PATCH v2 -next] edac: i82975x: remove set but not used variable 'dtype'

2018-11-06 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/edac/i82975x_edac.c:378:16: warning:
 variable 'dtype' set but not used [-Wunused-but-set-variable]

It never used since introduction in commit
084a4fccef39 ("edac: move dimm properties to struct dimm_info")

Also remove function i82975x_dram_type and move the comment and the
assignment to the single called place.

Signed-off-by: YueHaibing 
---
v2: remove unnecessary function i82975x_dram_type
---
 drivers/edac/i82975x_edac.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
index 892815e..7f4a14c 100644
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -358,14 +358,6 @@ static int dual_channel_active(void __iomem *mch_window)
return dualch;
 }
 
-static enum dev_type i82975x_dram_type(void __iomem *mch_window, int rank)
-{
-   /*
-* ECC is possible on i92975x ONLY with DEV_X8
-*/
-   return DEV_X8;
-}
-
 static void i82975x_init_csrows(struct mem_ctl_info *mci,
struct pci_dev *pdev, void __iomem *mch_window)
 {
@@ -375,7 +367,6 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
u32 cumul_size, nr_pages;
int index, chan;
struct dimm_info *dimm;
-   enum dev_type dtype;
 
last_cumul_size = 0;
 
@@ -413,7 +404,6 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
 *   [0-7] for single-channel; i.e. csrow->nr_channels = 1
 *   [0-3] for dual-channel; i.e. csrow->nr_channels = 2
 */
-   dtype = i82975x_dram_type(mch_window, index);
for (chan = 0; chan < csrow->nr_channels; chan++) {
dimm = mci->csrows[index]->channels[chan]->dimm;
 
@@ -423,7 +413,10 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
 (chan == 0) ? 'A' : 'B',
 index);
dimm->grain = 1 << 7;   /* 128Byte cache-line 
resolution */
-   dimm->dtype = i82975x_dram_type(mch_window, index);
+   /*
+* ECC is possible on i92975x ONLY with DEV_X8
+*/
+   dimm->dtype = DEV_X8;
dimm->mtype = MEM_DDR2; /* I82975x supports only DDR2 */
dimm->edac_mode = EDAC_SECDED; /* only supported */
}
-- 
2.7.0




[PATCH -next] ufs: remove set but not used variable 'usb3'

2018-11-08 Thread YueHaibing
From: Yue Haibing 

Fixes gcc '-Wunused-but-set-variable' warning:

fs/ufs/super.c: In function 'ufs_statfs':
fs/ufs/super.c:1409:32: warning:
 variable 'usb3' set but not used [-Wunused-but-set-variable]

It not used any more after commit
c596961d1b4c ("ufs: fix s_size/s_dsize users")

Signed-off-by: Yue Haibing 
---
 fs/ufs/super.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index a4e07e9..6a5db06 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1406,11 +1406,9 @@ static int ufs_statfs(struct dentry *dentry, struct 
kstatfs *buf)
struct super_block *sb = dentry->d_sb;
struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi;
unsigned  flags = UFS_SB(sb)->s_flags;
-   struct ufs_super_block_third *usb3;
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
 
mutex_lock(_SB(sb)->s_lock);
-   usb3 = ubh_get_usb_third(uspi);

if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
buf->f_type = UFS2_MAGIC;





[PATCH -next] sysv: return 'err' instead of 0 in __sysv_write_inode

2018-11-09 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

fs/sysv/inode.c: In function '__sysv_write_inode':
fs/sysv/inode.c:239:6: warning:
 variable 'err' set but not used [-Wunused-but-set-variable]

__sysv_write_inode should return 'err' instead of 0

Fixes: 05459ca81ac3 ("repair sysv_write_inode(), switch sysv to simple_fsync()")
Signed-off-by: YueHaibing 
---
 fs/sysv/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 499a20a..273736f 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -275,7 +275,7 @@ static int __sysv_write_inode(struct inode *inode, int wait)
 }
 }
brelse(bh);
-   return 0;
+   return err;
 }
 
 int sysv_write_inode(struct inode *inode, struct writeback_control *wbc)





[PATCH -next] misc: mic/scif: fix copy-paste error in scif_create_remote_lookup

2018-11-13 Thread YueHaibing
gcc '-Wunused-but-set-variable' warning:

drivers/misc/mic/scif/scif_rma.c: In function 'scif_create_remote_lookup':
drivers/misc/mic/scif/scif_rma.c:373:25: warning:
 variable 'vmalloc_num_pages' set but not used [-Wunused-but-set-variable]

'vmalloc_num_pages' should be used to determine if the address is 
within the vmalloc range.

Fixes: ba612aa8b487 ("misc: mic: SCIF memory registration and unregistration")
Signed-off-by: YueHaibing 
---
 drivers/misc/mic/scif/scif_rma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c
index b441f6b..749321e 100644
--- a/drivers/misc/mic/scif/scif_rma.c
+++ b/drivers/misc/mic/scif/scif_rma.c
@@ -416,7 +416,7 @@ static int scif_create_remote_lookup(struct scif_dev 
*remote_dev,
if (err)
goto error_window;
err = scif_map_page(>num_pages_lookup.lookup[j],
-   vmalloc_dma_phys ?
+   vmalloc_num_pages ?
vmalloc_to_page(>num_pages[i]) :
virt_to_page(>num_pages[i]),
remote_dev);





[PATCH -next] drm/msm: dpu: Fix "WARNING: invalid free of devm_ allocated data"

2018-11-16 Thread YueHaibing
'dpu_enc' is a member of 'drm_enc'
And 'drm_enc' got allocated with devm_kzalloc in dpu_encoder_init.

This gives this error message:
./drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c:459:1-6:
 WARNING: invalid free of devm_ allocated data

Signed-off-by: YueHaibing 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 82c55ef..99526d9 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -455,8 +455,6 @@ static void dpu_encoder_destroy(struct drm_encoder *drm_enc)
 
drm_encoder_cleanup(drm_enc);
mutex_destroy(_enc->enc_lock);
-
-   kfree(dpu_enc);
 }
 
 void dpu_encoder_helper_split_config(
-- 
2.7.0




[PATCH -next] i3c: master: Remove set but not used variable 'old_i3c_scl_lim'

2018-11-13 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/i3c/master/i3c-master-cdns.c: In function 'cdns_i3c_master_do_daa':
drivers/i3c/master/i3c-master-cdns.c:1137:16: warning:
 variable 'old_i3c_scl_lim' set but not used [-Wunused-but-set-variable]

It never used since introdution in commit
  acfab7d324b2 ("i3c: master: Add driver for Cadence IP")

Signed-off-by: YueHaibing 
---
 drivers/i3c/master/i3c-master-cdns.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/i3c/master/i3c-master-cdns.c 
b/drivers/i3c/master/i3c-master-cdns.c
index ad40162..e828921 100644
--- a/drivers/i3c/master/i3c-master-cdns.c
+++ b/drivers/i3c/master/i3c-master-cdns.c
@@ -1133,7 +1133,6 @@ static void cdns_i3c_master_upd_i3c_scl_lim(struct 
cdns_i3c_master *master)
 static int cdns_i3c_master_do_daa(struct i3c_master_controller *m)
 {
struct cdns_i3c_master *master = to_cdns_i3c_master(m);
-   unsigned long old_i3c_scl_lim;
u32 olddevs, newdevs;
int ret, slot;
u8 addrs[MAX_DEVS] = { };
@@ -1165,9 +1164,6 @@ static int cdns_i3c_master_do_daa(struct 
i3c_master_controller *m)
newdevs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK;
newdevs &= ~olddevs;
 
-   /* Save the old limitation before add devices. */
-   old_i3c_scl_lim = master->i3c_scl_lim;
-
/*
 * Clear all retaining registers filled during DAA. We already
 * have the addressed assigned to them in the addrs array.





[PATCH -next] ASoC: amd: remove set but not used variable 'dma_buffer'

2018-11-14 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

sound/soc/amd/raven/acp3x-pcm-dma.c: In function 'acp3x_dma_hw_params':
sound/soc/amd/raven/acp3x-pcm-dma.c:333:25: warning:
 variable 'dma_buffer' set but not used [-Wunused-but-set-variable]

It never used since introduction in commit
8de1b5ed0337 ("ASoC: amd: add acp3x system resume pm op")

Signed-off-by: YueHaibing 
---
 sound/soc/amd/raven/acp3x-pcm-dma.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c 
b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 2e61cef..28a867f 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -330,7 +330,6 @@ static int acp3x_dma_hw_params(struct snd_pcm_substream 
*substream,
 {
int status;
u64 size;
-   struct snd_dma_buffer *dma_buffer;
struct page *pg;
struct snd_pcm_runtime *runtime = substream->runtime;
struct i2s_stream_instance *rtd = runtime->private_data;
@@ -338,7 +337,6 @@ static int acp3x_dma_hw_params(struct snd_pcm_substream 
*substream,
if (!rtd)
return -EINVAL;
 
-   dma_buffer = >dma_buffer;
size = params_buffer_bytes(params);
status = snd_pcm_lib_malloc_pages(substream, size);
if (status < 0)





[PATCH -next] eeprom: at25: remove unneeded 'at25_remove'

2018-10-05 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/misc/eeprom/at25.c: In function 'at25_remove':
drivers/misc/eeprom/at25.c:384:20: warning:
 variable 'at25' set but not used [-Wunused-but-set-variable]

Since commit 96d08fb43e30 ("eeprom: at25: use devm_nvmem_register()"),
at25_remove is do nothing, so can be removed.

Signed-off-by: YueHaibing 
---
 drivers/misc/eeprom/at25.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index d874df7..99de693 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -379,15 +379,6 @@ static int at25_probe(struct spi_device *spi)
return 0;
 }
 
-static int at25_remove(struct spi_device *spi)
-{
-   struct at25_data*at25;
-
-   at25 = spi_get_drvdata(spi);
-
-   return 0;
-}
-
 /*-*/
 
 static const struct of_device_id at25_of_match[] = {
@@ -402,7 +393,6 @@ static int at25_remove(struct spi_device *spi)
.of_match_table = at25_of_match,
},
.probe  = at25_probe,
-   .remove = at25_remove,
 };
 
 module_spi_driver(at25_driver);



[PATCH -next] staging: axis-fifo: remove duplicated include from axis-fifo.c

2018-10-05 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/staging/axis-fifo/axis-fifo.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/axis-fifo/axis-fifo.c 
b/drivers/staging/axis-fifo/axis-fifo.c
index 63c8efd..48a9877 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -27,8 +27,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 





[PATCH v2] mt76x0: pci: fix set external PA I/O current

2018-10-08 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/mediatek/mt76/mt76x0/pci.c: In function 
'mt76x0e_register_device':
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c:107:8: warning:
 variable 'data' set but not used [-Wunused-but-set-variable]

It seems correct value to write is 'data'

Fixes: 2b2cb40bcd7d ("mt76x0: pci: add hw initialization at bootstrap")
Signed-off-by: YueHaibing 
Acked-by: Lorenzo Bianconi 
---
v2: remove 'net-next' from patch title
---
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c 
b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 87997cd..0426c68 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -106,12 +106,12 @@ static int mt76x0e_register_device(struct mt76x02_dev 
*dev)
if (val & MT_EE_NIC_CONF_0_PA_IO_CURRENT) {
u32 data;
 
-   /* set external external PA I/O
+   /* set external PA I/O
 * current to 16mA
 */
data = mt76_rr(dev, 0x11c);
-   val |= 0xc03;
-   mt76_wr(dev, 0x11c, val);
+   data |= 0xc03;
+   mt76_wr(dev, 0x11c, data);
}
}



[PATCH -next] staging: rtlwifi: Remove set but not used variable 'ppsc'

2018-09-27 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c: In function 
'halbtc_leave_lps':
drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:284:21: warning:
 variable 'ppsc' set but not used [-Wunused-but-set-variable]

drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c: In function 
'halbtc_enter_lps':
drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:307:21: warning:
 variable 'ppsc' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
index 85a7490..24e19ff 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -281,11 +281,9 @@ bool halbtc_send_bt_mp_operation(struct btc_coexist 
*btcoexist, u8 op_code,
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
-   struct rtl_ps_ctl *ppsc;
bool ap_enable = false;
 
rtlpriv = btcoexist->adapter;
-   ppsc = rtl_psc(rtlpriv);
 
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
   _enable);
@@ -304,11 +302,9 @@ static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
-   struct rtl_ps_ctl *ppsc;
bool ap_enable = false;
 
rtlpriv = btcoexist->adapter;
-   ppsc = rtl_psc(rtlpriv);
 
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
   _enable);



[PATCH] mmc: tegra: fix inconsistent IS_ERR and PTR_ERR

2018-09-03 Thread YueHaibing
Fix inconsistent IS_ERR and PTR_ERR in tegra_sdhci_init_pinctrl_info,
the proper pointer to be passed as argument is 'pinctrl_state_1v8'

Signed-off-by: YueHaibing 
---
 drivers/mmc/host/sdhci-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index e80716c..c789158 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -724,7 +724,7 @@ static int tegra_sdhci_init_pinctrl_info(struct device *dev,
pinctrl_lookup_state(tegra_host->pinctrl_sdmmc, "sdmmc-1v8");
if (IS_ERR(tegra_host->pinctrl_state_1v8)) {
dev_warn(dev, "Missing 1.8V pad state, err: %ld\n",
-PTR_ERR(tegra_host->pinctrl_state_3v3));
+PTR_ERR(tegra_host->pinctrl_state_1v8));
return -1;
}
 
-- 
2.7.0




[PATCH -next] serial: imx: remove set but not used variable 'rtsirq'

2018-09-19 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/tty/serial/imx.c: In function 'imx_uart_probe':
drivers/tty/serial/imx.c:2198:20: warning:
 variable 'rtsirq' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/tty/serial/imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 4341589..1df7d23 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2195,7 +2195,7 @@ static int imx_uart_probe(struct platform_device *pdev)
int ret = 0;
u32 ucr1;
struct resource *res;
-   int txirq, rxirq, rtsirq;
+   int txirq, rxirq;
 
sport = devm_kzalloc(>dev, sizeof(*sport), GFP_KERNEL);
if (!sport)
@@ -2220,7 +2220,6 @@ static int imx_uart_probe(struct platform_device *pdev)
 
rxirq = platform_get_irq(pdev, 0);
txirq = platform_get_irq(pdev, 1);
-   rtsirq = platform_get_irq(pdev, 2);
 
sport->port.dev = >dev;
sport->port.mapbase = res->start;



[PATCH -next] pinctrl: qcom: spmi-mpp: Fix err handling of pmic_mpp_set_mux

2018-09-19 Thread YueHaibing
'ret' should be returned while pmic_mpp_write_mode_ctl fails. 

Fixes: 0e948042c420 ("pinctrl: qcom: spmi-mpp: Implement support for sink mode")
Signed-off-by: YueHaibing 
---
 drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c 
b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
index 98f6f40..d6ddc47 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
@@ -319,6 +319,8 @@ static int pmic_mpp_set_mux(struct pinctrl_dev *pctldev, 
unsigned function,
pad->function = function;
 
ret = pmic_mpp_write_mode_ctl(state, pad);
+   if (ret < 0)
+   return ret;
 
val = pad->is_enabled << PMIC_MPP_REG_MASTER_EN_SHIFT;



Re: [PATCH -next] RDMA/core: Properly return the error code of rdma_set_src_addr_rcu

2018-09-19 Thread YueHaibing
On 2018/9/20 0:14, Jason Gunthorpe wrote:
> On Wed, Sep 19, 2018 at 08:28:38PM +0800, YueHaibing wrote:
>> rdma_set_src_addr_rcu should check copy_src_l2_addr fails,
>> rather than always return 0. Also copy_src_l2_addr should return
>> 'ret' as its return value while rdma_translate_ip fails.
>>
>> Fixes: c31d4b2ddf07 ("RDMA/core: Protect against changing dst->dev during 
>> destination resolve")
>> Signed-off-by: YueHaibing 
>> Reviewed-by: Parav Pandit 
>> ---
>>  drivers/infiniband/core/addr.c | 9 ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> Applied to for-next, thanks
> 
>> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
>> index 7a0356c..8a31b11 100644
>> --- a/drivers/infiniband/core/addr.c
>> +++ b/drivers/infiniband/core/addr.c
>> @@ -468,7 +468,7 @@ static int addr_resolve_neigh(const struct dst_entry 
>> *dst,
>>  return ret;
>>  }
>>  
>> -static void copy_src_l2_addr(struct rdma_dev_addr *dev_addr,
>> +static int copy_src_l2_addr(struct rdma_dev_addr *dev_addr,
>>   const struct sockaddr *dst_in,
>>   const struct dst_entry *dst,
>>   const struct net_device *ndev)
> 
> I fixed the indenting as Parav pointed out
> 
>> @@ -492,6 +492,8 @@ static void copy_src_l2_addr(struct rdma_dev_addr 
>> *dev_addr,
>>  RDMA_NETWORK_IPV6;
>>  else
>>  dev_addr->network = RDMA_NETWORK_IB;
>> +
>> +return ret;
>>  }
>>  
>>  static int rdma_set_src_addr_rcu(struct rdma_dev_addr *dev_addr,
>> @@ -499,6 +501,7 @@ static int rdma_set_src_addr_rcu(struct rdma_dev_addr 
>> *dev_addr,
>>   const struct sockaddr *dst_in,
>>   const struct dst_entry *dst)
>>  {
>> +int ret;
>>  struct net_device *ndev = READ_ONCE(dst->dev);
>>  
>>  *ndev_flags = ndev->flags;
>> @@ -515,8 +518,8 @@ static int rdma_set_src_addr_rcu(struct rdma_dev_addr 
>> *dev_addr,
>>  return -ENODEV;
>>  }
>>  
>> -copy_src_l2_addr(dev_addr, dst_in, dst, ndev);
>> -return 0;
>> +ret = copy_src_l2_addr(dev_addr, dst_in, dst, ndev);
>> +return ret;
>>  }
> 
> And made this just 'return copy_src_l2_addr' without the ret.

Thank you.

> 
> Jason
> 
> .
> 



[PATCH -next] pinctrl: sunxi: fix 'pctrl->functions' allocation in sunxi_pinctrl_build_state

2018-09-20 Thread YueHaibing
fixes following Smatch static check warning:

 ./drivers/pinctrl/sunxi/pinctrl-sunxi.c:1112 sunxi_pinctrl_build_state()
 warn: passing devm_ allocated variable to kfree. 'pctrl->functions'

As we will be calling krealloc() on pointer 'pctrl->functions', which means
kfree() will be called in there, devm_kzalloc() shouldn't be used with
the allocation in the first place.  Fix the warning by calling kcalloc()
and managing the free procedure in error path on our own.

Fixes: 0e37f88d9ad8 ("ARM: sunxi: Add pinctrl driver for Allwinner SoCs")
Signed-off-by: YueHaibing 
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 3ccbe22..213a5d5 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -1079,10 +1079,9 @@ static int sunxi_pinctrl_build_state(struct 
platform_device *pdev)
 * We suppose that we won't have any more functions than pins,
 * we'll reallocate that later anyway
 */
-   pctl->functions = devm_kcalloc(>dev,
-  pctl->ngroups,
-  sizeof(*pctl->functions),
-  GFP_KERNEL);
+   pctl->functions = kcalloc(pctl->ngroups,
+ sizeof(*pctl->functions),
+ GFP_KERNEL);
if (!pctl->functions)
return -ENOMEM;
 
@@ -1133,8 +1132,10 @@ static int sunxi_pinctrl_build_state(struct 
platform_device *pdev)
 
func_item = sunxi_pinctrl_find_function_by_name(pctl,

func->name);
-   if (!func_item)
+   if (!func_item) {
+   kfree(pctl->functions);
return -EINVAL;
+   }
 
if (!func_item->groups) {
func_item->groups =
@@ -1142,8 +1143,10 @@ static int sunxi_pinctrl_build_state(struct 
platform_device *pdev)
 func_item->ngroups,
 sizeof(*func_item->groups),
 GFP_KERNEL);
-   if (!func_item->groups)
+   if (!func_item->groups) {
+   kfree(pctl->functions);
return -ENOMEM;
+   }
}
 
func_grp = func_item->groups;
-- 
2.7.0




Re: [PATCH net-next 17/22] hv_netvsc: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
On 2018/9/20 22:43, Stephen Hemminger wrote:
> On Thu, 20 Sep 2018 20:33:01 +0800
> YueHaibing  wrote:
> 
>> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
>> which is a typedef for an enum type, so make sure the implementation in
>> this driver has returns 'netdev_tx_t' value, and change the function
>> return type to netdev_tx_t.
>>
>> Found by coccinelle.
>>
>> Signed-off-by: YueHaibing 
>> ---
>>  drivers/net/hyperv/netvsc_drv.c | 10 +++---
>>  1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/hyperv/netvsc_drv.c 
>> b/drivers/net/hyperv/netvsc_drv.c
>> index 3af6d8d..056c472 100644
>> --- a/drivers/net/hyperv/netvsc_drv.c
>> +++ b/drivers/net/hyperv/netvsc_drv.c
>> @@ -511,7 +511,8 @@ static int netvsc_vf_xmit(struct net_device *net, struct 
>> net_device *vf_netdev,
>>  return rc;
>>  }
>>  
>> -static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
>> +static netdev_tx_t
>> +netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
>>  {
>>  struct net_device_context *net_device_ctx = netdev_priv(net);
>>  struct hv_netvsc_packet *packet = NULL;
>> @@ -528,8 +529,11 @@ static int netvsc_start_xmit(struct sk_buff *skb, 
>> struct net_device *net)
>>   */
>>  vf_netdev = rcu_dereference_bh(net_device_ctx->vf_netdev);
>>  if (vf_netdev && netif_running(vf_netdev) &&
>> -!netpoll_tx_running(net))
>> -return netvsc_vf_xmit(net, vf_netdev, skb);
>> +!netpoll_tx_running(net)) {
>> +ret = netvsc_vf_xmit(net, vf_netdev, skb);
>> +if (ret)
>> +return NETDEV_TX_BUSY;
>> +}
> 
> Sorry, the new code is wrong. It will fall through if ret == 0 (NETDEV_TX_OK)
> Please review and test your patches.

I'm sorry for this, will correct it as Haiyang's suggestion.

> 
> .
> 



[PATCH -next] bus: fsl-mc: remove duplicated include

2018-09-19 Thread YueHaibing
Remove duplicated include linux/fsl/mc.h

Signed-off-by: YueHaibing 
---
 drivers/bus/fsl-mc/dpbp.c  | 1 -
 drivers/bus/fsl-mc/dpcon.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/bus/fsl-mc/dpbp.c b/drivers/bus/fsl-mc/dpbp.c
index 17e3c5d..9003cd3 100644
--- a/drivers/bus/fsl-mc/dpbp.c
+++ b/drivers/bus/fsl-mc/dpbp.c
@@ -5,7 +5,6 @@
  */
 #include 
 #include 
-#include 
 
 #include "fsl-mc-private.h"
 
diff --git a/drivers/bus/fsl-mc/dpcon.c b/drivers/bus/fsl-mc/dpcon.c
index 760555d..97b6fa60 100644
--- a/drivers/bus/fsl-mc/dpcon.c
+++ b/drivers/bus/fsl-mc/dpcon.c
@@ -5,7 +5,6 @@
  */
 #include 
 #include 
-#include 
 
 #include "fsl-mc-private.h"
 
-- 
2.7.0




[PATCH -next] mm/gup_benchmark: Fix unsigned comparison to zero in __gup_benchmark_ioctl

2018-09-21 Thread YueHaibing
get_user_pages_fast will return negative value if no pages were pinned,
then be converted to a unsigned, which is compared to zero, giving
the wrong result.

Fixes: 09e35a4a1ca8 ("mm/gup_benchmark: handle gup failures")
Signed-off-by: YueHaibing 
---
 mm/gup_benchmark.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c
index 6a47370..7405c9d8 100644
--- a/mm/gup_benchmark.c
+++ b/mm/gup_benchmark.c
@@ -19,7 +19,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
struct gup_benchmark *gup)
 {
ktime_t start_time, end_time;
-   unsigned long i, nr, nr_pages, addr, next;
+   unsigned long i, nr_pages, addr, next;
+   int nr;
struct page **pages;
 
nr_pages = gup->size / PAGE_SIZE;
-- 
2.7.0




[PATCH net-next] l2tp: fix return type of ndo_start_xmit function

2018-09-26 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

Found by coccinelle.

Signed-off-by: YueHaibing 
---
 net/l2tp/l2tp_eth.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 8aadc4f..4173cb1 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -77,7 +77,8 @@ static void l2tp_eth_dev_uninit(struct net_device *dev)
 */
 }
 
-static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct l2tp_eth *priv = netdev_priv(dev);
struct l2tp_session *session = priv->session;
-- 
1.8.3.1




[PATCH -next] PCI: hotplug: Remove set but not used variable 'physical_slot'

2018-09-26 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/pci/hotplug/cpqphp_core.c: In function 'init_SERR':
drivers/pci/hotplug/cpqphp_core.c:124:5: warning:
 variable 'physical_slot' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/pci/hotplug/cpqphp_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp_core.c 
b/drivers/pci/hotplug/cpqphp_core.c
index 95b7d60..16bbb18 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -121,7 +121,6 @@ static int init_SERR(struct controller *ctrl)
 {
u32 tempdword;
u32 number_of_slots;
-   u8 physical_slot;
 
if (!ctrl)
return 1;
@@ -131,7 +130,6 @@ static int init_SERR(struct controller *ctrl)
number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
/* Loop through slots */
while (number_of_slots) {
-   physical_slot = tempdword;
writeb(0, ctrl->hpc_reg + SLOT_SERR);
tempdword++;
number_of_slots--;



[PATCH -next] ASoC: qcom: qdsp6: remove duplicated include

2018-09-26 Thread YueHaibing
Remove duplicated includes linux/of_platform.h
and linux/wait.h

Signed-off-by: YueHaibing 
---
 sound/soc/qcom/qdsp6/q6asm.c  | 1 -
 sound/soc/qcom/qdsp6/q6core.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
index 2b2c723..e1cfa84 100644
--- a/sound/soc/qcom/qdsp6/q6asm.c
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -11,7 +11,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/sound/soc/qcom/qdsp6/q6core.c b/sound/soc/qcom/qdsp6/q6core.c
index ca1be73..cdfc8ab 100644
--- a/sound/soc/qcom/qdsp6/q6core.c
+++ b/sound/soc/qcom/qdsp6/q6core.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include "q6core.h"
 #include "q6dsp-errno.h"
-- 
2.7.0




[PATCH -next] nfsd: remove set but not used variable 'dirp'

2018-09-25 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

fs/nfsd/vfs.c: In function 'nfsd_create':
fs/nfsd/vfs.c:1279:16: warning:
 variable 'dirp' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 fs/nfsd/vfs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index b53e763..d74583f 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1276,7 +1276,6 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh 
*fhp,
int type, dev_t rdev, struct svc_fh *resfhp)
 {
struct dentry   *dentry, *dchild = NULL;
-   struct inode*dirp;
__be32  err;
int host_err;
 
@@ -1288,7 +1287,6 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh 
*fhp,
return err;
 
dentry = fhp->fh_dentry;
-   dirp = d_inode(dentry);
 
host_err = fh_want_write(fhp);
if (host_err)



[PATCH -next] RDMA/core: Properly return the error code of rdma_set_src_addr_rcu

2018-09-19 Thread YueHaibing
rdma_set_src_addr_rcu should check copy_src_l2_addr fails,
rather than always return 0. Also copy_src_l2_addr should return
'ret' as its return value while rdma_translate_ip fails.

Fixes: c31d4b2ddf07 ("RDMA/core: Protect against changing dst->dev during 
destination resolve")
Signed-off-by: YueHaibing 
---
 drivers/infiniband/core/addr.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 7a0356c..8a31b11 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -468,7 +468,7 @@ static int addr_resolve_neigh(const struct dst_entry *dst,
return ret;
 }
 
-static void copy_src_l2_addr(struct rdma_dev_addr *dev_addr,
+static int copy_src_l2_addr(struct rdma_dev_addr *dev_addr,
 const struct sockaddr *dst_in,
 const struct dst_entry *dst,
 const struct net_device *ndev)
@@ -492,6 +492,8 @@ static void copy_src_l2_addr(struct rdma_dev_addr *dev_addr,
RDMA_NETWORK_IPV6;
else
dev_addr->network = RDMA_NETWORK_IB;
+
+   return ret;
 }
 
 static int rdma_set_src_addr_rcu(struct rdma_dev_addr *dev_addr,
@@ -499,6 +501,7 @@ static int rdma_set_src_addr_rcu(struct rdma_dev_addr 
*dev_addr,
 const struct sockaddr *dst_in,
 const struct dst_entry *dst)
 {
+   int ret;
struct net_device *ndev = READ_ONCE(dst->dev);
 
*ndev_flags = ndev->flags;
@@ -515,8 +518,8 @@ static int rdma_set_src_addr_rcu(struct rdma_dev_addr 
*dev_addr,
return -ENODEV;
}
 
-   copy_src_l2_addr(dev_addr, dst_in, dst, ndev);
-   return 0;
+   ret = copy_src_l2_addr(dev_addr, dst_in, dst, ndev);
+   return ret;
 }
 
 static int set_addr_netns_by_gid_rcu(struct rdma_dev_addr *addr)
-- 
2.7.0




Re: [PATCH -next] serial: imx: remove set but not used variable 'rtsirq'

2018-09-20 Thread YueHaibing
On 2018/9/20 17:41, Andy Duan wrote:
> From: Leonard Crestez Sent: 2018年9月20日 16:51
>> On Thu, 2018-09-20 at 08:45 +0200, Jiri Slaby wrote:
>>> On 09/20/2018, 03:58 AM, YueHaibing wrote:
>>>> Fixes gcc '-Wunused-but-set-variable' warning:
>>>>
>>>> drivers/tty/serial/imx.c: In function 'imx_uart_probe':
>>>> drivers/tty/serial/imx.c:2198:20: warning:
>>>>  variable 'rtsirq' set but not used [-Wunused-but-set-variable]
>>>>
>>>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c @@
>>>> -2220,7 +2220,6 @@ static int imx_uart_probe(struct
>> platform_device
>>>> *pdev)
>>>>
>>>>rxirq = platform_get_irq(pdev, 0);
>>>>txirq = platform_get_irq(pdev, 1);
>>>> -  rtsirq = platform_get_irq(pdev, 2);
>>>
>>> I am not sure this is correct. platform_get_irq has side effects (like
>>> enabling the IRQ). Are you sure this won't change the behaviour (this
>>> is question mostly to IMX fellows)?
>>
>> As far as I can tell there was a request_irq call for rtsirq which was
>> removed by mistake in commit afe9cbb1a6ad ("serial: imx: drop support
>> for IRDA"):
>>
>> -   /* do not use RTS IRQ on IrDA */
>> -   if (!USE_IRDA(sport)) {
>> -   ret = devm_request_irq(>dev, rtsirq,
>> -  imx_rtsint, 0,
>> -
>> dev_name(>dev), sport);
>> -   if (ret)
>> -   return ret;
>> -   }
>>
>> This should have just removed the IRDA check and request rtsirq
>> unconditionally. Nobody noticed this by testing RTS on imx1, this is an old
>> chip and later variants have a single combined irq.
>>
>> The correct fix for the warning would be to restore that request_irq.
>>
>> --
>> Regards,
>> Leonard
> 
> Yes, your explain is very correct! Thanks for your comment.
> We should restore rtsirq request that for i.MX1.

Ok, I will post a new fix patch as Leonard and suggested.

> 
> Regards,
> Andy Duan
> 



[PATCH net-next 00/22] net: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

YueHaibing (22):
  net: micrel: fix return type of ndo_start_xmit function
  net: freescale: fix return type of ndo_start_xmit function
  net: seeq: fix return type of ndo_start_xmit function
  net: cirrus: fix return type of ndo_start_xmit function
  net: sgi: fix return type of ndo_start_xmit function
  net: wiznet: fix return type of ndo_start_xmit function
  net: i825xx: fix return type of ndo_start_xmit function
  net: apple: fix return type of ndo_start_xmit function
  net: smsc: fix return type of ndo_start_xmit function
  net: ti: fix return type of ndo_start_xmit function
  net: faraday: fix return type of ndo_start_xmit function
  net: ovs: fix return type of ndo_start_xmit function
  net: xen-netback: fix return type of ndo_start_xmit function
  net: caif: fix return type of ndo_start_xmit function
  net: hamradio: fix return type of ndo_start_xmit function
  usbnet: ipheth: fix return type of ndo_start_xmit function
  hv_netvsc: fix return type of ndo_start_xmit function
  can: xilinx: fix return type of ndo_start_xmit function
  net: plip: fix return type of ndo_start_xmit function
  rionet: fix return type of ndo_start_xmit function
  l2tp: fix return type of ndo_start_xmit function
  net: hsr: fix return type of ndo_start_xmit function

 drivers/net/caif/caif_hsi.c   | 10 +-
 drivers/net/caif/caif_serial.c|  7 +--
 drivers/net/caif/caif_spi.c   |  6 +++---
 drivers/net/caif/caif_virtio.c|  2 +-
 drivers/net/can/xilinx_can.c  |  2 +-
 drivers/net/ethernet/apple/bmac.c |  4 ++--
 drivers/net/ethernet/apple/mace.c |  4 ++--
 drivers/net/ethernet/apple/macmace.c  |  4 ++--
 drivers/net/ethernet/cirrus/ep93xx_eth.c  |  2 +-
 drivers/net/ethernet/cirrus/mac89x0.c |  4 ++--
 drivers/net/ethernet/faraday/ftgmac100.c  |  4 ++--
 drivers/net/ethernet/faraday/ftmac100.c   |  7 ---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c|  3 ++-
 drivers/net/ethernet/freescale/fec_mpc52xx.c  |  3 ++-
 drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c |  3 ++-
 drivers/net/ethernet/freescale/gianfar.c  |  4 ++--
 drivers/net/ethernet/freescale/ucc_geth.c |  3 ++-
 drivers/net/ethernet/i825xx/ether1.c  |  5 +++--
 drivers/net/ethernet/i825xx/lib82596.c|  4 ++--
 drivers/net/ethernet/i825xx/sun3_82586.c  |  6 --
 drivers/net/ethernet/micrel/ks8695net.c   |  2 +-
 drivers/net/ethernet/micrel/ks8851_mll.c  |  4 ++--
 drivers/net/ethernet/seeq/ether3.c|  5 +++--
 drivers/net/ethernet/seeq/sgiseeq.c   |  3 ++-
 drivers/net/ethernet/sgi/ioc3-eth.c   |  4 ++--
 drivers/net/ethernet/sgi/meth.c   |  2 +-
 drivers/net/ethernet/smsc/smc911x.c   |  3 ++-
 drivers/net/ethernet/smsc/smc91x.c|  3 ++-
 drivers/net/ethernet/smsc/smsc911x.c  |  3 ++-
 drivers/net/ethernet/ti/cpmac.c   |  2 +-
 drivers/net/ethernet/ti/davinci_emac.c|  2 +-
 drivers/net/ethernet/ti/netcp_core.c  |  8 
 drivers/net/ethernet/wiznet/w5100.c   |  2 +-
 drivers/net/ethernet/wiznet/w5300.c   |  2 +-
 drivers/net/hamradio/baycom_epp.c |  3 ++-
 drivers/net/hamradio/dmascc.c |  4 ++--
 drivers/net/hyperv/netvsc_drv.c   | 10 +++---
 drivers/net/plip/plip.c   |  4 ++--
 drivers/net/rionet.c  |  3 ++-
 drivers/net/usb/ipheth.c  |  2 +-
 drivers/net/xen-netback/interface.c   |  3 ++-
 net/caif/chnl_net.c   |  3 ++-
 net/hsr/hsr_device.c  |  2 +-
 net/l2tp/l2tp_eth.c   |  3 ++-
 net/openvswitch/vport-internal_dev.c  |  5 +++--
 45 files changed, 100 insertions(+), 74 deletions(-)

-- 
1.8.3.1




[PATCH net-next 05/22] net: sgi: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

Found by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/sgi/ioc3-eth.c | 4 ++--
 drivers/net/ethernet/sgi/meth.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c 
b/drivers/net/ethernet/sgi/ioc3-eth.c
index 18d533f..3140999 100644
--- a/drivers/net/ethernet/sgi/ioc3-eth.c
+++ b/drivers/net/ethernet/sgi/ioc3-eth.c
@@ -99,7 +99,7 @@ struct ioc3_private {
 
 static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void ioc3_set_multicast_list(struct net_device *dev);
-static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t ioc3_start_xmit(struct sk_buff *skb, struct net_device 
*dev);
 static void ioc3_timeout(struct net_device *dev);
 static inline unsigned int ioc3_hash(const unsigned char *addr);
 static inline void ioc3_stop(struct ioc3_private *ip);
@@ -1390,7 +1390,7 @@ static void ioc3_remove_one(struct pci_dev *pdev)
.remove = ioc3_remove_one,
 };
 
-static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
unsigned long data;
struct ioc3_private *ip = netdev_priv(dev);
diff --git a/drivers/net/ethernet/sgi/meth.c b/drivers/net/ethernet/sgi/meth.c
index ea55abd..703fbbe 100644
--- a/drivers/net/ethernet/sgi/meth.c
+++ b/drivers/net/ethernet/sgi/meth.c
@@ -697,7 +697,7 @@ static void meth_add_to_tx_ring(struct meth_private *priv, 
struct sk_buff *skb)
 /*
  * Transmit a packet (called by the kernel)
  */
-static int meth_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t meth_tx(struct sk_buff *skb, struct net_device *dev)
 {
struct meth_private *priv = netdev_priv(dev);
unsigned long flags;
-- 
1.8.3.1




[PATCH net-next 02/22] net: freescale: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

Found by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c| 3 ++-
 drivers/net/ethernet/freescale/fec_mpc52xx.c  | 3 ++-
 drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 3 ++-
 drivers/net/ethernet/freescale/gianfar.c  | 4 ++--
 drivers/net/ethernet/freescale/ucc_geth.c | 3 ++-
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index a5131a5..84843de 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2044,7 +2044,8 @@ static inline int dpaa_xmit(struct dpaa_priv *priv,
return 0;
 }
 
-static int dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
+static netdev_tx_t
+dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
 {
const int queue_mapping = skb_get_queue_mapping(skb);
bool nonlinear = skb_is_nonlinear(skb);
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c 
b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 6d7269d..b90bab7 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -305,7 +305,8 @@ static int mpc52xx_fec_close(struct net_device *dev)
  * invariant will hold if you make sure that the netif_*_queue()
  * calls are done at the proper times.
  */
-static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
struct bcom_fec_bd *bd;
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c 
b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 2c2976a..7c548ed 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -481,7 +481,8 @@ static struct sk_buff *tx_skb_align_workaround(struct 
net_device *dev,
 }
 #endif
 
-static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct fs_enet_private *fep = netdev_priv(dev);
cbd_t __iomem *bdp;
diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index c488d31..0bd21a4 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -110,7 +110,7 @@
 const char gfar_driver_version[] = "2.0";
 
 static int gfar_enet_open(struct net_device *dev);
-static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t gfar_start_xmit(struct sk_buff *skb, struct net_device 
*dev);
 static void gfar_reset_task(struct work_struct *work);
 static void gfar_timeout(struct net_device *dev);
 static int gfar_close(struct net_device *dev);
@@ -2332,7 +2332,7 @@ static inline bool gfar_csum_errata_76(struct 
gfar_private *priv,
 /* This is called by the kernel when a frame is ready for transmission.
  * It is pointed to by the dev->hard_start_xmit function pointer
  */
-static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct gfar_private *priv = netdev_priv(dev);
struct gfar_priv_tx_q *tx_queue = NULL;
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c 
b/drivers/net/ethernet/freescale/ucc_geth.c
index 9600837..32e0270 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3078,7 +3078,8 @@ static int ucc_geth_startup(struct ucc_geth_private 
*ugeth)
 
 /* This is called by the kernel when a frame is ready for transmission. */
 /* It is pointed to by the dev->hard_start_xmit function pointer */
-static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct ucc_geth_private *ugeth = netdev_priv(dev);
 #ifdef CONFIG_UGETH_TX_ON_DEMAND
-- 
1.8.3.1




[PATCH net-next 09/22] net: smsc: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

Found by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/smsc/smc911x.c  | 3 ++-
 drivers/net/ethernet/smsc/smc91x.c   | 3 ++-
 drivers/net/ethernet/smsc/smsc911x.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index b1b53f6..8355dfb 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -513,7 +513,8 @@ static void smc911x_hardware_send_pkt(struct net_device 
*dev)
  * now, or set the card to generates an interrupt when ready
  * for the packet.
  */
-static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct smc911x_local *lp = netdev_priv(dev);
unsigned int free;
diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index b944828..8d6cff8 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -638,7 +638,8 @@ static void smc_hardware_send_pkt(unsigned long data)
  * now, or set the card to generates an interrupt when ready
  * for the packet.
  */
-static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct smc_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
diff --git a/drivers/net/ethernet/smsc/smsc911x.c 
b/drivers/net/ethernet/smsc/smsc911x.c
index c009407..99a5a8a 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1786,7 +1786,8 @@ static int smsc911x_stop(struct net_device *dev)
 }
 
 /* Entry point for transmitting a packet */
-static int smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device 
*dev)
+static netdev_tx_t
+smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct smsc911x_data *pdata = netdev_priv(dev);
unsigned int freespace;
-- 
1.8.3.1




[PATCH net-next 11/22] net: faraday: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, but the implementation in this
driver returns an 'int'.

Found by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 4 ++--
 drivers/net/ethernet/faraday/ftmac100.c  | 7 ---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index d8ead7e..4d67322 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -712,8 +712,8 @@ static bool ftgmac100_prep_tx_csum(struct sk_buff *skb, u32 
*csum_vlan)
return skb_checksum_help(skb) == 0;
 }
 
-static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
-struct net_device *netdev)
+static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
+struct net_device *netdev)
 {
struct ftgmac100 *priv = netdev_priv(netdev);
struct ftgmac100_txdes *txdes, *first;
diff --git a/drivers/net/ethernet/faraday/ftmac100.c 
b/drivers/net/ethernet/faraday/ftmac100.c
index a1197d3..570caeb 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -634,8 +634,8 @@ static void ftmac100_tx_complete(struct ftmac100 *priv)
;
 }
 
-static int ftmac100_xmit(struct ftmac100 *priv, struct sk_buff *skb,
-dma_addr_t map)
+static netdev_tx_t ftmac100_xmit(struct ftmac100 *priv, struct sk_buff *skb,
+dma_addr_t map)
 {
struct net_device *netdev = priv->netdev;
struct ftmac100_txdes *txdes;
@@ -1016,7 +1016,8 @@ static int ftmac100_stop(struct net_device *netdev)
return 0;
 }
 
-static int ftmac100_hard_start_xmit(struct sk_buff *skb, struct net_device 
*netdev)
+static netdev_tx_t
+ftmac100_hard_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
struct ftmac100 *priv = netdev_priv(netdev);
dma_addr_t map;
-- 
1.8.3.1




[PATCH net-next 14/22] net: caif: fix return type of ndo_start_xmit function

2018-09-20 Thread YueHaibing
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

Found by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/net/caif/caif_hsi.c| 10 +-
 drivers/net/caif/caif_serial.c |  7 +--
 drivers/net/caif/caif_spi.c|  6 +++---
 drivers/net/caif/caif_virtio.c |  2 +-
 net/caif/chnl_net.c|  3 ++-
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
index 433a14b..70c449e 100644
--- a/drivers/net/caif/caif_hsi.c
+++ b/drivers/net/caif/caif_hsi.c
@@ -1006,7 +1006,7 @@ static void cfhsi_aggregation_tout(struct timer_list *t)
cfhsi_start_tx(cfhsi);
 }
 
-static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct cfhsi *cfhsi = NULL;
int start_xfer = 0;
@@ -1014,7 +1014,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct 
net_device *dev)
int prio;
 
if (!dev)
-   return -EINVAL;
+   return NETDEV_TX_BUSY;
 
cfhsi = netdev_priv(dev);
 
@@ -1048,7 +1048,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct 
net_device *dev)
if (WARN_ON(test_bit(CFHSI_SHUTDOWN, >bits))) {
spin_unlock_bh(>lock);
cfhsi_abort_tx(cfhsi);
-   return -EINVAL;
+   return NETDEV_TX_BUSY;
}
 
/* Send flow off if number of packets is above high water mark. */
@@ -1072,7 +1072,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct 
net_device *dev)
spin_unlock_bh(>lock);
if (aggregate_ready)
cfhsi_start_tx(cfhsi);
-   return 0;
+   return NETDEV_TX_OK;
}
 
/* Delete inactivity timer if started. */
@@ -1102,7 +1102,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct 
net_device *dev)
queue_work(cfhsi->wq, >wake_up_work);
}
 
-   return 0;
+   return NETDEV_TX_OK;
 }
 
 static const struct net_device_ops cfhsi_netdevops;
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index a0f954f..acb3264 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -275,7 +275,7 @@ static int handle_tx(struct ser_device *ser)
return tty_wr;
 }
 
-static int caif_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t caif_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct ser_device *ser;
 
@@ -290,7 +290,10 @@ static int caif_xmit(struct sk_buff *skb, struct 
net_device *dev)
ser->common.flowctrl(ser->dev, OFF);
 
skb_queue_tail(>head, skb);
-   return handle_tx(ser);
+   if (handle_tx(ser))
+   return NETDEV_TX_BUSY;
+
+   return NETDEV_TX_OK;
 }
 
 
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index d28a139..9040658 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -486,12 +486,12 @@ static void cfspi_xfer_done_cb(struct cfspi_ifc *ifc)
complete(>comp);
 }
 
-static int cfspi_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t cfspi_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct cfspi *cfspi = NULL;
unsigned long flags;
if (!dev)
-   return -EINVAL;
+   return NETDEV_TX_BUSY;
 
cfspi = netdev_priv(dev);
 
@@ -512,7 +512,7 @@ static int cfspi_xmit(struct sk_buff *skb, struct 
net_device *dev)
cfspi->cfdev.flowctrl(cfspi->ndev, 0);
}
 
-   return 0;
+   return NETDEV_TX_OK;
 }
 
 int cfspi_rxfrm(struct cfspi *cfspi, u8 *buf, size_t len)
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index 2814e0d..f5507db 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -519,7 +519,7 @@ static struct buf_info *cfv_alloc_and_copy_to_shm(struct 
cfv_info *cfv,
 }
 
 /* Put the CAIF packet on the virtio ring and kick the receiver */
-static int cfv_netdev_tx(struct sk_buff *skb, struct net_device *netdev)
+static netdev_tx_t cfv_netdev_tx(struct sk_buff *skb, struct net_device 
*netdev)
 {
struct cfv_info *cfv = netdev_priv(netdev);
struct buf_info *buf_info;
diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 13e2ae6..30be426 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -211,7 +211,8 @@ static void chnl_flowctrl_cb(struct cflayer *layr, enum 
caif_ctrlcmd flow,
}
 }
 
-static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct chnl_net

  1   2   >