Re: [PATCH v2 2/4] platform/mellanox: mlxbf-pmc: Fix signed/unsigned mix-up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 9 Feb 2024, Shravan Kumar Ramani wrote:

> Signed-off-by: Shravan Kumar Ramani <shravankr@xxxxxxxxxx>
> ---
>  drivers/platform/mellanox/mlxbf-pmc.c | 110 ++++++++++++++------------
>  1 file changed, 58 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
> index 71d919832e2a..e3f1ae772e43 100644
> --- a/drivers/platform/mellanox/mlxbf-pmc.c
> +++ b/drivers/platform/mellanox/mlxbf-pmc.c
> @@ -99,8 +99,8 @@
>   */
>  struct mlxbf_pmc_attribute {
>  	struct device_attribute dev_attr;
> -	int index;
> -	int nr;
> +	unsigned int index;
> +	unsigned int nr;
>  };
>  
>  /**
> @@ -121,7 +121,7 @@ struct mlxbf_pmc_block_info {
>  	void __iomem *mmio_base;
>  	size_t blk_size;
>  	size_t counters;
> -	int type;
> +	unsigned int type;
>  	struct mlxbf_pmc_attribute *attr_counter;
>  	struct mlxbf_pmc_attribute *attr_event;
>  	struct mlxbf_pmc_attribute attr_event_list;
> @@ -169,7 +169,7 @@ struct mlxbf_pmc_context {
>   * @evt_name: Name of the event
>   */
>  struct mlxbf_pmc_events {
> -	int evt_num;
> +	u32 evt_num;
>  	char *evt_name;
>  };
>  
> @@ -959,7 +959,7 @@ static int mlxbf_pmc_write(void __iomem *addr, int command, u64 value)
>  }
>  
>  /* Check if the register offset is within the mapped region for the block */
> -static bool mlxbf_pmc_valid_range(int blk_num, u32 offset)
> +static bool mlxbf_pmc_valid_range(unsigned int blk_num, u32 offset)
>  {
>  	if ((offset >= 0) && !(offset % MLXBF_PMC_REG_SIZE) &&
>  	    (offset + MLXBF_PMC_REG_SIZE <= pmc->block[blk_num].blk_size))
> @@ -970,7 +970,7 @@ static bool mlxbf_pmc_valid_range(int blk_num, u32 offset)
>  
>  /* Get the event list corresponding to a certain block */
>  static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk,
> -							   int *size)
> +							   unsigned int *size)

Usually size_t is the type that is preferred for sizes of memory blocks 
(including this case where it's array size that is just memory block 
size divided by another).

-- 
 i.





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux