mirror of
https://github.com/proski/madwifi
synced 2024-11-26 00:09:46 +03:00
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
This commit is contained in:
parent
63c6adeeb8
commit
ef6d84125b
12
ath/if_ath.c
12
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 */
|
/* Allocate space for dynamically determined maximum VAP count */
|
||||||
sc->sc_bslot =
|
sc->sc_bslot =
|
||||||
kmalloc(ath_maxvaps * sizeof(struct ieee80211vap), GFP_KERNEL);
|
kzalloc(ath_maxvaps * sizeof(struct ieee80211vap), GFP_KERNEL);
|
||||||
memset(sc->sc_bslot, 0, ath_maxvaps * sizeof(struct ieee80211vap));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cache line size is used to size and align various
|
* Cache line size is used to size and align various
|
||||||
@ -5658,12 +5657,11 @@ ath_descdma_setup(struct ath_softc *sc,
|
|||||||
|
|
||||||
/* allocate buffers */
|
/* allocate buffers */
|
||||||
bsize = sizeof(struct ath_buf) * nbuf;
|
bsize = sizeof(struct ath_buf) * nbuf;
|
||||||
bf = kmalloc(bsize, GFP_KERNEL);
|
bf = kzalloc(bsize, GFP_KERNEL);
|
||||||
if (bf == NULL) {
|
if (bf == NULL) {
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
goto fail2;
|
goto fail2;
|
||||||
}
|
}
|
||||||
memset(bf, 0, bsize);
|
|
||||||
dd->dd_bufptr = bf;
|
dd->dd_bufptr = bf;
|
||||||
|
|
||||||
STAILQ_INIT(head);
|
STAILQ_INIT(head);
|
||||||
@ -5752,9 +5750,8 @@ ath_node_alloc(struct ieee80211vap *vap)
|
|||||||
{
|
{
|
||||||
struct ath_softc *sc = vap->iv_ic->ic_dev->priv;
|
struct ath_softc *sc = vap->iv_ic->ic_dev->priv;
|
||||||
const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space;
|
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) {
|
if (an != NULL) {
|
||||||
memset(an, 0, space);
|
|
||||||
an->an_decomp_index = INVALID_DECOMP_INDEX;
|
an->an_decomp_index = INVALID_DECOMP_INDEX;
|
||||||
an->an_avgrssi = ATH_RSSI_DUMMY_MARKER;
|
an->an_avgrssi = ATH_RSSI_DUMMY_MARKER;
|
||||||
/*
|
/*
|
||||||
@ -11271,7 +11268,7 @@ ath_dynamic_sysctl_register(struct ath_softc *sc)
|
|||||||
char *dev_name = NULL;
|
char *dev_name = NULL;
|
||||||
|
|
||||||
space = 5 * sizeof(struct ctl_table) + sizeof(ath_sysctl_template);
|
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) {
|
if (sc->sc_sysctls == NULL) {
|
||||||
EPRINTF(sc, "Insufficient memory for sysctl table!\n");
|
EPRINTF(sc, "Insufficient memory for sysctl table!\n");
|
||||||
return;
|
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);
|
strncpy(dev_name, DEV_NAME(sc->sc_dev), strlen(DEV_NAME(sc->sc_dev)) + 1);
|
||||||
|
|
||||||
/* setup the table */
|
/* setup the table */
|
||||||
memset(sc->sc_sysctls, 0, space);
|
|
||||||
sc->sc_sysctls[0].ctl_name = CTL_DEV;
|
sc->sc_sysctls[0].ctl_name = CTL_DEV;
|
||||||
sc->sc_sysctls[0].procname = "dev";
|
sc->sc_sysctls[0].procname = "dev";
|
||||||
sc->sc_sysctls[0].mode = 0555;
|
sc->sc_sysctls[0].mode = 0555;
|
||||||
|
@ -1535,11 +1535,9 @@ void ath_rp_init(struct ath_softc *sc)
|
|||||||
|
|
||||||
ath_rp_clear(sc);
|
ath_rp_clear(sc);
|
||||||
|
|
||||||
sc->sc_rp = (struct ath_rp *)kmalloc(
|
sc->sc_rp = (struct ath_rp *)kzalloc(
|
||||||
sizeof(struct ath_rp) *
|
sizeof(struct ath_rp) *
|
||||||
ATH_RADAR_PULSE_NR, GFP_KERNEL);
|
ATH_RADAR_PULSE_NR, GFP_KERNEL);
|
||||||
memset(sc->sc_rp, 0, sizeof(struct ath_rp) *
|
|
||||||
ATH_RADAR_PULSE_NR);
|
|
||||||
|
|
||||||
if (sc->sc_rp == NULL)
|
if (sc->sc_rp == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -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 */
|
/* ensure 32-byte alignment of the private area */
|
||||||
alloc_size = sizeof (*dev) + sizeof_priv + 31;
|
alloc_size = sizeof (*dev) + sizeof_priv + 31;
|
||||||
|
|
||||||
dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
|
dev = (struct net_device *)kzalloc(alloc_size, GFP_KERNEL);
|
||||||
if (dev == NULL)
|
if (dev == NULL) {
|
||||||
{
|
|
||||||
printk(KERN_ERR "alloc_dev: Unable to allocate device memory.\n");
|
printk(KERN_ERR "alloc_dev: Unable to allocate device memory.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(dev, 0, alloc_size);
|
|
||||||
|
|
||||||
if (sizeof_priv)
|
if (sizeof_priv)
|
||||||
dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
|
dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
|
||||||
|
|
||||||
|
@ -995,12 +995,7 @@ EXPORT_SYMBOL(ath_hal_getuptime);
|
|||||||
void * __ahdecl
|
void * __ahdecl
|
||||||
ath_hal_malloc(size_t size)
|
ath_hal_malloc(size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
return kzalloc(size, GFP_KERNEL);
|
||||||
p = kmalloc(size, GFP_KERNEL);
|
|
||||||
if (p)
|
|
||||||
OS_MEMZERO(p, size);
|
|
||||||
return p;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __ahdecl
|
void __ahdecl
|
||||||
|
@ -1024,13 +1024,12 @@ ath_proc_ratesample_open(struct inode *inode, struct file *file)
|
|||||||
struct proc_dir_entry *dp = PDE(inode);
|
struct proc_dir_entry *dp = PDE(inode);
|
||||||
struct ieee80211vap *vap = dp->data;
|
struct ieee80211vap *vap = dp->data;
|
||||||
|
|
||||||
if (!(file->private_data = kmalloc(sizeof(struct proc_ieee80211_priv),
|
if (!(file->private_data = kzalloc(sizeof(struct proc_ieee80211_priv),
|
||||||
GFP_KERNEL)))
|
GFP_KERNEL)))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Initially allocate both read and write buffers */
|
/* Initially allocate both read and write buffers */
|
||||||
pv = (struct proc_ieee80211_priv *) file->private_data;
|
pv = (struct proc_ieee80211_priv *)file->private_data;
|
||||||
memset(pv, 0, sizeof(struct proc_ieee80211_priv));
|
|
||||||
pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE);
|
pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE);
|
||||||
if (!pv->rbuf) {
|
if (!pv->rbuf) {
|
||||||
kfree(pv);
|
kfree(pv);
|
||||||
|
@ -1064,13 +1064,12 @@ proc_ratesample_open(struct inode *inode, struct file *file)
|
|||||||
struct ieee80211vap *vap = dp->data;
|
struct ieee80211vap *vap = dp->data;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
if (!(file->private_data = kmalloc(sizeof(struct proc_ieee80211_priv),
|
if (!(file->private_data = kzalloc(sizeof(struct proc_ieee80211_priv),
|
||||||
GFP_KERNEL)))
|
GFP_KERNEL)))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* initially allocate both read and write buffers */
|
/* initially allocate both read and write buffers */
|
||||||
pv = (struct proc_ieee80211_priv *) file->private_data;
|
pv = (struct proc_ieee80211_priv *)file->private_data;
|
||||||
memset(pv, 0, sizeof(struct proc_ieee80211_priv));
|
|
||||||
pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE);
|
pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE);
|
||||||
if (!pv->rbuf) {
|
if (!pv->rbuf) {
|
||||||
kfree(pv);
|
kfree(pv);
|
||||||
|
@ -456,11 +456,11 @@ proc_ieee80211_open(struct inode *inode, struct file *file)
|
|||||||
struct proc_dir_entry *dp = PDE(inode);
|
struct proc_dir_entry *dp = PDE(inode);
|
||||||
struct ieee80211vap *vap = dp->data;
|
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;
|
return -ENOMEM;
|
||||||
/* initially allocate both read and write buffers */
|
/* initially allocate both read and write buffers */
|
||||||
pv = (struct proc_ieee80211_priv *) file->private_data;
|
pv = (struct proc_ieee80211_priv *)file->private_data;
|
||||||
memset(pv, 0, sizeof(struct proc_ieee80211_priv));
|
|
||||||
pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE);
|
pv->rbuf = vmalloc(MAX_PROC_IEEE80211_SIZE);
|
||||||
if (!pv->rbuf) {
|
if (!pv->rbuf) {
|
||||||
kfree(pv);
|
kfree(pv);
|
||||||
@ -744,7 +744,7 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
|
|||||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) */
|
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) */
|
||||||
|
|
||||||
space = 5 * sizeof(struct ctl_table) + sizeof(ieee80211_sysctl_template);
|
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) {
|
if (vap->iv_sysctls == NULL) {
|
||||||
printk("%s: no memory for sysctl table!\n", __func__);
|
printk("%s: no memory for sysctl table!\n", __func__);
|
||||||
return;
|
return;
|
||||||
@ -762,7 +762,6 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
|
|||||||
strncpy(devname, vap->iv_dev->name, strlen(vap->iv_dev->name) + 1);
|
strncpy(devname, vap->iv_dev->name, strlen(vap->iv_dev->name) + 1);
|
||||||
|
|
||||||
/* setup the table */
|
/* setup the table */
|
||||||
memset(vap->iv_sysctls, 0, space);
|
|
||||||
vap->iv_sysctls[0].ctl_name = CTL_NET;
|
vap->iv_sysctls[0].ctl_name = CTL_NET;
|
||||||
vap->iv_sysctls[0].procname = "net";
|
vap->iv_sysctls[0].procname = "net";
|
||||||
vap->iv_sysctls[0].mode = 0555;
|
vap->iv_sysctls[0].mode = 0555;
|
||||||
|
Loading…
Reference in New Issue
Block a user