[PATCH] drm/amdgpu: Prefer pr_err/_info over printk in amdgpu_atpx_handler.c

Luben Tuikov luben.tuikov at amd.com
Mon Jul 31 18:06:40 UTC 2023


On 2023-07-31 08:18, Srinivasan Shanmugam wrote:
> Fixes the following style issues:
> 
> ERROR: open brace '{' following function definitions go on the next line
> WARNING: printk() should include KERN_<LEVEL> facility level
> 
> Cc: Guchun Chen <guchun.chen at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: Bert Karwatzki <spasswolf at web.de>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>  .../gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c  | 29 +++++++++++--------
>  1 file changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
> index d6d986be906a..9ba49a1b7c34 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
> @@ -74,24 +74,29 @@ struct atpx_mux {
>  	u16 mux;
>  } __packed;
>  
> -bool amdgpu_has_atpx(void) {
> +bool amdgpu_has_atpx(void)
> +{
>  	return amdgpu_atpx_priv.atpx_detected;
>  }
>  
> -bool amdgpu_has_atpx_dgpu_power_cntl(void) {
> +bool amdgpu_has_atpx_dgpu_power_cntl(void)
> +{
>  	return amdgpu_atpx_priv.atpx.functions.power_cntl;
>  }
>  
> -bool amdgpu_is_atpx_hybrid(void) {
> +bool amdgpu_is_atpx_hybrid(void)
> +{
>  	return amdgpu_atpx_priv.atpx.is_hybrid;
>  }
>  
> -bool amdgpu_atpx_dgpu_req_power_for_displays(void) {
> +bool amdgpu_atpx_dgpu_req_power_for_displays(void)
> +{
>  	return amdgpu_atpx_priv.atpx.dgpu_req_power_for_displays;
>  }
>  
>  #if defined(CONFIG_ACPI)
> -void *amdgpu_atpx_get_dhandle(void) {
> +void *amdgpu_atpx_get_dhandle(void)
> +{
>  	return amdgpu_atpx_priv.dhandle;
>  }
>  #endif
> @@ -134,7 +139,7 @@ static union acpi_object *amdgpu_atpx_call(acpi_handle handle, int function,
>  
>  	/* Fail only if calling the method fails and ATPX is supported */
>  	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> -		printk("failed to evaluate ATPX got %s\n",
> +		pr_err("failed to evaluate ATPX got %s\n",
>  		       acpi_format_exception(status));
>  		kfree(buffer.pointer);
>  		return NULL;
> @@ -190,7 +195,7 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
>  
>  		size = *(u16 *) info->buffer.pointer;
>  		if (size < 10) {
> -			printk("ATPX buffer is too small: %zu\n", size);
> +			pr_err("ATPX buffer is too small: %zu\n", size);
>  			kfree(info);
>  			return -EINVAL;
>  		}
> @@ -223,11 +228,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
>  	atpx->is_hybrid = false;
>  	if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
>  		if (amdgpu_atpx_priv.quirks & AMDGPU_PX_QUIRK_FORCE_ATPX) {
> -			printk("ATPX Hybrid Graphics, forcing to ATPX\n");
> +			pr_info("ATPX Hybrid Graphics, forcing to ATPX\n");

This should be a pr_warn().

>  			atpx->functions.power_cntl = true;
>  			atpx->is_hybrid = false;
>  		} else {
> -			printk("ATPX Hybrid Graphics\n");
> +			pr_info("ATPX Hybrid Graphics\n");

I'd use pr_notice() here.

>  			/*
>  			 * Disable legacy PM methods only when pcie port PM is usable,
>  			 * otherwise the device might fail to power off or power on.
> @@ -269,7 +274,7 @@ static int amdgpu_atpx_verify_interface(struct amdgpu_atpx *atpx)
>  
>  	size = *(u16 *) info->buffer.pointer;
>  	if (size < 8) {
> -		printk("ATPX buffer is too small: %zu\n", size);
> +		pr_err("ATPX buffer is too small: %zu\n", size);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -278,8 +283,8 @@ static int amdgpu_atpx_verify_interface(struct amdgpu_atpx *atpx)
>  	memcpy(&output, info->buffer.pointer, size);
>  
>  	/* TODO: check version? */
> -	printk("ATPX version %u, functions 0x%08x\n",
> -	       output.version, output.function_bits);
> +	pr_info("ATPX version %u, functions 0x%08x\n",
> +		output.version, output.function_bits);

Probably pr_notice().

>  
>  	amdgpu_atpx_parse_functions(&atpx->functions, output.function_bits);
>  

-- 
Regards,
Luben



More information about the amd-gfx mailing list