Use standard logging functions

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford 2025-06-04 15:36:06 -06:00
parent c81a34d0fc
commit f886317ae8
No known key found for this signature in database
GPG Key ID: 68E558D2BBD856E3
5 changed files with 49 additions and 56 deletions

View File

@ -116,7 +116,7 @@ static int __init ap_led_init(struct device *dev)
}
if (device_create_file(ap_led.dev, &ap_led_invert_dev_attr) != 0) {
S76_ERROR("failed to create ap_led_invert\n");
pr_err("failed to create ap_led_invert\n");
}
ap_led_resume();

View File

@ -58,7 +58,7 @@ static struct task_struct *s76_input_polling_task;
static void s76_input_key(unsigned int code)
{
S76_DEBUG("Send key %x\n", code);
pr_debug("Send key %x\n", code);
mutex_lock(&s76_input_report_mutex);
@ -73,7 +73,7 @@ static void s76_input_key(unsigned int code)
static int s76_input_polling_thread(void *data)
{
S76_DEBUG("Polling thread started (PID: %i), polling at %i Hz\n",
pr_debug("Polling thread started (PID: %i), polling at %i Hz\n",
current->pid, param_poll_freq);
while (!kthread_should_stop()) {
@ -83,7 +83,7 @@ static int s76_input_polling_thread(void *data)
if (byte & 0x40) {
ec_write(0xDB, byte & ~0x40);
S76_DEBUG("Airplane-Mode Hotkey pressed (EC)\n");
pr_debug("Airplane-Mode Hotkey pressed (EC)\n");
s76_input_key(AIRPLANE_KEY);
}
@ -91,21 +91,21 @@ static int s76_input_polling_thread(void *data)
msleep_interruptible(1000 / param_poll_freq);
}
S76_DEBUG("Polling thread exiting\n");
pr_debug("Polling thread exiting\n");
return 0;
}
static void s76_input_airplane_wmi(void)
{
S76_DEBUG("Airplane-Mode Hotkey pressed (WMI)\n");
pr_debug("Airplane-Mode Hotkey pressed (WMI)\n");
s76_input_key(AIRPLANE_KEY);
}
static void s76_input_screen_wmi(void)
{
S76_DEBUG("Screen Hotkey pressed (WMI)\n");
pr_debug("Screen Hotkey pressed (WMI)\n");
s76_input_key(SCREEN_KEY);
}
@ -123,7 +123,7 @@ static int s76_input_open(struct input_dev *dev)
if (unlikely(IS_ERR(s76_input_polling_task))) {
res = PTR_ERR(s76_input_polling_task);
s76_input_polling_task = NULL;
S76_ERROR("Could not create polling thread: %d\n", res);
pr_err("Could not create polling thread: %d\n", res);
return res;
}
}
@ -148,7 +148,7 @@ static int __init s76_input_init(struct device *dev)
s76_input_device = input_allocate_device();
if (unlikely(!s76_input_device)) {
S76_ERROR("Error allocating input device\n");
pr_err("Error allocating input device\n");
return -ENOMEM;
}
@ -171,7 +171,7 @@ static int __init s76_input_init(struct device *dev)
err = input_register_device(s76_input_device);
if (unlikely(err)) {
S76_ERROR("Error registering input device\n");
pr_err("Error registering input device\n");
goto err_free_input_device;
}

View File

@ -63,7 +63,7 @@ static enum led_brightness kb_led_get(struct led_classdev *led_cdev)
static int kb_led_set(struct led_classdev *led_cdev, enum led_brightness value)
{
S76_DEBUG("kb_led_set %d\n", (int)value);
pr_debug("kb_led_set %d\n", (int)value);
if (!s76_wmbb(SET_KB_LED, 0xF4000000 | value, NULL)) {
kb_led_brightness = value;
@ -76,7 +76,7 @@ static void kb_led_color_set(enum kb_led_region region, union kb_led_color color
{
u32 cmd;
S76_DEBUG("kb_led_color_set %d %06X\n", (int)region, (int)color.rgb);
pr_debug("kb_led_color_set %d %06X\n", (int)region, (int)color.rgb);
switch (region) {
case KB_LED_REGION_LEFT:
@ -212,21 +212,21 @@ static struct device_attribute kb_led_color_extra_dev_attr = {
static void kb_led_enable(void)
{
S76_DEBUG("kb_led_enable\n");
pr_debug("kb_led_enable\n");
s76_wmbb(SET_KB_LED, 0xE007F001, NULL);
}
static void kb_led_disable(void)
{
S76_DEBUG("kb_led_disable\n");
pr_debug("kb_led_disable\n");
s76_wmbb(SET_KB_LED, 0xE0003001, NULL);
}
static void kb_led_suspend(void)
{
S76_DEBUG("kb_led_suspend\n");
pr_debug("kb_led_suspend\n");
// Disable keyboard backlight
kb_led_disable();
@ -236,7 +236,7 @@ static void kb_led_resume(void)
{
enum kb_led_region region;
S76_DEBUG("kb_led_resume\n");
pr_debug("kb_led_resume\n");
// Disable keyboard backlight
kb_led_disable();
@ -263,19 +263,19 @@ static int __init kb_led_init(struct device *dev)
}
if (device_create_file(kb_led.dev, &kb_led_color_left_dev_attr) != 0) {
S76_ERROR("failed to create kb_led_color_left\n");
pr_err("failed to create kb_led_color_left\n");
}
if (device_create_file(kb_led.dev, &kb_led_color_center_dev_attr) != 0) {
S76_ERROR("failed to create kb_led_color_center\n");
pr_err("failed to create kb_led_color_center\n");
}
if (device_create_file(kb_led.dev, &kb_led_color_right_dev_attr) != 0) {
S76_ERROR("failed to create kb_led_color_right\n");
pr_err("failed to create kb_led_color_right\n");
}
if (device_create_file(kb_led.dev, &kb_led_color_extra_dev_attr) != 0) {
S76_ERROR("failed to create kb_led_color_extra\n");
pr_err("failed to create kb_led_color_extra\n");
}
kb_led_resume();
@ -297,7 +297,7 @@ static void __exit kb_led_exit(void)
static void kb_wmi_brightness(enum led_brightness value)
{
S76_DEBUG("kb_wmi_brightness %d\n", (int)value);
pr_debug("kb_wmi_brightness %d\n", (int)value);
kb_led_set(&kb_led, value);
led_classdev_notify_brightness_hw_changed(&kb_led, value);

View File

@ -46,12 +46,12 @@ static int is_card_disabled(void)
if (tmp_dev->vendor == PCI_VENDOR_ID_NVIDIA) {
sub_dev = tmp_dev;
S76_INFO("Found NVIDIA audio device %s\n", dev_name(&tmp_dev->dev));
pr_info("Found NVIDIA audio device %s\n", dev_name(&tmp_dev->dev));
}
}
if (sub_dev == NULL) {
S76_INFO("No NVIDIA audio device found, unsetting config bit.\n");
pr_info("No NVIDIA audio device found, unsetting config bit.\n");
cfg_word|=0x2000000;
pci_write_config_dword(dis_dev, 0x488, cfg_word);
return 1;
@ -74,7 +74,7 @@ static void nv_hda_off(void)
pci_dev_put(sub_dev);
pci_stop_and_remove_bus_device(sub_dev);
S76_INFO("NVIDIA audio: disabling\n");
pr_info("NVIDIA audio: disabling\n");
// setting bit to turn off
pci_read_config_dword(dis_dev, 0x488, &cfg_word);
@ -91,7 +91,7 @@ static void nv_hda_on(void)
return;
}
S76_INFO("NVIDIA audio: enabling\n");
pr_info("NVIDIA audio: enabling\n");
// read,set bit, write config word at 0x488
pci_read_config_dword(dis_dev, 0x488, &cfg_word);
@ -102,17 +102,17 @@ static void nv_hda_on(void)
pci_read_config_byte(dis_dev, PCI_HEADER_TYPE, &hdr_type);
if (!(hdr_type & 0x80)) {
S76_ERROR("NVIDIA not multifunction, no audio\n");
pr_err("NVIDIA not multifunction, no audio\n");
return;
}
sub_dev = pci_scan_single_device(dis_dev->bus, 1);
if (!sub_dev) {
S76_ERROR("No NVIDIA audio device found\n");
pr_err("No NVIDIA audio device found\n");
return;
}
S76_INFO("NVIDIA audio found, adding\n");
pr_info("NVIDIA audio found, adding\n");
pci_assign_unassigned_bus_resources(dis_dev->bus);
pci_bus_add_devices(dis_dev->bus);
pci_dev_get(sub_dev);
@ -147,12 +147,12 @@ static int __init nv_hda_init(struct device *dev)
if (pdev->vendor == PCI_VENDOR_ID_NVIDIA) {
dis_dev = pdev;
S76_INFO("NVIDIA device %s\n", dev_name(&pdev->dev));
pr_info("NVIDIA device %s\n", dev_name(&pdev->dev));
}
}
if (dis_dev == NULL) {
S76_ERROR("No NVIDIA device found\n");
pr_err("No NVIDIA device found\n");
return -ENODEV;
}
@ -160,7 +160,7 @@ static int __init nv_hda_init(struct device *dev)
nv_hda_on();
S76_INFO("NVIDIA Audio %s is %s\n", dev_name(&dis_dev->dev), is_card_disabled() ? "off" : "on");
pr_info("NVIDIA Audio %s is %s\n", dev_name(&dis_dev->dev), is_card_disabled() ? "off" : "on");
dis_dev_put();

View File

@ -43,13 +43,6 @@
#include <linux/version.h>
#include <linux/workqueue.h>
#define __S76_PR(lvl, fmt, ...) do { pr_##lvl(fmt, ##__VA_ARGS__); } \
while (0)
#define S76_INFO(fmt, ...) __S76_PR(info, fmt, ##__VA_ARGS__)
#define S76_ERROR(fmt, ...) __S76_PR(err, fmt, ##__VA_ARGS__)
#define S76_DEBUG(fmt, ...) __S76_PR(debug, "[%s:%u] " fmt, \
__func__, __LINE__, ##__VA_ARGS__)
#define S76_EVENT_GUID "ABBC0F6B-8EA1-11D1-00A0-C90629100000"
#define S76_WMBB_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
@ -79,7 +72,7 @@ static int s76_wmbb(u32 method_id, u32 arg, u32 *retval)
acpi_status status;
u32 tmp;
S76_DEBUG("%0#4x IN : %0#6x\n", method_id, arg);
pr_debug("%0#4x IN : %0#6x\n", method_id, arg);
status = wmi_evaluate_method(S76_WMBB_GUID, 0, method_id, &in, &out);
@ -94,7 +87,7 @@ static int s76_wmbb(u32 method_id, u32 arg, u32 *retval)
tmp = 0;
}
S76_DEBUG("%0#4x OUT: %0#6x (IN: %0#6x)\n", method_id, tmp, arg);
pr_debug("%0#4x OUT: %0#6x (IN: %0#6x)\n", method_id, tmp, arg);
if (likely(retval)) {
*retval = tmp;
@ -121,19 +114,19 @@ static void s76_wmi_notify(u32 value, void *context)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0)
if (obj->type != ACPI_TYPE_INTEGER) {
S76_DEBUG("Unexpected WMI event (%0#6x)\n", obj);
pr_debug("Unexpected WMI event (%0#6x)\n", obj);
return;
}
#else
if (value != 0xD0) {
S76_DEBUG("Unexpected WMI event (%0#6x)\n", value);
pr_debug("Unexpected WMI event (%0#6x)\n", value);
return;
}
#endif
s76_wmbb(GET_EVENT, 0, &event);
S76_DEBUG("WMI event code (%x)\n", event);
pr_debug("WMI event code (%x)\n", event);
switch (event) {
case 0x81:
@ -180,7 +173,7 @@ static void s76_wmi_notify(u32 value, void *context)
// Touchpad WMI (enable)
break;
default:
S76_DEBUG("Unknown WMI event code (%x)\n", event);
pr_debug("Unknown WMI event code (%x)\n", event);
break;
}
}
@ -192,21 +185,21 @@ static int __init s76_probe(struct platform_device *dev)
if (driver_flags & DRIVER_AP_LED) {
err = ap_led_init(&dev->dev);
if (unlikely(err)) {
S76_ERROR("Could not register LED device\n");
pr_err("Could not register LED device\n");
}
}
if (driver_flags & DRIVER_KB_LED) {
err = kb_led_init(&dev->dev);
if (unlikely(err)) {
S76_ERROR("Could not register LED device\n");
pr_err("Could not register LED device\n");
}
}
if (driver_flags & DRIVER_INPUT) {
err = s76_input_init(&dev->dev);
if (unlikely(err)) {
S76_ERROR("Could not register input device\n");
pr_err("Could not register input device\n");
}
}
@ -218,12 +211,12 @@ static int __init s76_probe(struct platform_device *dev)
err = nv_hda_init(&dev->dev);
if (unlikely(err)) {
S76_ERROR("Could not register NVIDIA audio device\n");
pr_err("Could not register NVIDIA audio device\n");
}
err = wmi_install_notify_handler(S76_EVENT_GUID, s76_wmi_notify, NULL);
if (unlikely(ACPI_FAILURE(err))) {
S76_ERROR("Could not register WMI notify handler (%0#6x)\n", err);
pr_err("Could not register WMI notify handler (%0#6x)\n", err);
return -EIO;
}
@ -269,7 +262,7 @@ static int s76_remove(struct platform_device *dev)
static int s76_suspend(struct platform_device *dev, pm_message_t status)
{
S76_DEBUG("s76_suspend\n");
pr_debug("s76_suspend\n");
if (driver_flags & DRIVER_KB_LED) {
kb_led_suspend();
@ -280,7 +273,7 @@ static int s76_suspend(struct platform_device *dev, pm_message_t status)
static int s76_resume(struct platform_device *dev)
{
S76_DEBUG("s76_resume\n");
pr_debug("s76_resume\n");
msleep(2000);
@ -314,7 +307,7 @@ static struct platform_driver s76_platform_driver = {
static int __init s76_dmi_matched(const struct dmi_system_id *id)
{
S76_INFO("Model %s found\n", id->ident);
pr_info("Model %s found\n", id->ident);
driver_flags = (uint64_t)id->driver_data;
return 1;
}
@ -376,22 +369,22 @@ MODULE_DEVICE_TABLE(dmi, s76_dmi_table);
static int __init s76_init(void)
{
if (!dmi_check_system(s76_dmi_table)) {
S76_INFO("Model does not utilize this driver");
pr_info("Model does not utilize this driver");
return -ENODEV;
}
if (!driver_flags) {
S76_INFO("Driver data not defined");
pr_info("Driver data not defined");
return -ENODEV;
}
if (!wmi_has_guid(S76_EVENT_GUID)) {
S76_INFO("No known WMI event notification GUID found\n");
pr_info("No known WMI event notification GUID found\n");
return -ENODEV;
}
if (!wmi_has_guid(S76_WMBB_GUID)) {
S76_INFO("No known WMI control method GUID found\n");
pr_info("No known WMI control method GUID found\n");
return -ENODEV;
}