| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * toshiba_acpi.c - Toshiba Laptop ACPI Extras |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (C) 2008 Philip Langdale |
|---|
| 6 | 7 | * Copyright (C) 2010 Pierre Ducroquet |
|---|
| 7 | 8 | * Copyright (C) 2014-2016 Azael Avalos |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * The full GNU General Public License is included in this distribution in |
|---|
| 20 | | - * the file called "COPYING". |
|---|
| 21 | 9 | * |
|---|
| 22 | 10 | * The devolpment page for this driver is located at |
|---|
| 23 | 11 | * http://memebeam.org/toys/ToshibaAcpiDriver. |
|---|
| .. | .. |
|---|
| 217 | 205 | unsigned int special_functions; |
|---|
| 218 | 206 | |
|---|
| 219 | 207 | bool kbd_event_generated; |
|---|
| 220 | | - bool kbd_led_registered; |
|---|
| 221 | | - bool illumination_led_registered; |
|---|
| 222 | | - bool eco_led_registered; |
|---|
| 223 | 208 | bool killswitch; |
|---|
| 224 | 209 | }; |
|---|
| 225 | 210 | |
|---|
| .. | .. |
|---|
| 470 | 455 | acpi_status status; |
|---|
| 471 | 456 | |
|---|
| 472 | 457 | dev->illumination_supported = 0; |
|---|
| 473 | | - dev->illumination_led_registered = false; |
|---|
| 474 | 458 | |
|---|
| 475 | 459 | if (!sci_open(dev)) |
|---|
| 476 | 460 | return; |
|---|
| .. | .. |
|---|
| 540 | 524 | acpi_status status; |
|---|
| 541 | 525 | |
|---|
| 542 | 526 | dev->kbd_illum_supported = 0; |
|---|
| 543 | | - dev->kbd_led_registered = false; |
|---|
| 544 | 527 | dev->kbd_event_generated = false; |
|---|
| 545 | 528 | |
|---|
| 546 | 529 | if (!sci_open(dev)) |
|---|
| .. | .. |
|---|
| 685 | 668 | acpi_status status; |
|---|
| 686 | 669 | |
|---|
| 687 | 670 | dev->eco_supported = 0; |
|---|
| 688 | | - dev->eco_led_registered = false; |
|---|
| 689 | 671 | |
|---|
| 690 | 672 | status = tci_raw(dev, in, out); |
|---|
| 691 | 673 | if (ACPI_FAILURE(status)) { |
|---|
| .. | .. |
|---|
| 1444 | 1426 | return count; |
|---|
| 1445 | 1427 | } |
|---|
| 1446 | 1428 | |
|---|
| 1447 | | -static const struct file_operations lcd_proc_fops = { |
|---|
| 1448 | | - .owner = THIS_MODULE, |
|---|
| 1449 | | - .open = lcd_proc_open, |
|---|
| 1450 | | - .read = seq_read, |
|---|
| 1451 | | - .llseek = seq_lseek, |
|---|
| 1452 | | - .release = single_release, |
|---|
| 1453 | | - .write = lcd_proc_write, |
|---|
| 1429 | +static const struct proc_ops lcd_proc_ops = { |
|---|
| 1430 | + .proc_open = lcd_proc_open, |
|---|
| 1431 | + .proc_read = seq_read, |
|---|
| 1432 | + .proc_lseek = seq_lseek, |
|---|
| 1433 | + .proc_release = single_release, |
|---|
| 1434 | + .proc_write = lcd_proc_write, |
|---|
| 1454 | 1435 | }; |
|---|
| 1455 | 1436 | |
|---|
| 1456 | 1437 | /* Video-Out */ |
|---|
| .. | .. |
|---|
| 1550 | 1531 | return ret ? -EIO : count; |
|---|
| 1551 | 1532 | } |
|---|
| 1552 | 1533 | |
|---|
| 1553 | | -static const struct file_operations video_proc_fops = { |
|---|
| 1554 | | - .owner = THIS_MODULE, |
|---|
| 1555 | | - .open = video_proc_open, |
|---|
| 1556 | | - .read = seq_read, |
|---|
| 1557 | | - .llseek = seq_lseek, |
|---|
| 1558 | | - .release = single_release, |
|---|
| 1559 | | - .write = video_proc_write, |
|---|
| 1534 | +static const struct proc_ops video_proc_ops = { |
|---|
| 1535 | + .proc_open = video_proc_open, |
|---|
| 1536 | + .proc_read = seq_read, |
|---|
| 1537 | + .proc_lseek = seq_lseek, |
|---|
| 1538 | + .proc_release = single_release, |
|---|
| 1539 | + .proc_write = video_proc_write, |
|---|
| 1560 | 1540 | }; |
|---|
| 1561 | 1541 | |
|---|
| 1562 | 1542 | /* Fan status */ |
|---|
| .. | .. |
|---|
| 1628 | 1608 | return count; |
|---|
| 1629 | 1609 | } |
|---|
| 1630 | 1610 | |
|---|
| 1631 | | -static const struct file_operations fan_proc_fops = { |
|---|
| 1632 | | - .owner = THIS_MODULE, |
|---|
| 1633 | | - .open = fan_proc_open, |
|---|
| 1634 | | - .read = seq_read, |
|---|
| 1635 | | - .llseek = seq_lseek, |
|---|
| 1636 | | - .release = single_release, |
|---|
| 1637 | | - .write = fan_proc_write, |
|---|
| 1611 | +static const struct proc_ops fan_proc_ops = { |
|---|
| 1612 | + .proc_open = fan_proc_open, |
|---|
| 1613 | + .proc_read = seq_read, |
|---|
| 1614 | + .proc_lseek = seq_lseek, |
|---|
| 1615 | + .proc_release = single_release, |
|---|
| 1616 | + .proc_write = fan_proc_write, |
|---|
| 1638 | 1617 | }; |
|---|
| 1639 | 1618 | |
|---|
| 1640 | 1619 | static int keys_proc_show(struct seq_file *m, void *v) |
|---|
| .. | .. |
|---|
| 1673 | 1652 | return count; |
|---|
| 1674 | 1653 | } |
|---|
| 1675 | 1654 | |
|---|
| 1676 | | -static const struct file_operations keys_proc_fops = { |
|---|
| 1677 | | - .owner = THIS_MODULE, |
|---|
| 1678 | | - .open = keys_proc_open, |
|---|
| 1679 | | - .read = seq_read, |
|---|
| 1680 | | - .llseek = seq_lseek, |
|---|
| 1681 | | - .release = single_release, |
|---|
| 1682 | | - .write = keys_proc_write, |
|---|
| 1655 | +static const struct proc_ops keys_proc_ops = { |
|---|
| 1656 | + .proc_open = keys_proc_open, |
|---|
| 1657 | + .proc_read = seq_read, |
|---|
| 1658 | + .proc_lseek = seq_lseek, |
|---|
| 1659 | + .proc_release = single_release, |
|---|
| 1660 | + .proc_write = keys_proc_write, |
|---|
| 1683 | 1661 | }; |
|---|
| 1684 | 1662 | |
|---|
| 1685 | 1663 | static int __maybe_unused version_proc_show(struct seq_file *m, void *v) |
|---|
| .. | .. |
|---|
| 1699 | 1677 | { |
|---|
| 1700 | 1678 | if (dev->backlight_dev) |
|---|
| 1701 | 1679 | proc_create_data("lcd", S_IRUGO | S_IWUSR, toshiba_proc_dir, |
|---|
| 1702 | | - &lcd_proc_fops, dev); |
|---|
| 1680 | + &lcd_proc_ops, dev); |
|---|
| 1703 | 1681 | if (dev->video_supported) |
|---|
| 1704 | 1682 | proc_create_data("video", S_IRUGO | S_IWUSR, toshiba_proc_dir, |
|---|
| 1705 | | - &video_proc_fops, dev); |
|---|
| 1683 | + &video_proc_ops, dev); |
|---|
| 1706 | 1684 | if (dev->fan_supported) |
|---|
| 1707 | 1685 | proc_create_data("fan", S_IRUGO | S_IWUSR, toshiba_proc_dir, |
|---|
| 1708 | | - &fan_proc_fops, dev); |
|---|
| 1686 | + &fan_proc_ops, dev); |
|---|
| 1709 | 1687 | if (dev->hotkey_dev) |
|---|
| 1710 | 1688 | proc_create_data("keys", S_IRUGO | S_IWUSR, toshiba_proc_dir, |
|---|
| 1711 | | - &keys_proc_fops, dev); |
|---|
| 1689 | + &keys_proc_ops, dev); |
|---|
| 1712 | 1690 | proc_create_single_data("version", S_IRUGO, toshiba_proc_dir, |
|---|
| 1713 | 1691 | version_proc_show, dev); |
|---|
| 1714 | 1692 | } |
|---|
| .. | .. |
|---|
| 2769 | 2747 | result = hci_write(dev, HCI_SYSTEM_EVENT, 1); |
|---|
| 2770 | 2748 | if (result == TOS_SUCCESS) |
|---|
| 2771 | 2749 | pr_notice("Re-enabled hotkeys\n"); |
|---|
| 2772 | | - /* Fall through */ |
|---|
| 2750 | + fallthrough; |
|---|
| 2773 | 2751 | default: |
|---|
| 2774 | 2752 | retries--; |
|---|
| 2775 | 2753 | break; |
|---|
| .. | .. |
|---|
| 3009 | 2987 | |
|---|
| 3010 | 2988 | backlight_device_unregister(dev->backlight_dev); |
|---|
| 3011 | 2989 | |
|---|
| 3012 | | - if (dev->illumination_led_registered) |
|---|
| 3013 | | - led_classdev_unregister(&dev->led_dev); |
|---|
| 3014 | | - |
|---|
| 3015 | | - if (dev->kbd_led_registered) |
|---|
| 3016 | | - led_classdev_unregister(&dev->kbd_led); |
|---|
| 3017 | | - |
|---|
| 3018 | | - if (dev->eco_led_registered) |
|---|
| 3019 | | - led_classdev_unregister(&dev->eco_led); |
|---|
| 2990 | + led_classdev_unregister(&dev->led_dev); |
|---|
| 2991 | + led_classdev_unregister(&dev->kbd_led); |
|---|
| 2992 | + led_classdev_unregister(&dev->eco_led); |
|---|
| 3020 | 2993 | |
|---|
| 3021 | 2994 | if (dev->wwan_rfk) { |
|---|
| 3022 | 2995 | rfkill_unregister(dev->wwan_rfk); |
|---|
| .. | .. |
|---|
| 3108 | 3081 | dev->led_dev.max_brightness = 1; |
|---|
| 3109 | 3082 | dev->led_dev.brightness_set = toshiba_illumination_set; |
|---|
| 3110 | 3083 | dev->led_dev.brightness_get = toshiba_illumination_get; |
|---|
| 3111 | | - if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev)) |
|---|
| 3112 | | - dev->illumination_led_registered = true; |
|---|
| 3084 | + led_classdev_register(&acpi_dev->dev, &dev->led_dev); |
|---|
| 3113 | 3085 | } |
|---|
| 3114 | 3086 | |
|---|
| 3115 | 3087 | toshiba_eco_mode_available(dev); |
|---|
| .. | .. |
|---|
| 3118 | 3090 | dev->eco_led.max_brightness = 1; |
|---|
| 3119 | 3091 | dev->eco_led.brightness_set = toshiba_eco_mode_set_status; |
|---|
| 3120 | 3092 | dev->eco_led.brightness_get = toshiba_eco_mode_get_status; |
|---|
| 3121 | | - if (!led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led)) |
|---|
| 3122 | | - dev->eco_led_registered = true; |
|---|
| 3093 | + led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led); |
|---|
| 3123 | 3094 | } |
|---|
| 3124 | 3095 | |
|---|
| 3125 | 3096 | toshiba_kbd_illum_available(dev); |
|---|
| .. | .. |
|---|
| 3135 | 3106 | dev->kbd_led.max_brightness = 1; |
|---|
| 3136 | 3107 | dev->kbd_led.brightness_set = toshiba_kbd_backlight_set; |
|---|
| 3137 | 3108 | dev->kbd_led.brightness_get = toshiba_kbd_backlight_get; |
|---|
| 3138 | | - if (!led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led)) |
|---|
| 3139 | | - dev->kbd_led_registered = true; |
|---|
| 3109 | + led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led); |
|---|
| 3140 | 3110 | } |
|---|
| 3141 | 3111 | |
|---|
| 3142 | 3112 | ret = toshiba_touchpad_get(dev, &dummy); |
|---|
| .. | .. |
|---|
| 3144 | 3114 | |
|---|
| 3145 | 3115 | toshiba_accelerometer_available(dev); |
|---|
| 3146 | 3116 | if (dev->accelerometer_supported) { |
|---|
| 3147 | | - dev->indio_dev = iio_device_alloc(sizeof(*dev)); |
|---|
| 3117 | + dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev)); |
|---|
| 3148 | 3118 | if (!dev->indio_dev) { |
|---|
| 3149 | 3119 | pr_err("Unable to allocate iio device\n"); |
|---|
| 3150 | 3120 | goto iio_error; |
|---|
| .. | .. |
|---|
| 3154 | 3124 | |
|---|
| 3155 | 3125 | dev->indio_dev->info = &toshiba_iio_accel_info; |
|---|
| 3156 | 3126 | dev->indio_dev->name = "Toshiba accelerometer"; |
|---|
| 3157 | | - dev->indio_dev->dev.parent = &acpi_dev->dev; |
|---|
| 3158 | 3127 | dev->indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 3159 | 3128 | dev->indio_dev->channels = toshiba_iio_accel_channels; |
|---|
| 3160 | 3129 | dev->indio_dev->num_channels = |
|---|