diff mbox series

[net-next] net: txgbe: remove unused buffer in txgbe_calc_eeprom_checksum

Message ID 20230619085709.104271-1-shaozhengchao@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: txgbe: remove unused buffer in txgbe_calc_eeprom_checksum | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 8 this patch: 9
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang fail Errors and warnings before: 8 this patch: 10
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 8 this patch: 9
netdev/checkpatch warning WARNING: line length of 86 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao June 19, 2023, 8:57 a.m. UTC
Half a year passed since commit 049fe5365324c ("net: txgbe: Add operations
to interact with firmware") was submitted, the buffer in
txgbe_calc_eeprom_checksum was not used. So remove it and the related
branch codes.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 31 +++++++------------
 1 file changed, 11 insertions(+), 20 deletions(-)

Comments

Jiawen Wu June 19, 2023, 10:10 a.m. UTC | #1
On Monday, June 19, 2023 4:57 PM, Zhengchao Shao wrote:
> Half a year passed since commit 049fe5365324c ("net: txgbe: Add operations
> to interact with firmware") was submitted, the buffer in
> txgbe_calc_eeprom_checksum was not used. So remove it and the related
> branch codes.
> 
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 31 +++++++------------
>  1 file changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
> index ebc46f3be056..173437c7a55f 100644
> --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
> +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
> @@ -161,33 +161,24 @@ static int txgbe_calc_eeprom_checksum(struct wx *wx, u16 *checksum)
>  {
>  	u16 *eeprom_ptrs = NULL;
>  	u32 buffer_size = 0;
> -	u16 *buffer = NULL;
>  	u16 *local_buffer;
>  	int status;
>  	u16 i;
> 
>  	wx_init_eeprom_params(wx);
> 
> -	if (!buffer) {
> -		eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16),
> -					     GFP_KERNEL);
> -		if (!eeprom_ptrs)
> -			return -ENOMEM;
> -		/* Read pointer area */
> -		status = wx_read_ee_hostif_buffer(wx, 0,
> -						  TXGBE_EEPROM_LAST_WORD,
> -						  eeprom_ptrs);
> -		if (status != 0) {
> -			wx_err(wx, "Failed to read EEPROM image\n");
> -			kvfree(eeprom_ptrs);
> -			return status;
> -		}
> -		local_buffer = eeprom_ptrs;
> -	} else {
> -		if (buffer_size < TXGBE_EEPROM_LAST_WORD)
> -			return -EFAULT;
> -		local_buffer = buffer;
> +	eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16),
> +				     GFP_KERNEL);
> +	if (!eeprom_ptrs)
> +		return -ENOMEM;
> +	/* Read pointer area */
> +	status = wx_read_ee_hostif_buffer(wx, 0, TXGBE_EEPROM_LAST_WORD, eeprom_ptrs);
> +	if (status != 0) {
> +		wx_err(wx, "Failed to read EEPROM image\n");
> +		kvfree(eeprom_ptrs);
> +		return status;
>  	}
> +	local_buffer = eeprom_ptrs;
> 
>  	for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++)
>  		if (i != wx->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)
> --
> 2.34.1
> 

Reviewed-by: Jiawen Wu <jiawenwu@trustnetic.com>
kernel test robot June 19, 2023, 6:54 p.m. UTC | #2
Hi Zhengchao,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhengchao-Shao/net-txgbe-remove-unused-buffer-in-txgbe_calc_eeprom_checksum/20230619-165935
base:   net-next/main
patch link:    https://lore.kernel.org/r/20230619085709.104271-1-shaozhengchao%40huawei.com
patch subject: [PATCH net-next] net: txgbe: remove unused buffer in txgbe_calc_eeprom_checksum
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230620/202306200242.FXsHokaJ-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230620/202306200242.FXsHokaJ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306200242.FXsHokaJ-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c: In function 'txgbe_calc_eeprom_checksum':
>> drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c:163:13: warning: unused variable 'buffer_size' [-Wunused-variable]
     163 |         u32 buffer_size = 0;
         |             ^~~~~~~~~~~


vim +/buffer_size +163 drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c

049fe5365324c8 Jiawen Wu      2022-10-31  152  
049fe5365324c8 Jiawen Wu      2022-10-31  153  /**
049fe5365324c8 Jiawen Wu      2022-10-31  154   *  txgbe_calc_eeprom_checksum - Calculates and returns the checksum
9607a3e62645c2 Jiawen Wu      2023-01-06  155   *  @wx: pointer to hardware structure
049fe5365324c8 Jiawen Wu      2022-10-31  156   *  @checksum: pointer to cheksum
049fe5365324c8 Jiawen Wu      2022-10-31  157   *
049fe5365324c8 Jiawen Wu      2022-10-31  158   *  Returns a negative error code on error
049fe5365324c8 Jiawen Wu      2022-10-31  159   **/
9607a3e62645c2 Jiawen Wu      2023-01-06  160  static int txgbe_calc_eeprom_checksum(struct wx *wx, u16 *checksum)
049fe5365324c8 Jiawen Wu      2022-10-31  161  {
049fe5365324c8 Jiawen Wu      2022-10-31  162  	u16 *eeprom_ptrs = NULL;
049fe5365324c8 Jiawen Wu      2022-10-31 @163  	u32 buffer_size = 0;
049fe5365324c8 Jiawen Wu      2022-10-31  164  	u16 *local_buffer;
049fe5365324c8 Jiawen Wu      2022-10-31  165  	int status;
049fe5365324c8 Jiawen Wu      2022-10-31  166  	u16 i;
049fe5365324c8 Jiawen Wu      2022-10-31  167  
9607a3e62645c2 Jiawen Wu      2023-01-06  168  	wx_init_eeprom_params(wx);
049fe5365324c8 Jiawen Wu      2022-10-31  169  
049fe5365324c8 Jiawen Wu      2022-10-31  170  	eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16),
049fe5365324c8 Jiawen Wu      2022-10-31  171  				     GFP_KERNEL);
049fe5365324c8 Jiawen Wu      2022-10-31  172  	if (!eeprom_ptrs)
049fe5365324c8 Jiawen Wu      2022-10-31  173  		return -ENOMEM;
049fe5365324c8 Jiawen Wu      2022-10-31  174  	/* Read pointer area */
f5b8ea1c5022db Zhengchao Shao 2023-06-19  175  	status = wx_read_ee_hostif_buffer(wx, 0, TXGBE_EEPROM_LAST_WORD, eeprom_ptrs);
049fe5365324c8 Jiawen Wu      2022-10-31  176  	if (status != 0) {
9607a3e62645c2 Jiawen Wu      2023-01-06  177  		wx_err(wx, "Failed to read EEPROM image\n");
a068d33e542f5d YueHaibing     2022-11-05  178  		kvfree(eeprom_ptrs);
049fe5365324c8 Jiawen Wu      2022-10-31  179  		return status;
049fe5365324c8 Jiawen Wu      2022-10-31  180  	}
049fe5365324c8 Jiawen Wu      2022-10-31  181  	local_buffer = eeprom_ptrs;
049fe5365324c8 Jiawen Wu      2022-10-31  182  
049fe5365324c8 Jiawen Wu      2022-10-31  183  	for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++)
9607a3e62645c2 Jiawen Wu      2023-01-06  184  		if (i != wx->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)
049fe5365324c8 Jiawen Wu      2022-10-31  185  			*checksum += local_buffer[i];
049fe5365324c8 Jiawen Wu      2022-10-31  186  
a068d33e542f5d YueHaibing     2022-11-05  187  	if (eeprom_ptrs)
a068d33e542f5d YueHaibing     2022-11-05  188  		kvfree(eeprom_ptrs);
a068d33e542f5d YueHaibing     2022-11-05  189  
5e2ea7801faccc YueHaibing     2022-11-05  190  	if (*checksum > TXGBE_EEPROM_SUM)
049fe5365324c8 Jiawen Wu      2022-10-31  191  		return -EINVAL;
049fe5365324c8 Jiawen Wu      2022-10-31  192  
5e2ea7801faccc YueHaibing     2022-11-05  193  	*checksum = TXGBE_EEPROM_SUM - *checksum;
5e2ea7801faccc YueHaibing     2022-11-05  194  
049fe5365324c8 Jiawen Wu      2022-10-31  195  	return 0;
049fe5365324c8 Jiawen Wu      2022-10-31  196  }
049fe5365324c8 Jiawen Wu      2022-10-31  197
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
index ebc46f3be056..173437c7a55f 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
@@ -161,33 +161,24 @@  static int txgbe_calc_eeprom_checksum(struct wx *wx, u16 *checksum)
 {
 	u16 *eeprom_ptrs = NULL;
 	u32 buffer_size = 0;
-	u16 *buffer = NULL;
 	u16 *local_buffer;
 	int status;
 	u16 i;
 
 	wx_init_eeprom_params(wx);
 
-	if (!buffer) {
-		eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16),
-					     GFP_KERNEL);
-		if (!eeprom_ptrs)
-			return -ENOMEM;
-		/* Read pointer area */
-		status = wx_read_ee_hostif_buffer(wx, 0,
-						  TXGBE_EEPROM_LAST_WORD,
-						  eeprom_ptrs);
-		if (status != 0) {
-			wx_err(wx, "Failed to read EEPROM image\n");
-			kvfree(eeprom_ptrs);
-			return status;
-		}
-		local_buffer = eeprom_ptrs;
-	} else {
-		if (buffer_size < TXGBE_EEPROM_LAST_WORD)
-			return -EFAULT;
-		local_buffer = buffer;
+	eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16),
+				     GFP_KERNEL);
+	if (!eeprom_ptrs)
+		return -ENOMEM;
+	/* Read pointer area */
+	status = wx_read_ee_hostif_buffer(wx, 0, TXGBE_EEPROM_LAST_WORD, eeprom_ptrs);
+	if (status != 0) {
+		wx_err(wx, "Failed to read EEPROM image\n");
+		kvfree(eeprom_ptrs);
+		return status;
 	}
+	local_buffer = eeprom_ptrs;
 
 	for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++)
 		if (i != wx->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)