@@ -823,15 +823,15 @@ static int init_shared_mem(struct s2io_nic *nic)
823
823
}
824
824
mem_allocated += size ;
825
825
memset (tmp_v_addr , 0 , size );
826
+
827
+ size = sizeof (struct rxd_info ) *
828
+ rxd_count [nic -> rxd_mode ];
826
829
rx_blocks -> block_virt_addr = tmp_v_addr ;
827
830
rx_blocks -> block_dma_addr = tmp_p_addr ;
828
- rx_blocks -> rxds = kmalloc (sizeof (struct rxd_info )*
829
- rxd_count [nic -> rxd_mode ],
830
- GFP_KERNEL );
831
+ rx_blocks -> rxds = kmalloc (size , GFP_KERNEL );
831
832
if (!rx_blocks -> rxds )
832
833
return - ENOMEM ;
833
- mem_allocated +=
834
- (sizeof (struct rxd_info )* rxd_count [nic -> rxd_mode ]);
834
+ mem_allocated += size ;
835
835
for (l = 0 ; l < rxd_count [nic -> rxd_mode ];l ++ ) {
836
836
rx_blocks -> rxds [l ].virt_addr =
837
837
rx_blocks -> block_virt_addr +
@@ -867,41 +867,37 @@ static int init_shared_mem(struct s2io_nic *nic)
867
867
868
868
blk_cnt = rx_cfg -> num_rxd /
869
869
(rxd_count [nic -> rxd_mode ]+ 1 );
870
- ring -> ba = kmalloc (( sizeof (struct buffAdd * ) * blk_cnt ),
871
- GFP_KERNEL );
870
+ size = sizeof (struct buffAdd * ) * blk_cnt ;
871
+ ring -> ba = kmalloc ( size , GFP_KERNEL );
872
872
if (!ring -> ba )
873
873
return - ENOMEM ;
874
- mem_allocated += ( sizeof ( struct buffAdd * ) * blk_cnt ) ;
874
+ mem_allocated += size ;
875
875
for (j = 0 ; j < blk_cnt ; j ++ ) {
876
876
int k = 0 ;
877
- ring -> ba [ j ] =
878
- kmalloc (( sizeof (struct buffAdd ) *
879
- (rxd_count [nic -> rxd_mode ] + 1 )),
880
- GFP_KERNEL );
877
+
878
+ size = sizeof (struct buffAdd ) *
879
+ (rxd_count [nic -> rxd_mode ] + 1 );
880
+ ring -> ba [ j ] = kmalloc ( size , GFP_KERNEL );
881
881
if (!ring -> ba [j ])
882
882
return - ENOMEM ;
883
- mem_allocated += (sizeof (struct buffAdd ) * \
884
- (rxd_count [nic -> rxd_mode ] + 1 ));
883
+ mem_allocated += size ;
885
884
while (k != rxd_count [nic -> rxd_mode ]) {
886
885
ba = & ring -> ba [j ][k ];
887
-
888
- ba -> ba_0_org = (void * ) kmalloc
889
- (BUF0_LEN + ALIGN_SIZE , GFP_KERNEL );
886
+ size = BUF0_LEN + ALIGN_SIZE ;
887
+ ba -> ba_0_org = kmalloc (size , GFP_KERNEL );
890
888
if (!ba -> ba_0_org )
891
889
return - ENOMEM ;
892
- mem_allocated +=
893
- (BUF0_LEN + ALIGN_SIZE );
890
+ mem_allocated += size ;
894
891
tmp = (unsigned long )ba -> ba_0_org ;
895
892
tmp += ALIGN_SIZE ;
896
893
tmp &= ~((unsigned long ) ALIGN_SIZE );
897
894
ba -> ba_0 = (void * ) tmp ;
898
895
899
- ba -> ba_1_org = ( void * ) kmalloc
900
- ( BUF1_LEN + ALIGN_SIZE , GFP_KERNEL );
896
+ size = BUF1_LEN + ALIGN_SIZE ;
897
+ ba -> ba_1_org = kmalloc ( size , GFP_KERNEL );
901
898
if (!ba -> ba_1_org )
902
899
return - ENOMEM ;
903
- mem_allocated
904
- += (BUF1_LEN + ALIGN_SIZE );
900
+ mem_allocated += size ;
905
901
tmp = (unsigned long ) ba -> ba_1_org ;
906
902
tmp += ALIGN_SIZE ;
907
903
tmp &= ~((unsigned long ) ALIGN_SIZE );
@@ -3835,23 +3831,22 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3835
3831
u64 rx_mat ;
3836
3832
u16 msi_control ; /* Temp variable */
3837
3833
int ret , i , j , msix_indx = 1 ;
3834
+ int size ;
3838
3835
3839
- nic -> entries = kmalloc ( nic -> num_entries * sizeof (struct msix_entry ),
3840
- GFP_KERNEL );
3836
+ size = nic -> num_entries * sizeof (struct msix_entry );
3837
+ nic -> entries = kmalloc ( size , GFP_KERNEL );
3841
3838
if (!nic -> entries ) {
3842
3839
DBG_PRINT (INFO_DBG , "%s: Memory allocation failed\n" , \
3843
3840
__func__ );
3844
3841
nic -> mac_control .stats_info -> sw_stat .mem_alloc_fail_cnt ++ ;
3845
3842
return - ENOMEM ;
3846
3843
}
3847
- nic -> mac_control .stats_info -> sw_stat .mem_allocated
3848
- += (nic -> num_entries * sizeof (struct msix_entry ));
3844
+ nic -> mac_control .stats_info -> sw_stat .mem_allocated += size ;
3849
3845
3850
- memset (nic -> entries , 0 , nic -> num_entries * sizeof ( struct msix_entry ) );
3846
+ memset (nic -> entries , 0 , size );
3851
3847
3852
- nic -> s2io_entries =
3853
- kmalloc (nic -> num_entries * sizeof (struct s2io_msix_entry ),
3854
- GFP_KERNEL );
3848
+ size = nic -> num_entries * sizeof (struct s2io_msix_entry );
3849
+ nic -> s2io_entries = kmalloc (size , GFP_KERNEL );
3855
3850
if (!nic -> s2io_entries ) {
3856
3851
DBG_PRINT (INFO_DBG , "%s: Memory allocation failed\n" ,
3857
3852
__func__ );
@@ -3861,10 +3856,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3861
3856
+= (nic -> num_entries * sizeof (struct msix_entry ));
3862
3857
return - ENOMEM ;
3863
3858
}
3864
- nic -> mac_control .stats_info -> sw_stat .mem_allocated
3865
- += (nic -> num_entries * sizeof (struct s2io_msix_entry ));
3866
- memset (nic -> s2io_entries , 0 ,
3867
- nic -> num_entries * sizeof (struct s2io_msix_entry ));
3859
+ nic -> mac_control .stats_info -> sw_stat .mem_allocated += size ;
3860
+ memset (nic -> s2io_entries , 0 , size );
3868
3861
3869
3862
nic -> entries [0 ].entry = 0 ;
3870
3863
nic -> s2io_entries [0 ].entry = 0 ;
0 commit comments