hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/acpi/acpi_dbg.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ACPI AML interfacing support
34 *
45 * Copyright (C) 2015, Intel Corporation
56 * Authors: Lv Zheng <lv.zheng@intel.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 /* #define DEBUG */
....@@ -390,7 +387,7 @@
390387 return size > 0 ? size : ret;
391388 }
392389
393
-static int acpi_aml_thread(void *unsed)
390
+static int acpi_aml_thread(void *unused)
394391 {
395392 acpi_osd_exec_callback function = NULL;
396393 void *context;
....@@ -614,7 +611,7 @@
614611
615612 if (!count)
616613 return 0;
617
- if (!access_ok(VERIFY_WRITE, buf, count))
614
+ if (!access_ok(buf, count))
618615 return -EFAULT;
619616
620617 while (count > 0) {
....@@ -684,7 +681,7 @@
684681
685682 if (!count)
686683 return 0;
687
- if (!access_ok(VERIFY_READ, buf, count))
684
+ if (!access_ok(buf, count))
688685 return -EFAULT;
689686
690687 while (count > 0) {
....@@ -748,14 +745,9 @@
748745 .notify_command_complete = acpi_aml_notify_command_complete,
749746 };
750747
751
-int __init acpi_aml_init(void)
748
+static int __init acpi_aml_init(void)
752749 {
753
- int ret = 0;
754
-
755
- if (!acpi_debugfs_dir) {
756
- ret = -ENOENT;
757
- goto err_exit;
758
- }
750
+ int ret;
759751
760752 if (acpi_disabled)
761753 return -ENODEV;
....@@ -765,36 +757,29 @@
765757 init_waitqueue_head(&acpi_aml_io.wait);
766758 acpi_aml_io.out_crc.buf = acpi_aml_io.out_buf;
767759 acpi_aml_io.in_crc.buf = acpi_aml_io.in_buf;
760
+
768761 acpi_aml_dentry = debugfs_create_file("acpidbg",
769762 S_IFREG | S_IRUGO | S_IWUSR,
770763 acpi_debugfs_dir, NULL,
771764 &acpi_aml_operations);
772
- if (acpi_aml_dentry == NULL) {
773
- ret = -ENODEV;
774
- goto err_exit;
775
- }
776
- ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger);
777
- if (ret)
778
- goto err_fs;
779
- acpi_aml_initialized = true;
780765
781
-err_fs:
766
+ ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger);
782767 if (ret) {
783768 debugfs_remove(acpi_aml_dentry);
784769 acpi_aml_dentry = NULL;
770
+ return ret;
785771 }
786
-err_exit:
787
- return ret;
772
+
773
+ acpi_aml_initialized = true;
774
+ return 0;
788775 }
789776
790
-void __exit acpi_aml_exit(void)
777
+static void __exit acpi_aml_exit(void)
791778 {
792779 if (acpi_aml_initialized) {
793780 acpi_unregister_debugger(&acpi_aml_debugger);
794
- if (acpi_aml_dentry) {
795
- debugfs_remove(acpi_aml_dentry);
796
- acpi_aml_dentry = NULL;
797
- }
781
+ debugfs_remove(acpi_aml_dentry);
782
+ acpi_aml_dentry = NULL;
798783 acpi_aml_initialized = false;
799784 }
800785 }