.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * ACPI Sony Notebook Control Driver (SNC and SPIC) |
---|
3 | 4 | * |
---|
.. | .. |
---|
25 | 26 | * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com> |
---|
26 | 27 | * |
---|
27 | 28 | * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras. |
---|
28 | | - * |
---|
29 | | - * This program is free software; you can redistribute it and/or modify |
---|
30 | | - * it under the terms of the GNU General Public License as published by |
---|
31 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
32 | | - * (at your option) any later version. |
---|
33 | | - * |
---|
34 | | - * This program is distributed in the hope that it will be useful, |
---|
35 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
36 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
37 | | - * GNU General Public License for more details. |
---|
38 | | - * |
---|
39 | | - * You should have received a copy of the GNU General Public License |
---|
40 | | - * along with this program; if not, write to the Free Software |
---|
41 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
42 | | - * |
---|
43 | 29 | */ |
---|
44 | 30 | |
---|
45 | 31 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
771 | 757 | return result; |
---|
772 | 758 | } |
---|
773 | 759 | |
---|
774 | | -static int sony_nc_int_call(acpi_handle handle, char *name, int *value, |
---|
775 | | - int *result) |
---|
776 | | -{ |
---|
777 | | - union acpi_object *object = NULL; |
---|
778 | | - if (value) { |
---|
779 | | - u64 v = *value; |
---|
780 | | - object = __call_snc_method(handle, name, &v); |
---|
781 | | - } else |
---|
782 | | - object = __call_snc_method(handle, name, NULL); |
---|
783 | | - |
---|
784 | | - if (!object) |
---|
785 | | - return -EINVAL; |
---|
786 | | - |
---|
787 | | - if (object->type != ACPI_TYPE_INTEGER) { |
---|
788 | | - pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n", |
---|
789 | | - ACPI_TYPE_INTEGER, object->type); |
---|
790 | | - kfree(object); |
---|
791 | | - return -EINVAL; |
---|
792 | | - } |
---|
793 | | - |
---|
794 | | - if (result) |
---|
795 | | - *result = object->integer.value; |
---|
796 | | - |
---|
797 | | - kfree(object); |
---|
798 | | - return 0; |
---|
799 | | -} |
---|
800 | | - |
---|
801 | 760 | #define MIN(a, b) (a > b ? b : a) |
---|
802 | 761 | static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value, |
---|
803 | 762 | void *buffer, size_t buflen) |
---|
.. | .. |
---|
809 | 768 | if (!object) |
---|
810 | 769 | return -EINVAL; |
---|
811 | 770 | |
---|
812 | | - if (object->type == ACPI_TYPE_BUFFER) { |
---|
| 771 | + if (!buffer) { |
---|
| 772 | + /* do nothing */ |
---|
| 773 | + } else if (object->type == ACPI_TYPE_BUFFER) { |
---|
813 | 774 | len = MIN(buflen, object->buffer.length); |
---|
| 775 | + memset(buffer, 0, buflen); |
---|
814 | 776 | memcpy(buffer, object->buffer.pointer, len); |
---|
815 | 777 | |
---|
816 | 778 | } else if (object->type == ACPI_TYPE_INTEGER) { |
---|
817 | 779 | len = MIN(buflen, sizeof(object->integer.value)); |
---|
| 780 | + memset(buffer, 0, buflen); |
---|
818 | 781 | memcpy(buffer, &object->integer.value, len); |
---|
819 | 782 | |
---|
820 | 783 | } else { |
---|
821 | | - pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n", |
---|
822 | | - ACPI_TYPE_BUFFER, object->type); |
---|
| 784 | + pr_warn("Unexpected acpi_object: 0x%x\n", object->type); |
---|
823 | 785 | ret = -EINVAL; |
---|
824 | 786 | } |
---|
825 | 787 | |
---|
826 | 788 | kfree(object); |
---|
| 789 | + return ret; |
---|
| 790 | +} |
---|
| 791 | + |
---|
| 792 | +static int sony_nc_int_call(acpi_handle handle, char *name, int *value, int |
---|
| 793 | + *result) |
---|
| 794 | +{ |
---|
| 795 | + int ret; |
---|
| 796 | + |
---|
| 797 | + if (value) { |
---|
| 798 | + u64 v = *value; |
---|
| 799 | + |
---|
| 800 | + ret = sony_nc_buffer_call(handle, name, &v, result, |
---|
| 801 | + sizeof(*result)); |
---|
| 802 | + } else { |
---|
| 803 | + ret = sony_nc_buffer_call(handle, name, NULL, result, |
---|
| 804 | + sizeof(*result)); |
---|
| 805 | + } |
---|
827 | 806 | return ret; |
---|
828 | 807 | } |
---|
829 | 808 | |
---|
.. | .. |
---|
841 | 820 | int i; |
---|
842 | 821 | |
---|
843 | 822 | for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { |
---|
844 | | - len += snprintf(buffer + len, PAGE_SIZE - len, "0x%.4x ", |
---|
| 823 | + len += scnprintf(buffer + len, PAGE_SIZE - len, "0x%.4x ", |
---|
845 | 824 | handles->cap[i]); |
---|
846 | 825 | } |
---|
847 | | - len += snprintf(buffer + len, PAGE_SIZE - len, "\n"); |
---|
| 826 | + len += scnprintf(buffer + len, PAGE_SIZE - len, "\n"); |
---|
848 | 827 | |
---|
849 | 828 | return len; |
---|
850 | 829 | } |
---|
.. | .. |
---|
1913 | 1892 | break; |
---|
1914 | 1893 | } |
---|
1915 | 1894 | |
---|
1916 | | - ret = sony_call_snc_handle(handle, probe_base, &result); |
---|
1917 | | - if (ret) |
---|
1918 | | - return ret; |
---|
| 1895 | + /* |
---|
| 1896 | + * Only probe if there is a separate probe_base, otherwise the probe call |
---|
| 1897 | + * is equivalent to __sony_nc_kbd_backlight_mode_set(0), resulting in |
---|
| 1898 | + * the keyboard backlight being turned off. |
---|
| 1899 | + */ |
---|
| 1900 | + if (probe_base) { |
---|
| 1901 | + ret = sony_call_snc_handle(handle, probe_base, &result); |
---|
| 1902 | + if (ret) |
---|
| 1903 | + return ret; |
---|
1919 | 1904 | |
---|
1920 | | - if ((handle == 0x0137 && !(result & 0x02)) || |
---|
1921 | | - !(result & 0x01)) { |
---|
1922 | | - dprintk("no backlight keyboard found\n"); |
---|
1923 | | - return 0; |
---|
| 1905 | + if ((handle == 0x0137 && !(result & 0x02)) || |
---|
| 1906 | + !(result & 0x01)) { |
---|
| 1907 | + dprintk("no backlight keyboard found\n"); |
---|
| 1908 | + return 0; |
---|
| 1909 | + } |
---|
1924 | 1910 | } |
---|
1925 | 1911 | |
---|
1926 | 1912 | kbdbl_ctl = kzalloc(sizeof(*kbdbl_ctl), GFP_KERNEL); |
---|
.. | .. |
---|
2201 | 2187 | |
---|
2202 | 2188 | for (cnt = 0; cnt < THM_PROFILE_MAX; cnt++) { |
---|
2203 | 2189 | if (!cnt || (th_handle->profiles & cnt)) |
---|
2204 | | - idx += snprintf(buffer + idx, PAGE_SIZE - idx, "%s ", |
---|
| 2190 | + idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "%s ", |
---|
2205 | 2191 | snc_thermal_profiles[cnt]); |
---|
2206 | 2192 | } |
---|
2207 | | - idx += snprintf(buffer + idx, PAGE_SIZE - idx, "\n"); |
---|
| 2193 | + idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "\n"); |
---|
2208 | 2194 | |
---|
2209 | 2195 | return idx; |
---|
2210 | 2196 | } |
---|
.. | .. |
---|
2309 | 2295 | #ifdef CONFIG_PM_SLEEP |
---|
2310 | 2296 | static void sony_nc_thermal_resume(void) |
---|
2311 | 2297 | { |
---|
2312 | | - unsigned int status = sony_nc_thermal_mode_get(); |
---|
| 2298 | + int status; |
---|
| 2299 | + |
---|
| 2300 | + if (!th_handle) |
---|
| 2301 | + return; |
---|
| 2302 | + |
---|
| 2303 | + status = sony_nc_thermal_mode_get(); |
---|
2313 | 2304 | |
---|
2314 | 2305 | if (status != th_handle->mode) |
---|
2315 | 2306 | sony_nc_thermal_mode_set(th_handle->mode); |
---|
.. | .. |
---|
4392 | 4383 | list_add(&interrupt->list, &dev->interrupts); |
---|
4393 | 4384 | interrupt->irq.triggering = p->triggering; |
---|
4394 | 4385 | interrupt->irq.polarity = p->polarity; |
---|
4395 | | - interrupt->irq.sharable = p->sharable; |
---|
| 4386 | + interrupt->irq.shareable = p->shareable; |
---|
4396 | 4387 | interrupt->irq.interrupt_count = 1; |
---|
4397 | 4388 | interrupt->irq.interrupts[0] = p->interrupts[i]; |
---|
4398 | 4389 | } |
---|
.. | .. |
---|
4548 | 4539 | memcpy(&resource->res3.data.irq, &irq->irq, |
---|
4549 | 4540 | sizeof(struct acpi_resource_irq)); |
---|
4550 | 4541 | /* we requested a shared irq */ |
---|
4551 | | - resource->res3.data.irq.sharable = ACPI_SHARED; |
---|
| 4542 | + resource->res3.data.irq.shareable = ACPI_SHARED; |
---|
4552 | 4543 | |
---|
4553 | 4544 | resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; |
---|
4554 | 4545 | resource->res4.length = sizeof(struct acpi_resource); |
---|
.. | .. |
---|
4567 | 4558 | memcpy(&resource->res2.data.irq, &irq->irq, |
---|
4568 | 4559 | sizeof(struct acpi_resource_irq)); |
---|
4569 | 4560 | /* we requested a shared irq */ |
---|
4570 | | - resource->res2.data.irq.sharable = ACPI_SHARED; |
---|
| 4561 | + resource->res2.data.irq.shareable = ACPI_SHARED; |
---|
4571 | 4562 | |
---|
4572 | 4563 | resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; |
---|
4573 | 4564 | resource->res3.length = sizeof(struct acpi_resource); |
---|
.. | .. |
---|
4781 | 4772 | irq->irq.interrupts[0], |
---|
4782 | 4773 | irq->irq.triggering, |
---|
4783 | 4774 | irq->irq.polarity, |
---|
4784 | | - irq->irq.sharable); |
---|
| 4775 | + irq->irq.shareable); |
---|
4785 | 4776 | spic_dev.cur_irq = irq; |
---|
4786 | 4777 | break; |
---|
4787 | 4778 | } |
---|