* [PATCH -next] qlcnic: use vzalloc() instead of vmalloc()/memset(0) @ 2014-01-07 13:48 Wei Yongjun 2014-01-07 18:22 ` Jitendra Kalsaria 0 siblings, 1 reply; 3+ messages in thread From: Wei Yongjun @ 2014-01-07 13:48 UTC (permalink / raw) To: himanshu.madhani, rajesh.borundia, shahed.shaikh, jitendra.kalsaria, sony.chacko, sucheta.chakraborty Cc: yongjun_wei, linux-driver, netdev From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Use vzalloc() instead of vmalloc() and memset(0). Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c index b529667..16912e2 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c @@ -935,11 +935,10 @@ static ssize_t qlcnic_sysfs_read_pci_config(struct file *file, return QL_STATUS_INVALID_PARAM; pci_info_sz = pci_func_count * sizeof(*pci_info); - pci_info = vmalloc(pci_info_sz); + pci_info = vzalloc(pci_info_sz); if (!pci_info) return -ENOMEM; - memset(pci_info, 0, pci_info_sz); memset(buf, 0, pci_cfg_sz); pci_cfg = (struct qlcnic_pci_func_cfg *)buf; ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] qlcnic: use vzalloc() instead of vmalloc()/memset(0) 2014-01-07 13:48 [PATCH -next] qlcnic: use vzalloc() instead of vmalloc()/memset(0) Wei Yongjun @ 2014-01-07 18:22 ` Jitendra Kalsaria 2014-01-07 19:14 ` Joe Perches 0 siblings, 1 reply; 3+ messages in thread From: Jitendra Kalsaria @ 2014-01-07 18:22 UTC (permalink / raw) To: Wei Yongjun, Himanshu Madhani, Rajesh Borundia, Shahed Shaikh, Sony Chacko, Sucheta Chakraborty Cc: yongjun_wei@trendmicro.com.cn, Dept-Eng Linux Driver, netdev On 1/7/14 5:48 AM, "Wei Yongjun" <weiyj.lk@gmail.com> wrote: >From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > >Use vzalloc() instead of vmalloc() and memset(0). > >Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> >--- > drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Acked-by: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com> > >diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c >b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c >index b529667..16912e2 100644 >--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c >+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c >@@ -935,11 +935,10 @@ static ssize_t qlcnic_sysfs_read_pci_config(struct >file *file, > return QL_STATUS_INVALID_PARAM; > > pci_info_sz = pci_func_count * sizeof(*pci_info); >- pci_info = vmalloc(pci_info_sz); >+ pci_info = vzalloc(pci_info_sz); > if (!pci_info) > return -ENOMEM; > >- memset(pci_info, 0, pci_info_sz); > memset(buf, 0, pci_cfg_sz); > pci_cfg = (struct qlcnic_pci_func_cfg *)buf; > > Thanks, Jiten ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] qlcnic: use vzalloc() instead of vmalloc()/memset(0) 2014-01-07 18:22 ` Jitendra Kalsaria @ 2014-01-07 19:14 ` Joe Perches 0 siblings, 0 replies; 3+ messages in thread From: Joe Perches @ 2014-01-07 19:14 UTC (permalink / raw) To: Jitendra Kalsaria Cc: Wei Yongjun, Himanshu Madhani, Rajesh Borundia, Shahed Shaikh, Sony Chacko, Sucheta Chakraborty, yongjun_wei@trendmicro.com.cn, Dept-Eng Linux Driver, netdev On Tue, 2014-01-07 at 18:22 +0000, Jitendra Kalsaria wrote: > On 1/7/14 5:48 AM, "Wei Yongjun" <weiyj.lk@gmail.com> wrote: > >From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > >Use vzalloc() instead of vmalloc() and memset(0). [] > >diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c > >@@ -935,11 +935,10 @@ static ssize_t qlcnic_sysfs_read_pci_config(struct > >file *file, > > return QL_STATUS_INVALID_PARAM; > > > > pci_info_sz = pci_func_count * sizeof(*pci_info); > >- pci_info = vmalloc(pci_info_sz); > >+ pci_info = vzalloc(pci_info_sz); Maybe this is a bit more comprehensive? pci_info_sz is now used once and might as well be eliminated. Use ETH_ALEN for 6 Remove memset to 0 of buf, add set to 0 of only unset member. --- drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index 35d4876..8d7aa4c 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h @@ -1267,7 +1267,7 @@ struct qlcnic_pci_func_cfg { u16 port_num; u8 pci_func; u8 func_state; - u8 def_mac_addr[6]; + u8 def_mac_addr[ETH_ALEN]; }; struct qlcnic_npar_func_cfg { diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c index b529667..4ac8b20 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c @@ -927,31 +927,28 @@ static ssize_t qlcnic_sysfs_read_pci_config(struct file *file, u32 pci_func_count = qlcnic_get_pci_func_count(adapter); struct qlcnic_pci_func_cfg *pci_cfg; struct qlcnic_pci_info *pci_info; - size_t pci_info_sz, pci_cfg_sz; + size_t pci_cfg_sz; int i, ret; pci_cfg_sz = pci_func_count * sizeof(*pci_cfg); if (size != pci_cfg_sz) return QL_STATUS_INVALID_PARAM; - pci_info_sz = pci_func_count * sizeof(*pci_info); - pci_info = vmalloc(pci_info_sz); + pci_info = vzalloc(pci_func_count * sizeof(*pci_info)); if (!pci_info) return -ENOMEM; - memset(pci_info, 0, pci_info_sz); - memset(buf, 0, pci_cfg_sz); - pci_cfg = (struct qlcnic_pci_func_cfg *)buf; - ret = qlcnic_get_pci_info(adapter, pci_info); if (ret) { vfree(pci_info); return ret; } + pci_cfg = (struct qlcnic_pci_func_cfg *)buf; for (i = 0; i < pci_func_count; i++) { pci_cfg[i].pci_func = pci_info[i].id; pci_cfg[i].func_type = pci_info[i].type; + pci_cfg[i].func_state = 0; pci_cfg[i].port_num = pci_info[i].default_port; pci_cfg[i].min_bw = pci_info[i].tx_min_bw; pci_cfg[i].max_bw = pci_info[i].tx_max_bw; ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-07 19:14 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-07 13:48 [PATCH -next] qlcnic: use vzalloc() instead of vmalloc()/memset(0) Wei Yongjun 2014-01-07 18:22 ` Jitendra Kalsaria 2014-01-07 19:14 ` Joe Perches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox