From ef6d84125bb0526ea22dd064c8b4d00df46b0698 Mon Sep 17 00:00:00 2001 From: mentor Date: Thu, 24 Apr 2008 14:10:42 +0000 Subject: [PATCH] Convert as many things as possible to use kzalloc git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3573 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath/if_ath.c | 12 ++++-------- ath/if_ath_radar.c | 4 +--- ath/if_athvar.h | 7 ++----- ath_hal/ah_os.c | 7 +------ ath_rate/minstrel/minstrel.c | 7 +++---- ath_rate/sample/sample.c | 7 +++---- net80211/ieee80211_linux.c | 9 ++++----- 7 files changed, 18 insertions(+), 35 deletions(-) diff --git a/ath/if_ath.c b/ath/if_ath.c index 3334e9c..3d655c7 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -532,8 +532,7 @@ ath_attach(u_int16_t devid, struct net_device *dev, HAL_BUS_TAG tag) /* Allocate space for dynamically determined maximum VAP count */ sc->sc_bslot = - kmalloc(ath_maxvaps * sizeof(struct ieee80211vap), GFP_KERNEL); - memset(sc->sc_bslot, 0, ath_maxvaps * sizeof(struct ieee80211vap)); + kzalloc(ath_maxvaps * sizeof(struct ieee80211vap), GFP_KERNEL); /* * Cache line size is used to size and align various @@ -5658,12 +5657,11 @@ ath_descdma_setup(struct ath_softc *sc, /* allocate buffers */ bsize = sizeof(struct ath_buf) * nbuf; - bf = kmalloc(bsize, GFP_KERNEL); + bf = kzalloc(bsize, GFP_KERNEL); if (bf == NULL) { error = -ENOMEM; goto fail2; } - memset(bf, 0, bsize); dd->dd_bufptr = bf; STAILQ_INIT(head); @@ -5752,9 +5750,8 @@ ath_node_alloc(struct ieee80211vap *vap) { struct ath_softc *sc = vap->iv_ic->ic_dev->priv; const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; - struct ath_node *an = kmalloc(space, GFP_ATOMIC); + struct ath_node *an = kzalloc(space, GFP_ATOMIC); if (an != NULL) { - memset(an, 0, space); an->an_decomp_index = INVALID_DECOMP_INDEX; an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; /* @@ -11271,7 +11268,7 @@ ath_dynamic_sysctl_register(struct ath_softc *sc) char *dev_name = NULL; space = 5 * sizeof(struct ctl_table) + sizeof(ath_sysctl_template); - sc->sc_sysctls = kmalloc(space, GFP_KERNEL); + sc->sc_sysctls = kzalloc(space, GFP_KERNEL); if (sc->sc_sysctls == NULL) { EPRINTF(sc, "Insufficient memory for sysctl table!\n"); return; @@ -11292,7 +11289,6 @@ ath_dynamic_sysctl_register(struct ath_softc *sc) strncpy(dev_name, DEV_NAME(sc->sc_dev), strlen(DEV_NAME(sc->sc_dev)) + 1); /* setup the table */ - memset(sc->sc_sysctls, 0, space); sc->sc_sysctls[0].ctl_name = CTL_DEV; sc->sc_sysctls[0].procname = "dev"; sc->sc_sysctls[0].mode = 0555; diff --git a/ath/if_ath_radar.c b/ath/if_ath_radar.c index fcfd6ab..9afa2c2 100644 --- a/ath/if_ath_radar.c +++ b/ath/if_ath_radar.c @@ -1535,11 +1535,9 @@ void ath_rp_init(struct ath_softc *sc) ath_rp_clear(sc); - sc->sc_rp = (struct ath_rp *)kmalloc( + sc->sc_rp = (struct ath_rp *)kzalloc( sizeof(struct ath_rp) * ATH_RADAR_PULSE_NR, GFP_KERNEL); - memset(sc->sc_rp, 0, sizeof(struct ath_rp) * - ATH_RADAR_PULSE_NR); if (sc->sc_rp == NULL) return; diff --git a/ath/if_athvar.h b/ath/if_athvar.h index 31d2f50..667f606 100644 --- a/ath/if_athvar.h +++ b/ath/if_athvar.h @@ -136,15 +136,12 @@ static inline struct net_device *_alloc_netdev(int sizeof_priv, const char *mask /* ensure 32-byte alignment of the private area */ alloc_size = sizeof (*dev) + sizeof_priv + 31; - dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL); - if (dev == NULL) - { + dev = (struct net_device *)kzalloc(alloc_size, GFP_KERNEL); + if (dev == NULL) { printk(KERN_ERR "alloc_dev: Unable to allocate device memory.\n"); return NULL; } - memset(dev, 0, alloc_size); - if (sizeof_priv) dev->priv = (void *) (((long)(dev + 1) + 31) & ~31); diff --git a/ath_hal/ah_os.c b/ath_hal/ah_os.c index c4ca4fc..4ace49f 100644 --- a/ath_hal/ah_os.c +++ b/ath_hal/ah_os.c @@ -995,12 +995,7 @@ EXPORT_SYMBOL(ath_hal_getuptime); void * __ahdecl ath_hal_malloc(size_t size) { - void *p; - p = kmalloc(size, GFP_KERNEL); - if (p) - OS_MEMZERO(p, size); - return p; - + return kzalloc(size, GFP_KERNEL); } void __ahdecl diff --git a/ath_rate/minstrel/minstrel.c b/ath_rate/minstrel/minstrel.c index 26938a7..326130d 100644 --- a/ath_rate/minstrel/minstrel.c +++ b/ath_rate/minstrel/minstrel.c @@ -1024,13 +1024,12 @@ ath_proc_ratesample_open(struct inode *inode, struct file *file) struct proc_dir_entry *dp = PDE(inode); struct ieee80211vap *vap = dp->data; - if (!(file->private_data = kmalloc(sizeof(struct proc_ieee80211_priv), - GFP_KERNEL))) + if (!(file->private_data = kzalloc(sizeof(struct proc_ieee80211_priv), + GFP_KERNEL))) return -ENOMEM; /* Initially allocate both read and write buffers */ - pv = (struct proc_ieee80211_priv *) file->private_data; - memset(pv, 0, sizeof(struct proc_ieee80211_priv)); + pv = (struct proc_ieee80211_priv *)file->private_data; pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE); if (!pv->rbuf) { kfree(pv); diff --git a/ath_rate/sample/sample.c b/ath_rate/sample/sample.c index e264f2c..1e2a7a6 100644 --- a/ath_rate/sample/sample.c +++ b/ath_rate/sample/sample.c @@ -1064,13 +1064,12 @@ proc_ratesample_open(struct inode *inode, struct file *file) struct ieee80211vap *vap = dp->data; unsigned long size; - if (!(file->private_data = kmalloc(sizeof(struct proc_ieee80211_priv), - GFP_KERNEL))) + if (!(file->private_data = kzalloc(sizeof(struct proc_ieee80211_priv), + GFP_KERNEL))) return -ENOMEM; /* initially allocate both read and write buffers */ - pv = (struct proc_ieee80211_priv *) file->private_data; - memset(pv, 0, sizeof(struct proc_ieee80211_priv)); + pv = (struct proc_ieee80211_priv *)file->private_data; pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE); if (!pv->rbuf) { kfree(pv); diff --git a/net80211/ieee80211_linux.c b/net80211/ieee80211_linux.c index b9c5fa8..c26fe80 100644 --- a/net80211/ieee80211_linux.c +++ b/net80211/ieee80211_linux.c @@ -456,11 +456,11 @@ proc_ieee80211_open(struct inode *inode, struct file *file) struct proc_dir_entry *dp = PDE(inode); struct ieee80211vap *vap = dp->data; - if (!(file->private_data = kmalloc(sizeof(struct proc_ieee80211_priv), GFP_KERNEL))) + if (!(file->private_data = kzalloc(sizeof(struct proc_ieee80211_priv), + GFP_KERNEL))) return -ENOMEM; /* initially allocate both read and write buffers */ - pv = (struct proc_ieee80211_priv *) file->private_data; - memset(pv, 0, sizeof(struct proc_ieee80211_priv)); + pv = (struct proc_ieee80211_priv *)file->private_data; pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE); if (!pv->rbuf) { kfree(pv); @@ -744,7 +744,7 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap) #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) */ space = 5 * sizeof(struct ctl_table) + sizeof(ieee80211_sysctl_template); - vap->iv_sysctls = kmalloc(space, GFP_KERNEL); + vap->iv_sysctls = kzalloc(space, GFP_KERNEL); if (vap->iv_sysctls == NULL) { printk("%s: no memory for sysctl table!\n", __func__); return; @@ -762,7 +762,6 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap) strncpy(devname, vap->iv_dev->name, strlen(vap->iv_dev->name) + 1); /* setup the table */ - memset(vap->iv_sysctls, 0, space); vap->iv_sysctls[0].ctl_name = CTL_NET; vap->iv_sysctls[0].procname = "net"; vap->iv_sysctls[0].mode = 0555; -- 2.35.1