aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/via-velocity.c
diff options
context:
space:
mode:
authorMariusz Kozlowski <m.kozlowski@tuxland.pl>2007-07-31 18:11:50 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:50:22 -0400
commitae94607d19028f9805e82da8975c66d3858fcfd8 (patch)
treee27db2fcf8f8542a67275f51f07e0522e3d8e953 /drivers/net/via-velocity.c
parentc477f3348abb5f6fb8b627cfdb1d7ae4b8fe613b (diff)
drivers/net/via-velocity.c: mostly kmalloc + memset conversion to kcalloc
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl> drivers/net/via-velocity.c | 88263 -> 88120 (-143 bytes) drivers/net/via-velocity.o | 254264 -> 253828 (-436 bytes) drivers/net/via-velocity.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/via-velocity.c')
-rw-r--r--drivers/net/via-velocity.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 93574add4063..a4729bc385f4 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1071,14 +1071,12 @@ static int velocity_rx_refill(struct velocity_info *vptr)
1071 1071
1072static int velocity_init_rd_ring(struct velocity_info *vptr) 1072static int velocity_init_rd_ring(struct velocity_info *vptr)
1073{ 1073{
1074 int ret = -ENOMEM; 1074 int ret;
1075 unsigned int rsize = sizeof(struct velocity_rd_info) *
1076 vptr->options.numrx;
1077 1075
1078 vptr->rd_info = kmalloc(rsize, GFP_KERNEL); 1076 vptr->rd_info = kcalloc(vptr->options.numrx,
1079 if(vptr->rd_info == NULL) 1077 sizeof(struct velocity_rd_info), GFP_KERNEL);
1080 goto out; 1078 if (!vptr->rd_info)
1081 memset(vptr->rd_info, 0, rsize); 1079 return -ENOMEM;
1082 1080
1083 vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0; 1081 vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0;
1084 1082
@@ -1088,7 +1086,7 @@ static int velocity_init_rd_ring(struct velocity_info *vptr)
1088 "%s: failed to allocate RX buffer.\n", vptr->dev->name); 1086 "%s: failed to allocate RX buffer.\n", vptr->dev->name);
1089 velocity_free_rd_ring(vptr); 1087 velocity_free_rd_ring(vptr);
1090 } 1088 }
1091out: 1089
1092 return ret; 1090 return ret;
1093} 1091}
1094 1092
@@ -1142,21 +1140,19 @@ static int velocity_init_td_ring(struct velocity_info *vptr)
1142 dma_addr_t curr; 1140 dma_addr_t curr;
1143 struct tx_desc *td; 1141 struct tx_desc *td;
1144 struct velocity_td_info *td_info; 1142 struct velocity_td_info *td_info;
1145 unsigned int tsize = sizeof(struct velocity_td_info) *
1146 vptr->options.numtx;
1147 1143
1148 /* Init the TD ring entries */ 1144 /* Init the TD ring entries */
1149 for (j = 0; j < vptr->num_txq; j++) { 1145 for (j = 0; j < vptr->num_txq; j++) {
1150 curr = vptr->td_pool_dma[j]; 1146 curr = vptr->td_pool_dma[j];
1151 1147
1152 vptr->td_infos[j] = kmalloc(tsize, GFP_KERNEL); 1148 vptr->td_infos[j] = kcalloc(vptr->options.numtx,
1153 if(vptr->td_infos[j] == NULL) 1149 sizeof(struct velocity_td_info),
1154 { 1150 GFP_KERNEL);
1151 if (!vptr->td_infos[j]) {
1155 while(--j >= 0) 1152 while(--j >= 0)
1156 kfree(vptr->td_infos[j]); 1153 kfree(vptr->td_infos[j]);
1157 return -ENOMEM; 1154 return -ENOMEM;
1158 } 1155 }
1159 memset(vptr->td_infos[j], 0, tsize);
1160 1156
1161 for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) { 1157 for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) {
1162 td = &(vptr->td_rings[j][i]); 1158 td = &(vptr->td_rings[j][i]);