linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Erik Kaneda <erik.kaneda@intel.com>,
	Joe Perches <joe@perches.com>, Hanjun Guo <guohanjun@huawei.com>
Subject: Re: [PATCH v3 4/5] ACPI: video: Clean up printing messages
Date: Thu, 4 Feb 2021 19:33:25 +0100	[thread overview]
Message-ID: <fc92bf0f-b770-a4d5-7c0f-0936a4a35a38@redhat.com> (raw)
In-Reply-To: <1924490.ZvBDFke9FE@kreacher>

Hi,

On 2/3/21 7:48 PM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Replace the ACPI_DEBUG_PRINT() instances in acpi_video.c with
> acpi_handle_debug() calls and the ACPI_EXCEPTION()/ACPI_ERROR()/
> ACPI_WARNING() instances in there with acpi_handle_info() calls,
> which among other things causes the excessive log levels of those
> messages to be increased.
> 
> Drop the _COMPONENT and ACPI_MODULE_NAME() definitions that are not
> used any more from acpi_video.c, drop the no longer needed
> ACPI_VIDEO_COMPONENT definition from the headers and update the
> documentation accordingly.
> 
> While at it, add a pr_fmt() definition to acpi_video.c, replace the
> direct printk() invocations in there with acpi_handle_info() or
> pr_info() (and reduce the excessive log level where applicable) and
> drop the PREFIX sybmbol definition which is not necessary any more
> from acpi_video.c.
> 
> Also make unrelated janitorial changes to fix up white space and
> use ACPI_FAILURE() instead of negating ACPI_SUCCESS().
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
> 
> v2 -> v3: Replace more !ACPI_SUCCESS() instances with ACPI_FAILURE().
> 
> v1 -> v2: Changelog update.
> 
> ---
>  Documentation/firmware-guide/acpi/debug.rst |    1 
>  drivers/acpi/acpi_video.c                   |   99 ++++++++++++++--------------
>  drivers/acpi/sysfs.c                        |    1 
>  include/acpi/acpi_drivers.h                 |    1 
>  4 files changed, 51 insertions(+), 51 deletions(-)
> 
> Index: linux-pm/drivers/acpi/acpi_video.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/acpi_video.c
> +++ linux-pm/drivers/acpi/acpi_video.c
> @@ -7,6 +7,8 @@
>   *  Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
>   */
>  
> +#define pr_fmt(fmt) "ACPI: video: " fmt
> +
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/init.h>
> @@ -26,16 +28,11 @@
>  #include <acpi/video.h>
>  #include <linux/uaccess.h>
>  
> -#define PREFIX "ACPI: "
> -
>  #define ACPI_VIDEO_BUS_NAME		"Video Bus"
>  #define ACPI_VIDEO_DEVICE_NAME		"Video Device"
>  
>  #define MAX_NAME_LEN	20
>  
> -#define _COMPONENT		ACPI_VIDEO_COMPONENT
> -ACPI_MODULE_NAME("video");
> -
>  MODULE_AUTHOR("Bruno Ducrot");
>  MODULE_DESCRIPTION("ACPI Video Driver");
>  MODULE_LICENSE("GPL");
> @@ -326,11 +323,11 @@ acpi_video_device_lcd_query_levels(acpi_
>  	*levels = NULL;
>  
>  	status = acpi_evaluate_object(handle, "_BCL", NULL, &buffer);
> -	if (!ACPI_SUCCESS(status))
> +	if (ACPI_FAILURE(status))
>  		return status;
>  	obj = (union acpi_object *)buffer.pointer;
>  	if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
> -		printk(KERN_ERR PREFIX "Invalid _BCL data\n");
> +		acpi_handle_info(handle, "Invalid _BCL data\n");
>  		status = -EFAULT;
>  		goto err;
>  	}
> @@ -354,7 +351,7 @@ acpi_video_device_lcd_set_level(struct a
>  	status = acpi_execute_simple_method(device->dev->handle,
>  					    "_BCM", level);
>  	if (ACPI_FAILURE(status)) {
> -		ACPI_ERROR((AE_INFO, "Evaluating _BCM failed"));
> +		acpi_handle_info(device->dev->handle, "_BCM evaluation failed\n");
>  		return -EIO;
>  	}
>  
> @@ -368,7 +365,7 @@ acpi_video_device_lcd_set_level(struct a
>  			return 0;
>  		}
>  
> -	ACPI_ERROR((AE_INFO, "Current brightness invalid"));
> +	acpi_handle_info(device->dev->handle, "Current brightness invalid\n");
>  	return -EINVAL;
>  }
>  
> @@ -622,9 +619,8 @@ acpi_video_device_lcd_get_level_current(
>  			 * BQC returned an invalid level.
>  			 * Stop using it.
>  			 */
> -			ACPI_WARNING((AE_INFO,
> -				      "%s returned an invalid level",
> -				      buf));
> +			acpi_handle_info(device->dev->handle,
> +					 "%s returned an invalid level", buf);
>  			device->cap._BQC = device->cap._BCQ = 0;
>  		} else {
>  			/*
> @@ -635,7 +631,8 @@ acpi_video_device_lcd_get_level_current(
>  			 * ACPI video backlight still works w/ buggy _BQC.
>  			 * http://bugzilla.kernel.org/show_bug.cgi?id=12233
>  			 */
> -			ACPI_WARNING((AE_INFO, "Evaluating %s failed", buf));
> +			acpi_handle_info(device->dev->handle,
> +					 "%s evaluation failed", buf);
>  			device->cap._BQC = device->cap._BCQ = 0;
>  		}
>  	}
> @@ -675,7 +672,7 @@ acpi_video_device_EDID(struct acpi_video
>  	if (obj && obj->type == ACPI_TYPE_BUFFER)
>  		*edid = obj;
>  	else {
> -		printk(KERN_ERR PREFIX "Invalid _DDC data\n");
> +		acpi_handle_info(device->dev->handle, "Invalid _DDC data\n");
>  		status = -EFAULT;
>  		kfree(obj);
>  	}
> @@ -827,10 +824,9 @@ int acpi_video_get_levels(struct acpi_de
>  	int result = 0;
>  	u32 value;
>  
> -	if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device->handle,
> -								&obj))) {
> -		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
> -						"LCD brightness level\n"));
> +	if (ACPI_FAILURE(acpi_video_device_lcd_query_levels(device->handle, &obj))) {
> +		acpi_handle_debug(device->handle,
> +				  "Could not query available LCD brightness level\n");
>  		result = -ENODEV;
>  		goto out;
>  	}
> @@ -842,7 +838,6 @@ int acpi_video_get_levels(struct acpi_de
>  
>  	br = kzalloc(sizeof(*br), GFP_KERNEL);
>  	if (!br) {
> -		printk(KERN_ERR "can't allocate memory\n");
>  		result = -ENOMEM;
>  		goto out;
>  	}
> @@ -863,7 +858,7 @@ int acpi_video_get_levels(struct acpi_de
>  	for (i = 0; i < obj->package.count; i++) {
>  		o = (union acpi_object *)&obj->package.elements[i];
>  		if (o->type != ACPI_TYPE_INTEGER) {
> -			printk(KERN_ERR PREFIX "Invalid data\n");
> +			acpi_handle_info(device->handle, "Invalid data\n");
>  			continue;
>  		}
>  		value = (u32) o->integer.value;
> @@ -900,7 +895,8 @@ int acpi_video_get_levels(struct acpi_de
>  			br->levels[i] = br->levels[i - level_ac_battery];
>  		count += level_ac_battery;
>  	} else if (level_ac_battery > ACPI_VIDEO_FIRST_LEVEL)
> -		ACPI_ERROR((AE_INFO, "Too many duplicates in _BCL package"));
> +		acpi_handle_info(device->handle,
> +				 "Too many duplicates in _BCL package");
>  
>  	/* Check if the _BCL package is in a reversed order */
>  	if (max_level == br->levels[ACPI_VIDEO_FIRST_LEVEL]) {
> @@ -910,8 +906,8 @@ int acpi_video_get_levels(struct acpi_de
>  		     sizeof(br->levels[ACPI_VIDEO_FIRST_LEVEL]),
>  		     acpi_video_cmp_level, NULL);
>  	} else if (max_level != br->levels[count - 1])
> -		ACPI_ERROR((AE_INFO,
> -			    "Found unordered _BCL package"));
> +		acpi_handle_info(device->handle,
> +				 "Found unordered _BCL package");
>  
>  	br->count = count;
>  	*dev_br = br;
> @@ -989,9 +985,9 @@ set_level:
>  	if (result)
>  		goto out_free_levels;
>  
> -	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> -			  "found %d brightness levels\n",
> -			  br->count - ACPI_VIDEO_FIRST_LEVEL));
> +	acpi_handle_debug(device->dev->handle, "found %d brightness levels\n",
> +			  br->count - ACPI_VIDEO_FIRST_LEVEL);
> +
>  	return 0;
>  
>  out_free_levels:
> @@ -1023,7 +1019,8 @@ static void acpi_video_device_find_cap(s
>  	if (acpi_has_method(device->dev->handle, "_BQC")) {
>  		device->cap._BQC = 1;
>  	} else if (acpi_has_method(device->dev->handle, "_BCQ")) {
> -		printk(KERN_WARNING FW_BUG "_BCQ is used instead of _BQC\n");
> +		acpi_handle_info(device->dev->handle,
> +				 "_BCQ is used instead of _BQC\n");
>  		device->cap._BCQ = 1;
>  	}
>  
> @@ -1083,8 +1080,7 @@ static int acpi_video_bus_check(struct a
>  	/* Does this device support video switching? */
>  	if (video->cap._DOS || video->cap._DOD) {
>  		if (!video->cap._DOS) {
> -			printk(KERN_WARNING FW_BUG
> -				"ACPI(%s) defines _DOD but not _DOS\n",
> +			pr_info(FW_BUG "ACPI(%s) defines _DOD but not _DOS\n",
>  				acpi_device_bid(video->device));
>  		}
>  		video->flags.multihead = 1;
> @@ -1272,7 +1268,8 @@ acpi_video_device_bind(struct acpi_video
>  		ids = &video->attached_array[i];
>  		if (device->device_id == (ids->value.int_val & 0xffff)) {
>  			ids->bind_info = device;
> -			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
> +			acpi_handle_debug(video->device->handle, "%s: %d\n",
> +					  __func__, i);
>  		}
>  	}
>  }
> @@ -1324,20 +1321,22 @@ static int acpi_video_device_enumerate(s
>  		return AE_NOT_EXIST;
>  
>  	status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer);
> -	if (!ACPI_SUCCESS(status)) {
> -		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
> +	if (ACPI_FAILURE(status)) {
> +		acpi_handle_info(video->device->handle,
> +				 "_DOD evaluation failed: %s\n",
> +				 acpi_format_exception(status));
>  		return status;
>  	}
>  
>  	dod = buffer.pointer;
>  	if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
> -		ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
> +		acpi_handle_info(video->device->handle, "Invalid _DOD data\n");
>  		status = -EFAULT;
>  		goto out;
>  	}
>  
> -	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
> -			  dod->package.count));
> +	acpi_handle_debug(video->device->handle, "Found %d video heads in _DOD\n",
> +			  dod->package.count);
>  
>  	active_list = kcalloc(1 + dod->package.count,
>  			      sizeof(struct acpi_video_enumerated_device),
> @@ -1352,15 +1351,18 @@ static int acpi_video_device_enumerate(s
>  		obj = &dod->package.elements[i];
>  
>  		if (obj->type != ACPI_TYPE_INTEGER) {
> -			printk(KERN_ERR PREFIX
> -				"Invalid _DOD data in element %d\n", i);
> +			acpi_handle_info(video->device->handle,
> +					 "Invalid _DOD data in element %d\n", i);
>  			continue;
>  		}
>  
>  		active_list[count].value.int_val = obj->integer.value;
>  		active_list[count].bind_info = NULL;
> -		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i,
> -				  (int)obj->integer.value));
> +
> +		acpi_handle_debug(video->device->handle,
> +				  "_DOD element[%d] = %d\n", i,
> +				  (int)obj->integer.value);
> +
>  		count++;
>  	}
>  
> @@ -1451,7 +1453,8 @@ acpi_video_switch_brightness(struct work
>  
>  out:
>  	if (result)
> -		printk(KERN_ERR PREFIX "Failed to switch the brightness\n");
> +		acpi_handle_info(device->dev->handle,
> +				 "Failed to switch brightness\n");
>  }
>  
>  int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
> @@ -1601,8 +1604,8 @@ static void acpi_video_bus_notify(struct
>  		break;
>  
>  	default:
> -		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> -				  "Unsupported event [0x%x]\n", event));
> +		acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
> +				  event);
>  		break;
>  	}
>  
> @@ -1675,8 +1678,7 @@ static void acpi_video_device_notify(acp
>  		keycode = KEY_DISPLAY_OFF;
>  		break;
>  	default:
> -		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> -				  "Unsupported event [0x%x]\n", event));
> +		acpi_handle_debug(handle, "Unsupported event [0x%x]\n", event);
>  		break;
>  	}
>  
> @@ -1812,11 +1814,12 @@ static void acpi_video_dev_register_back
>  			&device->cooling_dev->device.kobj,
>  			"thermal_cooling");
>  	if (result)
> -		printk(KERN_ERR PREFIX "Create sysfs link\n");
> +		pr_info("sysfs link creation failed\n");
> +
>  	result = sysfs_create_link(&device->cooling_dev->device.kobj,
>  			&device->dev->dev.kobj, "device");
>  	if (result)
> -		printk(KERN_ERR PREFIX "Create sysfs link\n");
> +		pr_info("Reverse sysfs link creation failed\n");
>  }
>  
>  static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video)
> @@ -2030,7 +2033,7 @@ static int acpi_video_bus_add(struct acp
>  				acpi_video_bus_match, NULL,
>  				device, NULL);
>  	if (status == AE_ALREADY_EXISTS) {
> -		printk(KERN_WARNING FW_BUG
> +		pr_info(FW_BUG
>  			"Duplicate ACPI video bus devices for the"
>  			" same VGA controller, please try module "
>  			"parameter \"video.allow_duplicates=1\""
> @@ -2073,7 +2076,7 @@ static int acpi_video_bus_add(struct acp
>  	if (error)
>  		goto err_put_video;
>  
> -	printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
> +	pr_info("%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
>  	       ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
>  	       video->flags.multihead ? "yes" : "no",
>  	       video->flags.rom ? "yes" : "no",
> Index: linux-pm/Documentation/firmware-guide/acpi/debug.rst
> ===================================================================
> --- linux-pm.orig/Documentation/firmware-guide/acpi/debug.rst
> +++ linux-pm/Documentation/firmware-guide/acpi/debug.rst
> @@ -59,7 +59,6 @@ shows the supported mask values, current
>      ACPI_SYSTEM_COMPONENT           0x02000000
>      ACPI_THERMAL_COMPONENT          0x04000000
>      ACPI_MEMORY_DEVICE_COMPONENT    0x08000000
> -    ACPI_VIDEO_COMPONENT            0x10000000
>      ACPI_PROCESSOR_COMPONENT        0x20000000
>  
>  debug_level
> Index: linux-pm/drivers/acpi/sysfs.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/sysfs.c
> +++ linux-pm/drivers/acpi/sysfs.c
> @@ -59,7 +59,6 @@ static const struct acpi_dlayer acpi_deb
>  	ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT),
>  	ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT),
>  	ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT),
> -	ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT),
>  	ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT),
>  };
>  
> Index: linux-pm/include/acpi/acpi_drivers.h
> ===================================================================
> --- linux-pm.orig/include/acpi/acpi_drivers.h
> +++ linux-pm/include/acpi/acpi_drivers.h
> @@ -22,7 +22,6 @@
>  #define ACPI_SYSTEM_COMPONENT		0x02000000
>  #define ACPI_THERMAL_COMPONENT		0x04000000
>  #define ACPI_MEMORY_DEVICE_COMPONENT	0x08000000
> -#define ACPI_VIDEO_COMPONENT		0x10000000
>  #define ACPI_PROCESSOR_COMPONENT	0x20000000
>  
>  /*
> 
> 
> 


  parent reply	other threads:[~2021-02-04 18:35 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 18:14 [PATCH v1 0/5] ACPI: More cleanups related to printing messages Rafael J. Wysocki
2021-02-01 18:15 ` [PATCH v1 1/5] ACPI: AC: Clean up " Rafael J. Wysocki
2021-02-01 18:16 ` [PATCH v1 2/5] ACPI: battery: " Rafael J. Wysocki
2021-02-01 18:35   ` Joe Perches
2021-02-01 18:44     ` Rafael J. Wysocki
2021-02-02 13:38       ` Joe Perches
2021-02-02 14:09         ` Rafael J. Wysocki
2021-02-01 18:17 ` [PATCH v1 3/5] ACPI: button: " Rafael J. Wysocki
2021-02-01 18:18 ` [PATCH v1 4/5] ACPI: video: " Rafael J. Wysocki
2021-02-01 18:19 ` [PATCH v1 5/5] ACPI: thermal: " Rafael J. Wysocki
2021-02-02 18:11 ` [PATCH v2 0/5] ACPI: More cleanups related to " Rafael J. Wysocki
2021-02-02 18:14   ` [PATCH v2 1/5] ACPI: AC: Clean up " Rafael J. Wysocki
2021-02-03  1:31     ` Hanjun Guo
2021-02-03 18:27       ` Rafael J. Wysocki
2021-02-02 18:15   ` [PATCH v2 2/5] ACPI: battery: " Rafael J. Wysocki
2021-02-03  1:44     ` Hanjun Guo
2021-02-02 18:17   ` [PATCH v2 3/5] ACPI: button: " Rafael J. Wysocki
2021-02-03  1:56     ` Hanjun Guo
2021-02-02 18:18   ` [PATCH v2 4/5] ACPI: video: " Rafael J. Wysocki
2021-02-03  2:16     ` Hanjun Guo
2021-02-02 18:19   ` [PATCH v2 5/5] ACPI: thermal: " Rafael J. Wysocki
2021-02-03  2:23     ` Hanjun Guo
2021-02-03 18:40   ` [PATCH v3 0/5] ACPI: More cleanups related to " Rafael J. Wysocki
2021-02-03 18:43     ` [PATCH v3 1/5] ACPI: AC: Clean up " Rafael J. Wysocki
2021-02-04  1:12       ` Hanjun Guo
2021-02-04 18:25       ` Hans de Goede
2021-02-03 18:44     ` [PATCH v3 2/5] ACPI: battery: " Rafael J. Wysocki
2021-02-04  1:18       ` Hanjun Guo
2021-02-04 18:27       ` Hans de Goede
2021-02-04 18:31         ` Hans de Goede
2021-02-03 18:46     ` [PATCH v3 3/5] ACPI: button: " Rafael J. Wysocki
2021-02-04 18:28       ` Hans de Goede
2021-02-03 18:48     ` [PATCH v3 4/5] ACPI: video: " Rafael J. Wysocki
2021-02-04  1:42       ` Hanjun Guo
2021-02-04 18:33       ` Hans de Goede [this message]
2021-02-03 18:49     ` [PATCH v3 5/5] ACPI: thermal: " Rafael J. Wysocki
2021-02-04 18:36       ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc92bf0f-b770-a4d5-7c0f-0936a4a35a38@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=erik.kaneda@intel.com \
    --cc=guohanjun@huawei.com \
    --cc=joe@perches.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).