diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-11-21 19:15:06 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-28 01:53:38 -0500 |
commit | 89bf67f1f080c947c92f8773482d9e57767ca292 (patch) | |
tree | ae492f5f31a32a4f838778cd34320da0bedf9dfd /drivers/net/vxge | |
parent | fe6d2a38b2076cba515dc95b5dc1589a7ab51c17 (diff) |
drivers/net: use vzalloc()
Use vzalloc() and vzalloc_node() in net drivers
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Jon Mason <jon.mason@exar.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxge')
-rw-r--r-- | drivers/net/vxge/vxge-config.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c index 409c2e6053d0..44d3ddd37b3e 100644 --- a/drivers/net/vxge/vxge-config.c +++ b/drivers/net/vxge/vxge-config.c | |||
@@ -1220,13 +1220,12 @@ vxge_hw_device_initialize( | |||
1220 | goto exit; | 1220 | goto exit; |
1221 | 1221 | ||
1222 | hldev = (struct __vxge_hw_device *) | 1222 | hldev = (struct __vxge_hw_device *) |
1223 | vmalloc(sizeof(struct __vxge_hw_device)); | 1223 | vzalloc(sizeof(struct __vxge_hw_device)); |
1224 | if (hldev == NULL) { | 1224 | if (hldev == NULL) { |
1225 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 1225 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
1226 | goto exit; | 1226 | goto exit; |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | memset(hldev, 0, sizeof(struct __vxge_hw_device)); | ||
1230 | hldev->magic = VXGE_HW_DEVICE_MAGIC; | 1229 | hldev->magic = VXGE_HW_DEVICE_MAGIC; |
1231 | 1230 | ||
1232 | vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_ALL); | 1231 | vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_ALL); |
@@ -2064,15 +2063,12 @@ __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate, | |||
2064 | * allocate new memblock and its private part at once. | 2063 | * allocate new memblock and its private part at once. |
2065 | * This helps to minimize memory usage a lot. */ | 2064 | * This helps to minimize memory usage a lot. */ |
2066 | mempool->memblocks_priv_arr[i] = | 2065 | mempool->memblocks_priv_arr[i] = |
2067 | vmalloc(mempool->items_priv_size * n_items); | 2066 | vzalloc(mempool->items_priv_size * n_items); |
2068 | if (mempool->memblocks_priv_arr[i] == NULL) { | 2067 | if (mempool->memblocks_priv_arr[i] == NULL) { |
2069 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2068 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
2070 | goto exit; | 2069 | goto exit; |
2071 | } | 2070 | } |
2072 | 2071 | ||
2073 | memset(mempool->memblocks_priv_arr[i], 0, | ||
2074 | mempool->items_priv_size * n_items); | ||
2075 | |||
2076 | /* allocate DMA-capable memblock */ | 2072 | /* allocate DMA-capable memblock */ |
2077 | mempool->memblocks_arr[i] = | 2073 | mempool->memblocks_arr[i] = |
2078 | __vxge_hw_blockpool_malloc(mempool->devh, | 2074 | __vxge_hw_blockpool_malloc(mempool->devh, |
@@ -2145,12 +2141,11 @@ __vxge_hw_mempool_create( | |||
2145 | } | 2141 | } |
2146 | 2142 | ||
2147 | mempool = (struct vxge_hw_mempool *) | 2143 | mempool = (struct vxge_hw_mempool *) |
2148 | vmalloc(sizeof(struct vxge_hw_mempool)); | 2144 | vzalloc(sizeof(struct vxge_hw_mempool)); |
2149 | if (mempool == NULL) { | 2145 | if (mempool == NULL) { |
2150 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2146 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
2151 | goto exit; | 2147 | goto exit; |
2152 | } | 2148 | } |
2153 | memset(mempool, 0, sizeof(struct vxge_hw_mempool)); | ||
2154 | 2149 | ||
2155 | mempool->devh = devh; | 2150 | mempool->devh = devh; |
2156 | mempool->memblock_size = memblock_size; | 2151 | mempool->memblock_size = memblock_size; |
@@ -2170,31 +2165,27 @@ __vxge_hw_mempool_create( | |||
2170 | 2165 | ||
2171 | /* allocate array of memblocks */ | 2166 | /* allocate array of memblocks */ |
2172 | mempool->memblocks_arr = | 2167 | mempool->memblocks_arr = |
2173 | (void **) vmalloc(sizeof(void *) * mempool->memblocks_max); | 2168 | (void **) vzalloc(sizeof(void *) * mempool->memblocks_max); |
2174 | if (mempool->memblocks_arr == NULL) { | 2169 | if (mempool->memblocks_arr == NULL) { |
2175 | __vxge_hw_mempool_destroy(mempool); | 2170 | __vxge_hw_mempool_destroy(mempool); |
2176 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2171 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
2177 | mempool = NULL; | 2172 | mempool = NULL; |
2178 | goto exit; | 2173 | goto exit; |
2179 | } | 2174 | } |
2180 | memset(mempool->memblocks_arr, 0, | ||
2181 | sizeof(void *) * mempool->memblocks_max); | ||
2182 | 2175 | ||
2183 | /* allocate array of private parts of items per memblocks */ | 2176 | /* allocate array of private parts of items per memblocks */ |
2184 | mempool->memblocks_priv_arr = | 2177 | mempool->memblocks_priv_arr = |
2185 | (void **) vmalloc(sizeof(void *) * mempool->memblocks_max); | 2178 | (void **) vzalloc(sizeof(void *) * mempool->memblocks_max); |
2186 | if (mempool->memblocks_priv_arr == NULL) { | 2179 | if (mempool->memblocks_priv_arr == NULL) { |
2187 | __vxge_hw_mempool_destroy(mempool); | 2180 | __vxge_hw_mempool_destroy(mempool); |
2188 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2181 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
2189 | mempool = NULL; | 2182 | mempool = NULL; |
2190 | goto exit; | 2183 | goto exit; |
2191 | } | 2184 | } |
2192 | memset(mempool->memblocks_priv_arr, 0, | ||
2193 | sizeof(void *) * mempool->memblocks_max); | ||
2194 | 2185 | ||
2195 | /* allocate array of memblocks DMA objects */ | 2186 | /* allocate array of memblocks DMA objects */ |
2196 | mempool->memblocks_dma_arr = (struct vxge_hw_mempool_dma *) | 2187 | mempool->memblocks_dma_arr = (struct vxge_hw_mempool_dma *) |
2197 | vmalloc(sizeof(struct vxge_hw_mempool_dma) * | 2188 | vzalloc(sizeof(struct vxge_hw_mempool_dma) * |
2198 | mempool->memblocks_max); | 2189 | mempool->memblocks_max); |
2199 | 2190 | ||
2200 | if (mempool->memblocks_dma_arr == NULL) { | 2191 | if (mempool->memblocks_dma_arr == NULL) { |
@@ -2203,20 +2194,16 @@ __vxge_hw_mempool_create( | |||
2203 | mempool = NULL; | 2194 | mempool = NULL; |
2204 | goto exit; | 2195 | goto exit; |
2205 | } | 2196 | } |
2206 | memset(mempool->memblocks_dma_arr, 0, | ||
2207 | sizeof(struct vxge_hw_mempool_dma) * | ||
2208 | mempool->memblocks_max); | ||
2209 | 2197 | ||
2210 | /* allocate hash array of items */ | 2198 | /* allocate hash array of items */ |
2211 | mempool->items_arr = | 2199 | mempool->items_arr = |
2212 | (void **) vmalloc(sizeof(void *) * mempool->items_max); | 2200 | (void **) vzalloc(sizeof(void *) * mempool->items_max); |
2213 | if (mempool->items_arr == NULL) { | 2201 | if (mempool->items_arr == NULL) { |
2214 | __vxge_hw_mempool_destroy(mempool); | 2202 | __vxge_hw_mempool_destroy(mempool); |
2215 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2203 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
2216 | mempool = NULL; | 2204 | mempool = NULL; |
2217 | goto exit; | 2205 | goto exit; |
2218 | } | 2206 | } |
2219 | memset(mempool->items_arr, 0, sizeof(void *) * mempool->items_max); | ||
2220 | 2207 | ||
2221 | /* calculate initial number of memblocks */ | 2208 | /* calculate initial number of memblocks */ |
2222 | memblocks_to_allocate = (mempool->items_initial + | 2209 | memblocks_to_allocate = (mempool->items_initial + |
@@ -4272,14 +4259,12 @@ vxge_hw_vpath_open(struct __vxge_hw_device *hldev, | |||
4272 | goto vpath_open_exit1; | 4259 | goto vpath_open_exit1; |
4273 | 4260 | ||
4274 | vp = (struct __vxge_hw_vpath_handle *) | 4261 | vp = (struct __vxge_hw_vpath_handle *) |
4275 | vmalloc(sizeof(struct __vxge_hw_vpath_handle)); | 4262 | vzalloc(sizeof(struct __vxge_hw_vpath_handle)); |
4276 | if (vp == NULL) { | 4263 | if (vp == NULL) { |
4277 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 4264 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
4278 | goto vpath_open_exit2; | 4265 | goto vpath_open_exit2; |
4279 | } | 4266 | } |
4280 | 4267 | ||
4281 | memset(vp, 0, sizeof(struct __vxge_hw_vpath_handle)); | ||
4282 | |||
4283 | vp->vpath = vpath; | 4268 | vp->vpath = vpath; |
4284 | 4269 | ||
4285 | if (vpath->vp_config->fifo.enable == VXGE_HW_FIFO_ENABLE) { | 4270 | if (vpath->vp_config->fifo.enable == VXGE_HW_FIFO_ENABLE) { |