| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ACPI AML interfacing support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2015, Intel Corporation |
|---|
| 5 | 6 | * 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. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | /* #define DEBUG */ |
|---|
| .. | .. |
|---|
| 390 | 387 | return size > 0 ? size : ret; |
|---|
| 391 | 388 | } |
|---|
| 392 | 389 | |
|---|
| 393 | | -static int acpi_aml_thread(void *unsed) |
|---|
| 390 | +static int acpi_aml_thread(void *unused) |
|---|
| 394 | 391 | { |
|---|
| 395 | 392 | acpi_osd_exec_callback function = NULL; |
|---|
| 396 | 393 | void *context; |
|---|
| .. | .. |
|---|
| 614 | 611 | |
|---|
| 615 | 612 | if (!count) |
|---|
| 616 | 613 | return 0; |
|---|
| 617 | | - if (!access_ok(VERIFY_WRITE, buf, count)) |
|---|
| 614 | + if (!access_ok(buf, count)) |
|---|
| 618 | 615 | return -EFAULT; |
|---|
| 619 | 616 | |
|---|
| 620 | 617 | while (count > 0) { |
|---|
| .. | .. |
|---|
| 684 | 681 | |
|---|
| 685 | 682 | if (!count) |
|---|
| 686 | 683 | return 0; |
|---|
| 687 | | - if (!access_ok(VERIFY_READ, buf, count)) |
|---|
| 684 | + if (!access_ok(buf, count)) |
|---|
| 688 | 685 | return -EFAULT; |
|---|
| 689 | 686 | |
|---|
| 690 | 687 | while (count > 0) { |
|---|
| .. | .. |
|---|
| 748 | 745 | .notify_command_complete = acpi_aml_notify_command_complete, |
|---|
| 749 | 746 | }; |
|---|
| 750 | 747 | |
|---|
| 751 | | -int __init acpi_aml_init(void) |
|---|
| 748 | +static int __init acpi_aml_init(void) |
|---|
| 752 | 749 | { |
|---|
| 753 | | - int ret = 0; |
|---|
| 754 | | - |
|---|
| 755 | | - if (!acpi_debugfs_dir) { |
|---|
| 756 | | - ret = -ENOENT; |
|---|
| 757 | | - goto err_exit; |
|---|
| 758 | | - } |
|---|
| 750 | + int ret; |
|---|
| 759 | 751 | |
|---|
| 760 | 752 | if (acpi_disabled) |
|---|
| 761 | 753 | return -ENODEV; |
|---|
| .. | .. |
|---|
| 765 | 757 | init_waitqueue_head(&acpi_aml_io.wait); |
|---|
| 766 | 758 | acpi_aml_io.out_crc.buf = acpi_aml_io.out_buf; |
|---|
| 767 | 759 | acpi_aml_io.in_crc.buf = acpi_aml_io.in_buf; |
|---|
| 760 | + |
|---|
| 768 | 761 | acpi_aml_dentry = debugfs_create_file("acpidbg", |
|---|
| 769 | 762 | S_IFREG | S_IRUGO | S_IWUSR, |
|---|
| 770 | 763 | acpi_debugfs_dir, NULL, |
|---|
| 771 | 764 | &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; |
|---|
| 780 | 765 | |
|---|
| 781 | | -err_fs: |
|---|
| 766 | + ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger); |
|---|
| 782 | 767 | if (ret) { |
|---|
| 783 | 768 | debugfs_remove(acpi_aml_dentry); |
|---|
| 784 | 769 | acpi_aml_dentry = NULL; |
|---|
| 770 | + return ret; |
|---|
| 785 | 771 | } |
|---|
| 786 | | -err_exit: |
|---|
| 787 | | - return ret; |
|---|
| 772 | + |
|---|
| 773 | + acpi_aml_initialized = true; |
|---|
| 774 | + return 0; |
|---|
| 788 | 775 | } |
|---|
| 789 | 776 | |
|---|
| 790 | | -void __exit acpi_aml_exit(void) |
|---|
| 777 | +static void __exit acpi_aml_exit(void) |
|---|
| 791 | 778 | { |
|---|
| 792 | 779 | if (acpi_aml_initialized) { |
|---|
| 793 | 780 | 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; |
|---|
| 798 | 783 | acpi_aml_initialized = false; |
|---|
| 799 | 784 | } |
|---|
| 800 | 785 | } |
|---|