| .. | .. |
|---|
| 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 | } |
|---|
| .. | .. |
|---|
| 2201 | 2180 | |
|---|
| 2202 | 2181 | for (cnt = 0; cnt < THM_PROFILE_MAX; cnt++) { |
|---|
| 2203 | 2182 | if (!cnt || (th_handle->profiles & cnt)) |
|---|
| 2204 | | - idx += snprintf(buffer + idx, PAGE_SIZE - idx, "%s ", |
|---|
| 2183 | + idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "%s ", |
|---|
| 2205 | 2184 | snc_thermal_profiles[cnt]); |
|---|
| 2206 | 2185 | } |
|---|
| 2207 | | - idx += snprintf(buffer + idx, PAGE_SIZE - idx, "\n"); |
|---|
| 2186 | + idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "\n"); |
|---|
| 2208 | 2187 | |
|---|
| 2209 | 2188 | return idx; |
|---|
| 2210 | 2189 | } |
|---|
| .. | .. |
|---|
| 2309 | 2288 | #ifdef CONFIG_PM_SLEEP |
|---|
| 2310 | 2289 | static void sony_nc_thermal_resume(void) |
|---|
| 2311 | 2290 | { |
|---|
| 2312 | | - unsigned int status = sony_nc_thermal_mode_get(); |
|---|
| 2291 | + int status; |
|---|
| 2292 | + |
|---|
| 2293 | + if (!th_handle) |
|---|
| 2294 | + return; |
|---|
| 2295 | + |
|---|
| 2296 | + status = sony_nc_thermal_mode_get(); |
|---|
| 2313 | 2297 | |
|---|
| 2314 | 2298 | if (status != th_handle->mode) |
|---|
| 2315 | 2299 | sony_nc_thermal_mode_set(th_handle->mode); |
|---|
| .. | .. |
|---|
| 4392 | 4376 | list_add(&interrupt->list, &dev->interrupts); |
|---|
| 4393 | 4377 | interrupt->irq.triggering = p->triggering; |
|---|
| 4394 | 4378 | interrupt->irq.polarity = p->polarity; |
|---|
| 4395 | | - interrupt->irq.sharable = p->sharable; |
|---|
| 4379 | + interrupt->irq.shareable = p->shareable; |
|---|
| 4396 | 4380 | interrupt->irq.interrupt_count = 1; |
|---|
| 4397 | 4381 | interrupt->irq.interrupts[0] = p->interrupts[i]; |
|---|
| 4398 | 4382 | } |
|---|
| .. | .. |
|---|
| 4548 | 4532 | memcpy(&resource->res3.data.irq, &irq->irq, |
|---|
| 4549 | 4533 | sizeof(struct acpi_resource_irq)); |
|---|
| 4550 | 4534 | /* we requested a shared irq */ |
|---|
| 4551 | | - resource->res3.data.irq.sharable = ACPI_SHARED; |
|---|
| 4535 | + resource->res3.data.irq.shareable = ACPI_SHARED; |
|---|
| 4552 | 4536 | |
|---|
| 4553 | 4537 | resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; |
|---|
| 4554 | 4538 | resource->res4.length = sizeof(struct acpi_resource); |
|---|
| .. | .. |
|---|
| 4567 | 4551 | memcpy(&resource->res2.data.irq, &irq->irq, |
|---|
| 4568 | 4552 | sizeof(struct acpi_resource_irq)); |
|---|
| 4569 | 4553 | /* we requested a shared irq */ |
|---|
| 4570 | | - resource->res2.data.irq.sharable = ACPI_SHARED; |
|---|
| 4554 | + resource->res2.data.irq.shareable = ACPI_SHARED; |
|---|
| 4571 | 4555 | |
|---|
| 4572 | 4556 | resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; |
|---|
| 4573 | 4557 | resource->res3.length = sizeof(struct acpi_resource); |
|---|
| .. | .. |
|---|
| 4781 | 4765 | irq->irq.interrupts[0], |
|---|
| 4782 | 4766 | irq->irq.triggering, |
|---|
| 4783 | 4767 | irq->irq.polarity, |
|---|
| 4784 | | - irq->irq.sharable); |
|---|
| 4768 | + irq->irq.shareable); |
|---|
| 4785 | 4769 | spic_dev.cur_irq = irq; |
|---|
| 4786 | 4770 | break; |
|---|
| 4787 | 4771 | } |
|---|