Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'platform-drivers-x86-v7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver updates from Ilpo Järvinen:
"asus-wmi:
- Retain battery charge threshold during boot which avoids
unsolicited change to 100%. Return -ENODATA when the limit
is not yet known
- Improve screenpad power/brightness handling consistency
- Fix screenpad brightness range

barco-p50-gpio:
- Normalize gpio_get return values

bitland-mifs-wmi:
- Add driver for Bitland laptops (supports platform profile,
hwmon, kbd backlight, gpu mode, hotkeys, and fan boost)

dell_rbu:
- Fix using uninitialized value in sysfs write function

dell-wmi-sysman:
- Respect destination length when constructing enum strings

hp-wmi:
- Propagate fan setting apply failures and log an error
- Fix sysfs write vs work handler cancel_delayed_work_sync() deadlock
- Correct keepalive schedule_delayed_work() to mod_delayed_work()
- Fix u8 underflows in GPU delta calculation
- Use mutex to protect fan pwm/mode
- Ignore kbd backlight and FnLock key events that are handled by FW
- Fix fan table parsing (use correct field)
- Add support for Omen 14-fb0xxx, 16-n0xxx, 16-wf1xxx, and
Omen MAX 16-ak0xxxx

input: trackpoint & thinkpad_acpi:
- Enable doubletap by default and add sysfs enable/disable

int3472:
- Add support for GPIO type 0x02 (IR flood LED)

intel-speed-select: (updated to v1.26)
- Avoid using current base frequency as maximum
- Fix CPU extended family ID decoding
- Fix exit code
- Improve error reporting

intel/vsec:
- Refactor to support ACPI-enumerated PMT endpoints.

pcengines-apuv2:
- Attach software node to the gpiochip

uniwill:
- Refactor hwmon to smaller parts to accomodate HW diversity
- Support USB-C power/performance priority switch through sysfs
- Add another XMG Fusion 15 (L19) DMI vendor
- Enable fine-grained features to device lineup mapping

wmi:
- Perform output size check within WMI core to allow simpler WMI
drivers

misc:
- acpi_driver -> platform driver conversions (a large number of
changes from Rafael J. Wysocki)
- cleanups / refactoring / improvements"

* tag 'platform-drivers-x86-v7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (106 commits)
platform/x86: hp-wmi: Add support for Omen 16-wf1xxx (8C77)
platform/x86: hp-wmi: Add support for Omen 16-n0xxx (8A44)
platform/x86: hp-wmi: Add support for OMEN MAX 16-ak0xxx (8D87)
platform/x86: hp-wmi: fix fan table parsing
platform/x86: hp-wmi: add Omen 14-fb0xxx (board 8C58) support
platform/wmi: Replace .no_notify_data with .min_event_size
platform/wmi: Extend wmidev_query_block() to reject undersized data
platform/wmi: Extend wmidev_invoke_method() to reject undersized data
platform/wmi: Prepare to reject undersized unmarshalling results
platform/wmi: Convert drivers to use wmidev_invoke_procedure()
platform/wmi: Add wmidev_invoke_procedure()
platform/x86: int3472: Add support for GPIO type 0x02 (IR flood LED)
platform/x86: int3472: Parameterize LED con_id in registration
platform/x86: int3472: Rename pled to led in LED registration code
platform/x86: int3472: Use local variable for LED struct access
platform/x86: thinkpad_acpi: remove obsolete TODO comment
platform/x86: dell-wmi-sysman: bound enumeration string aggregation
platform/x86: hp-wmi: Ignore backlight and FnLock events
platform/x86: uniwill-laptop: Fix signedness bug
platform/x86: dell_rbu: avoid uninit value usage in packet_size_write()
...

+3088 -1324
+27
Documentation/ABI/testing/sysfs-driver-uniwill-laptop
··· 51 51 52 52 Reading this file returns the current status of the breathing animation 53 53 functionality. 54 + 55 + What: /sys/bus/platform/devices/INOU0000:XX/ctgp_offset 56 + Date: January 2026 57 + KernelVersion: 7.0 58 + Contact: Werner Sembach <wse@tuxedocomputers.com> 59 + Description: 60 + Allows userspace applications to set the configurable TGP offset on top of the base 61 + TGP. Base TGP and max TGP and therefore the max cTGP offset are device specific. 62 + Note that setting the maximum cTGP leaves no window open for Dynamic Boost as 63 + Dynamic Boost also can not go over max TGP. Setting the cTGP to maximum is 64 + effectively disabling Dynamic Boost and telling the device to always prioritize the 65 + GPU over the CPU. 66 + 67 + Reading this file returns the current configurable TGP offset. 68 + 69 + What: /sys/bus/platform/devices/INOU0000:XX/usb_c_power_priority 70 + Date: February 2026 71 + KernelVersion: 7.1 72 + Contact: Werner Sembach <wse@tuxedocomputers.com> 73 + Description: 74 + Allows userspace applications to choose the USB-C power distribution profile between 75 + one that offers a bigger share of the power to the battery and one that offers more 76 + of it to the CPU. Writing "charging"/"performance" into this file selects the 77 + respective profile. 78 + 79 + Reading this file returns the profile names with the currently active one in 80 + brackets.
+21
Documentation/admin-guide/laptops/thinkpad-acpi.rst
··· 1522 1522 The property is read-only. If the platform doesn't have support the sysfs 1523 1523 class is not created. 1524 1524 1525 + doubletap_enable 1526 + ---------------- 1527 + 1528 + sysfs: doubletap_enable 1529 + 1530 + Controls whether TrackPoint doubletap events are filtered out. Doubletap is a 1531 + feature where quickly tapping the TrackPoint twice triggers a special function key event. 1532 + 1533 + The available commands are:: 1534 + 1535 + cat /sys/devices/platform/thinkpad_acpi/doubletap_enable 1536 + echo 1 | sudo tee /sys/devices/platform/thinkpad_acpi/doubletap_enable 1537 + echo 0 | sudo tee /sys/devices/platform/thinkpad_acpi/doubletap_enable 1538 + 1539 + Values: 1540 + 1541 + * 1 - doubletap events are processed (default) 1542 + * 0 - doubletap events are filtered out (ignored) 1543 + 1544 + This setting can also be toggled via the Fn+doubletap hotkey. 1545 + 1525 1546 Auxmac 1526 1547 ------ 1527 1548
+12
Documentation/admin-guide/laptops/uniwill-laptop.rst
··· 50 50 Additionally the driver signals the presence of battery charging issues through the standard 51 51 ``health`` power supply sysfs attribute. 52 52 53 + It also lets you set whether a USB-C power source should prioritise charging the battery or 54 + delivering immediate power to the cpu. See Documentation/ABI/testing/sysfs-driver-uniwill-laptop for 55 + details. 56 + 53 57 Lightbar 54 58 -------- 55 59 ··· 62 58 63 59 See Documentation/ABI/testing/sysfs-driver-uniwill-laptop for details on how to control the various 64 60 animation modes of the lightbar. 61 + 62 + Configurable TGP 63 + ---------------- 64 + 65 + The ``uniwill-laptop`` driver allows to set the configurable TGP for devices with NVIDIA GPUs that 66 + allow it. 67 + 68 + See Documentation/ABI/testing/sysfs-driver-uniwill-laptop for details.
+207
Documentation/wmi/devices/bitland-mifs-wmi.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-or-later 2 + 3 + ======================================== 4 + Bitland MIFS driver (bitland-mifs-wmi) 5 + ======================================== 6 + 7 + Introduction 8 + ============ 9 + 10 + 11 + EC WMI interface description 12 + ============================ 13 + 14 + The EC WMI interface description can be decoded from the embedded binary MOF (bmof) 15 + data using the `bmfdec <https://github.com/pali/bmfdec>`_ utility: 16 + 17 + :: 18 + 19 + class WMIEvent : __ExtrinsicEvent { 20 + }; 21 + 22 + [WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x40A"), Description("Root WMI HID_EVENT20"), guid("{46c93e13-ee9b-4262-8488-563bca757fef}")] 23 + class HID_EVENT20 : WmiEvent { 24 + [key, read] string InstanceName; 25 + [read] boolean Active; 26 + [WmiDataId(1), read, write, Description("Package Data")] uint8 EventDetail[8]; 27 + }; 28 + 29 + [WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x40A"), Description("Root WMI HID_EVENT21"), guid("{fa78e245-2c0f-4ca1-91cf-15f34e474850}")] 30 + class HID_EVENT21 : WmiEvent { 31 + [key, read] string InstanceName; 32 + [read] boolean Active; 33 + [WmiDataId(1), read, write, Description("Package Data")] uint8 EventDetail[8]; 34 + }; 35 + 36 + [WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x40A"), Description("Root WMI HID_EVENT22"), guid("{1dceaf0a-4d63-44bb-bd0c-0d6281bfddc5}")] 37 + class HID_EVENT22 : WmiEvent { 38 + [key, read] string InstanceName; 39 + [read] boolean Active; 40 + [WmiDataId(1), read, write, Description("Package Data")] uint8 EventDetail[8]; 41 + }; 42 + 43 + [WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x40A"), Description("Root WMI HID_EVENT23"), guid("{3f9e3c26-b077-4f86-91f5-37ff64d8c7ed}")] 44 + class HID_EVENT23 : WmiEvent { 45 + [key, read] string InstanceName; 46 + [read] boolean Active; 47 + [WmiDataId(1), read, write, Description("Package Data")] uint8 EventDetail[8]; 48 + }; 49 + 50 + [WMI, Dynamic, provider("WmiProv"), Locale("MS\\0x409"), Description("Class used to operate firmware interface"), guid("{b60bfb48-3e5b-49e4-a0e9-8cffe1b3434b}")] 51 + class MICommonInterface { 52 + [key, read] string InstanceName; 53 + [read] boolean Active; 54 + 55 + [WmiMethodId(1), Implemented, read, write, Description("Method used to support system functions.")] void MiInterface([in, Description("WMI Interface")] uint8 InData[32], [out] uint8 OutData[30], [out] uint16 Reserved); 56 + }; 57 + 58 + Reverse-Engineering the EC WMI interface 59 + ======================================== 60 + 61 + The OEM software can be download from `this link <https://iknow.lenovo.com.cn/detail/429447>`_ 62 + 63 + Nothing is obfuscated, In this case, `ILSpy <https://github.com/icsharpcode/ILSpy>`_ could be helpful. 64 + 65 + WMI Methods (MICommonInterface) 66 + ======================================== 67 + 68 + The ``MICommonInterface`` class (GUID: ``{b60bfb48-3e5b-49e4-a0e9-8cffe1b3434b}``) 69 + is the primary control interface. It uses a 32-byte buffer for both input 70 + (``InData``) and output (``OutData``). 71 + 72 + Method Structure 73 + ---------------- 74 + 75 + The data packet follows a standardized format: 76 + 77 + +----------+------------------------------------------------------------------+ 78 + | Byte | Description | 79 + +==========+==================================================================+ 80 + | 1 | Method Type: Get (0xFA / 250) or Set (0xFB / 251) | 81 + +----------+------------------------------------------------------------------+ 82 + | 3 | Command ID (Method Name) | 83 + +----------+------------------------------------------------------------------+ 84 + | 4 - 31 | Arguments (for Set) or Return Data (for Get) | 85 + +----------+------------------------------------------------------------------+ 86 + 87 + 88 + Command IDs 89 + ----------- 90 + 91 + The following Command IDs are used in the third byte of the buffer: 92 + 93 + +----------+-----------------------+------------------------------------------+ 94 + | ID | Name | Values / Description | 95 + +==========+=======================+==========================================+ 96 + | 8 | SystemPerMode | 0: Balance, 1: Performance, 2: Quiet, | 97 + | | | 3: Full-speed | 98 + +----------+-----------------------+------------------------------------------+ 99 + | 9 | GPUMode | 0: Hybrid, 1: Discrete, 2: UMA | 100 + +----------+-----------------------+------------------------------------------+ 101 + | 10 | KeyboardType | 0: White, 1: Single RGB, 2: Zone RGB | 102 + +----------+-----------------------+------------------------------------------+ 103 + | 11 | FnLock | 0: Off, 1: On | 104 + +----------+-----------------------+------------------------------------------+ 105 + | 12 | TPLock | 0: Unlock, 1: Lock (Touchpad) | 106 + +----------+-----------------------+------------------------------------------+ 107 + | 13 | CPUGPUSYSFanSpeed | Returns 12 bytes of fan data: | 108 + | | | Bytes 4-5: CPU Fan RPM (Little Endian) | 109 + | | | Bytes 6-7: GPU Fan RPM (Little Endian) | 110 + | | | Bytes 10-11: SYS Fan RPM (Little Endian) | 111 + +----------+-----------------------+------------------------------------------+ 112 + | 16 | RGBKeyboardMode | 0: Off, 1: Auto Cyclic, 2: Fixed, | 113 + | | | 3: Custom | 114 + +----------+-----------------------+------------------------------------------+ 115 + | 17 | RGBKeyboardColor | Bytes 4, 5, 6: Red, Green, Blue values | 116 + +----------+-----------------------+------------------------------------------+ 117 + | 18 | RGBKeyboardBrightness | 0-10: Brightness Levels, 128: Auto | 118 + +----------+-----------------------+------------------------------------------+ 119 + | 19 | SystemAcType | 1: Type-C, 2: Circular Hole (DC) | 120 + +----------+-----------------------+------------------------------------------+ 121 + | 20 | MaxFanSpeedSwitch | Byte 4: Fan Type (0: CPU/GPU, 1: SYS) | 122 + | | | Byte 5: State (0: Off, 1: On) | 123 + +----------+-----------------------+------------------------------------------+ 124 + | 21 | MaxFanSpeed | Sets manual fan speed duty cycle | 125 + +----------+-----------------------+------------------------------------------+ 126 + | 22 | CPUThermometer | Returns CPU Temperature | 127 + +----------+-----------------------+------------------------------------------+ 128 + 129 + WMI Events (HID_EVENT20) 130 + ======================== 131 + 132 + The driver listens for events from the ``HID_EVENT20`` class 133 + (GUID: ``{46c93e13-ee9b-4262-8488-563bca757fef}``). These events are triggered 134 + by hotkeys or system state changes (e.g., plugging in AC power). 135 + 136 + Event Structure 137 + --------------- 138 + 139 + The event data is provided in an 8-byte array (``EventDetail``): 140 + 141 + +----------+------------------------------------------------------------------+ 142 + | Byte | Description | 143 + +==========+==================================================================+ 144 + | 0 | Event Type (Always 0x01 for HotKey/Notification) | 145 + +----------+------------------------------------------------------------------+ 146 + | 1 | Event ID (Corresponds to the Command IDs above) | 147 + +----------+------------------------------------------------------------------+ 148 + | 2 | Value (The new state or value of the feature) | 149 + +----------+------------------------------------------------------------------+ 150 + 151 + Common Event IDs: 152 + ----------------- 153 + 154 + Note: reserved event ids are not listed there 155 + 156 + +----------+------------------------------------------------------------------+ 157 + | Event Id | Description | 158 + +==========+==================================================================+ 159 + | 4 | AirPlane mode change | 160 + +----------+------------------------------------------------------------------+ 161 + | 5 | Keyboard brightness change | 162 + +----------+------------------------------------------------------------------+ 163 + | 6 | Touchpad state (enabled/disabled) change | 164 + +----------+------------------------------------------------------------------+ 165 + | 7 | FnLock state (enabled/disabled) change | 166 + +----------+------------------------------------------------------------------+ 167 + | 8 | Keyboard mode change | 168 + +----------+------------------------------------------------------------------+ 169 + | 9 | CapsLock state change | 170 + +----------+------------------------------------------------------------------+ 171 + | 13 | NumLock state change | 172 + +----------+------------------------------------------------------------------+ 173 + | 14 | ScrollLock state change | 174 + +----------+------------------------------------------------------------------+ 175 + | 15 | Performance plan change | 176 + +----------+------------------------------------------------------------------+ 177 + | 25 | Display refresh rate change | 178 + +----------+------------------------------------------------------------------+ 179 + | 33 | Super key lock state (enabled/disabled) change | 180 + +----------+------------------------------------------------------------------+ 181 + | 35 | Open control center key | 182 + +----------+------------------------------------------------------------------+ 183 + 184 + Implementation Details 185 + ====================== 186 + 187 + Performance Modes 188 + ----------------- 189 + Changing the performance mode via Command ID 0x08 (SystemPerMode) affects the 190 + power limits (PL1/PL2) and fan curves managed by the Embedded Controller (EC). 191 + Note that the "Full-speed" and "Performance" mode (1, 3) is typically only 192 + available when the system is connected to a DC power source (not USB-C/PD). 193 + 194 + In the driver implementation, switch to performance/full-speed mode without 195 + DC power connected will throw the EOPNOTSUPP error. 196 + 197 + Graphics Switching 198 + ------------------ 199 + The ``GPUMode`` (0x09) allows switching between Hybrid (Muxless) and Discrete 200 + (Muxed) graphics. Changing this value usually requires a system reboot to 201 + take effect in the BIOS/Firmware. 202 + 203 + Fan Control 204 + ----------- 205 + The system supports both automatic EC control and manual overrides. Command ID 206 + 0x14 (``MaxFanSpeedSwitch``) is used to toggle manual control, while ID 0x15 207 + sets the actual PWM duty cycle.
+7 -4
Documentation/wmi/driver-development-guide.rst
··· 71 71 .remove = foo_remove, /* optional, devres is preferred */ 72 72 .shutdown = foo_shutdown, /* optional, called during shutdown */ 73 73 .notify_new = foo_notify, /* optional, for event handling */ 74 - .no_notify_data = true, /* optional, enables events containing no additional data */ 74 + .min_event_size = X, /* optional, simplifies event payload size verification */ 75 75 .no_singleton = true, /* required for new WMI drivers */ 76 76 }; 77 77 module_wmi_driver(foo_driver); ··· 106 106 107 107 WMI drivers can call WMI device methods using wmidev_invoke_method(). For each WMI method 108 108 invocation the WMI driver needs to provide the instance number and the method ID, as well as 109 - a buffer with the method arguments and optionally a buffer for the results. 109 + a buffer with the method arguments and optionally a buffer for the results. When calling WMI 110 + methods that do not return any values, wmidev_invoke_procedure() should be used instead. 110 111 111 112 The layout of said buffers is device-specific and described by the Binary MOF data associated 112 113 with a given WMI device. Said Binary MOF data also describes the method ID of a given WMI method ··· 142 141 However WMI driver developers should be aware that multiple WMI events can be received concurrently, 143 142 so any locking (if necessary) needs to be provided by the WMI driver itself. 144 143 145 - In order to be able to receive WMI events containing no additional event data, 146 - the ``no_notify_data`` flag inside struct wmi_driver should be set to ``true``. 144 + The WMI driver can furthermore instruct the WMI driver core to automatically reject WMI events 145 + that contain a undersized event payload by populating the ``min_event_size`` field inside 146 + struct wmi_driver. Setting this field to 0 will thus enable the WMI driver to receive WMI events 147 + without any event payload. 147 148 148 149 Take a look at drivers/platform/x86/xiaomi-wmi.c for an example WMI event driver. 149 150
+1 -1
drivers/gpu/drm/xe/xe_debugfs.c
··· 45 45 u64 residency = 0; 46 46 int ret; 47 47 48 - ret = xe_pmt_telem_read(to_pci_dev(xe->drm.dev), 48 + ret = xe_pmt_telem_read(xe->drm.dev, 49 49 xe_mmio_read32(mmio, PUNIT_TELEMETRY_GUID), 50 50 &residency, offset, sizeof(residency)); 51 51 if (ret != sizeof(residency)) {
+1 -1
drivers/gpu/drm/xe/xe_hwmon.c
··· 506 506 if (hwmon->xe->info.platform == XE_BATTLEMAGE) { 507 507 u64 pmt_val; 508 508 509 - ret = xe_pmt_telem_read(to_pci_dev(hwmon->xe->drm.dev), 509 + ret = xe_pmt_telem_read(hwmon->xe->drm.dev, 510 510 xe_mmio_read32(mmio, PUNIT_TELEMETRY_GUID), 511 511 &pmt_val, BMG_ENERGY_STATUS_PMT_OFFSET, sizeof(pmt_val)); 512 512 if (ret != sizeof(pmt_val)) {
+3 -4
drivers/gpu/drm/xe/xe_vsec.c
··· 140 140 return 0; 141 141 } 142 142 143 - int xe_pmt_telem_read(struct pci_dev *pdev, u32 guid, u64 *data, loff_t user_offset, 143 + int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offset, 144 144 u32 count) 145 145 { 146 - struct xe_device *xe = pdev_to_xe_device(pdev); 146 + struct xe_device *xe = kdev_to_xe_device(dev); 147 147 void __iomem *telem_addr = xe->mmio.regs + BMG_TELEMETRY_OFFSET; 148 148 u32 mem_region; 149 149 u32 offset; ··· 198 198 { 199 199 struct intel_vsec_platform_info *info; 200 200 struct device *dev = xe->drm.dev; 201 - struct pci_dev *pdev = to_pci_dev(dev); 202 201 enum xe_vsec platform; 203 202 204 203 platform = get_platform_info(xe); ··· 220 221 * Register a VSEC. Cleanup is handled using device managed 221 222 * resources. 222 223 */ 223 - intel_vsec_register(pdev, info); 224 + intel_vsec_register(dev, info); 224 225 } 225 226 MODULE_IMPORT_NS("INTEL_VSEC");
+2 -2
drivers/gpu/drm/xe/xe_vsec.h
··· 6 6 7 7 #include <linux/types.h> 8 8 9 - struct pci_dev; 9 + struct device; 10 10 struct xe_device; 11 11 12 12 void xe_vsec_init(struct xe_device *xe); 13 - int xe_pmt_telem_read(struct pci_dev *pdev, u32 guid, u64 *data, loff_t user_offset, u32 count); 13 + int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offset, u32 count); 14 14 15 15 #endif
+46
drivers/input/mouse/trackpoint.c
··· 5 5 * Trademarks are the property of their respective owners. 6 6 */ 7 7 8 + #include <linux/array_size.h> 8 9 #include <linux/slab.h> 9 10 #include <linux/delay.h> 10 11 #include <linux/serio.h> ··· 13 12 #include <linux/input.h> 14 13 #include <linux/libps2.h> 15 14 #include <linux/proc_fs.h> 15 + #include <linux/string.h> 16 16 #include <linux/uaccess.h> 17 17 #include "psmouse.h" 18 18 #include "trackpoint.h" ··· 395 393 return 0; 396 394 } 397 395 396 + /* List of known incapable device PNP IDs */ 397 + static const char * const dt_incompatible_devices[] = { 398 + "LEN0304", 399 + "LEN0306", 400 + "LEN0317", 401 + "LEN031A", 402 + "LEN031B", 403 + "LEN031C", 404 + "LEN031D", 405 + }; 406 + 407 + /* 408 + * Checks if it's a doubletap capable device. 409 + * The PNP ID format is "PNP: LEN030d PNP0f13". 410 + */ 411 + static bool trackpoint_is_dt_capable(const char *pnp_id) 412 + { 413 + size_t i; 414 + 415 + if (!pnp_id) 416 + return false; 417 + 418 + /* Must start with "PNP: LEN03" */ 419 + if (!strstarts(pnp_id, "PNP: LEN03")) 420 + return false; 421 + 422 + /* Ensure enough length before comparing */ 423 + if (strlen(pnp_id) < 12) 424 + return false; 425 + 426 + /* Check deny-list */ 427 + for (i = 0; i < ARRAY_SIZE(dt_incompatible_devices); i++) { 428 + if (!strncmp(pnp_id + 5, dt_incompatible_devices[i], 7)) 429 + return false; 430 + } 431 + return true; 432 + } 433 + 398 434 int trackpoint_detect(struct psmouse *psmouse, bool set_properties) 399 435 { 400 436 struct ps2dev *ps2dev = &psmouse->ps2dev; ··· 509 469 "%s TrackPoint firmware: 0x%02x, buttons: %d/%d\n", 510 470 psmouse->vendor, firmware_id, 511 471 (button_info & 0xf0) >> 4, button_info & 0x0f); 472 + 473 + if (trackpoint_is_dt_capable(ps2dev->serio->firmware_id)) { 474 + error = trackpoint_write(ps2dev, TP_DOUBLETAP, TP_DOUBLETAP_ENABLE); 475 + if (error) 476 + psmouse_warn(psmouse, "Failed to enable doubletap: %d\n", error); 477 + } 512 478 513 479 return 0; 514 480 }
+5
drivers/input/mouse/trackpoint.h
··· 69 69 /* (how hard it is to drag */ 70 70 /* with Z-axis pressed) */ 71 71 72 + #define TP_DOUBLETAP 0x58 /* TrackPoint doubletap register */ 73 + 72 74 #define TP_MINDRAG 0x59 /* Minimum amount of force needed */ 73 75 /* to trigger dragging */ 74 76 ··· 112 110 external device will be forced to 1 */ 113 111 #define TP_MASK_EXT_TAG 0x04 114 112 113 + /* Doubletap register values */ 114 + #define TP_DOUBLETAP_ENABLE 0xFF /* Enable value */ 115 + #define TP_DOUBLETAP_DISABLE 0xFE /* Disable value */ 115 116 116 117 /* Power on Self Test Results */ 117 118 #define TP_POR_SUCCESS 0x3B
-1
drivers/platform/mellanox/nvsw-sn2201.c
··· 10 10 #include <linux/i2c.h> 11 11 #include <linux/interrupt.h> 12 12 #include <linux/irq.h> 13 - #include <linux/gpio.h> 14 13 #include <linux/module.h> 15 14 #include <linux/platform_data/mlxcpld.h> 16 15 #include <linux/platform_data/mlxreg.h>
+1 -1
drivers/platform/surface/surface_hotplug.c
··· 14 14 */ 15 15 16 16 #include <linux/acpi.h> 17 - #include <linux/gpio.h> 17 + #include <linux/gpio/consumer.h> 18 18 #include <linux/interrupt.h> 19 19 #include <linux/kernel.h> 20 20 #include <linux/module.h>
+40 -31
drivers/platform/surface/surfacepro3_button.c
··· 14 14 #include <linux/types.h> 15 15 #include <linux/input.h> 16 16 #include <linux/acpi.h> 17 + #include <linux/platform_device.h> 17 18 #include <acpi/button.h> 18 19 19 20 #define SURFACE_PRO3_BUTTON_HID "MSHW0028" ··· 73 72 bool suspended; 74 73 }; 75 74 76 - static void surface_button_notify(struct acpi_device *device, u32 event) 75 + static void surface_button_notify(acpi_handle handle, u32 event, void *data) 77 76 { 78 - struct surface_button *button = acpi_driver_data(device); 77 + struct device *dev = data; 78 + struct surface_button *button = dev_get_drvdata(dev); 79 79 struct input_dev *input; 80 80 int key_code = KEY_RESERVED; 81 81 bool pressed = false; ··· 111 109 key_code = KEY_VOLUMEDOWN; 112 110 break; 113 111 case SURFACE_BUTTON_NOTIFY_TABLET_MODE: 114 - dev_warn_once(&device->dev, "Tablet mode is not supported\n"); 112 + dev_warn_once(dev, "Tablet mode is not supported\n"); 115 113 break; 116 114 default: 117 - dev_info_ratelimited(&device->dev, 118 - "Unsupported event [0x%x]\n", event); 115 + dev_info_ratelimited(dev, "Unsupported event [0x%x]\n", event); 119 116 break; 120 117 } 121 118 input = button->input; 122 119 if (key_code == KEY_RESERVED) 123 120 return; 124 121 if (pressed) 125 - pm_wakeup_dev_event(&device->dev, 0, button->suspended); 122 + pm_wakeup_dev_event(dev, 0, button->suspended); 126 123 if (button->suspended) 127 124 return; 128 125 input_report_key(input, key_code, pressed?1:0); ··· 131 130 #ifdef CONFIG_PM_SLEEP 132 131 static int surface_button_suspend(struct device *dev) 133 132 { 134 - struct acpi_device *device = to_acpi_device(dev); 135 - struct surface_button *button = acpi_driver_data(device); 133 + struct surface_button *button = dev_get_drvdata(dev); 136 134 137 135 button->suspended = true; 138 136 return 0; ··· 139 139 140 140 static int surface_button_resume(struct device *dev) 141 141 { 142 - struct acpi_device *device = to_acpi_device(dev); 143 - struct surface_button *button = acpi_driver_data(device); 142 + struct surface_button *button = dev_get_drvdata(dev); 144 143 145 144 button->suspended = false; 146 145 return 0; ··· 154 155 * Returns true if the driver should bind to this device, i.e. the device is 155 156 * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1. 156 157 */ 157 - static bool surface_button_check_MSHW0040(struct acpi_device *dev) 158 + static bool surface_button_check_MSHW0040(struct device *dev, acpi_handle handle) 158 159 { 159 - acpi_handle handle = dev->handle; 160 160 union acpi_object *result; 161 161 u64 oem_platform_rev = 0; // valid revisions are nonzero 162 162 ··· 177 179 ACPI_FREE(result); 178 180 } 179 181 180 - dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev); 182 + dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev); 181 183 182 184 return oem_platform_rev == 0; 183 185 } 184 186 185 187 186 - static int surface_button_add(struct acpi_device *device) 188 + static int surface_button_probe(struct platform_device *pdev) 187 189 { 190 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 188 191 struct surface_button *button; 189 192 struct input_dev *input; 190 193 const char *hid = acpi_device_hid(device); ··· 195 196 strlen(SURFACE_BUTTON_OBJ_NAME))) 196 197 return -ENODEV; 197 198 198 - if (!surface_button_check_MSHW0040(device)) 199 + if (!surface_button_check_MSHW0040(&pdev->dev, device->handle)) 199 200 return -ENODEV; 200 201 201 202 button = kzalloc_obj(struct surface_button); 202 203 if (!button) 203 204 return -ENOMEM; 204 205 205 - device->driver_data = button; 206 + platform_set_drvdata(pdev, button); 206 207 button->input = input = input_allocate_device(); 207 208 if (!input) { 208 209 error = -ENOMEM; ··· 215 216 input->name = acpi_device_name(device); 216 217 input->phys = button->phys; 217 218 input->id.bustype = BUS_HOST; 218 - input->dev.parent = &device->dev; 219 + input->dev.parent = &pdev->dev; 219 220 input_set_capability(input, EV_KEY, KEY_POWER); 220 221 input_set_capability(input, EV_KEY, KEY_LEFTMETA); 221 222 input_set_capability(input, EV_KEY, KEY_VOLUMEUP); ··· 225 226 if (error) 226 227 goto err_free_input; 227 228 228 - device_init_wakeup(&device->dev, true); 229 - dev_info(&device->dev, "%s [%s]\n", acpi_device_name(device), 229 + device_init_wakeup(&pdev->dev, true); 230 + 231 + error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 232 + surface_button_notify, &pdev->dev); 233 + if (error) { 234 + device_init_wakeup(&pdev->dev, false); 235 + input_unregister_device(input); 236 + goto err_free_button; 237 + } 238 + 239 + dev_info(&pdev->dev, "%s [%s]\n", acpi_device_name(device), 230 240 acpi_device_bid(device)); 231 241 return 0; 232 242 ··· 246 238 return error; 247 239 } 248 240 249 - static void surface_button_remove(struct acpi_device *device) 241 + static void surface_button_remove(struct platform_device *pdev) 250 242 { 251 - struct surface_button *button = acpi_driver_data(device); 243 + struct surface_button *button = platform_get_drvdata(pdev); 252 244 245 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 246 + ACPI_DEVICE_NOTIFY, surface_button_notify); 247 + device_init_wakeup(&pdev->dev, false); 253 248 input_unregister_device(button->input); 254 249 kfree(button); 255 250 } ··· 260 249 static SIMPLE_DEV_PM_OPS(surface_button_pm, 261 250 surface_button_suspend, surface_button_resume); 262 251 263 - static struct acpi_driver surface_button_driver = { 264 - .name = "surface_pro3_button", 265 - .class = "SurfacePro3", 266 - .ids = surface_button_device_ids, 267 - .ops = { 268 - .add = surface_button_add, 269 - .remove = surface_button_remove, 270 - .notify = surface_button_notify, 252 + static struct platform_driver surface_button_driver = { 253 + .probe = surface_button_probe, 254 + .remove = surface_button_remove, 255 + .driver = { 256 + .name = "surface_pro3_button", 257 + .acpi_match_table = surface_button_device_ids, 258 + .pm = &surface_button_pm, 271 259 }, 272 - .drv.pm = &surface_button_pm, 273 260 }; 274 261 275 - module_acpi_driver(surface_button_driver); 262 + module_platform_driver(surface_button_driver);
+68 -21
drivers/platform/wmi/core.c
··· 364 364 EXPORT_SYMBOL_GPL(wmidev_evaluate_method); 365 365 366 366 /** 367 - * wmidev_invoke_method - Invoke a WMI method 367 + * wmidev_invoke_method - Invoke a WMI method that returns values 368 368 * @wdev: A wmi bus device from a driver 369 369 * @instance: Instance index 370 370 * @method_id: Method ID to call 371 371 * @in: Mandatory WMI buffer containing input for the method call 372 - * @out: Optional WMI buffer to return the method results 372 + * @out: Mandatory WMI buffer to return the method results 373 + * @min_size: Minimum size of the method result data in bytes 373 374 * 374 - * Invoke a WMI method, the caller must free the resulting data inside @out. 375 - * Said data is guaranteed to be aligned on a 8-byte boundary. 375 + * Invoke a WMI method that returns values, the caller must free the resulting 376 + * data inside @out using kfree(). Said data is guaranteed to be aligned on a 377 + * 8-byte boundary. Use wmidev_invoke_procedure() for WMI methods that 378 + * return no values. 376 379 * 377 380 * Return: 0 on success or negative error code on failure. 378 381 */ 379 382 int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id, 380 - const struct wmi_buffer *in, struct wmi_buffer *out) 383 + const struct wmi_buffer *in, struct wmi_buffer *out, size_t min_size) 381 384 { 382 385 struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev); 383 386 struct acpi_buffer aout = { ACPI_ALLOCATE_BUFFER, NULL }; ··· 401 398 ain.pointer = in->data; 402 399 } 403 400 404 - if (out) 405 - status = wmidev_evaluate_method(wdev, instance, method_id, &ain, &aout); 406 - else 407 - status = wmidev_evaluate_method(wdev, instance, method_id, &ain, NULL); 401 + status = wmidev_evaluate_method(wdev, instance, method_id, &ain, &aout); 408 402 409 403 if (wblock->gblock.flags & ACPI_WMI_STRING) 410 404 kfree(ain.pointer); 411 405 412 406 if (ACPI_FAILURE(status)) 413 407 return -EIO; 414 - 415 - if (!out) 416 - return 0; 417 408 418 409 obj = aout.pointer; 419 410 if (!obj) { ··· 417 420 return 0; 418 421 } 419 422 420 - ret = wmi_unmarshal_acpi_object(obj, out); 423 + ret = wmi_unmarshal_acpi_object(obj, out, min_size); 421 424 kfree(obj); 422 425 423 426 return ret; 424 427 } 425 428 EXPORT_SYMBOL_GPL(wmidev_invoke_method); 429 + 430 + /** 431 + * wmidev_invoke_procedure - Invoke a WMI method that does not return values 432 + * @wdev: A wmi bus device from a driver 433 + * @instance: Instance index 434 + * @method_id: Method ID to call 435 + * @in: Mandatory WMI buffer containing input for the method call 436 + * 437 + * Invoke a WMI method that does not return any values. Use wmidev_invoke_method() 438 + * for WMI methods that do return values. 439 + * 440 + * Return: 0 on success or negative error code on failure. 441 + */ 442 + int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id, 443 + const struct wmi_buffer *in) 444 + { 445 + struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev); 446 + struct acpi_buffer ain; 447 + acpi_status status; 448 + int ret; 449 + 450 + if (wblock->gblock.flags & ACPI_WMI_STRING) { 451 + ret = wmi_marshal_string(in, &ain); 452 + if (ret < 0) 453 + return ret; 454 + } else { 455 + if (in->length > U32_MAX) 456 + return -E2BIG; 457 + 458 + ain.length = in->length; 459 + ain.pointer = in->data; 460 + } 461 + 462 + status = wmidev_evaluate_method(wdev, instance, method_id, &ain, NULL); 463 + 464 + if (wblock->gblock.flags & ACPI_WMI_STRING) 465 + kfree(ain.pointer); 466 + 467 + if (ACPI_FAILURE(status)) 468 + return -EIO; 469 + 470 + return 0; 471 + } 472 + EXPORT_SYMBOL_GPL(wmidev_invoke_procedure); 426 473 427 474 static acpi_status __query_block(struct wmi_block *wblock, u8 instance, 428 475 struct acpi_buffer *out) ··· 565 524 * @wdev: A wmi bus device from a driver 566 525 * @instance: Instance index 567 526 * @out: WMI buffer to fill 527 + * @min_size: Minimum size of the result data in bytes 568 528 * 569 - * Query a WMI data block, the caller must free the resulting data inside @out. 570 - * Said data is guaranteed to be aligned on a 8-byte boundary. 529 + * Query a WMI data block, the caller must free the resulting data inside @out 530 + * using kfree(). Said data is guaranteed to be aligned on a 8-byte boundary. 571 531 * 572 532 * Return: 0 on success or a negative error code on failure. 573 533 */ 574 - int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out) 534 + int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out, 535 + size_t min_size) 575 536 { 576 537 union acpi_object *obj; 577 538 int ret; ··· 582 539 if (!obj) 583 540 return -EIO; 584 541 585 - ret = wmi_unmarshal_acpi_object(obj, out); 542 + ret = wmi_unmarshal_acpi_object(obj, out, min_size); 586 543 kfree(obj); 587 544 588 545 return ret; ··· 1013 970 } 1014 971 1015 972 if (wdriver->notify || wdriver->notify_new) { 1016 - if (test_bit(WMI_NO_EVENT_DATA, &wblock->flags) && !wdriver->no_notify_data) 973 + if (test_bit(WMI_NO_EVENT_DATA, &wblock->flags) && wdriver->min_event_size) 1017 974 return -ENODEV; 1018 975 } 1019 976 ··· 1372 1329 static void wmi_notify_driver(struct wmi_block *wblock, union acpi_object *obj) 1373 1330 { 1374 1331 struct wmi_driver *driver = to_wmi_driver(wblock->dev.dev.driver); 1332 + struct wmi_buffer dummy = { 1333 + .length = 0, 1334 + .data = ZERO_SIZE_PTR, 1335 + }; 1375 1336 struct wmi_buffer buffer; 1376 1337 int ret; 1377 1338 1378 - if (!obj && !driver->no_notify_data) { 1339 + if (!obj && driver->min_event_size) { 1379 1340 dev_warn(&wblock->dev.dev, "Event contains no event data\n"); 1380 1341 return; 1381 1342 } ··· 1389 1342 1390 1343 if (driver->notify_new) { 1391 1344 if (!obj) { 1392 - driver->notify_new(&wblock->dev, NULL); 1345 + driver->notify_new(&wblock->dev, &dummy); 1393 1346 return; 1394 1347 } 1395 1348 1396 - ret = wmi_unmarshal_acpi_object(obj, &buffer); 1349 + ret = wmi_unmarshal_acpi_object(obj, &buffer, driver->min_event_size); 1397 1350 if (ret < 0) { 1398 1351 dev_warn(&wblock->dev.dev, "Failed to unmarshal event data: %d\n", ret); 1399 1352 return;
+2 -1
drivers/platform/wmi/internal.h
··· 11 11 union acpi_object; 12 12 struct wmi_buffer; 13 13 14 - int wmi_unmarshal_acpi_object(const union acpi_object *obj, struct wmi_buffer *buffer); 14 + int wmi_unmarshal_acpi_object(const union acpi_object *obj, struct wmi_buffer *buffer, 15 + size_t min_size); 15 16 int wmi_marshal_string(const struct wmi_buffer *buffer, struct acpi_buffer *out); 16 17 17 18 #endif /* _WMI_INTERNAL_H_ */
+5 -1
drivers/platform/wmi/marshalling.c
··· 151 151 return 0; 152 152 } 153 153 154 - int wmi_unmarshal_acpi_object(const union acpi_object *obj, struct wmi_buffer *buffer) 154 + int wmi_unmarshal_acpi_object(const union acpi_object *obj, struct wmi_buffer *buffer, 155 + size_t min_size) 155 156 { 156 157 size_t length, alloc_length; 157 158 u8 *data; ··· 161 160 ret = wmi_obj_get_buffer_length(obj, &length); 162 161 if (ret < 0) 163 162 return ret; 163 + 164 + if (length < min_size) 165 + return -ENODATA; 164 166 165 167 if (ARCH_KMALLOC_MINALIGN < 8) { 166 168 /*
+22 -2
drivers/platform/wmi/tests/marshalling_kunit.c
··· 372 372 struct wmi_buffer result; 373 373 int ret; 374 374 375 - ret = wmi_unmarshal_acpi_object(&param->obj, &result); 375 + ret = wmi_unmarshal_acpi_object(&param->obj, &result, param->buffer.length); 376 376 if (ret < 0) 377 377 KUNIT_FAIL_AND_ABORT(test, "Unmarshalling of ACPI object failed\n"); 378 378 ··· 389 389 struct wmi_buffer result; 390 390 int ret; 391 391 392 - ret = wmi_unmarshal_acpi_object(&param->obj, &result); 392 + ret = wmi_unmarshal_acpi_object(&param->obj, &result, 0); 393 393 if (ret < 0) 394 394 return; 395 395 ··· 427 427 KUNIT_FAIL(test, "Invalid string was not rejected\n"); 428 428 } 429 429 430 + static void wmi_unmarshal_acpi_object_undersized_test(struct kunit *test) 431 + { 432 + const union acpi_object obj = { 433 + .integer = { 434 + .type = ACPI_TYPE_INTEGER, 435 + .value = 0xdeadbeef, 436 + }, 437 + }; 438 + struct wmi_buffer result; 439 + int ret; 440 + 441 + ret = wmi_unmarshal_acpi_object(&obj, &result, sizeof(expected_single_integer) + 1); 442 + if (ret < 0) 443 + return; 444 + 445 + kfree(result.data); 446 + KUNIT_FAIL(test, "Undersized unmarshalling result was not rejected\n"); 447 + } 448 + 430 449 static struct kunit_case wmi_marshalling_test_cases[] = { 431 450 KUNIT_CASE_PARAM(wmi_unmarshal_acpi_object_test, 432 451 wmi_unmarshal_acpi_object_gen_params), ··· 455 436 wmi_unmarshal_acpi_object_failure_gen_params), 456 437 KUNIT_CASE_PARAM(wmi_marshal_string_failure_test, 457 438 wmi_marshal_string_failure_gen_params), 439 + KUNIT_CASE(wmi_unmarshal_acpi_object_undersized_test), 458 440 {} 459 441 }; 460 442
+18
drivers/platform/x86/Kconfig
··· 113 113 To compile this driver as a module, choose M here: the module will 114 114 be called gigabyte-wmi. 115 115 116 + config BITLAND_MIFS_WMI 117 + tristate "Bitland MIFS (MiInterface) WMI driver" 118 + depends on ACPI_WMI 119 + depends on HWMON 120 + depends on INPUT 121 + depends on POWER_SUPPLY 122 + select ACPI_PLATFORM_PROFILE 123 + select INPUT_SPARSEKMAP 124 + help 125 + This is a driver for Bitland MiInterface based laptops. 126 + 127 + It provides the access to the temperature, fan speed, gpu 128 + control, keyboard backlight brightness and platform profile 129 + via hwmon and sysfs. 130 + 131 + To compile this driver as a module, choose M here: the module will 132 + be called bitland-mifs-wmi. 133 + 116 134 config ACERHDF 117 135 tristate "Acer Aspire One temperature and fan driver" 118 136 depends on ACPI_EC && THERMAL
+1
drivers/platform/x86/Makefile
··· 14 14 obj-$(CONFIG_XIAOMI_WMI) += xiaomi-wmi.o 15 15 obj-$(CONFIG_REDMI_WMI) += redmi-wmi.o 16 16 obj-$(CONFIG_GIGABYTE_WMI) += gigabyte-wmi.o 17 + obj-$(CONFIG_BITLAND_MIFS_WMI) += bitland-mifs-wmi.o 17 18 18 19 # Acer 19 20 obj-$(CONFIG_ACERHDF) += acerhdf.o
+32 -16
drivers/platform/x86/acer-wireless.c
··· 10 10 #include <linux/kernel.h> 11 11 #include <linux/module.h> 12 12 #include <linux/pci_ids.h> 13 + #include <linux/platform_device.h> 13 14 #include <linux/types.h> 14 15 15 16 static const struct acpi_device_id acer_wireless_acpi_ids[] = { ··· 19 18 }; 20 19 MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids); 21 20 22 - static void acer_wireless_notify(struct acpi_device *adev, u32 event) 21 + static void acer_wireless_notify(acpi_handle handle, u32 event, void *data) 23 22 { 24 - struct input_dev *idev = acpi_driver_data(adev); 23 + struct device *dev = data; 24 + struct input_dev *idev = dev_get_drvdata(dev); 25 25 26 - dev_dbg(&adev->dev, "event=%#x\n", event); 26 + dev_dbg(dev, "event=%#x\n", event); 27 27 if (event != 0x80) { 28 - dev_notice(&adev->dev, "Unknown SMKB event: %#x\n", event); 28 + dev_notice(dev, "Unknown SMKB event: %#x\n", event); 29 29 return; 30 30 } 31 31 input_report_key(idev, KEY_RFKILL, 1); ··· 35 33 input_sync(idev); 36 34 } 37 35 38 - static int acer_wireless_add(struct acpi_device *adev) 36 + static int acer_wireless_probe(struct platform_device *pdev) 39 37 { 40 38 struct input_dev *idev; 39 + int ret; 41 40 42 - idev = devm_input_allocate_device(&adev->dev); 41 + idev = devm_input_allocate_device(&pdev->dev); 43 42 if (!idev) 44 43 return -ENOMEM; 45 44 46 - adev->driver_data = idev; 45 + platform_set_drvdata(pdev, idev); 47 46 idev->name = "Acer Wireless Radio Control"; 48 47 idev->phys = "acer-wireless/input0"; 49 48 idev->id.bustype = BUS_HOST; ··· 53 50 set_bit(EV_KEY, idev->evbit); 54 51 set_bit(KEY_RFKILL, idev->keybit); 55 52 56 - return input_register_device(idev); 53 + ret = input_register_device(idev); 54 + if (ret) 55 + return ret; 56 + 57 + return acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev), 58 + ACPI_DEVICE_NOTIFY, 59 + acer_wireless_notify, 60 + &pdev->dev); 57 61 } 58 62 59 - static struct acpi_driver acer_wireless_driver = { 60 - .name = "Acer Wireless Radio Control Driver", 61 - .class = "hotkey", 62 - .ids = acer_wireless_acpi_ids, 63 - .ops = { 64 - .add = acer_wireless_add, 65 - .notify = acer_wireless_notify, 63 + static void acer_wireless_remove(struct platform_device *pdev) 64 + { 65 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 66 + ACPI_DEVICE_NOTIFY, 67 + acer_wireless_notify); 68 + } 69 + 70 + static struct platform_driver acer_wireless_driver = { 71 + .probe = acer_wireless_probe, 72 + .remove = acer_wireless_remove, 73 + .driver = { 74 + .name = "Acer Wireless Radio Control Driver", 75 + .acpi_match_table = acer_wireless_acpi_ids, 66 76 }, 67 77 }; 68 - module_acpi_driver(acer_wireless_driver); 78 + module_platform_driver(acer_wireless_driver); 69 79 70 80 MODULE_DESCRIPTION("Acer Wireless Radio Control Driver"); 71 81 MODULE_AUTHOR("Chris Chiu <chiu@gmail.com>");
+25 -19
drivers/platform/x86/asus-laptop.c
··· 1517 1517 /* 1518 1518 * ACPI driver 1519 1519 */ 1520 - static void asus_acpi_notify(struct acpi_device *device, u32 event) 1520 + static void asus_acpi_notify(acpi_handle handle, u32 event, void *data) 1521 1521 { 1522 - struct asus_laptop *asus = acpi_driver_data(device); 1522 + struct asus_laptop *asus = data; 1523 1523 u16 count; 1524 1524 1525 1525 /* TODO Find a better way to handle events count. */ ··· 1824 1824 1825 1825 static bool asus_device_present; 1826 1826 1827 - static int asus_acpi_add(struct acpi_device *device) 1827 + static int asus_acpi_probe(struct platform_device *pdev) 1828 1828 { 1829 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1829 1830 struct asus_laptop *asus; 1830 1831 int result; 1831 1832 ··· 1838 1837 asus->handle = device->handle; 1839 1838 strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME); 1840 1839 strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS); 1841 - device->driver_data = asus; 1842 1840 asus->device = device; 1843 1841 1844 1842 asus_dmi_check(); ··· 1845 1845 result = asus_acpi_init(asus); 1846 1846 if (result) 1847 1847 goto fail_platform; 1848 + 1849 + platform_set_drvdata(pdev, asus); 1848 1850 1849 1851 /* 1850 1852 * Need platform type detection first, then the platform ··· 1883 1881 if (result && result != -ENODEV) 1884 1882 goto fail_pega_rfkill; 1885 1883 1884 + result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 1885 + asus_acpi_notify, asus); 1886 + if (result) 1887 + goto fail_pega_rfkill; 1888 + 1886 1889 asus_device_present = true; 1887 1890 return 0; 1888 1891 ··· 1909 1902 return result; 1910 1903 } 1911 1904 1912 - static void asus_acpi_remove(struct acpi_device *device) 1905 + static void asus_acpi_remove(struct platform_device *pdev) 1913 1906 { 1914 - struct asus_laptop *asus = acpi_driver_data(device); 1907 + struct asus_laptop *asus = platform_get_drvdata(pdev); 1915 1908 1909 + acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY, 1910 + asus_acpi_notify); 1916 1911 asus_backlight_exit(asus); 1917 1912 asus_rfkill_exit(asus); 1918 1913 asus_led_exit(asus); ··· 1933 1924 }; 1934 1925 MODULE_DEVICE_TABLE(acpi, asus_device_ids); 1935 1926 1936 - static struct acpi_driver asus_acpi_driver = { 1937 - .name = ASUS_LAPTOP_NAME, 1938 - .class = ASUS_LAPTOP_CLASS, 1939 - .ids = asus_device_ids, 1940 - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 1941 - .ops = { 1942 - .add = asus_acpi_add, 1943 - .remove = asus_acpi_remove, 1944 - .notify = asus_acpi_notify, 1945 - }, 1927 + static struct platform_driver asus_acpi_driver = { 1928 + .probe = asus_acpi_probe, 1929 + .remove = asus_acpi_remove, 1930 + .driver = { 1931 + .name = ASUS_LAPTOP_NAME, 1932 + .acpi_match_table = asus_device_ids, 1933 + }, 1946 1934 }; 1947 1935 1948 1936 static int __init asus_laptop_init(void) ··· 1950 1944 if (result < 0) 1951 1945 return result; 1952 1946 1953 - result = acpi_bus_register_driver(&asus_acpi_driver); 1947 + result = platform_driver_register(&asus_acpi_driver); 1954 1948 if (result < 0) 1955 1949 goto fail_acpi_driver; 1956 1950 if (!asus_device_present) { ··· 1960 1954 return 0; 1961 1955 1962 1956 fail_no_device: 1963 - acpi_bus_unregister_driver(&asus_acpi_driver); 1957 + platform_driver_unregister(&asus_acpi_driver); 1964 1958 fail_acpi_driver: 1965 1959 platform_driver_unregister(&platform_driver); 1966 1960 return result; ··· 1968 1962 1969 1963 static void __exit asus_laptop_exit(void) 1970 1964 { 1971 - acpi_bus_unregister_driver(&asus_acpi_driver); 1965 + platform_driver_unregister(&asus_acpi_driver); 1972 1966 platform_driver_unregister(&platform_driver); 1973 1967 } 1974 1968
+35 -20
drivers/platform/x86/asus-wireless.c
··· 12 12 #include <linux/acpi.h> 13 13 #include <linux/input.h> 14 14 #include <linux/pci_ids.h> 15 + #include <linux/platform_device.h> 15 16 #include <linux/leds.h> 16 17 17 18 struct hswc_params { ··· 109 108 queue_work(data->wq, &data->led_work); 110 109 } 111 110 112 - static void asus_wireless_notify(struct acpi_device *adev, u32 event) 111 + static void asus_wireless_notify(acpi_handle handle, u32 event, void *context) 113 112 { 114 - struct asus_wireless_data *data = acpi_driver_data(adev); 113 + struct asus_wireless_data *data = context; 114 + struct acpi_device *adev = data->adev; 115 115 116 116 dev_dbg(&adev->dev, "event=%#x\n", event); 117 117 if (event != 0x88) { ··· 125 123 input_sync(data->idev); 126 124 } 127 125 128 - static int asus_wireless_add(struct acpi_device *adev) 126 + static int asus_wireless_probe(struct platform_device *pdev) 129 127 { 128 + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); 130 129 struct asus_wireless_data *data; 131 130 const struct acpi_device_id *id; 132 131 int err; 133 132 134 - data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL); 133 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 135 134 if (!data) 136 135 return -ENOMEM; 137 - adev->driver_data = data; 136 + 137 + platform_set_drvdata(pdev, data); 138 + 138 139 data->adev = adev; 139 140 140 - data->idev = devm_input_allocate_device(&adev->dev); 141 + data->idev = devm_input_allocate_device(&pdev->dev); 141 142 if (!data->idev) 142 143 return -ENOMEM; 143 144 data->idev->name = "Asus Wireless Radio Control"; ··· 169 164 data->led.flags = LED_CORE_SUSPENDRESUME; 170 165 data->led.max_brightness = 1; 171 166 data->led.default_trigger = "rfkill-none"; 172 - err = devm_led_classdev_register(&adev->dev, &data->led); 167 + err = devm_led_classdev_register(&pdev->dev, &data->led); 173 168 if (err) 174 - destroy_workqueue(data->wq); 169 + goto err; 175 170 171 + err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY, 172 + asus_wireless_notify, data); 173 + if (err) { 174 + devm_led_classdev_unregister(&pdev->dev, &data->led); 175 + goto err; 176 + } 177 + return 0; 178 + 179 + err: 180 + destroy_workqueue(data->wq); 176 181 return err; 177 182 } 178 183 179 - static void asus_wireless_remove(struct acpi_device *adev) 184 + static void asus_wireless_remove(struct platform_device *pdev) 180 185 { 181 - struct asus_wireless_data *data = acpi_driver_data(adev); 186 + struct asus_wireless_data *data = platform_get_drvdata(pdev); 182 187 188 + acpi_dev_remove_notify_handler(data->adev, ACPI_DEVICE_NOTIFY, 189 + asus_wireless_notify); 183 190 if (data->wq) { 184 - devm_led_classdev_unregister(&adev->dev, &data->led); 191 + devm_led_classdev_unregister(&pdev->dev, &data->led); 185 192 destroy_workqueue(data->wq); 186 193 } 187 194 } 188 195 189 - static struct acpi_driver asus_wireless_driver = { 190 - .name = "Asus Wireless Radio Control Driver", 191 - .class = "hotkey", 192 - .ids = device_ids, 193 - .ops = { 194 - .add = asus_wireless_add, 195 - .remove = asus_wireless_remove, 196 - .notify = asus_wireless_notify, 196 + static struct platform_driver asus_wireless_driver = { 197 + .probe = asus_wireless_probe, 198 + .remove = asus_wireless_remove, 199 + .driver = { 200 + .name = "Asus Wireless Radio Control Driver", 201 + .acpi_match_table = device_ids, 197 202 }, 198 203 }; 199 - module_acpi_driver(asus_wireless_driver); 204 + module_platform_driver(asus_wireless_driver); 200 205 201 206 MODULE_DESCRIPTION("Asus Wireless Radio Control Driver"); 202 207 MODULE_AUTHOR("João Paulo Rechi Vita <jprvita@gmail.com>");
+27 -50
drivers/platform/x86/asus-wmi.c
··· 125 125 #define NVIDIA_TEMP_MIN 75 126 126 #define NVIDIA_TEMP_MAX 87 127 127 128 - #define ASUS_SCREENPAD_BRIGHT_MIN 20 129 128 #define ASUS_SCREENPAD_BRIGHT_MAX 255 130 129 #define ASUS_SCREENPAD_BRIGHT_DEFAULT 60 131 130 ··· 1556 1557 struct device_attribute *attr, 1557 1558 char *buf) 1558 1559 { 1559 - return sysfs_emit(buf, "%d\n", charge_end_threshold); 1560 + if ((charge_end_threshold >= 0) && (charge_end_threshold <= 100)) 1561 + return sysfs_emit(buf, "%d\n", charge_end_threshold); 1562 + 1563 + return -ENODATA; 1560 1564 } 1561 1565 1562 1566 static DEVICE_ATTR_RW(charge_control_end_threshold); ··· 1582 1580 return -ENODEV; 1583 1581 1584 1582 /* The charge threshold is only reset when the system is power cycled, 1585 - * and we can't get the current threshold so let set it to 100% when 1586 - * a battery is added. 1583 + * and we can't read the current threshold, however the majority of 1584 + * platforms retains it, therefore signal the threshold as unknown 1585 + * until user explicitly sets it to a new value. 1587 1586 */ 1588 - asus_wmi_set_devstate(ASUS_WMI_DEVID_RSOC, 100, NULL); 1589 - charge_end_threshold = 100; 1587 + charge_end_threshold = -1; 1590 1588 1591 1589 return 0; 1592 1590 } ··· 4410 4408 return err; 4411 4409 /* The device brightness can only be read if powered, so return stored */ 4412 4410 if (err == BACKLIGHT_POWER_OFF) 4413 - return asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN; 4411 + return bd->props.brightness; 4414 4412 4415 4413 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &retval); 4416 4414 if (err < 0) 4417 4415 return err; 4418 4416 4419 - return (retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK) - ASUS_SCREENPAD_BRIGHT_MIN; 4417 + return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK; 4420 4418 } 4421 4419 4422 4420 static int update_screenpad_bl_status(struct backlight_device *bd) 4423 4421 { 4424 - struct asus_wmi *asus = bl_get_data(bd); 4425 - int power, err = 0; 4426 - u32 ctrl_param; 4422 + u32 ctrl_param = bd->props.brightness; 4423 + int err = 0; 4427 4424 4428 - power = read_screenpad_backlight_power(asus); 4429 - if (power < 0) 4430 - return power; 4425 + if (bd->props.power) { 4426 + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL); 4427 + if (err < 0) 4428 + return err; 4431 4429 4432 - if (bd->props.power != power) { 4433 - if (power != BACKLIGHT_POWER_ON) { 4434 - /* Only brightness > 0 can power it back on */ 4435 - ctrl_param = asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN; 4436 - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, 4437 - ctrl_param, NULL); 4438 - } else { 4439 - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL); 4440 - } 4441 - } else if (power == BACKLIGHT_POWER_ON) { 4442 - /* Only set brightness if powered on or we get invalid/unsync state */ 4443 - ctrl_param = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN; 4444 4430 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL); 4431 + if (err < 0) 4432 + return err; 4445 4433 } 4446 4434 4447 - /* Ensure brightness is stored to turn back on with */ 4448 - if (err == 0) 4449 - asus->driver->screenpad_brightness = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN; 4435 + if (!bd->props.power) { 4436 + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL); 4437 + if (err < 0) 4438 + return err; 4439 + } 4450 4440 4451 4441 return err; 4452 4442 } ··· 4456 4462 int err, power; 4457 4463 int brightness = 0; 4458 4464 4459 - power = read_screenpad_backlight_power(asus); 4465 + power = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_SCREENPAD_POWER); 4460 4466 if (power < 0) 4461 4467 return power; 4462 4468 4463 - if (power != BACKLIGHT_POWER_OFF) { 4469 + if (power) { 4464 4470 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &brightness); 4465 4471 if (err < 0) 4466 4472 return err; 4467 4473 } 4468 - /* default to an acceptable min brightness on boot if too low */ 4469 - if (brightness < ASUS_SCREENPAD_BRIGHT_MIN) 4470 - brightness = ASUS_SCREENPAD_BRIGHT_DEFAULT; 4471 4474 4472 4475 memset(&props, 0, sizeof(struct backlight_properties)); 4473 4476 props.type = BACKLIGHT_RAW; /* ensure this bd is last to be picked */ 4474 - props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX - ASUS_SCREENPAD_BRIGHT_MIN; 4477 + props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX; 4475 4478 bd = backlight_device_register("asus_screenpad", 4476 4479 &asus->platform_device->dev, asus, 4477 4480 &asus_screenpad_bl_ops, &props); ··· 4479 4488 4480 4489 asus->screenpad_backlight_device = bd; 4481 4490 asus->driver->screenpad_brightness = brightness; 4482 - bd->props.brightness = brightness - ASUS_SCREENPAD_BRIGHT_MIN; 4491 + bd->props.brightness = brightness; 4483 4492 bd->props.power = power; 4484 4493 backlight_update_status(bd); 4485 4494 ··· 5404 5413 used = false; 5405 5414 } 5406 5415 EXPORT_SYMBOL_GPL(asus_wmi_unregister_driver); 5407 - 5408 - static int __init asus_wmi_init(void) 5409 - { 5410 - pr_info("ASUS WMI generic driver loaded\n"); 5411 - return 0; 5412 - } 5413 - 5414 - static void __exit asus_wmi_exit(void) 5415 - { 5416 - pr_info("ASUS WMI generic driver unloaded\n"); 5417 - } 5418 - 5419 - module_init(asus_wmi_init); 5420 - module_exit(asus_wmi_exit);
+10 -13
drivers/platform/x86/barco-p50-gpio.c
··· 272 272 struct p50_gpio *p50 = gpiochip_get_data(gc); 273 273 int ret; 274 274 275 - mutex_lock(&p50->lock); 275 + guard(mutex)(&p50->lock); 276 276 277 277 ret = p50_send_mbox_cmd(p50, P50_MBOX_CMD_READ_GPIO, gpio_params[offset], 0); 278 - if (ret == 0) 279 - ret = p50_read_mbox_reg(p50, P50_MBOX_REG_DATA); 278 + if (ret < 0) 279 + return ret; 280 280 281 - mutex_unlock(&p50->lock); 281 + ret = p50_read_mbox_reg(p50, P50_MBOX_REG_DATA); 282 + if (ret < 0) 283 + return ret; 282 284 283 - return ret; 285 + return !!ret; 284 286 } 285 287 286 288 static int p50_gpio_set(struct gpio_chip *gc, unsigned int offset, int value) 287 289 { 288 290 struct p50_gpio *p50 = gpiochip_get_data(gc); 289 - int ret; 290 291 291 - mutex_lock(&p50->lock); 292 + guard(mutex)(&p50->lock); 292 293 293 - ret = p50_send_mbox_cmd(p50, P50_MBOX_CMD_WRITE_GPIO, 294 - gpio_params[offset], value); 295 - 296 - mutex_unlock(&p50->lock); 297 - 298 - return ret; 294 + return p50_send_mbox_cmd(p50, P50_MBOX_CMD_WRITE_GPIO, 295 + gpio_params[offset], value); 299 296 } 300 297 301 298 static int p50_gpio_probe(struct platform_device *pdev)
+837
drivers/platform/x86/bitland-mifs-wmi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Linux driver for Bitland notebooks. 4 + * 5 + * Copyright (C) 2026 2 Mingyou Chen <qby140326@gmail.com> 6 + */ 7 + 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + 10 + #include <linux/acpi.h> 11 + #include <linux/array_size.h> 12 + #include <linux/bits.h> 13 + #include <linux/container_of.h> 14 + #include <linux/dev_printk.h> 15 + #include <linux/device.h> 16 + #include <linux/device/devres.h> 17 + #include <linux/err.h> 18 + #include <linux/hwmon.h> 19 + #include <linux/init.h> 20 + #include <linux/input-event-codes.h> 21 + #include <linux/input.h> 22 + #include <linux/input/sparse-keymap.h> 23 + #include <linux/kernel.h> 24 + #include <linux/leds.h> 25 + #include <linux/module.h> 26 + #include <linux/notifier.h> 27 + #include <linux/platform_profile.h> 28 + #include <linux/pm.h> 29 + #include <linux/power_supply.h> 30 + #include <linux/stddef.h> 31 + #include <linux/string.h> 32 + #include <linux/sysfs.h> 33 + #include <linux/unaligned.h> 34 + #include <linux/units.h> 35 + #include <linux/wmi.h> 36 + 37 + #define DRV_NAME "bitland-mifs-wmi" 38 + #define BITLAND_MIFS_GUID "B60BFB48-3E5B-49E4-A0E9-8CFFE1B3434B" 39 + #define BITLAND_EVENT_GUID "46C93E13-EE9B-4262-8488-563BCA757FEF" 40 + 41 + enum bitland_mifs_operation { 42 + WMI_METHOD_GET = 250, 43 + WMI_METHOD_SET = 251, 44 + }; 45 + 46 + enum bitland_mifs_function { 47 + WMI_FN_SYSTEM_PER_MODE = 8, 48 + WMI_FN_GPU_MODE = 9, 49 + WMI_FN_KBD_TYPE = 10, 50 + WMI_FN_FN_LOCK = 11, 51 + WMI_FN_TP_LOCK = 12, 52 + WMI_FN_FAN_SPEEDS = 13, 53 + WMI_FN_RGB_KB_MODE = 16, 54 + WMI_FN_RGB_KB_COLOR = 17, 55 + WMI_FN_RGB_KB_BRIGHTNESS = 18, 56 + WMI_FN_SYSTEM_AC_TYPE = 19, 57 + WMI_FN_MAX_FAN_SWITCH = 20, 58 + WMI_FN_MAX_FAN_SPEED = 21, 59 + WMI_FN_CPU_THERMOMETER = 22, 60 + WMI_FN_CPU_POWER = 23, 61 + }; 62 + 63 + enum bitland_system_ac_mode { 64 + WMI_SYSTEM_AC_TYPEC = 1, 65 + /* Unknown type, this is unused in the original driver */ 66 + WMI_SYSTEM_AC_CIRCULARHOLE = 2, 67 + }; 68 + 69 + enum bitland_mifs_power_profile { 70 + WMI_PP_BALANCED = 0, 71 + WMI_PP_PERFORMANCE = 1, 72 + WMI_PP_QUIET = 2, 73 + WMI_PP_FULL_SPEED = 3, 74 + }; 75 + 76 + enum bitland_mifs_event_id { 77 + WMI_EVENT_RESERVED_1 = 1, 78 + WMI_EVENT_RESERVED_2 = 2, 79 + WMI_EVENT_RESERVED_3 = 3, 80 + WMI_EVENT_AIRPLANE_MODE = 4, 81 + WMI_EVENT_KBD_BRIGHTNESS = 5, 82 + WMI_EVENT_TOUCHPAD_STATE = 6, 83 + WMI_EVENT_FNLOCK_STATE = 7, 84 + WMI_EVENT_KBD_MODE = 8, 85 + WMI_EVENT_CAPSLOCK_STATE = 9, 86 + WMI_EVENT_CALCULATOR_START = 11, 87 + WMI_EVENT_BROWSER_START = 12, 88 + WMI_EVENT_NUMLOCK_STATE = 13, 89 + WMI_EVENT_SCROLLLOCK_STATE = 14, 90 + WMI_EVENT_PERFORMANCE_PLAN = 15, 91 + WMI_EVENT_FN_J = 16, 92 + WMI_EVENT_FN_F = 17, 93 + WMI_EVENT_FN_0 = 18, 94 + WMI_EVENT_FN_1 = 19, 95 + WMI_EVENT_FN_2 = 20, 96 + WMI_EVENT_FN_3 = 21, 97 + WMI_EVENT_FN_4 = 22, 98 + WMI_EVENT_FN_5 = 24, 99 + WMI_EVENT_REFRESH_RATE = 25, 100 + WMI_EVENT_CPU_FAN_SPEED = 26, 101 + WMI_EVENT_GPU_FAN_SPEED = 32, 102 + WMI_EVENT_WIN_KEY_LOCK = 33, 103 + WMI_EVENT_RESERVED_23 = 34, 104 + WMI_EVENT_OPEN_APP = 35, 105 + }; 106 + 107 + enum bitland_mifs_event_type { 108 + WMI_EVENT_TYPE_HOTKEY = 1, 109 + }; 110 + 111 + enum bitland_wmi_device_type { 112 + BITLAND_WMI_CONTROL = 0, 113 + BITLAND_WMI_EVENT = 1, 114 + }; 115 + 116 + struct bitland_mifs_input { 117 + u8 reserved1; 118 + u8 operation; 119 + u8 reserved2; 120 + u8 function; 121 + u8 payload[28]; 122 + } __packed; 123 + 124 + struct bitland_mifs_output { 125 + u8 reserved1; 126 + u8 operation; 127 + u8 reserved2; 128 + u8 function; 129 + u8 data[28]; 130 + } __packed; 131 + 132 + struct bitland_mifs_event { 133 + u8 event_type; 134 + u8 event_id; 135 + u8 value_low; /* For most events, this is the value */ 136 + u8 value_high; /* For fan speed events, combined with value_low */ 137 + u8 reserved[4]; 138 + } __packed; 139 + 140 + static BLOCKING_NOTIFIER_HEAD(bitland_notifier_list); 141 + 142 + enum bitland_notifier_actions { 143 + BITLAND_NOTIFY_KBD_BRIGHTNESS, 144 + BITLAND_NOTIFY_PLATFORM_PROFILE, 145 + BITLAND_NOTIFY_HWMON, 146 + }; 147 + 148 + struct bitland_fan_notify_data { 149 + int channel; /* 0 = CPU, 1 = GPU */ 150 + u16 speed; 151 + }; 152 + 153 + struct bitland_mifs_wmi_data { 154 + struct wmi_device *wdev; 155 + struct mutex lock; /* Protects WMI calls */ 156 + struct led_classdev kbd_led; 157 + struct notifier_block notifier; 158 + struct input_dev *input_dev; 159 + struct device *hwmon_dev; 160 + struct device *pp_dev; 161 + enum platform_profile_option saved_profile; 162 + }; 163 + 164 + static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data, 165 + const struct bitland_mifs_input *input, 166 + struct bitland_mifs_output *output) 167 + { 168 + struct wmi_buffer in_buf = { .length = sizeof(*input), .data = (void *)input }; 169 + struct wmi_buffer out_buf = { 0 }; 170 + int ret; 171 + 172 + guard(mutex)(&data->lock); 173 + 174 + if (!output) 175 + return wmidev_invoke_procedure(data->wdev, 0, 1, &in_buf); 176 + 177 + ret = wmidev_invoke_method(data->wdev, 0, 1, &in_buf, &out_buf, sizeof(*output)); 178 + if (ret) 179 + return ret; 180 + 181 + memcpy(output, out_buf.data, sizeof(*output)); 182 + kfree(out_buf.data); 183 + 184 + return 0; 185 + } 186 + 187 + static int laptop_profile_get(struct device *dev, 188 + enum platform_profile_option *profile) 189 + { 190 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 191 + struct bitland_mifs_input input = { 192 + .reserved1 = 0, 193 + .operation = WMI_METHOD_GET, 194 + .reserved2 = 0, 195 + .function = WMI_FN_SYSTEM_PER_MODE, 196 + }; 197 + struct bitland_mifs_output result; 198 + int ret; 199 + 200 + ret = bitland_mifs_wmi_call(data, &input, &result); 201 + if (ret) 202 + return ret; 203 + 204 + switch (result.data[0]) { 205 + case WMI_PP_BALANCED: 206 + *profile = PLATFORM_PROFILE_BALANCED; 207 + break; 208 + case WMI_PP_PERFORMANCE: 209 + *profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE; 210 + break; 211 + case WMI_PP_QUIET: 212 + *profile = PLATFORM_PROFILE_LOW_POWER; 213 + break; 214 + case WMI_PP_FULL_SPEED: 215 + *profile = PLATFORM_PROFILE_PERFORMANCE; 216 + break; 217 + default: 218 + return -EINVAL; 219 + } 220 + return 0; 221 + } 222 + 223 + static int bitland_check_performance_capability(struct bitland_mifs_wmi_data *data) 224 + { 225 + struct bitland_mifs_input input = { 226 + .operation = WMI_METHOD_GET, 227 + .function = WMI_FN_SYSTEM_AC_TYPE, 228 + }; 229 + struct bitland_mifs_output output; 230 + int ret; 231 + 232 + /* Full-speed/performance mode requires DC power (not USB-C) */ 233 + if (!power_supply_is_system_supplied()) 234 + return -EOPNOTSUPP; 235 + 236 + ret = bitland_mifs_wmi_call(data, &input, &output); 237 + if (ret) 238 + return ret; 239 + 240 + if (output.data[0] != WMI_SYSTEM_AC_CIRCULARHOLE) 241 + return -EOPNOTSUPP; 242 + 243 + return 0; 244 + } 245 + 246 + static int laptop_profile_set(struct device *dev, 247 + enum platform_profile_option profile) 248 + { 249 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 250 + struct bitland_mifs_input input = { 251 + .reserved1 = 0, 252 + .operation = WMI_METHOD_SET, 253 + .reserved2 = 0, 254 + .function = WMI_FN_SYSTEM_PER_MODE, 255 + }; 256 + int ret; 257 + u8 val; 258 + 259 + switch (profile) { 260 + case PLATFORM_PROFILE_LOW_POWER: 261 + val = WMI_PP_QUIET; 262 + break; 263 + case PLATFORM_PROFILE_BALANCED: 264 + val = WMI_PP_BALANCED; 265 + break; 266 + case PLATFORM_PROFILE_BALANCED_PERFORMANCE: 267 + ret = bitland_check_performance_capability(data); 268 + if (ret) 269 + return ret; 270 + val = WMI_PP_PERFORMANCE; 271 + break; 272 + case PLATFORM_PROFILE_PERFORMANCE: 273 + ret = bitland_check_performance_capability(data); 274 + if (ret) 275 + return ret; 276 + val = WMI_PP_FULL_SPEED; 277 + break; 278 + default: 279 + return -EOPNOTSUPP; 280 + } 281 + 282 + input.payload[0] = val; 283 + 284 + return bitland_mifs_wmi_call(data, &input, NULL); 285 + } 286 + 287 + static int platform_profile_probe(void *drvdata, unsigned long *choices) 288 + { 289 + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); 290 + set_bit(PLATFORM_PROFILE_BALANCED, choices); 291 + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); 292 + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); 293 + 294 + return 0; 295 + } 296 + 297 + static int bitland_mifs_wmi_suspend(struct device *dev) 298 + { 299 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 300 + enum platform_profile_option profile; 301 + int ret; 302 + 303 + ret = laptop_profile_get(data->pp_dev, &profile); 304 + if (ret == 0) 305 + data->saved_profile = profile; 306 + 307 + return ret; 308 + } 309 + 310 + static int bitland_mifs_wmi_resume(struct device *dev) 311 + { 312 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 313 + 314 + dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile); 315 + return laptop_profile_set(dev, data->saved_profile); 316 + } 317 + 318 + static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops, 319 + bitland_mifs_wmi_suspend, 320 + bitland_mifs_wmi_resume); 321 + 322 + static const struct platform_profile_ops laptop_profile_ops = { 323 + .probe = platform_profile_probe, 324 + .profile_get = laptop_profile_get, 325 + .profile_set = laptop_profile_set, 326 + }; 327 + 328 + static const char *const fan_labels[] = { 329 + "CPU", /* 0 */ 330 + "GPU", /* 1 */ 331 + "SYS", /* 2 */ 332 + }; 333 + 334 + static int laptop_hwmon_read(struct device *dev, enum hwmon_sensor_types type, 335 + u32 attr, int channel, long *val) 336 + { 337 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 338 + struct bitland_mifs_input input = { 339 + .reserved1 = 0, 340 + .operation = WMI_METHOD_GET, 341 + .reserved2 = 0, 342 + }; 343 + struct bitland_mifs_output res; 344 + int ret; 345 + 346 + switch (type) { 347 + case hwmon_temp: 348 + input.function = WMI_FN_CPU_THERMOMETER; 349 + ret = bitland_mifs_wmi_call(data, &input, &res); 350 + if (!ret) 351 + *val = res.data[0] * MILLIDEGREE_PER_DEGREE; 352 + return ret; 353 + case hwmon_fan: 354 + input.function = WMI_FN_FAN_SPEEDS; 355 + ret = bitland_mifs_wmi_call(data, &input, &res); 356 + if (ret) 357 + return ret; 358 + 359 + switch (channel) { 360 + case 0: /* CPU */ 361 + *val = get_unaligned_le16(&res.data[0]); 362 + return 0; 363 + case 1: /* GPU */ 364 + *val = get_unaligned_le16(&res.data[2]); 365 + return 0; 366 + case 2: /* SYS */ 367 + *val = get_unaligned_le16(&res.data[6]); 368 + return 0; 369 + default: 370 + return -EINVAL; 371 + } 372 + default: 373 + return -EINVAL; 374 + } 375 + } 376 + 377 + static int laptop_hwmon_read_string(struct device *dev, 378 + enum hwmon_sensor_types type, u32 attr, 379 + int channel, const char **str) 380 + { 381 + if (type == hwmon_fan && attr == hwmon_fan_label) { 382 + if (channel >= 0 && channel < ARRAY_SIZE(fan_labels)) { 383 + *str = fan_labels[channel]; 384 + return 0; 385 + } 386 + } 387 + return -EINVAL; 388 + } 389 + 390 + static const struct hwmon_channel_info *laptop_hwmon_info[] = { 391 + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), 392 + HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL, 393 + HWMON_F_INPUT | HWMON_F_LABEL, 394 + HWMON_F_INPUT | HWMON_F_LABEL), 395 + NULL 396 + }; 397 + 398 + static const struct hwmon_ops laptop_hwmon_ops = { 399 + .visible = 0444, 400 + .read = laptop_hwmon_read, 401 + .read_string = laptop_hwmon_read_string, 402 + }; 403 + 404 + static const struct hwmon_chip_info laptop_chip_info = { 405 + .ops = &laptop_hwmon_ops, 406 + .info = laptop_hwmon_info, 407 + }; 408 + 409 + static int laptop_kbd_led_set(struct led_classdev *led_cdev, 410 + enum led_brightness value) 411 + { 412 + struct bitland_mifs_wmi_data *data = 413 + container_of(led_cdev, struct bitland_mifs_wmi_data, kbd_led); 414 + struct bitland_mifs_input input = { 415 + .reserved1 = 0, 416 + .operation = WMI_METHOD_SET, 417 + .reserved2 = 0, 418 + .function = WMI_FN_RGB_KB_BRIGHTNESS, 419 + }; 420 + 421 + input.payload[0] = (u8)value; 422 + 423 + return bitland_mifs_wmi_call(data, &input, NULL); 424 + } 425 + 426 + static enum led_brightness laptop_kbd_led_get(struct led_classdev *led_cdev) 427 + { 428 + struct bitland_mifs_wmi_data *data = 429 + container_of(led_cdev, struct bitland_mifs_wmi_data, kbd_led); 430 + struct bitland_mifs_input input = { 431 + .reserved1 = 0, 432 + .operation = WMI_METHOD_GET, 433 + .reserved2 = 0, 434 + .function = WMI_FN_RGB_KB_BRIGHTNESS, 435 + }; 436 + struct bitland_mifs_output res; 437 + int ret; 438 + 439 + ret = bitland_mifs_wmi_call(data, &input, &res); 440 + if (ret) 441 + return ret; 442 + 443 + return res.data[0]; 444 + } 445 + 446 + static const char *const gpu_mode_strings[] = { 447 + "hybrid", 448 + "discrete", 449 + "uma", 450 + }; 451 + 452 + /* GPU Mode: 0:Hybrid, 1:Discrete, 2:UMA */ 453 + static ssize_t gpu_mode_show(struct device *dev, struct device_attribute *attr, 454 + char *buf) 455 + { 456 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 457 + struct bitland_mifs_input input = { 458 + .reserved1 = 0, 459 + .operation = WMI_METHOD_GET, 460 + .reserved2 = 0, 461 + .function = WMI_FN_GPU_MODE, 462 + }; 463 + struct bitland_mifs_output res; 464 + u8 mode_val; 465 + int ret; 466 + 467 + ret = bitland_mifs_wmi_call(data, &input, &res); 468 + if (ret) 469 + return ret; 470 + 471 + mode_val = res.data[0]; 472 + if (mode_val >= ARRAY_SIZE(gpu_mode_strings)) 473 + return -EPROTO; 474 + 475 + return sysfs_emit(buf, "%s\n", gpu_mode_strings[mode_val]); 476 + } 477 + 478 + static ssize_t gpu_mode_store(struct device *dev, struct device_attribute *attr, 479 + const char *buf, size_t count) 480 + { 481 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 482 + struct bitland_mifs_input input = { 483 + .reserved1 = 0, 484 + .operation = WMI_METHOD_SET, 485 + .reserved2 = 0, 486 + .function = WMI_FN_GPU_MODE, 487 + }; 488 + int val; 489 + int ret; 490 + 491 + val = sysfs_match_string(gpu_mode_strings, buf); 492 + if (val < 0) 493 + return -EINVAL; 494 + 495 + input.payload[0] = (u8)val; 496 + 497 + ret = bitland_mifs_wmi_call(data, &input, NULL); 498 + if (ret) 499 + return ret; 500 + 501 + return count; 502 + } 503 + 504 + static const char *const kb_mode_strings[] = { 505 + "off", /* 0 */ 506 + "cyclic", /* 1 */ 507 + "fixed", /* 2 */ 508 + "custom", /* 3 */ 509 + }; 510 + 511 + static ssize_t kb_mode_show(struct device *dev, struct device_attribute *attr, 512 + char *buf) 513 + { 514 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 515 + struct bitland_mifs_input input = { 516 + .reserved1 = 0, 517 + .operation = WMI_METHOD_GET, 518 + .reserved2 = 0, 519 + .function = WMI_FN_RGB_KB_MODE, 520 + }; 521 + struct bitland_mifs_output res; 522 + u8 mode_val; 523 + int ret; 524 + 525 + ret = bitland_mifs_wmi_call(data, &input, &res); 526 + if (ret) 527 + return ret; 528 + 529 + mode_val = res.data[0]; 530 + if (mode_val >= ARRAY_SIZE(kb_mode_strings)) 531 + return -EPROTO; 532 + 533 + return sysfs_emit(buf, "%s\n", kb_mode_strings[mode_val]); 534 + } 535 + 536 + static ssize_t kb_mode_store(struct device *dev, struct device_attribute *attr, 537 + const char *buf, size_t count) 538 + { 539 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 540 + struct bitland_mifs_input input = { 541 + .reserved1 = 0, 542 + .operation = WMI_METHOD_SET, 543 + .reserved2 = 0, 544 + .function = WMI_FN_RGB_KB_MODE, 545 + }; 546 + // the wmi value (0, 1, 2 or 3) 547 + int val; 548 + int ret; 549 + 550 + val = sysfs_match_string(kb_mode_strings, buf); 551 + if (val < 0) 552 + return -EINVAL; 553 + 554 + input.payload[0] = (u8)val; 555 + 556 + ret = bitland_mifs_wmi_call(data, &input, NULL); 557 + if (ret) 558 + return ret; 559 + 560 + return count; 561 + } 562 + 563 + /* Fan Boost: 0:Normal, 1:Max Speed */ 564 + static ssize_t fan_boost_store(struct device *dev, 565 + struct device_attribute *attr, const char *buf, 566 + size_t count) 567 + { 568 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); 569 + struct bitland_mifs_input input = { 570 + .reserved1 = 0, 571 + .operation = WMI_METHOD_SET, 572 + .reserved2 = 0, 573 + .function = WMI_FN_MAX_FAN_SWITCH, 574 + }; 575 + bool val; 576 + int ret; 577 + 578 + if (kstrtobool(buf, &val)) 579 + return -EINVAL; 580 + 581 + input.payload[0] = 0; /* CPU/GPU Fan */ 582 + input.payload[1] = val; 583 + 584 + ret = bitland_mifs_wmi_call(data, &input, NULL); 585 + if (ret) 586 + return ret; 587 + 588 + return count; 589 + } 590 + 591 + static const DEVICE_ATTR_RW(gpu_mode); 592 + static const DEVICE_ATTR_RW(kb_mode); 593 + static const DEVICE_ATTR_WO(fan_boost); 594 + 595 + static const struct attribute *const laptop_attrs[] = { 596 + &dev_attr_gpu_mode.attr, 597 + &dev_attr_kb_mode.attr, 598 + &dev_attr_fan_boost.attr, 599 + NULL, 600 + }; 601 + ATTRIBUTE_GROUPS(laptop); 602 + 603 + static const struct key_entry bitland_mifs_wmi_keymap[] = { 604 + { KE_KEY, WMI_EVENT_OPEN_APP, { KEY_PROG1 } }, 605 + { KE_KEY, WMI_EVENT_CALCULATOR_START, { KEY_CALC } }, 606 + { KE_KEY, WMI_EVENT_BROWSER_START, { KEY_WWW } }, 607 + { KE_IGNORE, WMI_EVENT_FN_J, { KEY_RESERVED } }, 608 + { KE_IGNORE, WMI_EVENT_FN_F, { KEY_RESERVED } }, 609 + { KE_IGNORE, WMI_EVENT_FN_0, { KEY_RESERVED } }, 610 + { KE_IGNORE, WMI_EVENT_FN_1, { KEY_RESERVED } }, 611 + { KE_IGNORE, WMI_EVENT_FN_2, { KEY_RESERVED } }, 612 + { KE_IGNORE, WMI_EVENT_FN_3, { KEY_RESERVED } }, 613 + { KE_IGNORE, WMI_EVENT_FN_4, { KEY_RESERVED } }, 614 + { KE_IGNORE, WMI_EVENT_FN_5, { KEY_RESERVED } }, 615 + { KE_END, 0 } 616 + }; 617 + 618 + static void bitland_notifier_unregister(void *data) 619 + { 620 + struct notifier_block *nb = data; 621 + 622 + blocking_notifier_chain_unregister(&bitland_notifier_list, nb); 623 + } 624 + 625 + static int bitland_notifier_callback(struct notifier_block *nb, 626 + unsigned long action, void *data) 627 + { 628 + struct bitland_mifs_wmi_data *data_ctx = 629 + container_of(nb, struct bitland_mifs_wmi_data, notifier); 630 + struct bitland_fan_notify_data *fan_info; 631 + u8 *brightness; 632 + 633 + switch (action) { 634 + case BITLAND_NOTIFY_KBD_BRIGHTNESS: 635 + brightness = data; 636 + led_classdev_notify_brightness_hw_changed(&data_ctx->kbd_led, 637 + *brightness); 638 + break; 639 + case BITLAND_NOTIFY_PLATFORM_PROFILE: 640 + platform_profile_notify(data_ctx->pp_dev); 641 + break; 642 + case BITLAND_NOTIFY_HWMON: 643 + fan_info = data; 644 + 645 + hwmon_notify_event(data_ctx->hwmon_dev, hwmon_fan, 646 + hwmon_fan_input, fan_info->channel); 647 + break; 648 + } 649 + 650 + return NOTIFY_OK; 651 + } 652 + 653 + static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context) 654 + { 655 + struct bitland_mifs_wmi_data *drv_data; 656 + enum bitland_wmi_device_type dev_type = 657 + (enum bitland_wmi_device_type)(unsigned long)context; 658 + struct led_init_data init_data = { 659 + .devicename = DRV_NAME, 660 + .default_label = ":" LED_FUNCTION_KBD_BACKLIGHT, 661 + .devname_mandatory = true, 662 + }; 663 + int ret; 664 + 665 + drv_data = devm_kzalloc(&wdev->dev, sizeof(*drv_data), GFP_KERNEL); 666 + if (!drv_data) 667 + return -ENOMEM; 668 + 669 + drv_data->wdev = wdev; 670 + 671 + ret = devm_mutex_init(&wdev->dev, &drv_data->lock); 672 + if (ret) 673 + return ret; 674 + 675 + dev_set_drvdata(&wdev->dev, drv_data); 676 + 677 + if (dev_type == BITLAND_WMI_EVENT) { 678 + /* Register input device for hotkeys */ 679 + drv_data->input_dev = devm_input_allocate_device(&wdev->dev); 680 + if (!drv_data->input_dev) 681 + return -ENOMEM; 682 + 683 + drv_data->input_dev->name = "Bitland MIFS WMI hotkeys"; 684 + drv_data->input_dev->phys = "wmi/input0"; 685 + drv_data->input_dev->id.bustype = BUS_HOST; 686 + drv_data->input_dev->dev.parent = &wdev->dev; 687 + 688 + ret = sparse_keymap_setup(drv_data->input_dev, 689 + bitland_mifs_wmi_keymap, NULL); 690 + if (ret) 691 + return ret; 692 + 693 + return input_register_device(drv_data->input_dev); 694 + } 695 + 696 + /* Register platform profile */ 697 + drv_data->pp_dev = devm_platform_profile_register(&wdev->dev, DRV_NAME, drv_data, 698 + &laptop_profile_ops); 699 + if (IS_ERR(drv_data->pp_dev)) 700 + return PTR_ERR(drv_data->pp_dev); 701 + 702 + /* Register hwmon */ 703 + drv_data->hwmon_dev = devm_hwmon_device_register_with_info(&wdev->dev, 704 + "bitland_mifs", 705 + drv_data, 706 + &laptop_chip_info, 707 + NULL); 708 + if (IS_ERR(drv_data->hwmon_dev)) 709 + return PTR_ERR(drv_data->hwmon_dev); 710 + 711 + /* Register keyboard LED */ 712 + drv_data->kbd_led.max_brightness = 3; 713 + drv_data->kbd_led.brightness_set_blocking = laptop_kbd_led_set; 714 + drv_data->kbd_led.brightness_get = laptop_kbd_led_get; 715 + drv_data->kbd_led.brightness = laptop_kbd_led_get(&drv_data->kbd_led); 716 + drv_data->kbd_led.flags = LED_CORE_SUSPENDRESUME | 717 + LED_BRIGHT_HW_CHANGED | 718 + LED_REJECT_NAME_CONFLICT; 719 + ret = devm_led_classdev_register_ext(&wdev->dev, &drv_data->kbd_led, &init_data); 720 + if (ret) 721 + return ret; 722 + 723 + drv_data->notifier.notifier_call = bitland_notifier_callback; 724 + ret = blocking_notifier_chain_register(&bitland_notifier_list, &drv_data->notifier); 725 + if (ret) 726 + return ret; 727 + 728 + return devm_add_action_or_reset(&wdev->dev, 729 + bitland_notifier_unregister, 730 + &drv_data->notifier); 731 + } 732 + 733 + static void bitland_mifs_wmi_notify(struct wmi_device *wdev, 734 + const struct wmi_buffer *buffer) 735 + { 736 + struct bitland_mifs_wmi_data *data = dev_get_drvdata(&wdev->dev); 737 + const struct bitland_mifs_event *event = buffer->data; 738 + struct bitland_fan_notify_data fan_data; 739 + u8 brightness; 740 + 741 + /* Validate event type */ 742 + if (event->event_type != WMI_EVENT_TYPE_HOTKEY) 743 + return; 744 + 745 + dev_dbg(&wdev->dev, 746 + "WMI event: id=0x%02x value_low=0x%02x value_high=0x%02x\n", 747 + event->event_id, event->value_low, event->value_high); 748 + 749 + switch (event->event_id) { 750 + case WMI_EVENT_KBD_BRIGHTNESS: 751 + brightness = event->value_low; 752 + blocking_notifier_call_chain(&bitland_notifier_list, 753 + BITLAND_NOTIFY_KBD_BRIGHTNESS, 754 + &brightness); 755 + break; 756 + 757 + case WMI_EVENT_PERFORMANCE_PLAN: 758 + blocking_notifier_call_chain(&bitland_notifier_list, 759 + BITLAND_NOTIFY_PLATFORM_PROFILE, 760 + NULL); 761 + break; 762 + 763 + case WMI_EVENT_OPEN_APP: 764 + case WMI_EVENT_CALCULATOR_START: 765 + case WMI_EVENT_BROWSER_START: { 766 + guard(mutex)(&data->lock); 767 + if (!sparse_keymap_report_event(data->input_dev, 768 + event->event_id, 1, true)) 769 + dev_warn(&wdev->dev, "Unknown key pressed: 0x%02x\n", 770 + event->event_id); 771 + break; 772 + } 773 + 774 + /* 775 + * The device has 3 fans (CPU, GPU, SYS), 776 + * but there are only the CPU and GPU fan has events 777 + */ 778 + case WMI_EVENT_CPU_FAN_SPEED: 779 + case WMI_EVENT_GPU_FAN_SPEED: 780 + if (event->event_id == WMI_EVENT_CPU_FAN_SPEED) 781 + fan_data.channel = 0; 782 + else 783 + fan_data.channel = 1; 784 + 785 + /* Fan speed is 16-bit value (value_low is LSB, value_high is MSB) */ 786 + fan_data.speed = (event->value_high << 8) | event->value_low; 787 + blocking_notifier_call_chain(&bitland_notifier_list, 788 + BITLAND_NOTIFY_HWMON, 789 + &fan_data); 790 + break; 791 + 792 + case WMI_EVENT_AIRPLANE_MODE: 793 + case WMI_EVENT_TOUCHPAD_STATE: 794 + case WMI_EVENT_FNLOCK_STATE: 795 + case WMI_EVENT_KBD_MODE: 796 + case WMI_EVENT_CAPSLOCK_STATE: 797 + case WMI_EVENT_NUMLOCK_STATE: 798 + case WMI_EVENT_SCROLLLOCK_STATE: 799 + case WMI_EVENT_REFRESH_RATE: 800 + case WMI_EVENT_WIN_KEY_LOCK: 801 + /* These events are informational or handled by firmware */ 802 + dev_dbg(&wdev->dev, "State change event: id=%d value=%d\n", 803 + event->event_id, event->value_low); 804 + break; 805 + 806 + default: 807 + dev_dbg(&wdev->dev, "Unknown event: id=0x%02x value=0x%02x\n", 808 + event->event_id, event->value_low); 809 + break; 810 + } 811 + } 812 + 813 + static const struct wmi_device_id bitland_mifs_wmi_id_table[] = { 814 + { BITLAND_MIFS_GUID, (void *)BITLAND_WMI_CONTROL }, 815 + { BITLAND_EVENT_GUID, (void *)BITLAND_WMI_EVENT }, 816 + {} 817 + }; 818 + MODULE_DEVICE_TABLE(wmi, bitland_mifs_wmi_id_table); 819 + 820 + static struct wmi_driver bitland_mifs_wmi_driver = { 821 + .no_singleton = true, 822 + .driver = { 823 + .name = DRV_NAME, 824 + .dev_groups = laptop_groups, 825 + .pm = pm_sleep_ptr(&bitland_mifs_wmi_pm_ops), 826 + }, 827 + .id_table = bitland_mifs_wmi_id_table, 828 + .min_event_size = sizeof(struct bitland_mifs_event), 829 + .probe = bitland_mifs_wmi_probe, 830 + .notify_new = bitland_mifs_wmi_notify, 831 + }; 832 + 833 + module_wmi_driver(bitland_mifs_wmi_driver); 834 + 835 + MODULE_AUTHOR("Mingyou Chen <qby140326@gmail.com>"); 836 + MODULE_DESCRIPTION("Bitland MIFS (MiInterface) WMI driver"); 837 + MODULE_LICENSE("GPL");
+77 -65
drivers/platform/x86/dell/dell-rbtn.c
··· 9 9 #include <linux/acpi.h> 10 10 #include <linux/rfkill.h> 11 11 #include <linux/input.h> 12 + #include <linux/platform_device.h> 12 13 13 14 #include "dell-rbtn.h" 14 15 ··· 110 109 .set_block = rbtn_rfkill_set_block, 111 110 }; 112 111 113 - static int rbtn_rfkill_init(struct acpi_device *device) 112 + static int rbtn_rfkill_init(struct device *dev) 114 113 { 115 - struct rbtn_data *rbtn_data = device->driver_data; 114 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 116 115 int ret; 117 116 118 117 if (rbtn_data->rfkill) ··· 123 122 * but rfkill interface does not support "ANY" type 124 123 * so "WLAN" type is used 125 124 */ 126 - rbtn_data->rfkill = rfkill_alloc("dell-rbtn", &device->dev, 127 - RFKILL_TYPE_WLAN, &rbtn_ops, device); 125 + rbtn_data->rfkill = rfkill_alloc("dell-rbtn", dev, RFKILL_TYPE_WLAN, 126 + &rbtn_ops, ACPI_COMPANION(dev)); 128 127 if (!rbtn_data->rfkill) 129 128 return -ENOMEM; 130 129 ··· 138 137 return 0; 139 138 } 140 139 141 - static void rbtn_rfkill_exit(struct acpi_device *device) 140 + static void rbtn_rfkill_exit(struct device *dev) 142 141 { 143 - struct rbtn_data *rbtn_data = device->driver_data; 142 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 144 143 145 144 if (!rbtn_data->rfkill) 146 145 return; ··· 150 149 rbtn_data->rfkill = NULL; 151 150 } 152 151 153 - static void rbtn_rfkill_event(struct acpi_device *device) 152 + static void rbtn_rfkill_event(struct device *dev) 154 153 { 155 - struct rbtn_data *rbtn_data = device->driver_data; 154 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 156 155 157 156 if (rbtn_data->rfkill) 158 - rbtn_rfkill_query(rbtn_data->rfkill, device); 157 + rbtn_rfkill_query(rbtn_data->rfkill, ACPI_COMPANION(dev)); 159 158 } 160 159 161 160 ··· 206 205 * acpi driver 207 206 */ 208 207 209 - static int rbtn_add(struct acpi_device *device); 210 - static void rbtn_remove(struct acpi_device *device); 211 - static void rbtn_notify(struct acpi_device *device, u32 event); 208 + static int rbtn_probe(struct platform_device *pdev); 209 + static void rbtn_remove(struct platform_device *pdev); 210 + static void rbtn_notify(acpi_handle handle, u32 event, void *data); 212 211 213 212 static const struct acpi_device_id rbtn_ids[] = { 214 213 { "DELRBTN", 0 }, ··· 252 251 253 252 static int rbtn_suspend(struct device *dev) 254 253 { 255 - struct acpi_device *device = to_acpi_device(dev); 256 - struct rbtn_data *rbtn_data = acpi_driver_data(device); 254 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 257 255 258 256 rbtn_data->suspended = true; 259 257 ··· 261 261 262 262 static int rbtn_resume(struct device *dev) 263 263 { 264 - struct acpi_device *device = to_acpi_device(dev); 265 - struct rbtn_data *rbtn_data = acpi_driver_data(device); 264 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 266 265 acpi_status status; 267 266 268 267 /* ··· 285 286 286 287 static SIMPLE_DEV_PM_OPS(rbtn_pm_ops, rbtn_suspend, rbtn_resume); 287 288 288 - static struct acpi_driver rbtn_driver = { 289 - .name = "dell-rbtn", 290 - .ids = rbtn_ids, 291 - .drv.pm = &rbtn_pm_ops, 292 - .ops = { 293 - .add = rbtn_add, 294 - .remove = rbtn_remove, 295 - .notify = rbtn_notify, 289 + static struct platform_driver rbtn_driver = { 290 + .probe = rbtn_probe, 291 + .remove = rbtn_remove, 292 + .driver = { 293 + .name = "dell-rbtn", 294 + .acpi_match_table = rbtn_ids, 295 + .pm = &rbtn_pm_ops, 296 296 }, 297 297 }; 298 298 ··· 306 308 307 309 static int rbtn_inc_count(struct device *dev, void *data) 308 310 { 309 - struct acpi_device *device = to_acpi_device(dev); 310 - struct rbtn_data *rbtn_data = device->driver_data; 311 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 311 312 int *count = data; 312 313 313 314 if (rbtn_data->type == RBTN_SLIDER) ··· 317 320 318 321 static int rbtn_switch_dev(struct device *dev, void *data) 319 322 { 320 - struct acpi_device *device = to_acpi_device(dev); 321 - struct rbtn_data *rbtn_data = device->driver_data; 323 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 322 324 bool enable = data; 323 325 324 326 if (rbtn_data->type != RBTN_SLIDER) 325 327 return 0; 326 328 327 329 if (enable) 328 - rbtn_rfkill_init(device); 330 + rbtn_rfkill_init(dev); 329 331 else 330 - rbtn_rfkill_exit(device); 332 + rbtn_rfkill_exit(dev); 331 333 332 334 return 0; 333 335 } ··· 338 342 int ret; 339 343 340 344 count = 0; 341 - ret = driver_for_each_device(&rbtn_driver.drv, NULL, &count, 345 + ret = driver_for_each_device(&rbtn_driver.driver, NULL, &count, 342 346 rbtn_inc_count); 343 347 if (ret || count == 0) 344 348 return -ENODEV; ··· 350 354 return ret; 351 355 352 356 if (auto_remove_rfkill && first) 353 - ret = driver_for_each_device(&rbtn_driver.drv, NULL, 357 + ret = driver_for_each_device(&rbtn_driver.driver, NULL, 354 358 (void *)false, rbtn_switch_dev); 355 359 356 360 return ret; ··· 366 370 return ret; 367 371 368 372 if (auto_remove_rfkill && !rbtn_chain_head.head) 369 - ret = driver_for_each_device(&rbtn_driver.drv, NULL, 373 + ret = driver_for_each_device(&rbtn_driver.driver, NULL, 370 374 (void *)true, rbtn_switch_dev); 371 375 372 376 return ret; ··· 378 382 * acpi driver functions 379 383 */ 380 384 381 - static int rbtn_add(struct acpi_device *device) 385 + static void rbtn_cleanup(struct device *dev) 382 386 { 387 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 388 + 389 + switch (rbtn_data->type) { 390 + case RBTN_TOGGLE: 391 + rbtn_input_exit(rbtn_data); 392 + break; 393 + case RBTN_SLIDER: 394 + rbtn_rfkill_exit(dev); 395 + break; 396 + default: 397 + break; 398 + } 399 + } 400 + 401 + static int rbtn_probe(struct platform_device *pdev) 402 + { 403 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 383 404 struct rbtn_data *rbtn_data; 384 405 enum rbtn_type type; 385 406 int ret = 0; 386 407 387 408 type = rbtn_check(device); 388 409 if (type == RBTN_UNKNOWN) { 389 - dev_info(&device->dev, "Unknown device type\n"); 410 + dev_info(&pdev->dev, "Unknown device type\n"); 390 411 return -EINVAL; 391 412 } 392 413 393 - rbtn_data = devm_kzalloc(&device->dev, sizeof(*rbtn_data), GFP_KERNEL); 414 + rbtn_data = devm_kzalloc(&pdev->dev, sizeof(*rbtn_data), GFP_KERNEL); 394 415 if (!rbtn_data) 395 416 return -ENOMEM; 396 417 397 418 ret = rbtn_acquire(device, true); 398 419 if (ret < 0) { 399 - dev_err(&device->dev, "Cannot enable device\n"); 420 + dev_err(&pdev->dev, "Cannot enable device\n"); 400 421 return ret; 401 422 } 402 423 424 + platform_set_drvdata(pdev, rbtn_data); 425 + 403 426 rbtn_data->type = type; 404 - device->driver_data = rbtn_data; 405 427 406 428 switch (rbtn_data->type) { 407 429 case RBTN_TOGGLE: ··· 429 415 if (auto_remove_rfkill && rbtn_chain_head.head) 430 416 ret = 0; 431 417 else 432 - ret = rbtn_rfkill_init(device); 418 + ret = rbtn_rfkill_init(&pdev->dev); 433 419 break; 434 420 default: 435 421 ret = -EINVAL; 436 422 break; 437 423 } 438 424 if (ret) 439 - rbtn_acquire(device, false); 425 + goto err; 440 426 427 + ret = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 428 + rbtn_notify, &pdev->dev); 429 + if (ret) 430 + goto err_cleanup; 431 + 432 + return 0; 433 + 434 + err_cleanup: 435 + rbtn_cleanup(&pdev->dev); 436 + err: 437 + rbtn_acquire(device, false); 441 438 return ret; 442 439 } 443 440 444 - static void rbtn_remove(struct acpi_device *device) 441 + static void rbtn_remove(struct platform_device *pdev) 445 442 { 446 - struct rbtn_data *rbtn_data = device->driver_data; 443 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 447 444 448 - switch (rbtn_data->type) { 449 - case RBTN_TOGGLE: 450 - rbtn_input_exit(rbtn_data); 451 - break; 452 - case RBTN_SLIDER: 453 - rbtn_rfkill_exit(device); 454 - break; 455 - default: 456 - break; 457 - } 458 - 445 + acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, rbtn_notify); 446 + rbtn_cleanup(&pdev->dev); 459 447 rbtn_acquire(device, false); 460 448 } 461 449 462 - static void rbtn_notify(struct acpi_device *device, u32 event) 450 + static void rbtn_notify(acpi_handle handle, u32 event, void *data) 463 451 { 464 - struct rbtn_data *rbtn_data = device->driver_data; 452 + struct device *dev = data; 453 + struct rbtn_data *rbtn_data = dev_get_drvdata(dev); 465 454 466 455 /* 467 456 * Some BIOSes send a notification at resume. 468 457 * Ignore it to prevent unwanted input events. 469 458 */ 470 459 if (rbtn_data->suspended) { 471 - dev_dbg(&device->dev, "ACPI notification ignored\n"); 460 + dev_dbg(dev, "ACPI notification ignored\n"); 472 461 return; 473 462 } 474 463 475 464 if (event != 0x80) { 476 - dev_info(&device->dev, "Received unknown event (0x%x)\n", 465 + dev_info(dev, "Received unknown event (0x%x)\n", 477 466 event); 478 467 return; 479 468 } ··· 486 469 rbtn_input_event(rbtn_data); 487 470 break; 488 471 case RBTN_SLIDER: 489 - rbtn_rfkill_event(device); 490 - atomic_notifier_call_chain(&rbtn_chain_head, event, device); 472 + rbtn_rfkill_event(dev); 473 + atomic_notifier_call_chain(&rbtn_chain_head, event, NULL); 491 474 break; 492 475 default: 493 476 break; 494 477 } 495 478 } 496 479 497 - 498 - /* 499 - * module functions 500 - */ 501 - 502 - module_acpi_driver(rbtn_driver); 480 + module_platform_driver(rbtn_driver); 503 481 504 482 module_param(auto_remove_rfkill, bool, 0444); 505 483
+1
drivers/platform/x86/dell/dell-wmi-base.c
··· 825 825 .name = "dell-wmi", 826 826 }, 827 827 .id_table = dell_wmi_id_table, 828 + .min_event_size = sizeof(u16), 828 829 .probe = dell_wmi_probe, 829 830 .remove = dell_wmi_remove, 830 831 .notify = dell_wmi_notify,
+2 -2
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h
··· 189 189 int init_bios_attr_set_interface(void); 190 190 int map_wmi_error(int error_code); 191 191 size_t calculate_string_buffer(const char *str); 192 - size_t calculate_security_buffer(char *authentication); 193 - void populate_security_buffer(char *buffer, char *authentication); 192 + size_t calculate_security_buffer(const char *authentication); 193 + void populate_security_buffer(char *buffer, const char *authentication); 194 194 ssize_t populate_string_buffer(char *buffer, size_t buffer_len, const char *str); 195 195 int set_new_password(const char *password_type, const char *new); 196 196 int init_bios_attr_pass_interface(void);
+28 -6
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c
··· 6 6 * Copyright (c) 2020 Dell Inc. 7 7 */ 8 8 9 + #include <linux/bug.h> 10 + 9 11 #include "dell-wmi-sysman.h" 10 12 11 13 get_instance_id(enumeration); 14 + 15 + static int append_enum_string(char *dest, const char *src) 16 + { 17 + size_t dest_len = strlen(dest); 18 + ssize_t copied; 19 + 20 + if (WARN_ON_ONCE(dest_len >= MAX_BUFF)) 21 + return -EINVAL; 22 + 23 + copied = strscpy(dest + dest_len, src, MAX_BUFF - dest_len); 24 + if (copied < 0) 25 + return -EINVAL; 26 + 27 + dest_len += copied; 28 + copied = strscpy(dest + dest_len, ";", MAX_BUFF - dest_len); 29 + if (copied < 0) 30 + return -EINVAL; 31 + 32 + return 0; 33 + } 12 34 13 35 static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 14 36 { ··· 198 176 return -EINVAL; 199 177 if (check_property_type(enumeration, next_obj, ACPI_TYPE_STRING)) 200 178 return -EINVAL; 201 - strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier, 202 - enumeration_obj[next_obj++].string.pointer); 203 - strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier, ";"); 179 + if (append_enum_string(wmi_priv.enumeration_data[instance_id].dell_value_modifier, 180 + enumeration_obj[next_obj++].string.pointer)) 181 + return -EINVAL; 204 182 } 205 183 206 184 if (next_obj >= enum_property_count) ··· 215 193 return -EINVAL; 216 194 if (check_property_type(enumeration, next_obj, ACPI_TYPE_STRING)) 217 195 return -EINVAL; 218 - strcat(wmi_priv.enumeration_data[instance_id].possible_values, 219 - enumeration_obj[next_obj++].string.pointer); 220 - strcat(wmi_priv.enumeration_data[instance_id].possible_values, ";"); 196 + if (append_enum_string(wmi_priv.enumeration_data[instance_id].possible_values, 197 + enumeration_obj[next_obj++].string.pointer)) 198 + return -EINVAL; 221 199 } 222 200 223 201 return sysfs_create_group(attr_name_kobj, &enumeration_attr_group);
+19 -49
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
··· 7 7 8 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 9 10 + #include <linux/align.h> 10 11 #include <linux/fs.h> 11 12 #include <linux/dmi.h> 12 13 #include <linux/module.h> 13 14 #include <linux/kernel.h> 15 + #include <linux/string.h> 16 + #include <linux/sysfs.h> 14 17 #include <linux/wmi.h> 15 18 #include "dell-wmi-sysman.h" 16 19 #include "../../firmware_attributes_class.h" ··· 75 72 * 76 73 * Currently only supported type is Admin password 77 74 */ 78 - size_t calculate_security_buffer(char *authentication) 75 + size_t calculate_security_buffer(const char *authentication) 79 76 { 80 - if (strlen(authentication) > 0) { 81 - return (sizeof(u32) * 2) + strlen(authentication) + 82 - strlen(authentication) % 2; 83 - } 84 - return sizeof(u32) * 2; 77 + return sizeof(u32) * 2 + ALIGN(strlen(authentication), 2); 85 78 } 86 79 87 80 /** ··· 87 88 * 88 89 * Currently only supported type is PLAIN TEXT 89 90 */ 90 - void populate_security_buffer(char *buffer, char *authentication) 91 + void populate_security_buffer(char *buffer, const char *authentication) 91 92 { 93 + size_t seclen = strlen(authentication); 92 94 char *auth = buffer + sizeof(u32) * 2; 93 95 u32 *sectype = (u32 *) buffer; 94 - u32 *seclen = sectype + 1; 96 + u32 *seclenp = sectype + 1; 95 97 96 - *sectype = strlen(authentication) > 0 ? 1 : 0; 97 - *seclen = strlen(authentication); 98 + *sectype = !!seclen; 99 + *seclenp = seclen; 98 100 99 101 /* plain text */ 100 - if (strlen(authentication) > 0) 101 - memcpy(auth, authentication, *seclen); 102 + memcpy(auth, authentication, seclen); 102 103 } 103 104 104 105 /** ··· 142 143 */ 143 144 static ssize_t reset_bios_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 144 145 { 145 - char *start = buf; 146 + ssize_t len = 0; 146 147 int i; 147 148 148 149 for (i = 0; i < MAX_TYPES; i++) { 149 150 if (i == reset_option) 150 - buf += sprintf(buf, "[%s] ", reset_types[i]); 151 + len += sysfs_emit_at(buf, len, "[%s] ", reset_types[i]); 151 152 else 152 - buf += sprintf(buf, "%s ", reset_types[i]); 153 + len += sysfs_emit_at(buf, len, "%s ", reset_types[i]); 153 154 } 154 - buf += sprintf(buf, "\n"); 155 - return buf-start; 155 + len += sysfs_emit_at(buf, len, "\n"); 156 + return len; 156 157 } 157 158 158 159 /** ··· 193 194 static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr, 194 195 char *buf) 195 196 { 196 - return sprintf(buf, "%d\n", wmi_priv.pending_changes); 197 + return sysfs_emit(buf, "%d\n", wmi_priv.pending_changes); 197 198 } 198 199 199 200 static struct kobj_attribute reset_bios = __ATTR_RW(reset_bios); ··· 219 220 return 0; 220 221 } 221 222 222 - static ssize_t wmi_sysman_attr_show(struct kobject *kobj, struct attribute *attr, 223 - char *buf) 224 - { 225 - struct kobj_attribute *kattr; 226 - ssize_t ret = -EIO; 227 - 228 - kattr = container_of(attr, struct kobj_attribute, attr); 229 - if (kattr->show) 230 - ret = kattr->show(kobj, kattr, buf); 231 - return ret; 232 - } 233 - 234 - static ssize_t wmi_sysman_attr_store(struct kobject *kobj, struct attribute *attr, 235 - const char *buf, size_t count) 236 - { 237 - struct kobj_attribute *kattr; 238 - ssize_t ret = -EIO; 239 - 240 - kattr = container_of(attr, struct kobj_attribute, attr); 241 - if (kattr->store) 242 - ret = kattr->store(kobj, kattr, buf, count); 243 - return ret; 244 - } 245 - 246 - static const struct sysfs_ops wmi_sysman_kobj_sysfs_ops = { 247 - .show = wmi_sysman_attr_show, 248 - .store = wmi_sysman_attr_store, 249 - }; 250 - 251 223 static void attr_name_release(struct kobject *kobj) 252 224 { 253 225 kfree(kobj); ··· 226 256 227 257 static const struct kobj_type attr_name_ktype = { 228 258 .release = attr_name_release, 229 - .sysfs_ops = &wmi_sysman_kobj_sysfs_ops, 259 + .sysfs_ops = &kobj_sysfs_ops, 230 260 }; 231 261 232 262 /** ··· 313 343 * destroy_attribute_objs() - Free a kset of kobjects 314 344 * @kset: The kset to destroy 315 345 * 316 - * Fress kobjects created for each attribute_name under attribute type kset 346 + * Frees kobjects created for each attribute_name under attribute type kset. 317 347 */ 318 348 static void destroy_attribute_objs(struct kset *kset) 319 349 {
+5 -1
drivers/platform/x86/dell/dell_rbu.c
··· 30 30 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 31 31 32 32 #include <linux/init.h> 33 + #include <linux/kstrtox.h> 33 34 #include <linux/module.h> 34 35 #include <linux/slab.h> 35 36 #include <linux/string.h> ··· 620 619 char *buffer, loff_t pos, size_t count) 621 620 { 622 621 unsigned long temp; 622 + 623 + if (kstrtoul(buffer, 10, &temp)) 624 + return -EINVAL; 625 + 623 626 spin_lock(&rbu_data.lock); 624 627 packet_empty_list(); 625 - sscanf(buffer, "%lu", &temp); 626 628 if (temp < 0xffffffff) 627 629 rbu_data.packetsize = temp; 628 630
+27 -18
drivers/platform/x86/eeepc-laptop.c
··· 1204 1204 pr_info("Unknown key %x pressed\n", event); 1205 1205 } 1206 1206 1207 - static void eeepc_acpi_notify(struct acpi_device *device, u32 event) 1207 + static void eeepc_acpi_notify(acpi_handle handle, u32 event, void *data) 1208 1208 { 1209 - struct eeepc_laptop *eeepc = acpi_driver_data(device); 1209 + struct eeepc_laptop *eeepc = data; 1210 + struct acpi_device *device = eeepc->device; 1210 1211 int old_brightness, new_brightness; 1211 1212 u16 count; 1212 1213 ··· 1361 1360 1362 1361 static bool eeepc_device_present; 1363 1362 1364 - static int eeepc_acpi_add(struct acpi_device *device) 1363 + static int eeepc_acpi_probe(struct platform_device *pdev) 1365 1364 { 1365 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1366 1366 struct eeepc_laptop *eeepc; 1367 1367 int result; 1368 1368 ··· 1374 1372 eeepc->handle = device->handle; 1375 1373 strscpy(acpi_device_name(device), EEEPC_ACPI_DEVICE_NAME); 1376 1374 strscpy(acpi_device_class(device), EEEPC_ACPI_CLASS); 1377 - device->driver_data = eeepc; 1378 1375 eeepc->device = device; 1376 + 1377 + platform_set_drvdata(pdev, eeepc); 1379 1378 1380 1379 eeepc->hotplug_disabled = hotplug_disabled; 1381 1380 ··· 1425 1422 if (result) 1426 1423 goto fail_rfkill; 1427 1424 1425 + result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY, 1426 + eeepc_acpi_notify, eeepc); 1427 + if (result) 1428 + goto fail_acpi_notifier; 1429 + 1428 1430 eeepc_device_present = true; 1429 1431 return 0; 1430 1432 1433 + fail_acpi_notifier: 1434 + eeepc_rfkill_exit(eeepc); 1431 1435 fail_rfkill: 1432 1436 eeepc_led_exit(eeepc); 1433 1437 fail_led: ··· 1450 1440 return result; 1451 1441 } 1452 1442 1453 - static void eeepc_acpi_remove(struct acpi_device *device) 1443 + static void eeepc_acpi_remove(struct platform_device *pdev) 1454 1444 { 1455 - struct eeepc_laptop *eeepc = acpi_driver_data(device); 1445 + struct eeepc_laptop *eeepc = platform_get_drvdata(pdev); 1456 1446 1447 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 1448 + ACPI_ALL_NOTIFY, eeepc_acpi_notify); 1457 1449 eeepc_backlight_exit(eeepc); 1458 1450 eeepc_rfkill_exit(eeepc); 1459 1451 eeepc_input_exit(eeepc); ··· 1472 1460 }; 1473 1461 MODULE_DEVICE_TABLE(acpi, eeepc_device_ids); 1474 1462 1475 - static struct acpi_driver eeepc_acpi_driver = { 1476 - .name = EEEPC_LAPTOP_NAME, 1477 - .class = EEEPC_ACPI_CLASS, 1478 - .ids = eeepc_device_ids, 1479 - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 1480 - .ops = { 1481 - .add = eeepc_acpi_add, 1482 - .remove = eeepc_acpi_remove, 1483 - .notify = eeepc_acpi_notify, 1463 + static struct platform_driver eeepc_acpi_driver = { 1464 + .probe = eeepc_acpi_probe, 1465 + .remove = eeepc_acpi_remove, 1466 + .driver = { 1467 + .name = EEEPC_LAPTOP_NAME, 1468 + .acpi_match_table = eeepc_device_ids, 1484 1469 }, 1485 1470 }; 1486 1471 ··· 1490 1481 if (result < 0) 1491 1482 return result; 1492 1483 1493 - result = acpi_bus_register_driver(&eeepc_acpi_driver); 1484 + result = platform_driver_register(&eeepc_acpi_driver); 1494 1485 if (result < 0) 1495 1486 goto fail_acpi_driver; 1496 1487 ··· 1502 1493 return 0; 1503 1494 1504 1495 fail_no_device: 1505 - acpi_bus_unregister_driver(&eeepc_acpi_driver); 1496 + platform_driver_unregister(&eeepc_acpi_driver); 1506 1497 fail_acpi_driver: 1507 1498 platform_driver_unregister(&platform_driver); 1508 1499 return result; ··· 1510 1501 1511 1502 static void __exit eeepc_laptop_exit(void) 1512 1503 { 1513 - acpi_bus_unregister_driver(&eeepc_acpi_driver); 1504 + platform_driver_unregister(&eeepc_acpi_driver); 1514 1505 platform_driver_unregister(&platform_driver); 1515 1506 } 1516 1507
+266 -253
drivers/platform/x86/fujitsu-laptop.c
··· 144 144 bool charge_control_supported; 145 145 }; 146 146 147 - static struct acpi_device *fext; 147 + static struct device *fext; 148 148 149 149 /* Fujitsu ACPI interface function */ 150 150 151 - static int call_fext_func(struct acpi_device *device, 151 + static int call_fext_func(struct device *dev, 152 152 int func, int op, int feature, int state) 153 153 { 154 154 union acpi_object params[4] = { ··· 158 158 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = state } 159 159 }; 160 160 struct acpi_object_list arg_list = { 4, params }; 161 + acpi_handle handle = ACPI_HANDLE(dev); 161 162 unsigned long long value; 162 163 acpi_status status; 163 164 164 - status = acpi_evaluate_integer(device->handle, "FUNC", &arg_list, 165 - &value); 165 + status = acpi_evaluate_integer(handle, "FUNC", &arg_list, &value); 166 166 if (ACPI_FAILURE(status)) { 167 - acpi_handle_err(device->handle, "Failed to evaluate FUNC\n"); 167 + acpi_handle_err(handle, "Failed to evaluate FUNC\n"); 168 168 return -ENODEV; 169 169 } 170 170 171 - acpi_handle_debug(device->handle, 172 - "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n", 171 + acpi_handle_debug(handle, "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n", 173 172 func, op, feature, state, (int)value); 174 173 return value; 175 174 } ··· 250 251 * These functions are intended to be called from acpi_fujitsu_laptop_add and 251 252 * acpi_fujitsu_laptop_remove. 252 253 */ 253 - static int fujitsu_battery_charge_control_add(struct acpi_device *device) 254 + static int fujitsu_battery_charge_control_add(struct device *dev) 254 255 { 255 - struct fujitsu_laptop *priv = acpi_driver_data(device); 256 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 256 257 int s006_cc_return; 257 258 258 259 priv->charge_control_supported = false; ··· 273 274 return 0; 274 275 } 275 276 276 - static void fujitsu_battery_charge_control_remove(struct acpi_device *device) 277 + static void fujitsu_battery_charge_control_remove(struct device *dev) 277 278 { 278 - struct fujitsu_laptop *priv = acpi_driver_data(device); 279 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 279 280 280 281 if (priv->charge_control_supported) 281 282 battery_hook_unregister(&battery_hook); ··· 283 284 284 285 /* Hardware access for LCD brightness control */ 285 286 286 - static int set_lcd_level(struct acpi_device *device, int level) 287 + static int set_lcd_level(struct device *dev, int level) 287 288 { 288 - struct fujitsu_bl *priv = acpi_driver_data(device); 289 + struct fujitsu_bl *priv = dev_get_drvdata(dev); 290 + acpi_handle handle = ACPI_HANDLE(dev); 289 291 acpi_status status; 290 292 char *method; 291 293 292 294 switch (use_alt_lcd_levels) { 293 295 case -1: 294 - if (acpi_has_method(device->handle, "SBL2")) 296 + if (acpi_has_method(handle, "SBL2")) 295 297 method = "SBL2"; 296 298 else 297 299 method = "SBLL"; ··· 305 305 break; 306 306 } 307 307 308 - acpi_handle_debug(device->handle, "set lcd level via %s [%d]\n", method, 309 - level); 308 + acpi_handle_debug(handle, "set lcd level via %s [%d]\n", method, level); 310 309 311 310 if (level < 0 || level >= priv->max_brightness) 312 311 return -EINVAL; 313 312 314 - status = acpi_execute_simple_method(device->handle, method, level); 313 + status = acpi_execute_simple_method(handle, method, level); 315 314 if (ACPI_FAILURE(status)) { 316 - acpi_handle_err(device->handle, "Failed to evaluate %s\n", 317 - method); 315 + acpi_handle_err(handle, "Failed to evaluate %s\n", method); 318 316 return -ENODEV; 319 317 } 320 318 ··· 321 323 return 0; 322 324 } 323 325 324 - static int get_lcd_level(struct acpi_device *device) 326 + static int get_lcd_level(struct device *dev) 325 327 { 326 - struct fujitsu_bl *priv = acpi_driver_data(device); 328 + struct fujitsu_bl *priv = dev_get_drvdata(dev); 329 + acpi_handle handle = ACPI_HANDLE(dev); 327 330 unsigned long long state = 0; 328 331 acpi_status status = AE_OK; 329 332 330 - acpi_handle_debug(device->handle, "get lcd level via GBLL\n"); 333 + acpi_handle_debug(handle, "get lcd level via GBLL\n"); 331 334 332 - status = acpi_evaluate_integer(device->handle, "GBLL", NULL, &state); 335 + status = acpi_evaluate_integer(handle, "GBLL", NULL, &state); 333 336 if (ACPI_FAILURE(status)) 334 337 return 0; 335 338 ··· 339 340 return priv->brightness_level; 340 341 } 341 342 342 - static int get_max_brightness(struct acpi_device *device) 343 + static int get_max_brightness(struct device *dev) 343 344 { 344 - struct fujitsu_bl *priv = acpi_driver_data(device); 345 + struct fujitsu_bl *priv = dev_get_drvdata(dev); 346 + acpi_handle handle = ACPI_HANDLE(dev); 345 347 unsigned long long state = 0; 346 348 acpi_status status = AE_OK; 347 349 348 - acpi_handle_debug(device->handle, "get max lcd level via RBLL\n"); 350 + acpi_handle_debug(handle, "get max lcd level via RBLL\n"); 349 351 350 - status = acpi_evaluate_integer(device->handle, "RBLL", NULL, &state); 352 + status = acpi_evaluate_integer(handle, "RBLL", NULL, &state); 351 353 if (ACPI_FAILURE(status)) 352 354 return -1; 353 355 ··· 361 361 362 362 static int bl_get_brightness(struct backlight_device *b) 363 363 { 364 - struct acpi_device *device = bl_get_data(b); 364 + struct device *dev = bl_get_data(b); 365 365 366 - return b->props.power == BACKLIGHT_POWER_OFF ? 0 : get_lcd_level(device); 366 + return b->props.power == BACKLIGHT_POWER_OFF ? 0 : get_lcd_level(dev); 367 367 } 368 368 369 369 static int bl_update_status(struct backlight_device *b) 370 370 { 371 - struct acpi_device *device = bl_get_data(b); 372 - 373 371 if (fext) { 374 372 if (b->props.power == BACKLIGHT_POWER_OFF) 375 373 call_fext_func(fext, FUNC_BACKLIGHT, 0x1, ··· 377 379 BACKLIGHT_PARAM_POWER, BACKLIGHT_ON); 378 380 } 379 381 380 - return set_lcd_level(device, b->props.brightness); 382 + return set_lcd_level(bl_get_data(b), b->props.brightness); 381 383 } 382 384 383 385 static const struct backlight_ops fujitsu_bl_ops = { ··· 453 455 { KE_END, 0 } 454 456 }; 455 457 456 - static int acpi_fujitsu_bl_input_setup(struct acpi_device *device) 458 + static int acpi_fujitsu_bl_input_setup(struct device *dev) 457 459 { 458 - struct fujitsu_bl *priv = acpi_driver_data(device); 460 + struct fujitsu_bl *priv = dev_get_drvdata(dev); 461 + struct acpi_device *device = ACPI_COMPANION(dev); 459 462 int ret; 460 463 461 - priv->input = devm_input_allocate_device(&device->dev); 464 + priv->input = devm_input_allocate_device(dev); 462 465 if (!priv->input) 463 466 return -ENOMEM; 464 467 ··· 478 479 return input_register_device(priv->input); 479 480 } 480 481 481 - static int fujitsu_backlight_register(struct acpi_device *device) 482 + static int fujitsu_backlight_register(struct device *dev) 482 483 { 483 - struct fujitsu_bl *priv = acpi_driver_data(device); 484 + struct fujitsu_bl *priv = dev_get_drvdata(dev); 484 485 const struct backlight_properties props = { 485 486 .brightness = priv->brightness_level, 486 487 .max_brightness = priv->max_brightness - 1, ··· 488 489 }; 489 490 struct backlight_device *bd; 490 491 491 - bd = devm_backlight_device_register(&device->dev, "fujitsu-laptop", 492 - &device->dev, device, 493 - &fujitsu_bl_ops, &props); 492 + bd = devm_backlight_device_register(dev, "fujitsu-laptop", 493 + dev, dev, &fujitsu_bl_ops, &props); 494 494 if (IS_ERR(bd)) 495 495 return PTR_ERR(bd); 496 496 ··· 498 500 return 0; 499 501 } 500 502 501 - static int acpi_fujitsu_bl_add(struct acpi_device *device) 503 + /* Brightness notify */ 504 + 505 + static void acpi_fujitsu_bl_notify(acpi_handle handle, u32 event, void *data) 502 506 { 507 + struct device *dev = data; 508 + struct fujitsu_bl *priv = dev_get_drvdata(dev); 509 + int oldb, newb; 510 + 511 + if (event != ACPI_FUJITSU_NOTIFY_CODE) { 512 + acpi_handle_info(handle, "unsupported event [0x%x]\n", event); 513 + sparse_keymap_report_event(priv->input, -1, 1, true); 514 + return; 515 + } 516 + 517 + oldb = priv->brightness_level; 518 + get_lcd_level(dev); 519 + newb = priv->brightness_level; 520 + 521 + acpi_handle_debug(handle, "brightness button event [%i -> %i]\n", 522 + oldb, newb); 523 + 524 + if (oldb == newb) 525 + return; 526 + 527 + if (!disable_brightness_adjust) 528 + set_lcd_level(dev, newb); 529 + 530 + sparse_keymap_report_event(priv->input, oldb < newb, 1, true); 531 + } 532 + 533 + static int acpi_fujitsu_bl_probe(struct platform_device *pdev) 534 + { 535 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 503 536 struct fujitsu_bl *priv; 504 537 int ret; 505 538 506 539 if (acpi_video_get_backlight_type() != acpi_backlight_vendor) 507 540 return -ENODEV; 508 541 509 - priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); 542 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 510 543 if (!priv) 511 544 return -ENOMEM; 512 545 513 546 fujitsu_bl = priv; 514 547 strscpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME); 515 548 strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS); 516 - device->driver_data = priv; 549 + 550 + platform_set_drvdata(pdev, priv); 517 551 518 552 pr_info("ACPI: %s [%s]\n", 519 553 acpi_device_name(device), acpi_device_bid(device)); 520 554 521 - if (get_max_brightness(device) <= 0) 555 + if (get_max_brightness(&pdev->dev) <= 0) 522 556 priv->max_brightness = FUJITSU_LCD_N_LEVELS; 523 - get_lcd_level(device); 557 + get_lcd_level(&pdev->dev); 524 558 525 - ret = acpi_fujitsu_bl_input_setup(device); 559 + ret = acpi_fujitsu_bl_input_setup(&pdev->dev); 526 560 if (ret) 527 561 return ret; 528 562 529 - return fujitsu_backlight_register(device); 563 + ret = fujitsu_backlight_register(&pdev->dev); 564 + if (ret) 565 + return ret; 566 + 567 + return acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 568 + acpi_fujitsu_bl_notify, &pdev->dev); 530 569 } 531 570 532 - /* Brightness notify */ 533 - 534 - static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event) 571 + static void acpi_fujitsu_bl_remove(struct platform_device *pdev) 535 572 { 536 - struct fujitsu_bl *priv = acpi_driver_data(device); 537 - int oldb, newb; 538 - 539 - if (event != ACPI_FUJITSU_NOTIFY_CODE) { 540 - acpi_handle_info(device->handle, "unsupported event [0x%x]\n", 541 - event); 542 - sparse_keymap_report_event(priv->input, -1, 1, true); 543 - return; 544 - } 545 - 546 - oldb = priv->brightness_level; 547 - get_lcd_level(device); 548 - newb = priv->brightness_level; 549 - 550 - acpi_handle_debug(device->handle, 551 - "brightness button event [%i -> %i]\n", oldb, newb); 552 - 553 - if (oldb == newb) 554 - return; 555 - 556 - if (!disable_brightness_adjust) 557 - set_lcd_level(device, newb); 558 - 559 - sparse_keymap_report_event(priv->input, oldb < newb, 1, true); 573 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 574 + ACPI_DEVICE_NOTIFY, acpi_fujitsu_bl_notify); 560 575 } 561 576 562 577 /* ACPI device for hotkey handling */ ··· 664 653 {} 665 654 }; 666 655 667 - static int acpi_fujitsu_laptop_input_setup(struct acpi_device *device) 656 + static int acpi_fujitsu_laptop_input_setup(struct device *dev) 668 657 { 669 - struct fujitsu_laptop *priv = acpi_driver_data(device); 658 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 659 + struct acpi_device *device = ACPI_COMPANION(dev); 670 660 int ret; 671 661 672 - priv->input = devm_input_allocate_device(&device->dev); 662 + priv->input = devm_input_allocate_device(dev); 673 663 if (!priv->input) 674 664 return -ENOMEM; 675 665 ··· 689 677 return input_register_device(priv->input); 690 678 } 691 679 692 - static int fujitsu_laptop_platform_add(struct acpi_device *device) 680 + static int fujitsu_laptop_platform_add(struct device *dev) 693 681 { 694 - struct fujitsu_laptop *priv = acpi_driver_data(device); 682 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 695 683 int ret; 696 684 697 685 priv->pf_device = platform_device_alloc("fujitsu-laptop", PLATFORM_DEVID_NONE); ··· 719 707 return ret; 720 708 } 721 709 722 - static void fujitsu_laptop_platform_remove(struct acpi_device *device) 710 + static void fujitsu_laptop_platform_remove(struct device *dev) 723 711 { 724 - struct fujitsu_laptop *priv = acpi_driver_data(device); 712 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 725 713 726 714 sysfs_remove_group(&priv->pf_device->dev.kobj, 727 715 &fujitsu_pf_attribute_group); ··· 731 719 static int logolamp_set(struct led_classdev *cdev, 732 720 enum led_brightness brightness) 733 721 { 734 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 722 + struct device *parent = cdev->dev->parent; 735 723 int poweron = FUNC_LED_ON, always = FUNC_LED_ON; 736 724 int ret; 737 725 ··· 741 729 if (brightness < LED_FULL) 742 730 always = FUNC_LED_OFF; 743 731 744 - ret = call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron); 732 + ret = call_fext_func(parent, FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron); 745 733 if (ret < 0) 746 734 return ret; 747 735 748 - return call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, always); 736 + return call_fext_func(parent, FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, always); 749 737 } 750 738 751 739 static enum led_brightness logolamp_get(struct led_classdev *cdev) 752 740 { 753 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 741 + struct device *parent = cdev->dev->parent; 754 742 int ret; 755 743 756 - ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0); 744 + ret = call_fext_func(parent, FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0); 757 745 if (ret == FUNC_LED_ON) 758 746 return LED_FULL; 759 747 760 - ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0); 748 + ret = call_fext_func(parent, FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0); 761 749 if (ret == FUNC_LED_ON) 762 750 return LED_HALF; 763 751 ··· 767 755 static int kblamps_set(struct led_classdev *cdev, 768 756 enum led_brightness brightness) 769 757 { 770 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 758 + struct device *parent = cdev->dev->parent; 771 759 772 760 if (brightness >= LED_FULL) 773 - return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS, 761 + return call_fext_func(parent, FUNC_LEDS, 0x1, KEYBOARD_LAMPS, 774 762 FUNC_LED_ON); 775 763 else 776 - return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS, 764 + return call_fext_func(parent, FUNC_LEDS, 0x1, KEYBOARD_LAMPS, 777 765 FUNC_LED_OFF); 778 766 } 779 767 780 768 static enum led_brightness kblamps_get(struct led_classdev *cdev) 781 769 { 782 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 783 770 enum led_brightness brightness = LED_OFF; 784 771 785 - if (call_fext_func(device, 772 + if (call_fext_func(cdev->dev->parent, 786 773 FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON) 787 774 brightness = LED_FULL; 788 775 ··· 791 780 static int radio_led_set(struct led_classdev *cdev, 792 781 enum led_brightness brightness) 793 782 { 794 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 783 + struct device *parent = cdev->dev->parent; 795 784 796 785 if (brightness >= LED_FULL) 797 - return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON, 786 + return call_fext_func(parent, FUNC_FLAGS, 0x5, RADIO_LED_ON, 798 787 RADIO_LED_ON); 799 788 else 800 - return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON, 789 + return call_fext_func(parent, FUNC_FLAGS, 0x5, RADIO_LED_ON, 801 790 0x0); 802 791 } 803 792 804 793 static enum led_brightness radio_led_get(struct led_classdev *cdev) 805 794 { 806 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 795 + struct device *parent = cdev->dev->parent; 807 796 enum led_brightness brightness = LED_OFF; 808 797 809 - if (call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON) 798 + if (call_fext_func(parent, FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON) 810 799 brightness = LED_FULL; 811 800 812 801 return brightness; ··· 815 804 static int eco_led_set(struct led_classdev *cdev, 816 805 enum led_brightness brightness) 817 806 { 818 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 807 + struct device *parent = cdev->dev->parent; 819 808 int curr; 820 809 821 - curr = call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0); 810 + curr = call_fext_func(parent, FUNC_LEDS, 0x2, ECO_LED, 0x0); 822 811 if (brightness >= LED_FULL) 823 - return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED, 812 + return call_fext_func(parent, FUNC_LEDS, 0x1, ECO_LED, 824 813 curr | ECO_LED_ON); 825 814 else 826 - return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED, 815 + return call_fext_func(parent, FUNC_LEDS, 0x1, ECO_LED, 827 816 curr & ~ECO_LED_ON); 828 817 } 829 818 830 819 static enum led_brightness eco_led_get(struct led_classdev *cdev) 831 820 { 832 - struct acpi_device *device = to_acpi_device(cdev->dev->parent); 821 + struct device *parent = cdev->dev->parent; 833 822 enum led_brightness brightness = LED_OFF; 834 823 835 - if (call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0) & ECO_LED_ON) 824 + if (call_fext_func(parent, FUNC_LEDS, 0x2, ECO_LED, 0x0) & ECO_LED_ON) 836 825 brightness = LED_FULL; 837 826 838 827 return brightness; 839 828 } 840 829 841 - static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) 830 + static int acpi_fujitsu_laptop_leds_register(struct device *dev) 842 831 { 843 - struct fujitsu_laptop *priv = acpi_driver_data(device); 832 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 844 833 struct led_classdev *led; 845 834 int ret; 846 835 847 - if (call_fext_func(device, 848 - FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { 849 - led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); 836 + if (call_fext_func(dev, FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { 837 + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 850 838 if (!led) 851 839 return -ENOMEM; 852 840 853 841 led->name = "fujitsu::logolamp"; 854 842 led->brightness_set_blocking = logolamp_set; 855 843 led->brightness_get = logolamp_get; 856 - ret = devm_led_classdev_register(&device->dev, led); 844 + ret = devm_led_classdev_register(dev, led); 857 845 if (ret) 858 846 return ret; 859 847 } 860 848 861 - if ((call_fext_func(device, 862 - FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) && 863 - (call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) { 864 - led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); 849 + if ((call_fext_func(dev, FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) && 850 + (call_fext_func(dev, FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) { 851 + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 865 852 if (!led) 866 853 return -ENOMEM; 867 854 868 855 led->name = "fujitsu::kblamps"; 869 856 led->brightness_set_blocking = kblamps_set; 870 857 led->brightness_get = kblamps_get; 871 - ret = devm_led_classdev_register(&device->dev, led); 858 + ret = devm_led_classdev_register(dev, led); 872 859 if (ret) 873 860 return ret; 874 861 } ··· 881 872 * whether given model has a radio toggle button. 882 873 */ 883 874 if (priv->flags_supported & BIT(17)) { 884 - led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); 875 + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 885 876 if (!led) 886 877 return -ENOMEM; 887 878 ··· 889 880 led->brightness_set_blocking = radio_led_set; 890 881 led->brightness_get = radio_led_get; 891 882 led->default_trigger = "rfkill-any"; 892 - ret = devm_led_classdev_register(&device->dev, led); 883 + ret = devm_led_classdev_register(dev, led); 893 884 if (ret) 894 885 return ret; 895 886 } ··· 899 890 * bit 14 seems to indicate presence of said led as well. 900 891 * Confirm by testing the status. 901 892 */ 902 - if ((call_fext_func(device, FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) && 903 - (call_fext_func(device, 904 - FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) { 905 - led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); 893 + if ((call_fext_func(dev, FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) && 894 + (call_fext_func(dev, FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) { 895 + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 906 896 if (!led) 907 897 return -ENOMEM; 908 898 909 899 led->name = "fujitsu::eco_led"; 910 900 led->brightness_set_blocking = eco_led_set; 911 901 led->brightness_get = eco_led_get; 912 - ret = devm_led_classdev_register(&device->dev, led); 902 + ret = devm_led_classdev_register(dev, led); 913 903 if (ret) 914 904 return ret; 915 905 } ··· 916 908 return 0; 917 909 } 918 910 919 - static int acpi_fujitsu_laptop_add(struct acpi_device *device) 911 + static void acpi_fujitsu_laptop_press(struct device *dev, int scancode) 920 912 { 921 - struct fujitsu_laptop *priv; 922 - int ret, i = 0; 923 - 924 - priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); 925 - if (!priv) 926 - return -ENOMEM; 927 - 928 - WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended."); 929 - fext = device; 930 - 931 - strscpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME); 932 - strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS); 933 - device->driver_data = priv; 934 - 935 - /* kfifo */ 936 - spin_lock_init(&priv->fifo_lock); 937 - ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), 938 - GFP_KERNEL); 939 - if (ret) 940 - return ret; 941 - 942 - pr_info("ACPI: %s [%s]\n", 943 - acpi_device_name(device), acpi_device_bid(device)); 944 - 945 - while (call_fext_func(device, FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 && 946 - i++ < MAX_HOTKEY_RINGBUFFER_SIZE) 947 - ; /* No action, result is discarded */ 948 - acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n", 949 - i); 950 - 951 - priv->flags_supported = call_fext_func(device, FUNC_FLAGS, 0x0, 0x0, 952 - 0x0); 953 - 954 - /* Make sure our bitmask of supported functions is cleared if the 955 - RFKILL function block is not implemented, like on the S7020. */ 956 - if (priv->flags_supported == UNSUPPORTED_CMD) 957 - priv->flags_supported = 0; 958 - 959 - if (priv->flags_supported) 960 - priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 961 - 0x0); 962 - 963 - /* Suspect this is a keymap of the application panel, print it */ 964 - acpi_handle_info(device->handle, "BTNI: [0x%x]\n", 965 - call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0)); 966 - 967 - /* Sync backlight power status */ 968 - if (fujitsu_bl && fujitsu_bl->bl_device && 969 - acpi_video_get_backlight_type() == acpi_backlight_vendor) { 970 - if (call_fext_func(fext, FUNC_BACKLIGHT, 0x2, 971 - BACKLIGHT_PARAM_POWER, 0x0) == BACKLIGHT_OFF) 972 - fujitsu_bl->bl_device->props.power = BACKLIGHT_POWER_OFF; 973 - else 974 - fujitsu_bl->bl_device->props.power = BACKLIGHT_POWER_ON; 975 - } 976 - 977 - ret = acpi_fujitsu_laptop_input_setup(device); 978 - if (ret) 979 - goto err_free_fifo; 980 - 981 - ret = acpi_fujitsu_laptop_leds_register(device); 982 - if (ret) 983 - goto err_free_fifo; 984 - 985 - ret = fujitsu_laptop_platform_add(device); 986 - if (ret) 987 - goto err_free_fifo; 988 - 989 - ret = fujitsu_battery_charge_control_add(device); 990 - if (ret < 0) 991 - pr_warn("Unable to register battery charge control: %d\n", ret); 992 - 993 - return 0; 994 - 995 - err_free_fifo: 996 - kfifo_free(&priv->fifo); 997 - 998 - return ret; 999 - } 1000 - 1001 - static void acpi_fujitsu_laptop_remove(struct acpi_device *device) 1002 - { 1003 - struct fujitsu_laptop *priv = acpi_driver_data(device); 1004 - 1005 - fujitsu_battery_charge_control_remove(device); 1006 - 1007 - fujitsu_laptop_platform_remove(device); 1008 - 1009 - kfifo_free(&priv->fifo); 1010 - } 1011 - 1012 - static void acpi_fujitsu_laptop_press(struct acpi_device *device, int scancode) 1013 - { 1014 - struct fujitsu_laptop *priv = acpi_driver_data(device); 913 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 1015 914 int ret; 1016 915 1017 916 ret = kfifo_in_locked(&priv->fifo, (unsigned char *)&scancode, ··· 933 1018 scancode); 934 1019 } 935 1020 936 - static void acpi_fujitsu_laptop_release(struct acpi_device *device) 1021 + static void acpi_fujitsu_laptop_release(struct device *dev) 937 1022 { 938 - struct fujitsu_laptop *priv = acpi_driver_data(device); 1023 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 939 1024 int scancode, ret; 940 1025 941 1026 while (true) { ··· 949 1034 } 950 1035 } 951 1036 952 - static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) 1037 + static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data) 953 1038 { 954 - struct fujitsu_laptop *priv = acpi_driver_data(device); 1039 + struct device *dev = data; 1040 + struct fujitsu_laptop *priv = dev_get_drvdata(dev); 955 1041 unsigned long flags; 956 1042 int scancode, i = 0; 957 1043 unsigned int irb; 958 1044 959 1045 if (event != ACPI_FUJITSU_NOTIFY_CODE) { 960 - acpi_handle_info(device->handle, "Unsupported event [0x%x]\n", 961 - event); 1046 + acpi_handle_info(handle, "Unsupported event [0x%x]\n", event); 962 1047 sparse_keymap_report_event(priv->input, -1, 1, true); 963 1048 return; 964 1049 } 965 1050 966 1051 if (priv->flags_supported) 967 - priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 968 - 0x0); 1052 + priv->flags_state = call_fext_func(dev, FUNC_FLAGS, 0x4, 0x0, 0x0); 969 1053 970 - while ((irb = call_fext_func(device, 971 - FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0 && 1054 + while ((irb = call_fext_func(dev, FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0 && 972 1055 i++ < MAX_HOTKEY_RINGBUFFER_SIZE) { 973 1056 scancode = irb & 0x4ff; 974 1057 if (sparse_keymap_entry_from_scancode(priv->input, scancode)) 975 - acpi_fujitsu_laptop_press(device, scancode); 1058 + acpi_fujitsu_laptop_press(dev, scancode); 976 1059 else if (scancode == 0) 977 - acpi_fujitsu_laptop_release(device); 1060 + acpi_fujitsu_laptop_release(dev); 978 1061 else 979 - acpi_handle_info(device->handle, 980 - "Unknown GIRB result [%x]\n", irb); 1062 + acpi_handle_info(handle, "Unknown GIRB result [%x]\n", irb); 981 1063 } 982 1064 983 1065 /* ··· 984 1072 * status flags queried using FUNC_FLAGS. 985 1073 */ 986 1074 if (priv->flags_supported & (FLAG_SOFTKEYS)) { 987 - flags = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0); 1075 + flags = call_fext_func(dev, FUNC_FLAGS, 0x1, 0x0, 0x0); 988 1076 flags &= (FLAG_SOFTKEYS); 989 1077 for_each_set_bit(i, &flags, BITS_PER_LONG) 990 1078 sparse_keymap_report_event(priv->input, BIT(i), 1, true); 991 1079 } 1080 + } 1081 + 1082 + static int acpi_fujitsu_laptop_probe(struct platform_device *pdev) 1083 + { 1084 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1085 + struct fujitsu_laptop *priv; 1086 + int ret, i = 0; 1087 + 1088 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 1089 + if (!priv) 1090 + return -ENOMEM; 1091 + 1092 + WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended."); 1093 + fext = &pdev->dev; 1094 + 1095 + strscpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME); 1096 + strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS); 1097 + 1098 + platform_set_drvdata(pdev, priv); 1099 + 1100 + /* kfifo */ 1101 + spin_lock_init(&priv->fifo_lock); 1102 + ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), 1103 + GFP_KERNEL); 1104 + if (ret) 1105 + return ret; 1106 + 1107 + pr_info("ACPI: %s [%s]\n", 1108 + acpi_device_name(device), acpi_device_bid(device)); 1109 + 1110 + while (call_fext_func(fext, FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 && 1111 + i++ < MAX_HOTKEY_RINGBUFFER_SIZE) 1112 + ; /* No action, result is discarded */ 1113 + acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n", 1114 + i); 1115 + 1116 + priv->flags_supported = call_fext_func(fext, FUNC_FLAGS, 0x0, 0x0, 0x0); 1117 + 1118 + /* Make sure our bitmask of supported functions is cleared if the 1119 + RFKILL function block is not implemented, like on the S7020. */ 1120 + if (priv->flags_supported == UNSUPPORTED_CMD) 1121 + priv->flags_supported = 0; 1122 + 1123 + if (priv->flags_supported) 1124 + priv->flags_state = call_fext_func(fext, FUNC_FLAGS, 0x4, 0x0, 1125 + 0x0); 1126 + 1127 + /* Suspect this is a keymap of the application panel, print it */ 1128 + acpi_handle_info(device->handle, "BTNI: [0x%x]\n", 1129 + call_fext_func(fext, FUNC_BUTTONS, 0x0, 0x0, 0x0)); 1130 + 1131 + /* Sync backlight power status */ 1132 + if (fujitsu_bl && fujitsu_bl->bl_device && 1133 + acpi_video_get_backlight_type() == acpi_backlight_vendor) { 1134 + if (call_fext_func(fext, FUNC_BACKLIGHT, 0x2, 1135 + BACKLIGHT_PARAM_POWER, 0x0) == BACKLIGHT_OFF) 1136 + fujitsu_bl->bl_device->props.power = BACKLIGHT_POWER_OFF; 1137 + else 1138 + fujitsu_bl->bl_device->props.power = BACKLIGHT_POWER_ON; 1139 + } 1140 + 1141 + ret = acpi_fujitsu_laptop_input_setup(fext); 1142 + if (ret) 1143 + goto err_free_fifo; 1144 + 1145 + ret = acpi_fujitsu_laptop_leds_register(fext); 1146 + if (ret) 1147 + goto err_free_fifo; 1148 + 1149 + ret = fujitsu_laptop_platform_add(fext); 1150 + if (ret) 1151 + goto err_free_fifo; 1152 + 1153 + ret = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 1154 + acpi_fujitsu_laptop_notify, fext); 1155 + if (ret) 1156 + goto err_platform_remove; 1157 + 1158 + ret = fujitsu_battery_charge_control_add(fext); 1159 + if (ret < 0) 1160 + pr_warn("Unable to register battery charge control: %d\n", ret); 1161 + 1162 + return 0; 1163 + 1164 + err_platform_remove: 1165 + fujitsu_laptop_platform_remove(fext); 1166 + err_free_fifo: 1167 + kfifo_free(&priv->fifo); 1168 + 1169 + return ret; 1170 + } 1171 + 1172 + static void acpi_fujitsu_laptop_remove(struct platform_device *pdev) 1173 + { 1174 + struct fujitsu_laptop *priv = platform_get_drvdata(pdev); 1175 + 1176 + fujitsu_battery_charge_control_remove(&pdev->dev); 1177 + 1178 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), ACPI_DEVICE_NOTIFY, 1179 + acpi_fujitsu_laptop_notify); 1180 + 1181 + fujitsu_laptop_platform_remove(&pdev->dev); 1182 + 1183 + kfifo_free(&priv->fifo); 992 1184 } 993 1185 994 1186 /* Initialization */ ··· 1102 1086 {"", 0}, 1103 1087 }; 1104 1088 1105 - static struct acpi_driver acpi_fujitsu_bl_driver = { 1106 - .name = ACPI_FUJITSU_BL_DRIVER_NAME, 1107 - .class = ACPI_FUJITSU_CLASS, 1108 - .ids = fujitsu_bl_device_ids, 1109 - .ops = { 1110 - .add = acpi_fujitsu_bl_add, 1111 - .notify = acpi_fujitsu_bl_notify, 1112 - }, 1089 + static struct platform_driver acpi_fujitsu_bl_driver = { 1090 + .probe = acpi_fujitsu_bl_probe, 1091 + .remove = acpi_fujitsu_bl_remove, 1092 + .driver = { 1093 + .name = ACPI_FUJITSU_BL_DRIVER_NAME, 1094 + .acpi_match_table = fujitsu_bl_device_ids, 1095 + }, 1113 1096 }; 1114 1097 1115 1098 static const struct acpi_device_id fujitsu_laptop_device_ids[] = { ··· 1116 1101 {"", 0}, 1117 1102 }; 1118 1103 1119 - static struct acpi_driver acpi_fujitsu_laptop_driver = { 1120 - .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME, 1121 - .class = ACPI_FUJITSU_CLASS, 1122 - .ids = fujitsu_laptop_device_ids, 1123 - .ops = { 1124 - .add = acpi_fujitsu_laptop_add, 1125 - .remove = acpi_fujitsu_laptop_remove, 1126 - .notify = acpi_fujitsu_laptop_notify, 1127 - }, 1104 + static struct platform_driver acpi_fujitsu_laptop_driver = { 1105 + .probe = acpi_fujitsu_laptop_probe, 1106 + .remove = acpi_fujitsu_laptop_remove, 1107 + .driver = { 1108 + .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME, 1109 + .acpi_match_table = fujitsu_laptop_device_ids, 1110 + }, 1128 1111 }; 1129 1112 1130 1113 static const struct acpi_device_id fujitsu_ids[] __used = { ··· 1136 1123 { 1137 1124 int ret; 1138 1125 1139 - ret = acpi_bus_register_driver(&acpi_fujitsu_bl_driver); 1126 + ret = platform_driver_register(&acpi_fujitsu_bl_driver); 1140 1127 if (ret) 1141 1128 return ret; 1142 1129 ··· 1148 1135 1149 1136 /* Register laptop driver */ 1150 1137 1151 - ret = acpi_bus_register_driver(&acpi_fujitsu_laptop_driver); 1138 + ret = platform_driver_register(&acpi_fujitsu_laptop_driver); 1152 1139 if (ret) 1153 1140 goto err_unregister_platform_driver; 1154 1141 ··· 1159 1146 err_unregister_platform_driver: 1160 1147 platform_driver_unregister(&fujitsu_pf_driver); 1161 1148 err_unregister_acpi: 1162 - acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); 1149 + platform_driver_unregister(&acpi_fujitsu_bl_driver); 1163 1150 1164 1151 return ret; 1165 1152 } 1166 1153 1167 1154 static void __exit fujitsu_cleanup(void) 1168 1155 { 1169 - acpi_bus_unregister_driver(&acpi_fujitsu_laptop_driver); 1156 + platform_driver_unregister(&acpi_fujitsu_laptop_driver); 1170 1157 1171 1158 platform_driver_unregister(&fujitsu_pf_driver); 1172 1159 1173 - acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); 1160 + platform_driver_unregister(&acpi_fujitsu_bl_driver); 1174 1161 1175 1162 pr_info("driver unloaded\n"); 1176 1163 }
+14 -16
drivers/platform/x86/fujitsu-tablet.c
··· 18 18 #include <linux/input.h> 19 19 #include <linux/delay.h> 20 20 #include <linux/dmi.h> 21 + #include <linux/platform_device.h> 21 22 22 23 #define MODULENAME "fujitsu-tablet" 23 24 ··· 443 442 } 444 443 } 445 444 446 - static int acpi_fujitsu_add(struct acpi_device *adev) 445 + static int acpi_fujitsu_probe(struct platform_device *pdev) 447 446 { 447 + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); 448 448 acpi_status status; 449 449 int error; 450 - 451 - if (!adev) 452 - return -EINVAL; 453 450 454 451 status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, 455 452 fujitsu_walk_resources, NULL); ··· 460 461 snprintf(fujitsu.phys, sizeof(fujitsu.phys), 461 462 "%s/input0", acpi_device_hid(adev)); 462 463 463 - error = input_fujitsu_setup(&adev->dev, 464 + error = input_fujitsu_setup(&pdev->dev, 464 465 acpi_device_name(adev), fujitsu.phys); 465 466 if (error) 466 467 return error; ··· 483 484 return 0; 484 485 } 485 486 486 - static void acpi_fujitsu_remove(struct acpi_device *adev) 487 + static void acpi_fujitsu_remove(struct platform_device *pdev) 487 488 { 488 489 free_irq(fujitsu.irq, fujitsu_interrupt); 489 490 release_region(fujitsu.io_base, fujitsu.io_length); ··· 500 501 501 502 static SIMPLE_DEV_PM_OPS(acpi_fujitsu_pm, NULL, acpi_fujitsu_resume); 502 503 503 - static struct acpi_driver acpi_fujitsu_driver = { 504 - .name = MODULENAME, 505 - .class = "hotkey", 506 - .ids = fujitsu_ids, 507 - .ops = { 508 - .add = acpi_fujitsu_add, 509 - .remove = acpi_fujitsu_remove, 504 + static struct platform_driver acpi_fujitsu_driver = { 505 + .probe = acpi_fujitsu_probe, 506 + .remove = acpi_fujitsu_remove, 507 + .driver = { 508 + .name = MODULENAME, 509 + .acpi_match_table = fujitsu_ids, 510 + .pm = &acpi_fujitsu_pm, 510 511 }, 511 - .drv.pm = &acpi_fujitsu_pm, 512 512 }; 513 513 514 514 static int __init fujitsu_module_init(void) ··· 516 518 517 519 dmi_check_system(dmi_ids); 518 520 519 - error = acpi_bus_register_driver(&acpi_fujitsu_driver); 521 + error = platform_driver_register(&acpi_fujitsu_driver); 520 522 if (error) 521 523 return error; 522 524 ··· 525 527 526 528 static void __exit fujitsu_module_exit(void) 527 529 { 528 - acpi_bus_unregister_driver(&acpi_fujitsu_driver); 530 + platform_driver_unregister(&acpi_fujitsu_driver); 529 531 } 530 532 531 533 module_init(fujitsu_module_init);
+99 -26
drivers/platform/x86/hp/hp-wmi.c
··· 48 48 49 49 enum hp_ec_offsets { 50 50 HP_EC_OFFSET_UNKNOWN = 0x00, 51 + HP_NO_THERMAL_PROFILE_OFFSET = 0x01, 51 52 HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET = 0x59, 52 53 HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET = 0x62, 53 54 HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET = 0x63, ··· 126 125 .ec_tp_offset = HP_OMEN_EC_THERMAL_PROFILE_OFFSET, 127 126 }; 128 127 128 + static const struct thermal_profile_params omen_v1_no_ec_thermal_params = { 129 + .performance = HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE, 130 + .balanced = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, 131 + .low_power = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, 132 + .ec_tp_offset = HP_NO_THERMAL_PROFILE_OFFSET, 133 + }; 134 + 129 135 /* 130 136 * A generic pointer for the currently-active board's thermal profile 131 137 * parameters. ··· 159 151 "8900", "8901", "8902", "8912", "8917", "8918", "8949", "894A", "89EB", 160 152 "8A15", "8A42", 161 153 "8BAD", 154 + "8C58", 162 155 "8E41", 163 156 }; 164 157 ··· 189 180 190 181 /* DMI Board names of Victus 16-r and Victus 16-s laptops */ 191 182 static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = { 183 + { 184 + .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A44") }, 185 + .driver_data = (void *)&omen_v1_legacy_thermal_params, 186 + }, 192 187 { 193 188 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") }, 194 189 .driver_data = (void *)&omen_v1_legacy_thermal_params, ··· 226 213 .driver_data = (void *)&omen_v1_thermal_params, 227 214 }, 228 215 { 216 + .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") }, 217 + .driver_data = (void *)&omen_v1_thermal_params, 218 + }, 219 + { 229 220 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") }, 230 221 .driver_data = (void *)&omen_v1_thermal_params, 231 222 }, ··· 244 227 { 245 228 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") }, 246 229 .driver_data = (void *)&victus_s_thermal_params, 230 + }, 231 + { 232 + .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") }, 233 + .driver_data = (void *)&omen_v1_no_ec_thermal_params, 247 234 }, 248 235 {}, 249 236 }; ··· 418 397 { KE_KEY, 0x21a9, { KEY_TOUCHPAD_OFF } }, 419 398 { KE_KEY, 0x121a9, { KEY_TOUCHPAD_ON } }, 420 399 { KE_KEY, 0x231b, { KEY_HELP } }, 400 + { KE_IGNORE, 0x21ab, }, /* FnLock on */ 401 + { KE_IGNORE, 0x121ab, }, /* FnLock off */ 402 + { KE_IGNORE, 0x30021aa, }, /* kbd backlight: level 2 -> off */ 403 + { KE_IGNORE, 0x33221aa, }, /* kbd backlight: off -> level 1 */ 404 + { KE_IGNORE, 0x36421aa, }, /* kbd backlight: level 1 -> level 2*/ 421 405 { KE_END, 0 } 422 406 }; 423 407 ··· 477 451 }; 478 452 479 453 struct hp_wmi_hwmon_priv { 454 + struct mutex lock; /* protects mode, pwm */ 480 455 u8 min_rpm; 481 456 u8 max_rpm; 482 - u8 gpu_delta; 457 + int gpu_delta; 483 458 u8 mode; 484 459 u8 pwm; 485 460 struct delayed_work keep_alive_dwork; 486 461 }; 487 462 488 463 struct victus_s_fan_table_header { 464 + u8 num_fans; 489 465 u8 unknown; 490 - u8 num_entries; 491 466 } __packed; 492 467 493 468 struct victus_s_fan_table_entry { 494 469 u8 cpu_rpm; 495 470 u8 gpu_rpm; 496 - u8 unknown; 471 + u8 noise_db; 497 472 } __packed; 498 473 499 474 struct victus_s_fan_table { ··· 1855 1828 const struct thermal_profile_params *params; 1856 1829 1857 1830 params = active_thermal_profile_params; 1858 - if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) { 1831 + if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN || 1832 + params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) { 1859 1833 *profile = active_platform_profile; 1860 1834 return 0; 1861 1835 } ··· 2211 2183 * behaves like a wrapper around active_platform_profile, to avoid using 2212 2184 * uninitialized data, we default to PLATFORM_PROFILE_BALANCED. 2213 2185 */ 2214 - if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) { 2186 + if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN || 2187 + active_thermal_profile_params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) { 2215 2188 active_platform_profile = PLATFORM_PROFILE_BALANCED; 2216 2189 } else { 2217 2190 err = platform_profile_victus_s_get_ec(&active_platform_profile); ··· 2380 2351 2381 2352 switch (priv->mode) { 2382 2353 case PWM_MODE_MAX: 2383 - if (is_victus_s_thermal_profile()) 2384 - hp_wmi_get_fan_count_userdefine_trigger(); 2354 + if (is_victus_s_thermal_profile()) { 2355 + ret = hp_wmi_get_fan_count_userdefine_trigger(); 2356 + if (ret < 0) 2357 + return ret; 2358 + } 2385 2359 ret = hp_wmi_fan_speed_max_set(1); 2386 2360 if (ret < 0) 2387 2361 return ret; 2388 - schedule_delayed_work(&priv->keep_alive_dwork, 2389 - secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); 2362 + mod_delayed_work(system_wq, &priv->keep_alive_dwork, 2363 + secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); 2390 2364 return 0; 2391 2365 case PWM_MODE_MANUAL: 2392 2366 if (!is_victus_s_thermal_profile()) ··· 2397 2365 ret = hp_wmi_fan_speed_set(priv, pwm_to_rpm(priv->pwm, priv)); 2398 2366 if (ret < 0) 2399 2367 return ret; 2400 - schedule_delayed_work(&priv->keep_alive_dwork, 2401 - secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); 2368 + mod_delayed_work(system_wq, &priv->keep_alive_dwork, 2369 + secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); 2402 2370 return 0; 2403 2371 case PWM_MODE_AUTO: 2404 2372 if (is_victus_s_thermal_profile()) { 2405 - hp_wmi_get_fan_count_userdefine_trigger(); 2373 + ret = hp_wmi_get_fan_count_userdefine_trigger(); 2374 + if (ret < 0) 2375 + return ret; 2406 2376 ret = hp_wmi_fan_speed_max_reset(priv); 2407 2377 } else { 2408 2378 ret = hp_wmi_fan_speed_max_set(0); 2409 2379 } 2410 2380 if (ret < 0) 2411 2381 return ret; 2412 - cancel_delayed_work_sync(&priv->keep_alive_dwork); 2382 + cancel_delayed_work(&priv->keep_alive_dwork); 2413 2383 return 0; 2414 2384 default: 2415 2385 /* shouldn't happen */ 2416 2386 return -EINVAL; 2417 2387 } 2418 - 2419 - return 0; 2420 2388 } 2421 2389 2422 2390 static umode_t hp_wmi_hwmon_is_visible(const void *data, ··· 2449 2417 { 2450 2418 struct hp_wmi_hwmon_priv *priv; 2451 2419 int rpm, ret; 2420 + u8 mode; 2452 2421 2453 2422 priv = dev_get_drvdata(dev); 2454 2423 switch (type) { ··· 2473 2440 *val = rpm_to_pwm(rpm / 100, priv); 2474 2441 return 0; 2475 2442 } 2476 - switch (priv->mode) { 2443 + scoped_guard(mutex, &priv->lock) 2444 + mode = priv->mode; 2445 + switch (mode) { 2477 2446 case PWM_MODE_MAX: 2478 2447 case PWM_MODE_MANUAL: 2479 2448 case PWM_MODE_AUTO: 2480 - *val = priv->mode; 2449 + *val = mode; 2481 2450 return 0; 2482 2451 default: 2483 2452 /* shouldn't happen */ ··· 2497 2462 int rpm; 2498 2463 2499 2464 priv = dev_get_drvdata(dev); 2465 + guard(mutex)(&priv->lock); 2500 2466 switch (type) { 2501 2467 case hwmon_pwm: 2502 2468 if (attr == hwmon_pwm_input) { ··· 2562 2526 { 2563 2527 struct delayed_work *dwork; 2564 2528 struct hp_wmi_hwmon_priv *priv; 2529 + int ret; 2565 2530 2566 2531 dwork = to_delayed_work(work); 2567 2532 priv = container_of(dwork, struct hp_wmi_hwmon_priv, keep_alive_dwork); 2533 + 2534 + guard(mutex)(&priv->lock); 2568 2535 /* 2569 2536 * Re-apply the current hwmon context settings. 2570 2537 * NOTE: hp_wmi_apply_fan_settings will handle the re-scheduling. 2571 2538 */ 2572 - hp_wmi_apply_fan_settings(priv); 2539 + ret = hp_wmi_apply_fan_settings(priv); 2540 + if (ret) 2541 + pr_warn_ratelimited("keep-alive failed to refresh fan settings: %d\n", 2542 + ret); 2573 2543 } 2574 2544 2575 2545 static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv) 2576 2546 { 2577 2547 u8 fan_data[128] = { 0 }; 2578 2548 struct victus_s_fan_table *fan_table; 2579 - u8 min_rpm, max_rpm, gpu_delta; 2580 - int ret; 2549 + u8 min_rpm, max_rpm; 2550 + u8 cpu_rpm, gpu_rpm, noise_db; 2551 + int gpu_delta, i, num_entries, ret; 2552 + size_t header_size, entry_size; 2581 2553 2582 2554 /* Default behaviour on hwmon init is automatic mode */ 2583 2555 priv->mode = PWM_MODE_AUTO; ··· 2600 2556 return ret; 2601 2557 2602 2558 fan_table = (struct victus_s_fan_table *)fan_data; 2603 - if (fan_table->header.num_entries == 0 || 2604 - sizeof(struct victus_s_fan_table_header) + 2605 - sizeof(struct victus_s_fan_table_entry) * fan_table->header.num_entries > sizeof(fan_data)) 2559 + if (fan_table->header.num_fans == 0) 2606 2560 return -EINVAL; 2607 2561 2608 - min_rpm = fan_table->entries[0].cpu_rpm; 2609 - max_rpm = fan_table->entries[fan_table->header.num_entries - 1].cpu_rpm; 2562 + header_size = sizeof(struct victus_s_fan_table_header); 2563 + entry_size = sizeof(struct victus_s_fan_table_entry); 2564 + num_entries = (sizeof(fan_data) - header_size) / entry_size; 2565 + min_rpm = U8_MAX; 2566 + max_rpm = 0; 2567 + 2568 + for (i = 0 ; i < num_entries ; i++) { 2569 + cpu_rpm = fan_table->entries[i].cpu_rpm; 2570 + gpu_rpm = fan_table->entries[i].gpu_rpm; 2571 + noise_db = fan_table->entries[i].noise_db; 2572 + 2573 + /* 2574 + * On some devices, the fan table is truncated with an all-zero row, 2575 + * hence we stop parsing here. 2576 + */ 2577 + if (cpu_rpm == 0 && gpu_rpm == 0 && noise_db == 0) 2578 + break; 2579 + 2580 + if (cpu_rpm < min_rpm) 2581 + min_rpm = cpu_rpm; 2582 + if (cpu_rpm > max_rpm) 2583 + max_rpm = cpu_rpm; 2584 + } 2585 + 2586 + if (min_rpm == U8_MAX || max_rpm == 0) 2587 + return -EINVAL; 2588 + 2610 2589 gpu_delta = fan_table->entries[0].gpu_rpm - fan_table->entries[0].cpu_rpm; 2611 2590 priv->min_rpm = min_rpm; 2612 2591 priv->max_rpm = max_rpm; ··· 2649 2582 if (!priv) 2650 2583 return -ENOMEM; 2651 2584 2585 + ret = devm_mutex_init(dev, &priv->lock); 2586 + if (ret) 2587 + return ret; 2588 + 2652 2589 ret = hp_wmi_setup_fan_settings(priv); 2653 2590 if (ret) 2654 2591 return ret; ··· 2666 2595 2667 2596 INIT_DELAYED_WORK(&priv->keep_alive_dwork, hp_wmi_hwmon_keep_alive_handler); 2668 2597 platform_set_drvdata(hp_wmi_platform_dev, priv); 2669 - hp_wmi_apply_fan_settings(priv); 2598 + ret = hp_wmi_apply_fan_settings(priv); 2599 + if (ret) 2600 + dev_warn(dev, "Failed to apply initial fan settings: %d\n", ret); 2670 2601 2671 2602 return 0; 2672 2603 }
+10 -3
drivers/platform/x86/intel/int3472/discrete.c
··· 212 212 *gpio_flags = GPIO_ACTIVE_HIGH; 213 213 break; 214 214 case INT3472_GPIO_TYPE_PRIVACY_LED: 215 - *con_id = "privacy-led"; 215 + *con_id = "privacy"; 216 + *gpio_flags = GPIO_ACTIVE_HIGH; 217 + break; 218 + case INT3472_GPIO_TYPE_STROBE: 219 + *con_id = "ir_flood"; 216 220 *gpio_flags = GPIO_ACTIVE_HIGH; 217 221 break; 218 222 case INT3472_GPIO_TYPE_HOTPLUG_DETECT: ··· 256 252 * 257 253 * 0x00 Reset 258 254 * 0x01 Power down 255 + * 0x02 Strobe 259 256 * 0x0b Power enable 260 257 * 0x0c Clock enable 261 258 * 0x0d Privacy LED ··· 341 336 break; 342 337 case INT3472_GPIO_TYPE_CLK_ENABLE: 343 338 case INT3472_GPIO_TYPE_PRIVACY_LED: 339 + case INT3472_GPIO_TYPE_STROBE: 344 340 case INT3472_GPIO_TYPE_POWER_ENABLE: 345 341 case INT3472_GPIO_TYPE_DOVDD: 346 342 case INT3472_GPIO_TYPE_HANDSHAKE: ··· 360 354 361 355 break; 362 356 case INT3472_GPIO_TYPE_PRIVACY_LED: 363 - ret = skl_int3472_register_pled(int3472, gpio); 357 + case INT3472_GPIO_TYPE_STROBE: 358 + ret = skl_int3472_register_led(int3472, gpio, con_id); 364 359 if (ret) 365 360 err_msg = "Failed to register LED\n"; 366 361 ··· 436 429 gpiod_remove_lookup_table(&int3472->gpios); 437 430 438 431 skl_int3472_unregister_clock(int3472); 439 - skl_int3472_unregister_pled(int3472); 432 + skl_int3472_unregister_leds(int3472); 440 433 skl_int3472_unregister_regulator(int3472); 441 434 } 442 435 EXPORT_SYMBOL_NS_GPL(int3472_discrete_cleanup, "INTEL_INT3472_DISCRETE");
+29 -26
drivers/platform/x86/intel/int3472/led.c
··· 6 6 #include <linux/leds.h> 7 7 #include <linux/platform_data/x86/int3472.h> 8 8 9 - static int int3472_pled_set(struct led_classdev *led_cdev, 10 - enum led_brightness brightness) 9 + static int int3472_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) 11 10 { 12 - struct int3472_discrete_device *int3472 = 13 - container_of(led_cdev, struct int3472_discrete_device, pled.classdev); 11 + struct int3472_led *led = container_of(led_cdev, struct int3472_led, classdev); 14 12 15 - gpiod_set_value_cansleep(int3472->pled.gpio, brightness); 13 + gpiod_set_value_cansleep(led->gpio, brightness); 16 14 return 0; 17 15 } 18 16 19 - int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio) 17 + int skl_int3472_register_led(struct int3472_discrete_device *int3472, struct gpio_desc *gpio, 18 + const char *con_id) 20 19 { 20 + struct int3472_led *led; 21 21 char *p; 22 22 int ret; 23 23 24 - if (int3472->pled.classdev.dev) 25 - return -EBUSY; 24 + if (int3472->n_leds >= INT3472_MAX_LEDS) 25 + return -ENOSPC; 26 26 27 - int3472->pled.gpio = gpio; 27 + led = &int3472->leds[int3472->n_leds]; 28 + led->gpio = gpio; 28 29 29 30 /* Generate the name, replacing the ':' in the ACPI devname with '_' */ 30 - snprintf(int3472->pled.name, sizeof(int3472->pled.name), 31 - "%s::privacy_led", acpi_dev_name(int3472->sensor)); 32 - p = strchr(int3472->pled.name, ':'); 31 + snprintf(led->name, sizeof(led->name), 32 + "%s::%s_led", acpi_dev_name(int3472->sensor), con_id); 33 + p = strchr(led->name, ':'); 33 34 if (p) 34 35 *p = '_'; 35 36 36 - int3472->pled.classdev.name = int3472->pled.name; 37 - int3472->pled.classdev.max_brightness = 1; 38 - int3472->pled.classdev.brightness_set_blocking = int3472_pled_set; 37 + led->classdev.name = led->name; 38 + led->classdev.max_brightness = 1; 39 + led->classdev.brightness_set_blocking = int3472_led_set; 39 40 40 - ret = led_classdev_register(int3472->dev, &int3472->pled.classdev); 41 + ret = led_classdev_register(int3472->dev, &led->classdev); 41 42 if (ret) 42 43 return ret; 43 44 44 - int3472->pled.lookup.provider = int3472->pled.name; 45 - int3472->pled.lookup.dev_id = int3472->sensor_name; 46 - int3472->pled.lookup.con_id = "privacy"; 47 - led_add_lookup(&int3472->pled.lookup); 45 + led->lookup.provider = led->name; 46 + led->lookup.dev_id = int3472->sensor_name; 47 + led->lookup.con_id = con_id; 48 + led_add_lookup(&led->lookup); 48 49 50 + int3472->n_leds++; 49 51 return 0; 50 52 } 51 53 52 - void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472) 54 + void skl_int3472_unregister_leds(struct int3472_discrete_device *int3472) 53 55 { 54 - if (IS_ERR_OR_NULL(int3472->pled.classdev.dev)) 55 - return; 56 + for (unsigned int i = 0; i < int3472->n_leds; i++) { 57 + struct int3472_led *led = &int3472->leds[i]; 56 58 57 - led_remove_lookup(&int3472->pled.lookup); 58 - led_classdev_unregister(&int3472->pled.classdev); 59 - gpiod_put(int3472->pled.gpio); 59 + led_remove_lookup(&led->lookup); 60 + led_classdev_unregister(&led->classdev); 61 + gpiod_put(led->gpio); 62 + } 60 63 }
+2 -2
drivers/platform/x86/intel/pmc/core.c
··· 1315 1315 unsigned int i; 1316 1316 1317 1317 for (i = 0; guids[i]; i++) { 1318 - ep = pmt_telem_find_and_register_endpoint(pcidev, guids[i], 0); 1318 + ep = pmt_telem_find_and_register_endpoint(&pcidev->dev, guids[i], 0); 1319 1319 if (!IS_ERR(ep)) 1320 1320 return ep; 1321 1321 } ··· 1600 1600 if (!pmc->map->lpm_req_guid) 1601 1601 return -ENXIO; 1602 1602 1603 - ep = pmt_telem_find_and_register_endpoint(pcidev, pmc->map->lpm_req_guid, 0); 1603 + ep = pmt_telem_find_and_register_endpoint(&pcidev->dev, pmc->map->lpm_req_guid, 0); 1604 1604 if (IS_ERR(ep)) { 1605 1605 dev_dbg(&pmcdev->pdev->dev, "couldn't get telem endpoint %pe", ep); 1606 1606 return -EPROBE_DEFER;
+1 -1
drivers/platform/x86/intel/pmc/ssram_telemetry.c
··· 60 60 info.base_addr = ssram_base; 61 61 info.parent = &pcidev->dev; 62 62 63 - return intel_vsec_register(pcidev, &info); 63 + return intel_vsec_register(&pcidev->dev, &info); 64 64 } 65 65 66 66 static inline u64 get_base(void __iomem *addr, u32 offset)
+4 -4
drivers/platform/x86/intel/pmt/class.c
··· 60 60 return count; 61 61 } 62 62 63 - int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, 63 + int pmt_telem_read_mmio(struct device *dev, struct pmt_callbacks *cb, u32 guid, void *buf, 64 64 void __iomem *addr, loff_t off, u32 count) 65 65 { 66 66 if (cb && cb->read_telem) 67 - return cb->read_telem(pdev, guid, buf, off, count); 67 + return cb->read_telem(dev, guid, buf, off, count); 68 68 69 69 addr += off; 70 70 ··· 99 99 if (count > entry->size - off) 100 100 count = entry->size - off; 101 101 102 - count = pmt_telem_read_mmio(entry->pcidev, entry->cb, entry->header.guid, buf, 102 + count = pmt_telem_read_mmio(entry->ep->dev, entry->cb, entry->header.guid, buf, 103 103 entry->base, off, count); 104 104 105 105 return count; ··· 208 208 struct intel_vsec_device *ivdev, 209 209 struct resource *disc_res) 210 210 { 211 - struct pci_dev *pci_dev = ivdev->pcidev; 211 + struct pci_dev *pci_dev = to_pci_dev(ivdev->dev); 212 212 struct device *dev = &ivdev->auxdev.dev; 213 213 struct intel_pmt_header *header = &entry->header; 214 214 u8 bir;
+3 -2
drivers/platform/x86/intel/pmt/class.h
··· 19 19 #define GET_BIR(v) ((v) & GENMASK(2, 0)) 20 20 #define GET_ADDRESS(v) ((v) & GENMASK(31, 3)) 21 21 22 + struct device; 22 23 struct pci_dev; 23 24 extern struct class intel_pmt_class; 24 25 25 26 struct telem_endpoint { 26 - struct pci_dev *pcidev; 27 + struct device *dev; 27 28 struct telem_header header; 28 29 struct pmt_callbacks *cb; 29 30 void __iomem *base; ··· 66 65 struct intel_pmt_entry *entry); 67 66 }; 68 67 69 - int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, 68 + int pmt_telem_read_mmio(struct device *dev, struct pmt_callbacks *cb, u32 guid, void *buf, 70 69 void __iomem *addr, loff_t off, u32 count); 71 70 bool intel_pmt_is_early_client_hw(struct device *dev); 72 71 int intel_pmt_dev_create(struct intel_pmt_entry *entry,
+2 -2
drivers/platform/x86/intel/pmt/discovery.c
··· 542 542 if (!priv) 543 543 return -ENOMEM; 544 544 545 - priv->parent = &ivdev->pcidev->dev; 545 + priv->parent = ivdev->dev; 546 546 auxiliary_set_drvdata(auxdev, priv); 547 547 548 548 priv->dev = device_create(&intel_pmt_class, &auxdev->dev, MKDEV(0, 0), priv, ··· 609 609 610 610 mutex_lock(&feature_list_lock); 611 611 list_for_each_entry(feature, &pmt_feature_list, list) { 612 - if (feature->priv->parent != &entry->ep->pcidev->dev) 612 + if (feature->priv->parent != entry->ep->dev) 613 613 continue; 614 614 615 615 pmt_get_features(entry, feature);
+7 -6
drivers/platform/x86/intel/pmt/telemetry.c
··· 112 112 return -ENOMEM; 113 113 114 114 ep = entry->ep; 115 - ep->pcidev = ivdev->pcidev; 115 + ep->dev = ivdev->dev; 116 116 ep->header.access_type = entry->header.access_type; 117 117 ep->header.guid = entry->header.guid; 118 118 ep->header.base_offset = entry->header.base_offset; ··· 204 204 goto unlock; 205 205 } 206 206 207 - info->pdev = entry->ep->pcidev; 207 + info->dev = entry->ep->dev; 208 208 info->header = entry->ep->header; 209 209 210 210 unlock: ··· 218 218 struct intel_pmt_entry *entry) 219 219 { 220 220 221 + struct pci_dev *pdev = to_pci_dev(entry->ep->dev); 221 222 struct oobmsm_plat_info *plat_info; 222 223 223 - plat_info = intel_vsec_get_mapping(entry->ep->pcidev); 224 + plat_info = intel_vsec_get_mapping(pdev); 224 225 if (IS_ERR(plat_info)) 225 226 return PTR_ERR(plat_info); 226 227 ··· 309 308 if (offset + NUM_BYTES_QWORD(count) > size) 310 309 return -EINVAL; 311 310 312 - pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base, offset, 311 + pmt_telem_read_mmio(ep->dev, ep->cb, ep->header.guid, data, ep->base, offset, 313 312 NUM_BYTES_QWORD(count)); 314 313 315 314 return ep->present ? 0 : -EPIPE; ··· 336 335 EXPORT_SYMBOL_NS_GPL(pmt_telem_read32, "INTEL_PMT_TELEMETRY"); 337 336 338 337 struct telem_endpoint * 339 - pmt_telem_find_and_register_endpoint(struct pci_dev *pcidev, u32 guid, u16 pos) 338 + pmt_telem_find_and_register_endpoint(struct device *dev, u32 guid, u16 pos) 340 339 { 341 340 int devid = 0; 342 341 int inst = 0; ··· 349 348 if (err) 350 349 return ERR_PTR(err); 351 350 352 - if (ep_info.header.guid == guid && ep_info.pdev == pcidev) { 351 + if (ep_info.header.guid == guid && ep_info.dev == dev) { 353 352 if (inst == pos) 354 353 return pmt_telem_register_endpoint(devid); 355 354 ++inst;
+6 -6
drivers/platform/x86/intel/pmt/telemetry.h
··· 6 6 #define PMT_TELEM_TELEMETRY 0 7 7 #define PMT_TELEM_CRASHLOG 1 8 8 9 + struct device; 9 10 struct telem_endpoint; 10 - struct pci_dev; 11 11 12 12 struct telem_header { 13 13 u8 access_type; ··· 17 17 }; 18 18 19 19 struct telem_endpoint_info { 20 - struct pci_dev *pdev; 20 + struct device *dev; 21 21 struct telem_header header; 22 22 }; 23 23 ··· 71 71 72 72 /** 73 73 * pmt_telem_find_and_register_endpoint() - Get a telemetry endpoint from 74 - * pci_dev device, guid and pos 75 - * @pdev: PCI device inside the Intel vsec 74 + * device, guid and pos 75 + * @dev: device inside the Intel vsec 76 76 * @guid: GUID of the telemetry space 77 77 * @pos: Instance of the guid 78 78 * ··· 80 80 * * endpoint - On success returns pointer to the telemetry endpoint 81 81 * * -ENXIO - telemetry endpoint not found 82 82 */ 83 - struct telem_endpoint *pmt_telem_find_and_register_endpoint(struct pci_dev *pcidev, 84 - u32 guid, u16 pos); 83 + struct telem_endpoint * 84 + pmt_telem_find_and_register_endpoint(struct device *dev, u32 guid, u16 pos); 85 85 86 86 /** 87 87 * pmt_telem_read() - Read qwords from counter sram using sample id
+13 -10
drivers/platform/x86/intel/rst.c
··· 5 5 6 6 #include <linux/acpi.h> 7 7 #include <linux/module.h> 8 + #include <linux/platform_device.h> 8 9 #include <linux/slab.h> 9 10 10 11 MODULE_DESCRIPTION("Intel Rapid Start Technology Driver"); ··· 100 99 .store = irst_store_wakeup_time 101 100 }; 102 101 103 - static int irst_add(struct acpi_device *acpi) 102 + static int irst_probe(struct platform_device *pdev) 104 103 { 104 + struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev); 105 105 int error; 106 106 107 107 error = device_create_file(&acpi->dev, &irst_timeout_attr); ··· 116 114 return error; 117 115 } 118 116 119 - static void irst_remove(struct acpi_device *acpi) 117 + static void irst_remove(struct platform_device *pdev) 120 118 { 119 + struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev); 120 + 121 121 device_remove_file(&acpi->dev, &irst_wakeup_attr); 122 122 device_remove_file(&acpi->dev, &irst_timeout_attr); 123 123 } ··· 129 125 {"", 0} 130 126 }; 131 127 132 - static struct acpi_driver irst_driver = { 133 - .name = "intel_rapid_start", 134 - .class = "intel_rapid_start", 135 - .ids = irst_ids, 136 - .ops = { 137 - .add = irst_add, 138 - .remove = irst_remove, 128 + static struct platform_driver irst_driver = { 129 + .probe = irst_probe, 130 + .remove = irst_remove, 131 + .driver = { 132 + .name = "intel_rapid_start", 133 + .acpi_match_table = irst_ids, 139 134 }, 140 135 }; 141 136 142 - module_acpi_driver(irst_driver); 137 + module_platform_driver(irst_driver); 143 138 144 139 MODULE_DEVICE_TABLE(acpi, irst_ids);
+3 -2
drivers/platform/x86/intel/sdsi.c
··· 599 599 return 0; 600 600 } 601 601 602 - static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *parent, 602 + static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct device *dev, 603 603 struct disc_table *disc_table, struct resource *disc_res) 604 604 { 605 605 u32 access_type = FIELD_GET(DT_ACCESS_TYPE, disc_table->access_info); 606 606 u32 size = FIELD_GET(DT_SIZE, disc_table->access_info); 607 607 u32 tbir = FIELD_GET(DT_TBIR, disc_table->offset); 608 608 u32 offset = DT_OFFSET(disc_table->offset); 609 + struct pci_dev *parent = to_pci_dev(dev); 609 610 struct resource res = {}; 610 611 611 612 /* Starting location of SDSi MMIO region based on access type */ ··· 682 681 return ret; 683 682 684 683 /* Map the SDSi mailbox registers */ 685 - ret = sdsi_map_mbox_registers(priv, intel_cap_dev->pcidev, &disc_table, disc_res); 684 + ret = sdsi_map_mbox_registers(priv, intel_cap_dev->dev, &disc_table, disc_res); 686 685 if (ret) 687 686 return ret; 688 687
+12 -11
drivers/platform/x86/intel/smartconnect.c
··· 5 5 6 6 #include <linux/acpi.h> 7 7 #include <linux/module.h> 8 + #include <linux/platform_device.h> 8 9 9 10 MODULE_DESCRIPTION("Intel Smart Connect disabling driver"); 10 11 MODULE_LICENSE("GPL"); 11 12 12 - static int smartconnect_acpi_init(struct acpi_device *acpi) 13 + static int smartconnect_acpi_probe(struct platform_device *pdev) 13 14 { 15 + acpi_handle handle = ACPI_HANDLE(&pdev->dev); 14 16 unsigned long long value; 15 17 acpi_status status; 16 18 17 - status = acpi_evaluate_integer(acpi->handle, "GAOS", NULL, &value); 19 + status = acpi_evaluate_integer(handle, "GAOS", NULL, &value); 18 20 if (ACPI_FAILURE(status)) 19 21 return -EINVAL; 20 22 21 23 if (value & 0x1) { 22 - dev_info(&acpi->dev, "Disabling Intel Smart Connect\n"); 23 - status = acpi_execute_simple_method(acpi->handle, "SAOS", 0); 24 + dev_info(&pdev->dev, "Disabling Intel Smart Connect\n"); 25 + status = acpi_execute_simple_method(handle, "SAOS", 0); 24 26 } 25 27 26 28 return 0; ··· 34 32 }; 35 33 MODULE_DEVICE_TABLE(acpi, smartconnect_ids); 36 34 37 - static struct acpi_driver smartconnect_driver = { 38 - .name = "intel_smart_connect", 39 - .class = "intel_smart_connect", 40 - .ids = smartconnect_ids, 41 - .ops = { 42 - .add = smartconnect_acpi_init, 35 + static struct platform_driver smartconnect_driver = { 36 + .probe = smartconnect_acpi_probe, 37 + .driver = { 38 + .name = "intel_smart_connect", 39 + .acpi_match_table = smartconnect_ids, 43 40 }, 44 41 }; 45 42 46 - module_acpi_driver(smartconnect_driver); 43 + module_platform_driver(smartconnect_driver);
+75 -46
drivers/platform/x86/intel/vsec.c
··· 24 24 #include <linux/intel_vsec.h> 25 25 #include <linux/kernel.h> 26 26 #include <linux/module.h> 27 + #include <linux/overflow.h> 27 28 #include <linux/pci.h> 29 + #include <linux/string.h> 28 30 #include <linux/types.h> 29 31 30 32 #define PMT_XA_START 0 ··· 44 42 }; 45 43 46 44 struct vsec_priv { 47 - struct intel_vsec_platform_info *info; 45 + const struct intel_vsec_platform_info *info; 48 46 struct device *suppliers[VSEC_FEATURE_COUNT]; 49 47 struct oobmsm_plat_info plat_info; 50 48 enum vsec_device_state state[VSEC_FEATURE_COUNT]; ··· 111 109 112 110 ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id); 113 111 112 + kfree(intel_vsec_dev->acpi_disc); 114 113 kfree(intel_vsec_dev->resource); 115 114 kfree(intel_vsec_dev); 116 115 } ··· 161 158 */ 162 159 static const struct pci_device_id intel_vsec_pci_ids[]; 163 160 164 - static int intel_vsec_link_devices(struct pci_dev *pdev, struct device *dev, 161 + static int intel_vsec_link_devices(struct device *parent, struct device *dev, 165 162 int consumer_id) 166 163 { 167 164 const struct vsec_feature_dependency *deps; 168 165 enum vsec_device_state *state; 169 166 struct device **suppliers; 170 167 struct vsec_priv *priv; 168 + struct pci_dev *pdev; 171 169 int supplier_id; 172 170 173 171 if (!consumer_id) 174 172 return 0; 175 173 174 + if (!dev_is_pci(parent)) 175 + return 0; 176 + 177 + pdev = to_pci_dev(parent); 176 178 if (!pci_match_id(intel_vsec_pci_ids, pdev)) 177 179 return 0; 178 180 ··· 212 204 return 0; 213 205 } 214 206 215 - int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, 207 + int intel_vsec_add_aux(struct device *parent, 216 208 struct intel_vsec_device *intel_vsec_dev, 217 209 const char *name) 218 210 { ··· 260 252 if (ret) 261 253 goto cleanup_aux; 262 254 263 - ret = intel_vsec_link_devices(pdev, &auxdev->dev, intel_vsec_dev->cap_id); 255 + ret = intel_vsec_link_devices(parent, &auxdev->dev, intel_vsec_dev->cap_id); 264 256 if (ret) 265 257 goto cleanup_aux; 266 258 ··· 277 269 } 278 270 EXPORT_SYMBOL_NS_GPL(intel_vsec_add_aux, "INTEL_VSEC"); 279 271 280 - static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *header, 281 - struct intel_vsec_platform_info *info, 282 - unsigned long cap_id) 272 + static int intel_vsec_add_dev(struct device *dev, struct intel_vsec_header *header, 273 + const struct intel_vsec_platform_info *info, 274 + unsigned long cap_id, u64 base_addr) 283 275 { 284 276 struct intel_vsec_device __free(kfree) *intel_vsec_dev = NULL; 285 277 struct resource __free(kfree) *res = NULL; 286 278 struct resource *tmp; 287 279 struct device *parent; 288 280 unsigned long quirks = info->quirks; 289 - u64 base_addr; 290 281 int i; 291 282 292 283 if (info->parent) 293 284 parent = info->parent; 294 285 else 295 - parent = &pdev->dev; 286 + parent = dev; 296 287 297 288 if (!intel_vsec_supported(header->id, info->caps)) 298 289 return -EINVAL; 299 290 300 291 if (!header->num_entries) { 301 - dev_dbg(&pdev->dev, "Invalid 0 entry count for header id %d\n", header->id); 292 + dev_dbg(dev, "Invalid 0 entry count for header id %d\n", header->id); 302 293 return -EINVAL; 303 294 } 304 295 305 296 if (!header->entry_size) { 306 - dev_dbg(&pdev->dev, "Invalid 0 entry size for header id %d\n", header->id); 297 + dev_dbg(dev, "Invalid 0 entry size for header id %d\n", header->id); 307 298 return -EINVAL; 308 299 } 309 300 ··· 317 310 if (quirks & VSEC_QUIRK_TABLE_SHIFT) 318 311 header->offset >>= TABLE_OFFSET_SHIFT; 319 312 320 - if (info->base_addr) 321 - base_addr = info->base_addr; 322 - else 323 - base_addr = pdev->resource[header->tbir].start; 324 - 325 313 /* 326 314 * The DVSEC/VSEC contains the starting offset and count for a block of 327 315 * discovery tables. Create a resource array of these tables to the 328 316 * auxiliary device driver. 329 317 */ 330 318 for (i = 0, tmp = res; i < header->num_entries; i++, tmp++) { 319 + /* 320 + * Skip resource mapping check for ACPI-based discovery 321 + * since those tables are read from _DSD, not MMIO. 322 + */ 323 + if (info->src == INTEL_VSEC_DISC_ACPI) 324 + break; 325 + 331 326 tmp->start = base_addr + header->offset + i * (header->entry_size * sizeof(u32)); 332 327 tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1; 333 328 tmp->flags = IORESOURCE_MEM; ··· 341 332 release_mem_region(tmp->start, resource_size(tmp)); 342 333 } 343 334 344 - intel_vsec_dev->pcidev = pdev; 335 + intel_vsec_dev->dev = dev; 345 336 intel_vsec_dev->resource = no_free_ptr(res); 346 337 intel_vsec_dev->num_resources = header->num_entries; 347 338 intel_vsec_dev->quirks = info->quirks; 348 339 intel_vsec_dev->base_addr = info->base_addr; 349 340 intel_vsec_dev->priv_data = info->priv_data; 350 341 intel_vsec_dev->cap_id = cap_id; 342 + intel_vsec_dev->src = info->src; 343 + 344 + if (info->src == INTEL_VSEC_DISC_ACPI) { 345 + size_t bytes; 346 + 347 + if (check_mul_overflow(intel_vsec_dev->num_resources, 348 + sizeof(*info->acpi_disc), &bytes)) 349 + return -EOVERFLOW; 350 + 351 + intel_vsec_dev->acpi_disc = kmemdup(info->acpi_disc, bytes, GFP_KERNEL); 352 + if (!intel_vsec_dev->acpi_disc) 353 + return -ENOMEM; 354 + } 351 355 352 356 if (header->id == VSEC_ID_SDSI) 353 357 intel_vsec_dev->ida = &intel_vsec_sdsi_ida; ··· 371 349 * Pass the ownership of intel_vsec_dev and resource within it to 372 350 * intel_vsec_add_aux() 373 351 */ 374 - return intel_vsec_add_aux(pdev, parent, no_free_ptr(intel_vsec_dev), 352 + return intel_vsec_add_aux(parent, no_free_ptr(intel_vsec_dev), 375 353 intel_vsec_name(header->id)); 376 354 } 377 355 ··· 432 410 return 0; 433 411 } 434 412 435 - static int intel_vsec_register_device(struct pci_dev *pdev, 413 + static int intel_vsec_register_device(struct device *dev, 436 414 struct intel_vsec_header *header, 437 - struct intel_vsec_platform_info *info) 415 + const struct intel_vsec_platform_info *info, 416 + u64 base_addr) 438 417 { 439 418 const struct vsec_feature_dependency *consumer_deps; 440 419 struct vsec_priv *priv; 420 + struct pci_dev *pdev; 441 421 unsigned long cap_id; 442 422 int ret; 443 423 ··· 451 427 * Only track dependencies for devices probed by the VSEC driver. 452 428 * For others using the exported APIs, add the device directly. 453 429 */ 430 + if (!dev_is_pci(dev)) 431 + return intel_vsec_add_dev(dev, header, info, cap_id, base_addr); 432 + 433 + pdev = to_pci_dev(dev); 454 434 if (!pci_match_id(intel_vsec_pci_ids, pdev)) 455 - return intel_vsec_add_dev(pdev, header, info, cap_id); 435 + return intel_vsec_add_dev(dev, header, info, cap_id, base_addr); 456 436 457 437 priv = pci_get_drvdata(pdev); 458 438 if (priv->state[cap_id] == STATE_REGISTERED || ··· 472 444 473 445 consumer_deps = get_consumer_dependencies(priv, cap_id); 474 446 if (!consumer_deps || suppliers_ready(priv, consumer_deps, cap_id)) { 475 - ret = intel_vsec_add_dev(pdev, header, info, cap_id); 447 + ret = intel_vsec_add_dev(dev, header, info, cap_id, base_addr); 476 448 if (ret) 477 449 priv->state[cap_id] = STATE_SKIP; 478 450 else ··· 484 456 return -EAGAIN; 485 457 } 486 458 487 - static bool intel_vsec_walk_header(struct pci_dev *pdev, 488 - struct intel_vsec_platform_info *info) 459 + static int intel_vsec_walk_header(struct device *dev, 460 + const struct intel_vsec_platform_info *info) 489 461 { 490 462 struct intel_vsec_header **header = info->headers; 491 - bool have_devices = false; 492 463 int ret; 493 464 494 465 for ( ; *header; header++) { 495 - ret = intel_vsec_register_device(pdev, *header, info); 496 - if (!ret) 497 - have_devices = true; 466 + ret = intel_vsec_register_device(dev, *header, info, info->base_addr); 467 + if (ret) 468 + return ret; 498 469 } 499 470 500 - return have_devices; 471 + return 0; 501 472 } 502 473 503 474 static bool intel_vsec_walk_dvsec(struct pci_dev *pdev, 504 - struct intel_vsec_platform_info *info) 475 + const struct intel_vsec_platform_info *info) 505 476 { 506 477 bool have_devices = false; 507 478 int pos = 0; ··· 539 512 pci_read_config_dword(pdev, pos + PCI_DVSEC_HEADER2, &hdr); 540 513 header.id = PCI_DVSEC_HEADER2_ID(hdr); 541 514 542 - ret = intel_vsec_register_device(pdev, &header, info); 515 + ret = intel_vsec_register_device(&pdev->dev, &header, info, 516 + pci_resource_start(pdev, header.tbir)); 543 517 if (ret) 544 518 continue; 545 519 ··· 551 523 } 552 524 553 525 static bool intel_vsec_walk_vsec(struct pci_dev *pdev, 554 - struct intel_vsec_platform_info *info) 526 + const struct intel_vsec_platform_info *info) 555 527 { 556 528 bool have_devices = false; 557 529 int pos = 0; ··· 585 557 header.tbir = INTEL_DVSEC_TABLE_BAR(table); 586 558 header.offset = INTEL_DVSEC_TABLE_OFFSET(table); 587 559 588 - ret = intel_vsec_register_device(pdev, &header, info); 560 + ret = intel_vsec_register_device(&pdev->dev, &header, info, 561 + pci_resource_start(pdev, header.tbir)); 589 562 if (ret) 590 563 continue; 591 564 ··· 596 567 return have_devices; 597 568 } 598 569 599 - int intel_vsec_register(struct pci_dev *pdev, 600 - struct intel_vsec_platform_info *info) 570 + int intel_vsec_register(struct device *dev, 571 + const struct intel_vsec_platform_info *info) 601 572 { 602 - if (!pdev || !info || !info->headers) 573 + if (!dev || !info || !info->headers) 603 574 return -EINVAL; 604 575 605 - if (!intel_vsec_walk_header(pdev, info)) 606 - return -ENODEV; 607 - else 608 - return 0; 576 + return intel_vsec_walk_header(dev, info); 609 577 } 610 578 EXPORT_SYMBOL_NS_GPL(intel_vsec_register, "INTEL_VSEC"); 611 579 612 580 static bool intel_vsec_get_features(struct pci_dev *pdev, 613 - struct intel_vsec_platform_info *info) 581 + const struct intel_vsec_platform_info *info) 614 582 { 615 583 bool found = false; 616 584 ··· 625 599 found = true; 626 600 627 601 if (info && (info->quirks & VSEC_QUIRK_NO_DVSEC) && 628 - intel_vsec_walk_header(pdev, info)) 602 + intel_vsec_walk_header(&pdev->dev, info)) 629 603 found = true; 630 604 631 605 return found; ··· 651 625 652 626 static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 653 627 { 654 - struct intel_vsec_platform_info *info; 628 + const struct intel_vsec_platform_info *info; 655 629 struct vsec_priv *priv; 656 630 int num_caps, ret; 657 631 int run_once = 0; ··· 662 636 return ret; 663 637 664 638 pci_save_state(pdev); 665 - info = (struct intel_vsec_platform_info *)id->driver_data; 639 + info = (const struct intel_vsec_platform_info *)id->driver_data; 666 640 if (!info) 667 641 return -EINVAL; 668 642 ··· 697 671 { 698 672 struct vsec_priv *priv; 699 673 700 - priv = pci_get_drvdata(vsec_dev->pcidev); 674 + if (!dev_is_pci(vsec_dev->dev)) 675 + return -ENODEV; 676 + 677 + priv = pci_get_drvdata(to_pci_dev(vsec_dev->dev)); 701 678 if (!priv) 702 679 return -EINVAL; 703 680 ··· 848 819 849 820 xa_for_each(&auxdev_array, index, intel_vsec_dev) { 850 821 /* check if pdev doesn't match */ 851 - if (pdev != intel_vsec_dev->pcidev) 822 + if (&pdev->dev != intel_vsec_dev->dev) 852 823 continue; 853 824 devm_release_action(&pdev->dev, intel_vsec_remove_aux, 854 825 &intel_vsec_dev->auxdev);
+8 -4
drivers/platform/x86/intel/vsec_tpmi.c
··· 46 46 * provided by the Intel VSEC driver. 47 47 */ 48 48 49 + #include <linux/align.h> 49 50 #include <linux/auxiliary_bus.h> 50 51 #include <linux/bitfield.h> 51 52 #include <linux/debugfs.h> ··· 480 479 addr = array[2]; 481 480 value = array[3]; 482 481 482 + if (!IS_ALIGNED(addr, sizeof(u32))) 483 + return -EINVAL; 484 + 483 485 if (punit >= pfs->pfs_header.num_entries) { 484 486 ret = -EINVAL; 485 487 goto exit_write; ··· 534 530 .release = single_release, 535 531 }; 536 532 537 - #define tpmi_to_dev(info) (&info->vsec_dev->pcidev->dev) 533 + #define tpmi_to_dev(info) ((info)->vsec_dev->dev) 538 534 539 535 static void tpmi_dbgfs_register(struct intel_tpmi_info *tpmi_info) 540 536 { ··· 646 642 tmp->flags = IORESOURCE_MEM; 647 643 } 648 644 649 - feature_vsec_dev->pcidev = vsec_dev->pcidev; 645 + feature_vsec_dev->dev = vsec_dev->dev; 650 646 feature_vsec_dev->resource = res; 651 647 feature_vsec_dev->num_resources = pfs->pfs_header.num_entries; 652 648 feature_vsec_dev->priv_data = &tpmi_info->plat_info; ··· 659 655 * feature_vsec_dev and res memory are also freed as part of 660 656 * device deletion. 661 657 */ 662 - return intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev, 658 + return intel_vsec_add_aux(&vsec_dev->auxdev.dev, 663 659 feature_vsec_dev, feature_id_name); 664 660 } 665 661 ··· 746 742 static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev) 747 743 { 748 744 struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev); 749 - struct pci_dev *pci_dev = vsec_dev->pcidev; 745 + struct pci_dev *pci_dev = to_pci_dev(vsec_dev->dev); 750 746 struct intel_tpmi_info *tpmi_info; 751 747 u64 pfs_start = 0; 752 748 int ret, i;
+1 -6
drivers/platform/x86/intel/wmi/sbl-fw-update.c
··· 28 28 __le32 *result; 29 29 int ret; 30 30 31 - ret = wmidev_query_block(to_wmi_device(dev), 0, &buffer); 31 + ret = wmidev_query_block(to_wmi_device(dev), 0, &buffer, sizeof(*result)); 32 32 if (ret < 0) 33 33 return ret; 34 - 35 - if (buffer.length < sizeof(*result)) { 36 - kfree(buffer.data); 37 - return -ENODATA; 38 - } 39 34 40 35 result = buffer.data; 41 36 *out = le32_to_cpu(*result);
+1 -1
drivers/platform/x86/intel/wmi/thunderbolt.c
··· 34 34 if (mode > 1) 35 35 return -EINVAL; 36 36 37 - ret = wmidev_invoke_method(to_wmi_device(dev), 0, 1, &buffer, NULL); 37 + ret = wmidev_invoke_procedure(to_wmi_device(dev), 0, 1, &buffer); 38 38 if (ret < 0) 39 39 return ret; 40 40
+1
drivers/platform/x86/lenovo/ideapad-laptop.c
··· 2340 2340 .name = "ideapad_wmi", 2341 2341 }, 2342 2342 .id_table = ideapad_wmi_ids, 2343 + .min_event_size = sizeof(u32), 2343 2344 .probe = ideapad_wmi_probe, 2344 2345 .notify = ideapad_wmi_notify, 2345 2346 };
+82 -111
drivers/platform/x86/lenovo/thinkpad_acpi.c
··· 299 299 300 300 struct tp_acpi_drv_struct { 301 301 const struct acpi_device_id *hid; 302 - struct acpi_driver *driver; 303 302 304 303 void (*notify) (struct ibm_struct *, u32); 305 304 acpi_handle *handle; ··· 321 322 struct tp_acpi_drv_struct *acpi; 322 323 323 324 struct { 324 - u8 acpi_driver_registered:1; 325 325 u8 acpi_notify_installed:1; 326 326 u8 proc_created:1; 327 327 u8 init_called:1; ··· 372 374 u32 hotkey_poll_active:1; 373 375 u32 has_adaptive_kbd:1; 374 376 u32 kbd_lang:1; 375 - u32 trackpoint_doubletap:1; 377 + u32 trackpoint_doubletap_enable:1; 376 378 struct quirk_entry *quirks; 377 379 } tp_features; 378 380 ··· 830 832 vdbg_printk(TPACPI_DBG_INIT, 831 833 "setting up ACPI notify for %s\n", ibm->name); 832 834 833 - ibm->acpi->device = acpi_fetch_acpi_dev(*ibm->acpi->handle); 835 + ibm->acpi->device = acpi_get_acpi_dev(*ibm->acpi->handle); 834 836 if (!ibm->acpi->device) { 835 - pr_err("acpi_fetch_acpi_dev(%s) failed\n", ibm->name); 837 + pr_err("acpi_get_acpi_dev(%s) failed\n", ibm->name); 836 838 return -ENODEV; 837 839 } 838 840 ··· 856 858 ibm->flags.acpi_notify_installed = 1; 857 859 return 0; 858 860 } 859 - 860 - static int __init tpacpi_device_add(struct acpi_device *device) 861 - { 862 - return 0; 863 - } 864 - 865 - static int __init register_tpacpi_subdriver(struct ibm_struct *ibm) 866 - { 867 - int rc; 868 - 869 - dbg_printk(TPACPI_DBG_INIT, 870 - "registering %s as an ACPI driver\n", ibm->name); 871 - 872 - BUG_ON(!ibm->acpi); 873 - 874 - ibm->acpi->driver = kzalloc_obj(struct acpi_driver); 875 - if (!ibm->acpi->driver) { 876 - pr_err("failed to allocate memory for ibm->acpi->driver\n"); 877 - return -ENOMEM; 878 - } 879 - 880 - sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); 881 - ibm->acpi->driver->ids = ibm->acpi->hid; 882 - 883 - ibm->acpi->driver->ops.add = &tpacpi_device_add; 884 - 885 - rc = acpi_bus_register_driver(ibm->acpi->driver); 886 - if (rc < 0) { 887 - pr_err("acpi_bus_register_driver(%s) failed: %d\n", 888 - ibm->name, rc); 889 - kfree(ibm->acpi->driver); 890 - ibm->acpi->driver = NULL; 891 - } else if (!rc) 892 - ibm->flags.acpi_driver_registered = 1; 893 - 894 - return rc; 895 - } 896 - 897 861 898 862 /**************************************************************************** 899 863 **************************************************************************** ··· 1275 1315 static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, struct seq_file *m) 1276 1316 { 1277 1317 if (id >= TPACPI_RFK_SW_MAX) 1278 - seq_printf(m, "status:\t\tnot supported\n"); 1318 + seq_puts(m, "status:\t\tnot supported\n"); 1279 1319 else { 1280 1320 int status; 1281 1321 ··· 1290 1330 } 1291 1331 1292 1332 seq_printf(m, "status:\t\t%s\n", str_enabled_disabled(status == TPACPI_RFK_RADIO_ON)); 1293 - seq_printf(m, "commands:\tenable, disable\n"); 1333 + seq_puts(m, "commands:\tenable, disable\n"); 1294 1334 } 1295 1335 1296 1336 return 0; ··· 2979 3019 .attrs = adaptive_kbd_attributes, 2980 3020 }; 2981 3021 3022 + /* sysfs doubletap enable --------------------------------------------- */ 3023 + static ssize_t doubletap_enable_show(struct device *dev, 3024 + struct device_attribute *attr, 3025 + char *buf) 3026 + { 3027 + return sysfs_emit(buf, "%d\n", tp_features.trackpoint_doubletap_enable); 3028 + } 3029 + 3030 + static ssize_t doubletap_enable_store(struct device *dev, 3031 + struct device_attribute *attr, 3032 + const char *buf, size_t count) 3033 + { 3034 + bool enable; 3035 + int err; 3036 + 3037 + err = kstrtobool(buf, &enable); 3038 + if (err) 3039 + return err; 3040 + 3041 + tp_features.trackpoint_doubletap_enable = enable; 3042 + return count; 3043 + } 3044 + 3045 + static DEVICE_ATTR_RW(doubletap_enable); 3046 + 2982 3047 /* --------------------------------------------------------------------- */ 2983 3048 2984 3049 static struct attribute *hotkey_attributes[] = { ··· 3018 3033 &dev_attr_hotkey_recommended_mask.attr, 3019 3034 &dev_attr_hotkey_tablet_mode.attr, 3020 3035 &dev_attr_hotkey_radio_sw.attr, 3036 + &dev_attr_doubletap_enable.attr, 3021 3037 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 3022 3038 &dev_attr_hotkey_source_mask.attr, 3023 3039 &dev_attr_hotkey_poll_freq.attr, ··· 3544 3558 3545 3559 hotkey_poll_setup_safe(true); 3546 3560 3547 - /* Enable doubletap by default */ 3548 - tp_features.trackpoint_doubletap = 1; 3561 + /* Enable TrackPoint doubletap event reporting by default. */ 3562 + tp_features.trackpoint_doubletap_enable = 1; 3549 3563 3550 3564 return 0; 3551 3565 } ··· 3850 3864 { 3851 3865 switch (hkey) { 3852 3866 case TP_HKEY_EV_TRACK_DOUBLETAP: 3853 - if (tp_features.trackpoint_doubletap) 3854 - tpacpi_input_send_key(hkey, send_acpi_ev); 3855 - 3867 + /* Only send event if doubletap is enabled */ 3868 + if (!tp_features.trackpoint_doubletap_enable) 3869 + *send_acpi_ev = false; 3856 3870 return true; 3857 3871 default: 3858 3872 return false; ··· 4003 4017 int res, status; 4004 4018 4005 4019 if (!tp_features.hotkey) { 4006 - seq_printf(m, "status:\t\tnot supported\n"); 4020 + seq_puts(m, "status:\t\tnot supported\n"); 4007 4021 return 0; 4008 4022 } 4009 4023 ··· 4019 4033 seq_printf(m, "status:\t\t%s\n", str_enabled_disabled(status & BIT(0))); 4020 4034 if (hotkey_all_mask) { 4021 4035 seq_printf(m, "mask:\t\t0x%08x\n", hotkey_user_mask); 4022 - seq_printf(m, "commands:\tenable, disable, reset, <mask>\n"); 4036 + seq_puts(m, "commands:\tenable, disable, reset, <mask>\n"); 4023 4037 } else { 4024 - seq_printf(m, "mask:\t\tnot supported\n"); 4025 - seq_printf(m, "commands:\tenable, disable, reset\n"); 4038 + seq_puts(m, "mask:\t\tnot supported\n"); 4039 + seq_puts(m, "commands:\tenable, disable, reset\n"); 4026 4040 } 4027 4041 4028 4042 return 0; ··· 4919 4933 int status, autosw; 4920 4934 4921 4935 if (video_supported == TPACPI_VIDEO_NONE) { 4922 - seq_printf(m, "status:\t\tnot supported\n"); 4936 + seq_puts(m, "status:\t\tnot supported\n"); 4923 4937 return 0; 4924 4938 } 4925 4939 ··· 4935 4949 if (autosw < 0) 4936 4950 return autosw; 4937 4951 4938 - seq_printf(m, "status:\t\tsupported\n"); 4952 + seq_puts(m, "status:\t\tsupported\n"); 4939 4953 seq_printf(m, "lcd:\t\t%s\n", str_enabled_disabled(status & BIT(0))); 4940 4954 seq_printf(m, "crt:\t\t%s\n", str_enabled_disabled(status & BIT(1))); 4941 4955 if (video_supported == TPACPI_VIDEO_NEW) 4942 4956 seq_printf(m, "dvi:\t\t%s\n", str_enabled_disabled(status & BIT(3))); 4943 4957 seq_printf(m, "auto:\t\t%s\n", str_enabled_disabled(autosw & BIT(0))); 4944 - seq_printf(m, "commands:\tlcd_enable, lcd_disable\n"); 4945 - seq_printf(m, "commands:\tcrt_enable, crt_disable\n"); 4958 + seq_puts(m, "commands:\tlcd_enable, lcd_disable\n"); 4959 + seq_puts(m, "commands:\tcrt_enable, crt_disable\n"); 4946 4960 if (video_supported == TPACPI_VIDEO_NEW) 4947 - seq_printf(m, "commands:\tdvi_enable, dvi_disable\n"); 4948 - seq_printf(m, "commands:\tauto_enable, auto_disable\n"); 4949 - seq_printf(m, "commands:\tvideo_switch, expand_toggle\n"); 4961 + seq_puts(m, "commands:\tdvi_enable, dvi_disable\n"); 4962 + seq_puts(m, "commands:\tauto_enable, auto_disable\n"); 4963 + seq_puts(m, "commands:\tvideo_switch, expand_toggle\n"); 4950 4964 4951 4965 return 0; 4952 4966 } ··· 5190 5204 int level; 5191 5205 5192 5206 if (!tp_features.kbdlight) { 5193 - seq_printf(m, "status:\t\tnot supported\n"); 5207 + seq_puts(m, "status:\t\tnot supported\n"); 5194 5208 } else { 5195 5209 level = kbdlight_get_level(); 5196 5210 if (level < 0) 5197 5211 seq_printf(m, "status:\t\terror %d\n", level); 5198 5212 else 5199 5213 seq_printf(m, "status:\t\t%d\n", level); 5200 - seq_printf(m, "commands:\t0, 1, 2\n"); 5214 + seq_puts(m, "commands:\t0, 1, 2\n"); 5201 5215 } 5202 5216 5203 5217 return 0; ··· 5364 5378 int status; 5365 5379 5366 5380 if (!tp_features.light) { 5367 - seq_printf(m, "status:\t\tnot supported\n"); 5381 + seq_puts(m, "status:\t\tnot supported\n"); 5368 5382 } else if (!tp_features.light_status) { 5369 - seq_printf(m, "status:\t\tunknown\n"); 5370 - seq_printf(m, "commands:\ton, off\n"); 5383 + seq_puts(m, "status:\t\tunknown\n"); 5384 + seq_puts(m, "commands:\ton, off\n"); 5371 5385 } else { 5372 5386 status = light_get_status(); 5373 5387 if (status < 0) 5374 5388 return status; 5375 5389 seq_printf(m, "status:\t\t%s\n", str_on_off(status & BIT(0))); 5376 - seq_printf(m, "commands:\ton, off\n"); 5390 + seq_puts(m, "commands:\ton, off\n"); 5377 5391 } 5378 5392 5379 5393 return 0; ··· 5463 5477 /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, 5464 5478 R30, R31, T20-22, X20-21 */ 5465 5479 if (!cmos_handle) 5466 - seq_printf(m, "status:\t\tnot supported\n"); 5480 + seq_puts(m, "status:\t\tnot supported\n"); 5467 5481 else { 5468 - seq_printf(m, "status:\t\tsupported\n"); 5469 - seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); 5482 + seq_puts(m, "status:\t\tsupported\n"); 5483 + seq_puts(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); 5470 5484 } 5471 5485 5472 5486 return 0; ··· 5832 5846 static int led_read(struct seq_file *m) 5833 5847 { 5834 5848 if (!led_supported) { 5835 - seq_printf(m, "status:\t\tnot supported\n"); 5849 + seq_puts(m, "status:\t\tnot supported\n"); 5836 5850 return 0; 5837 5851 } 5838 - seq_printf(m, "status:\t\tsupported\n"); 5852 + seq_puts(m, "status:\t\tsupported\n"); 5839 5853 5840 5854 if (led_supported == TPACPI_LED_570) { 5841 5855 /* 570 */ ··· 5848 5862 } 5849 5863 } 5850 5864 5851 - seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); 5865 + seq_puts(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); 5852 5866 5853 5867 return 0; 5854 5868 } ··· 5932 5946 static int beep_read(struct seq_file *m) 5933 5947 { 5934 5948 if (!beep_handle) 5935 - seq_printf(m, "status:\t\tnot supported\n"); 5949 + seq_puts(m, "status:\t\tnot supported\n"); 5936 5950 else { 5937 - seq_printf(m, "status:\t\tsupported\n"); 5938 - seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); 5951 + seq_puts(m, "status:\t\tsupported\n"); 5952 + seq_puts(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); 5939 5953 } 5940 5954 5941 5955 return 0; ··· 6384 6398 if (unlikely(n < 0)) 6385 6399 return n; 6386 6400 6387 - seq_printf(m, "temperatures:\t"); 6401 + seq_puts(m, "temperatures:\t"); 6388 6402 6389 6403 if (n > 0) { 6390 6404 for (i = 0; i < (n - 1); i++) 6391 6405 seq_printf(m, "%d ", t.temp[i] / 1000); 6392 6406 seq_printf(m, "%d\n", t.temp[i] / 1000); 6393 6407 } else 6394 - seq_printf(m, "not supported\n"); 6408 + seq_puts(m, "not supported\n"); 6395 6409 6396 6410 return 0; 6397 6411 } ··· 6904 6918 6905 6919 level = brightness_get(NULL); 6906 6920 if (level < 0) { 6907 - seq_printf(m, "level:\t\tunreadable\n"); 6921 + seq_puts(m, "level:\t\tunreadable\n"); 6908 6922 } else { 6909 6923 seq_printf(m, "level:\t\t%d\n", level); 6910 - seq_printf(m, "commands:\tup, down\n"); 6924 + seq_puts(m, "commands:\tup, down\n"); 6911 6925 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", 6912 6926 bright_maxlvl); 6913 6927 } ··· 7623 7637 u8 status; 7624 7638 7625 7639 if (volume_get_status(&status) < 0) { 7626 - seq_printf(m, "level:\t\tunreadable\n"); 7640 + seq_puts(m, "level:\t\tunreadable\n"); 7627 7641 } else { 7628 7642 if (tp_features.mixer_no_level_control) 7629 - seq_printf(m, "level:\t\tunsupported\n"); 7643 + seq_puts(m, "level:\t\tunsupported\n"); 7630 7644 else 7631 7645 seq_printf(m, "level:\t\t%d\n", 7632 7646 status & TP_EC_AUDIO_LVL_MSK); ··· 7634 7648 seq_printf(m, "mute:\t\t%s\n", str_on_off(status & BIT(TP_EC_AUDIO_MUTESW))); 7635 7649 7636 7650 if (volume_control_allowed) { 7637 - seq_printf(m, "commands:\tunmute, mute\n"); 7651 + seq_puts(m, "commands:\tunmute, mute\n"); 7638 7652 if (!tp_features.mixer_no_level_control) { 7639 - seq_printf(m, "commands:\tup, down\n"); 7653 + seq_puts(m, "commands:\tup, down\n"); 7640 7654 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", 7641 7655 TP_EC_VOLUME_MAX); 7642 7656 } ··· 9142 9156 } else if (fan_status_access_mode == TPACPI_FAN_RD_TPEC) { 9143 9157 if (status & TP_EC_FAN_FULLSPEED) 9144 9158 /* Disengaged mode takes precedence */ 9145 - seq_printf(m, "level:\t\tdisengaged\n"); 9159 + seq_puts(m, "level:\t\tdisengaged\n"); 9146 9160 else if (status & TP_EC_FAN_AUTO) 9147 - seq_printf(m, "level:\t\tauto\n"); 9161 + seq_puts(m, "level:\t\tauto\n"); 9148 9162 else 9149 9163 seq_printf(m, "level:\t\t%d\n", status); 9150 9164 } ··· 9152 9166 9153 9167 case TPACPI_FAN_NONE: 9154 9168 default: 9155 - seq_printf(m, "status:\t\tnot supported\n"); 9169 + seq_puts(m, "status:\t\tnot supported\n"); 9156 9170 } 9157 9171 9158 9172 if (fan_control_commands & TPACPI_FAN_CMD_LEVEL) { 9159 - seq_printf(m, "commands:\tlevel <level>"); 9173 + seq_puts(m, "commands:\tlevel <level>"); 9160 9174 9161 9175 switch (fan_control_access_mode) { 9162 9176 case TPACPI_FAN_WR_ACPI_SFAN: 9163 - seq_printf(m, " (<level> is 0-7)\n"); 9177 + seq_puts(m, " (<level> is 0-7)\n"); 9164 9178 break; 9165 9179 9166 9180 default: 9167 - seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); 9181 + seq_puts(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); 9168 9182 break; 9169 9183 } 9170 9184 } ··· 9174 9188 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); 9175 9189 9176 9190 if (fan_control_commands & TPACPI_FAN_CMD_SPEED) 9177 - seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); 9191 + seq_puts(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); 9178 9192 9179 9193 return 0; 9180 9194 } ··· 9234 9248 static int fan_write_cmd_speed(const char *cmd, int *rc) 9235 9249 { 9236 9250 int speed; 9237 - 9238 - /* TODO: 9239 - * Support speed <low> <medium> <high> ? */ 9240 9251 9241 9252 if (sscanf(cmd, "speed %d", &speed) != 1) 9242 9253 return 0; ··· 11471 11488 mutex_unlock(&tpacpi_inputdev_send_mutex); 11472 11489 return true; 11473 11490 case TP_HKEY_EV_DOUBLETAP_TOGGLE: 11474 - tp_features.trackpoint_doubletap = !tp_features.trackpoint_doubletap; 11491 + /* Toggle kernel-level doubletap event filtering */ 11492 + tp_features.trackpoint_doubletap_enable = 11493 + !tp_features.trackpoint_doubletap_enable; 11475 11494 return true; 11476 11495 case TP_HKEY_EV_PROFILE_TOGGLE: 11477 11496 case TP_HKEY_EV_PROFILE_TOGGLE2: ··· 11517 11532 acpi_remove_notify_handler(*ibm->acpi->handle, 11518 11533 ibm->acpi->type, 11519 11534 dispatch_acpi_notify); 11535 + ibm->acpi->device->driver_data = NULL; 11536 + acpi_dev_put(ibm->acpi->device); 11520 11537 ibm->flags.acpi_notify_installed = 0; 11521 11538 } 11522 11539 ··· 11527 11540 "%s: remove_proc_entry\n", ibm->name); 11528 11541 remove_proc_entry(ibm->name, proc_dir); 11529 11542 ibm->flags.proc_created = 0; 11530 - } 11531 - 11532 - if (ibm->flags.acpi_driver_registered) { 11533 - dbg_printk(TPACPI_DBG_EXIT, 11534 - "%s: acpi_bus_unregister_driver\n", ibm->name); 11535 - BUG_ON(!ibm->acpi); 11536 - acpi_bus_unregister_driver(ibm->acpi->driver); 11537 - kfree(ibm->acpi->driver); 11538 - ibm->acpi->driver = NULL; 11539 - ibm->flags.acpi_driver_registered = 0; 11540 11543 } 11541 11544 11542 11545 if (ibm->flags.init_called && ibm->exit) { ··· 11564 11587 } 11565 11588 11566 11589 if (ibm->acpi) { 11567 - if (ibm->acpi->hid) { 11568 - ret = register_tpacpi_subdriver(ibm); 11569 - if (ret) 11570 - goto err_out; 11571 - } 11572 - 11573 11590 if (ibm->acpi->notify) { 11574 11591 ret = setup_acpi_notify(ibm); 11575 11592 if (ret == -ENODEV) {
+1
drivers/platform/x86/lenovo/wmi-camera.c
··· 134 134 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 135 135 }, 136 136 .id_table = lenovo_wmi_id_table, 137 + .min_event_size = sizeof(u8), 137 138 .no_singleton = true, 138 139 .probe = lenovo_wmi_probe, 139 140 .notify = lenovo_wmi_notify,
+1
drivers/platform/x86/lenovo/wmi-events.c
··· 183 183 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 184 184 }, 185 185 .id_table = lwmi_events_id_table, 186 + .min_event_size = sizeof(u32), 186 187 .probe = lwmi_events_probe, 187 188 .notify = lwmi_events_notify, 188 189 .no_singleton = true,
+1
drivers/platform/x86/lenovo/ymc.c
··· 153 153 .name = "lenovo-ymc", 154 154 }, 155 155 .id_table = lenovo_ymc_wmi_id_table, 156 + .min_event_size = sizeof(u32), 156 157 .probe = lenovo_ymc_probe, 157 158 .notify = lenovo_ymc_notify, 158 159 };
+1 -1
drivers/platform/x86/lenovo/yogabook.c
··· 411 411 .name = "yogabook-wmi", 412 412 .pm = pm_sleep_ptr(&yogabook_pm_ops), 413 413 }, 414 - .no_notify_data = true, 415 414 .id_table = yogabook_wmi_id_table, 415 + .min_event_size = 0, 416 416 .probe = yogabook_wmi_probe, 417 417 .remove = yogabook_wmi_remove, 418 418 .notify = yogabook_wmi_notify,
+13 -38
drivers/platform/x86/lg-laptop.c
··· 271 271 } 272 272 } 273 273 274 - static void acpi_notify(struct acpi_device *device, u32 event) 275 - { 276 - acpi_handle_debug(device->handle, "notify: %d\n", event); 277 - } 278 - 279 274 static ssize_t fan_mode_store(struct device *dev, 280 275 struct device_attribute *attr, 281 276 const char *buffer, size_t count) ··· 759 764 &lg_laptop_address_space_handler); 760 765 } 761 766 762 - static int acpi_add(struct acpi_device *device) 767 + static int acpi_probe(struct platform_device *pdev) 763 768 { 769 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 764 770 struct platform_device_info pdev_info = { 765 771 .fwnode = acpi_fwnode_handle(device), 766 772 .name = PLATFORM_NAME, ··· 777 781 778 782 status = acpi_install_address_space_handler(device->handle, LG_ADDRESS_SPACE_ID, 779 783 &lg_laptop_address_space_handler, 780 - NULL, &device->dev); 784 + NULL, &pdev->dev); 781 785 if (ACPI_FAILURE(status)) 782 786 return -ENODEV; 783 787 784 - ret = devm_add_action_or_reset(&device->dev, lg_laptop_remove_address_space_handler, 788 + ret = devm_add_action_or_reset(&pdev->dev, lg_laptop_remove_address_space_handler, 785 789 device); 786 790 if (ret < 0) 787 791 return ret; ··· 875 879 return ret; 876 880 } 877 881 878 - static void acpi_remove(struct acpi_device *device) 882 + static void acpi_remove(struct platform_device *pdev) 879 883 { 880 884 sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group); 881 885 ··· 895 899 }; 896 900 MODULE_DEVICE_TABLE(acpi, device_ids); 897 901 898 - static struct acpi_driver acpi_driver = { 899 - .name = "LG Gram Laptop Support", 900 - .class = "lg-laptop", 901 - .ids = device_ids, 902 - .ops = { 903 - .add = acpi_add, 904 - .remove = acpi_remove, 905 - .notify = acpi_notify, 906 - }, 902 + static struct platform_driver acpi_driver = { 903 + .probe = acpi_probe, 904 + .remove = acpi_remove, 905 + .driver = { 906 + .name = "LG Gram Laptop Support", 907 + .acpi_match_table = device_ids, 908 + }, 907 909 }; 908 910 909 - static int __init acpi_init(void) 910 - { 911 - int result; 912 - 913 - result = acpi_bus_register_driver(&acpi_driver); 914 - if (result < 0) { 915 - pr_debug("Error registering driver\n"); 916 - return -ENODEV; 917 - } 918 - 919 - return 0; 920 - } 921 - 922 - static void __exit acpi_exit(void) 923 - { 924 - acpi_bus_unregister_driver(&acpi_driver); 925 - } 926 - 927 - module_init(acpi_init); 928 - module_exit(acpi_exit); 911 + module_platform_driver(acpi_driver);
-12
drivers/platform/x86/mxm-wmi.c
··· 80 80 return guid_valid; 81 81 } 82 82 EXPORT_SYMBOL_GPL(mxm_wmi_supported); 83 - 84 - static int __init mxm_wmi_init(void) 85 - { 86 - return 0; 87 - } 88 - 89 - static void __exit mxm_wmi_exit(void) 90 - { 91 - } 92 - 93 - module_init(mxm_wmi_init); 94 - module_exit(mxm_wmi_exit);
+39 -40
drivers/platform/x86/panasonic-laptop.c
··· 183 183 }; 184 184 /* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */ 185 185 186 - static int acpi_pcc_hotkey_add(struct acpi_device *device); 187 - static void acpi_pcc_hotkey_remove(struct acpi_device *device); 188 - static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event); 186 + static int acpi_pcc_hotkey_probe(struct platform_device *pdev); 187 + static void acpi_pcc_hotkey_remove(struct platform_device *pdev); 188 + static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data); 189 189 190 190 static const struct acpi_device_id pcc_device_ids[] = { 191 191 { "MAT0012", 0}, ··· 201 201 #endif 202 202 static SIMPLE_DEV_PM_OPS(acpi_pcc_hotkey_pm, NULL, acpi_pcc_hotkey_resume); 203 203 204 - static struct acpi_driver acpi_pcc_driver = { 205 - .name = ACPI_PCC_DRIVER_NAME, 206 - .class = ACPI_PCC_CLASS, 207 - .ids = pcc_device_ids, 208 - .ops = { 209 - .add = acpi_pcc_hotkey_add, 210 - .remove = acpi_pcc_hotkey_remove, 211 - .notify = acpi_pcc_hotkey_notify, 212 - }, 213 - .drv.pm = &acpi_pcc_hotkey_pm, 204 + static struct platform_driver acpi_pcc_driver = { 205 + .probe = acpi_pcc_hotkey_probe, 206 + .remove = acpi_pcc_hotkey_remove, 207 + .driver = { 208 + .name = ACPI_PCC_DRIVER_NAME, 209 + .acpi_match_table = pcc_device_ids, 210 + .pm = &acpi_pcc_hotkey_pm, 211 + }, 214 212 }; 215 213 216 214 static const struct key_entry panasonic_keymap[] = { ··· 867 869 pr_err("Unknown hotkey event: 0x%04llx\n", result); 868 870 } 869 871 870 - static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event) 872 + static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data) 871 873 { 872 - struct pcc_acpi *pcc = acpi_driver_data(device); 874 + struct pcc_acpi *pcc = data; 873 875 874 876 switch (event) { 875 877 case HKEY_NOTIFY: ··· 889 891 set_optd_power_state(0); 890 892 } 891 893 892 - static int pcc_register_optd_notifier(struct pcc_acpi *pcc, char *node) 894 + static void pcc_register_optd_notifier(struct pcc_acpi *pcc, char *node) 893 895 { 894 896 acpi_status status; 895 897 acpi_handle handle; ··· 902 904 pcc_optd_notify, pcc); 903 905 if (ACPI_FAILURE(status)) 904 906 pr_err("Failed to register notify on %s\n", node); 905 - } else 906 - return -ENODEV; 907 - 908 - return 0; 907 + } 909 908 } 910 909 911 910 static void pcc_unregister_optd_notifier(struct pcc_acpi *pcc, char *node) ··· 963 968 #ifdef CONFIG_PM_SLEEP 964 969 static int acpi_pcc_hotkey_resume(struct device *dev) 965 970 { 966 - struct pcc_acpi *pcc; 967 - 968 - if (!dev) 969 - return -EINVAL; 970 - 971 - pcc = acpi_driver_data(to_acpi_device(dev)); 972 - if (!pcc) 973 - return -EINVAL; 971 + struct pcc_acpi *pcc = acpi_driver_data(ACPI_COMPANION(dev)); 974 972 975 973 if (pcc->num_sifr > SINF_MUTE) 976 974 acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute); ··· 979 991 } 980 992 #endif 981 993 982 - static int acpi_pcc_hotkey_add(struct acpi_device *device) 994 + static int acpi_pcc_hotkey_probe(struct platform_device *pdev) 983 995 { 996 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 984 997 struct backlight_properties props; 985 998 struct pcc_acpi *pcc; 986 999 int num_sifr, result; 987 - 988 - if (!device) 989 - return -EINVAL; 990 1000 991 1001 num_sifr = acpi_pcc_get_sqty(device); 992 1002 ··· 1069 1083 if (result) 1070 1084 goto out_backlight; 1071 1085 1086 + result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 1087 + acpi_pcc_hotkey_notify, pcc); 1088 + if (result) 1089 + goto out_sysfs; 1090 + 1072 1091 /* optical drive initialization */ 1073 1092 if (ACPI_SUCCESS(check_optd_present())) { 1074 1093 pcc->platform = platform_device_register_simple("panasonic", 1075 1094 PLATFORM_DEVID_NONE, NULL, 0); 1076 1095 if (IS_ERR(pcc->platform)) { 1077 1096 result = PTR_ERR(pcc->platform); 1078 - goto out_sysfs; 1097 + goto out_notify_handler; 1079 1098 } 1080 1099 result = device_create_file(&pcc->platform->dev, 1081 1100 &dev_attr_cdpower); 1082 - pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD"); 1083 1101 if (result) 1084 1102 goto out_platform; 1103 + 1104 + pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD"); 1085 1105 } else { 1086 1106 pcc->platform = NULL; 1087 1107 } ··· 1097 1105 1098 1106 out_platform: 1099 1107 platform_device_unregister(pcc->platform); 1108 + out_notify_handler: 1109 + acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 1110 + acpi_pcc_hotkey_notify); 1100 1111 out_sysfs: 1101 1112 sysfs_remove_group(&device->dev.kobj, &pcc_attr_group); 1102 1113 out_backlight: ··· 1107 1112 out_input: 1108 1113 input_unregister_device(pcc->input_dev); 1109 1114 out_sinf: 1115 + device->driver_data = NULL; 1110 1116 kfree(pcc->sinf); 1111 1117 out_hotkey: 1112 1118 kfree(pcc); ··· 1115 1119 return result; 1116 1120 } 1117 1121 1118 - static void acpi_pcc_hotkey_remove(struct acpi_device *device) 1122 + static void acpi_pcc_hotkey_remove(struct platform_device *pdev) 1119 1123 { 1124 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1120 1125 struct pcc_acpi *pcc = acpi_driver_data(device); 1121 - 1122 - if (!device || !pcc) 1123 - return; 1124 1126 1125 1127 i8042_remove_filter(panasonic_i8042_filter); 1126 1128 1127 1129 if (pcc->platform) { 1130 + pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD"); 1128 1131 device_remove_file(&pcc->platform->dev, &dev_attr_cdpower); 1129 1132 platform_device_unregister(pcc->platform); 1130 1133 } 1131 - pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD"); 1134 + 1135 + acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 1136 + acpi_pcc_hotkey_notify); 1132 1137 1133 1138 sysfs_remove_group(&device->dev.kobj, &pcc_attr_group); 1134 1139 ··· 1137 1140 1138 1141 input_unregister_device(pcc->input_dev); 1139 1142 1143 + device->driver_data = NULL; 1144 + 1140 1145 kfree(pcc->sinf); 1141 1146 kfree(pcc); 1142 1147 } 1143 1148 1144 - module_acpi_driver(acpi_pcc_driver); 1149 + module_platform_driver(acpi_pcc_driver);
+2 -1
drivers/platform/x86/pcengines-apuv2.c
··· 294 294 } 295 295 296 296 apu_gpio_pdev = apu_create_pdev(AMD_FCH_GPIO_DRIVER_NAME, 297 - id->driver_data, sizeof(struct amd_fch_gpio_pdata), NULL); 297 + id->driver_data, sizeof(struct amd_fch_gpio_pdata), 298 + &apu2_gpiochip_node); 298 299 err = PTR_ERR_OR_ZERO(apu_gpio_pdev); 299 300 if (err) 300 301 goto err_unregister_swnodes;
+1
drivers/platform/x86/redmi-wmi.c
··· 141 141 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 142 142 }, 143 143 .id_table = redmi_wmi_id_table, 144 + .min_event_size = 32, 144 145 .probe = redmi_wmi_probe, 145 146 .notify = redmi_wmi_notify, 146 147 .no_singleton = true,
+62 -60
drivers/platform/x86/sony-laptop.c
··· 178 178 static int sony_rfkill_handle; 179 179 static struct rfkill *sony_rfkill_devices[N_SONY_RFKILL]; 180 180 static int sony_rfkill_address[N_SONY_RFKILL] = {0x300, 0x500, 0x700, 0x900}; 181 - static int sony_nc_rfkill_setup(struct acpi_device *device, 182 - unsigned int handle); 181 + static int sony_nc_rfkill_setup(struct device *dev, unsigned int handle); 183 182 static void sony_nc_rfkill_cleanup(void); 184 183 static void sony_nc_rfkill_update(void); 185 184 ··· 434 435 dprintk("unknown input event %.2x\n", event); 435 436 } 436 437 437 - static int sony_laptop_setup_input(struct acpi_device *acpi_device) 438 + static int sony_laptop_setup_input(struct device *parent) 438 439 { 439 440 struct input_dev *jog_dev; 440 441 struct input_dev *key_dev; ··· 467 468 key_dev->name = "Sony Vaio Keys"; 468 469 key_dev->id.bustype = BUS_ISA; 469 470 key_dev->id.vendor = PCI_VENDOR_ID_SONY; 470 - key_dev->dev.parent = &acpi_device->dev; 471 + key_dev->dev.parent = parent; 471 472 472 473 /* Initialize the Input Drivers: special keys */ 473 474 input_set_capability(key_dev, EV_MSC, MSC_SCAN); ··· 496 497 jog_dev->name = "Sony Vaio Jogdial"; 497 498 jog_dev->id.bustype = BUS_ISA; 498 499 jog_dev->id.vendor = PCI_VENDOR_ID_SONY; 499 - jog_dev->dev.parent = &acpi_device->dev; 500 + jog_dev->dev.parent = parent; 500 501 501 502 input_set_capability(jog_dev, EV_KEY, BTN_MIDDLE); 502 503 input_set_capability(jog_dev, EV_REL, REL_WHEEL); ··· 1175 1176 KILLSWITCH, 1176 1177 GFX_SWITCH 1177 1178 }; 1178 - static void sony_nc_notify(struct acpi_device *device, u32 event) 1179 + static void sony_nc_notify(acpi_handle ah, u32 event, void *data) 1179 1180 { 1180 1181 u32 real_ev = event; 1181 1182 u8 ev_type = 0; ··· 1286 1287 /* 1287 1288 * ACPI device 1288 1289 */ 1289 - static void sony_nc_function_setup(struct acpi_device *device, 1290 + static void sony_nc_function_setup(struct device *dev, 1290 1291 struct platform_device *pf_device) 1291 1292 { 1292 1293 unsigned int i, result, bitmask, arg; ··· 1359 1360 break; 1360 1361 case 0x0124: 1361 1362 case 0x0135: 1362 - result = sony_nc_rfkill_setup(device, handle); 1363 + result = sony_nc_rfkill_setup(dev, handle); 1363 1364 if (result) 1364 1365 pr_err("couldn't set up rfkill support (%d)\n", 1365 1366 result); ··· 1599 1600 .set_block = sony_nc_rfkill_set, 1600 1601 }; 1601 1602 1602 - static int sony_nc_setup_rfkill(struct acpi_device *device, 1603 - enum sony_nc_rfkill nc_type) 1603 + static int sony_nc_setup_rfkill(struct device *parent, enum sony_nc_rfkill nc_type) 1604 1604 { 1605 1605 int err; 1606 1606 struct rfkill *rfk; ··· 1629 1631 return -EINVAL; 1630 1632 } 1631 1633 1632 - rfk = rfkill_alloc(name, &device->dev, type, 1633 - &sony_rfkill_ops, (void *)nc_type); 1634 + rfk = rfkill_alloc(name, parent, type, &sony_rfkill_ops, (void *)nc_type); 1634 1635 if (!rfk) 1635 1636 return -ENOMEM; 1636 1637 ··· 1689 1692 } 1690 1693 } 1691 1694 1692 - static int sony_nc_rfkill_setup(struct acpi_device *device, 1693 - unsigned int handle) 1695 + static int sony_nc_rfkill_setup(struct device *parent, unsigned int handle) 1694 1696 { 1695 1697 u64 offset; 1696 1698 int i; ··· 1730 1734 dprintk("Radio devices, found 0x%.2x\n", buffer[i]); 1731 1735 1732 1736 if (buffer[i] == 0 && !sony_rfkill_devices[SONY_WIFI]) 1733 - sony_nc_setup_rfkill(device, SONY_WIFI); 1737 + sony_nc_setup_rfkill(parent, SONY_WIFI); 1734 1738 1735 1739 if (buffer[i] == 0x10 && !sony_rfkill_devices[SONY_BLUETOOTH]) 1736 - sony_nc_setup_rfkill(device, SONY_BLUETOOTH); 1740 + sony_nc_setup_rfkill(parent, SONY_BLUETOOTH); 1737 1741 1738 1742 if (((0xf0 & buffer[i]) == 0x20 || 1739 1743 (0xf0 & buffer[i]) == 0x50) && 1740 1744 !sony_rfkill_devices[SONY_WWAN]) 1741 - sony_nc_setup_rfkill(device, SONY_WWAN); 1745 + sony_nc_setup_rfkill(parent, SONY_WWAN); 1742 1746 1743 1747 if (buffer[i] == 0x30 && !sony_rfkill_devices[SONY_WIMAX]) 1744 - sony_nc_setup_rfkill(device, SONY_WIMAX); 1748 + sony_nc_setup_rfkill(parent, SONY_WIMAX); 1745 1749 } 1746 1750 return 0; 1747 1751 } ··· 3145 3149 backlight_device_unregister(sony_bl_props.dev); 3146 3150 } 3147 3151 3148 - static int sony_nc_add(struct acpi_device *device) 3152 + static int sony_nc_probe(struct platform_device *pdev) 3149 3153 { 3154 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 3150 3155 acpi_status status; 3151 3156 int result = 0; 3152 3157 struct sony_nc_value *item; ··· 3181 3184 } 3182 3185 } 3183 3186 3184 - result = sony_laptop_setup_input(device); 3187 + result = sony_laptop_setup_input(&pdev->dev); 3185 3188 if (result) { 3186 3189 pr_err("Unable to create input devices\n"); 3187 3190 goto outplatform; ··· 3198 3201 /* retrieve the available handles */ 3199 3202 result = sony_nc_handles_setup(sony_pf_device); 3200 3203 if (!result) 3201 - sony_nc_function_setup(device, sony_pf_device); 3204 + sony_nc_function_setup(&pdev->dev, sony_pf_device); 3202 3205 } 3203 3206 3204 3207 if (acpi_video_get_backlight_type() == acpi_backlight_vendor) ··· 3241 3244 } 3242 3245 } 3243 3246 3247 + result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 3248 + sony_nc_notify, NULL); 3249 + if (result) 3250 + goto out_sysfs; 3251 + 3244 3252 pr_info("SNC setup done.\n"); 3245 3253 return 0; 3246 3254 ··· 3268 3266 return result; 3269 3267 } 3270 3268 3271 - static void sony_nc_remove(struct acpi_device *device) 3269 + static void sony_nc_remove(struct platform_device *pdev) 3272 3270 { 3273 3271 struct sony_nc_value *item; 3272 + 3273 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 3274 + ACPI_DEVICE_NOTIFY, sony_nc_notify); 3274 3275 3275 3276 sony_nc_backlight_cleanup(); 3276 3277 ··· 3302 3297 {"", 0}, 3303 3298 }; 3304 3299 3305 - static struct acpi_driver sony_nc_driver = { 3306 - .name = SONY_NC_DRIVER_NAME, 3307 - .class = SONY_NC_CLASS, 3308 - .ids = sony_nc_device_ids, 3309 - .ops = { 3310 - .add = sony_nc_add, 3311 - .remove = sony_nc_remove, 3312 - .notify = sony_nc_notify, 3313 - }, 3314 - .drv.pm = &sony_nc_pm, 3300 + static struct platform_driver sony_nc_driver = { 3301 + .probe = sony_nc_probe, 3302 + .remove = sony_nc_remove, 3303 + .driver = { 3304 + .name = SONY_NC_DRIVER_NAME, 3305 + .acpi_match_table = sony_nc_device_ids, 3306 + .pm = &sony_nc_pm, 3307 + }, 3315 3308 }; 3316 3309 3317 3310 /*********** SPIC (SNY6001) Device ***********/ ··· 4279 4276 /* 4280 4277 * Disable the spic device by calling its _DIS method 4281 4278 */ 4282 - static int sony_pic_disable(struct acpi_device *device) 4279 + static int sony_pic_disable(struct device *dev) 4283 4280 { 4284 - acpi_status ret = acpi_evaluate_object(device->handle, "_DIS", NULL, 4281 + acpi_status ret = acpi_evaluate_object(ACPI_HANDLE(dev), "_DIS", NULL, 4285 4282 NULL); 4286 4283 4287 4284 if (ACPI_FAILURE(ret) && ret != AE_NOT_FOUND) ··· 4297 4294 * 4298 4295 * Call _SRS to set current resources 4299 4296 */ 4300 - static int sony_pic_enable(struct acpi_device *device, 4297 + static int sony_pic_enable(struct device *dev, 4301 4298 struct sony_pic_ioport *ioport, struct sony_pic_irq *irq) 4302 4299 { 4303 4300 acpi_status status; ··· 4379 4376 4380 4377 /* Attempt to set the resource */ 4381 4378 dprintk("Evaluating _SRS\n"); 4382 - status = acpi_set_current_resources(device->handle, &buffer); 4379 + status = acpi_set_current_resources(ACPI_HANDLE(dev), &buffer); 4383 4380 4384 4381 /* check for total failure */ 4385 4382 if (ACPI_FAILURE(status)) { ··· 4468 4465 * ACPI driver 4469 4466 * 4470 4467 *****************/ 4471 - static void sony_pic_remove(struct acpi_device *device) 4468 + static void sony_pic_remove(struct platform_device *pdev) 4472 4469 { 4473 4470 struct sony_pic_ioport *io, *tmp_io; 4474 4471 struct sony_pic_irq *irq, *tmp_irq; 4475 4472 4476 - if (sony_pic_disable(device)) { 4473 + if (sony_pic_disable(&pdev->dev)) { 4477 4474 pr_err("Couldn't disable device\n"); 4478 4475 return; 4479 4476 } ··· 4507 4504 dprintk(SONY_PIC_DRIVER_NAME " removed.\n"); 4508 4505 } 4509 4506 4510 - static int sony_pic_add(struct acpi_device *device) 4507 + static int sony_pic_probe(struct platform_device *pdev) 4511 4508 { 4512 - int result; 4509 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 4513 4510 struct sony_pic_ioport *io, *tmp_io; 4514 4511 struct sony_pic_irq *irq, *tmp_irq; 4512 + int result; 4515 4513 4516 4514 spic_dev.acpi_dev = device; 4517 4515 strscpy(acpi_device_class(device), "sony/hotkey"); ··· 4527 4523 } 4528 4524 4529 4525 /* setup input devices and helper fifo */ 4530 - result = sony_laptop_setup_input(device); 4526 + result = sony_laptop_setup_input(&pdev->dev); 4531 4527 if (result) { 4532 4528 pr_err("Unable to create input devices\n"); 4533 4529 goto err_free_resources; ··· 4597 4593 } 4598 4594 4599 4595 /* set resource status _SRS */ 4600 - result = sony_pic_enable(device, spic_dev.cur_ioport, spic_dev.cur_irq); 4596 + result = sony_pic_enable(&pdev->dev, spic_dev.cur_ioport, spic_dev.cur_irq); 4601 4597 if (result) { 4602 4598 pr_err("Couldn't enable device\n"); 4603 4599 goto err_free_irq; ··· 4620 4616 sony_pf_remove(); 4621 4617 4622 4618 err_disable_device: 4623 - sony_pic_disable(device); 4619 + sony_pic_disable(&pdev->dev); 4624 4620 4625 4621 err_free_irq: 4626 4622 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); ··· 4656 4652 #ifdef CONFIG_PM_SLEEP 4657 4653 static int sony_pic_suspend(struct device *dev) 4658 4654 { 4659 - if (sony_pic_disable(to_acpi_device(dev))) 4655 + if (sony_pic_disable(dev)) 4660 4656 return -ENXIO; 4661 4657 return 0; 4662 4658 } 4663 4659 4664 4660 static int sony_pic_resume(struct device *dev) 4665 4661 { 4666 - sony_pic_enable(to_acpi_device(dev), 4667 - spic_dev.cur_ioport, spic_dev.cur_irq); 4662 + sony_pic_enable(dev, spic_dev.cur_ioport, spic_dev.cur_irq); 4668 4663 return 0; 4669 4664 } 4670 4665 #endif ··· 4675 4672 {"", 0}, 4676 4673 }; 4677 4674 4678 - static struct acpi_driver sony_pic_driver = { 4679 - .name = SONY_PIC_DRIVER_NAME, 4680 - .class = SONY_PIC_CLASS, 4681 - .ids = sony_pic_device_ids, 4682 - .ops = { 4683 - .add = sony_pic_add, 4684 - .remove = sony_pic_remove, 4685 - }, 4686 - .drv.pm = &sony_pic_pm, 4675 + static struct platform_driver sony_pic_driver = { 4676 + .probe = sony_pic_probe, 4677 + .remove = sony_pic_remove, 4678 + .driver = { 4679 + .name = SONY_PIC_DRIVER_NAME, 4680 + .acpi_match_table = sony_pic_device_ids, 4681 + .pm = &sony_pic_pm, 4682 + }, 4687 4683 }; 4688 4684 4689 4685 static const struct dmi_system_id sonypi_dmi_table[] __initconst = { ··· 4708 4706 int result; 4709 4707 4710 4708 if (!no_spic && dmi_check_system(sonypi_dmi_table)) { 4711 - result = acpi_bus_register_driver(&sony_pic_driver); 4709 + result = platform_driver_register(&sony_pic_driver); 4712 4710 if (result) { 4713 4711 pr_err("Unable to register SPIC driver\n"); 4714 4712 goto out; ··· 4716 4714 spic_drv_registered = 1; 4717 4715 } 4718 4716 4719 - result = acpi_bus_register_driver(&sony_nc_driver); 4717 + result = platform_driver_register(&sony_nc_driver); 4720 4718 if (result) { 4721 4719 pr_err("Unable to register SNC driver\n"); 4722 4720 goto out_unregister_pic; ··· 4726 4724 4727 4725 out_unregister_pic: 4728 4726 if (spic_drv_registered) 4729 - acpi_bus_unregister_driver(&sony_pic_driver); 4727 + platform_driver_unregister(&sony_pic_driver); 4730 4728 out: 4731 4729 return result; 4732 4730 } 4733 4731 4734 4732 static void __exit sony_laptop_exit(void) 4735 4733 { 4736 - acpi_bus_unregister_driver(&sony_nc_driver); 4734 + platform_driver_unregister(&sony_nc_driver); 4737 4735 if (spic_drv_registered) 4738 - acpi_bus_unregister_driver(&sony_pic_driver); 4736 + platform_driver_unregister(&sony_pic_driver); 4739 4737 } 4740 4738 4741 4739 module_init(sony_laptop_init);
+34 -29
drivers/platform/x86/system76_acpi.c
··· 18 18 #include <linux/leds.h> 19 19 #include <linux/module.h> 20 20 #include <linux/pci_ids.h> 21 + #include <linux/platform_device.h> 21 22 #include <linux/power_supply.h> 22 23 #include <linux/sysfs.h> 23 24 #include <linux/types.h> ··· 645 644 } 646 645 647 646 // Handle ACPI notification 648 - static void system76_notify(struct acpi_device *acpi_dev, u32 event) 647 + static void system76_notify(acpi_handle handle, u32 event, void *context) 649 648 { 650 - struct system76_data *data; 649 + struct system76_data *data = context; 651 650 652 - data = acpi_driver_data(acpi_dev); 653 651 switch (event) { 654 652 case 0x80: 655 653 kb_led_hotkey_hardware(data); ··· 671 671 } 672 672 } 673 673 674 - // Add a System76 ACPI device 675 - static int system76_add(struct acpi_device *acpi_dev) 674 + // Probe a System76 platform device 675 + static int system76_probe(struct platform_device *pdev) 676 676 { 677 + struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev); 677 678 struct system76_data *data; 678 679 int err; 679 680 680 - data = devm_kzalloc(&acpi_dev->dev, sizeof(*data), GFP_KERNEL); 681 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 681 682 if (!data) 682 683 return -ENOMEM; 683 - acpi_dev->driver_data = data; 684 + 685 + platform_set_drvdata(pdev, data); 686 + 684 687 data->acpi_dev = acpi_dev; 685 688 686 689 // Some models do not run open EC firmware. Check for an ACPI method ··· 699 696 data->ap_led.brightness_set_blocking = ap_led_set; 700 697 data->ap_led.max_brightness = 1; 701 698 data->ap_led.default_trigger = "rfkill-none"; 702 - err = devm_led_classdev_register(&acpi_dev->dev, &data->ap_led); 699 + err = devm_led_classdev_register(&pdev->dev, &data->ap_led); 703 700 if (err) 704 701 return err; 705 702 ··· 743 740 } 744 741 745 742 if (data->kbled_type != KBLED_NONE) { 746 - err = devm_led_classdev_register(&acpi_dev->dev, &data->kb_led); 743 + err = devm_led_classdev_register(&pdev->dev, &data->kb_led); 747 744 if (err) 748 745 return err; 749 746 } 750 747 751 - data->input = devm_input_allocate_device(&acpi_dev->dev); 748 + data->input = devm_input_allocate_device(&pdev->dev); 752 749 if (!data->input) 753 750 return -ENOMEM; 754 751 755 752 data->input->name = "System76 ACPI Hotkeys"; 756 753 data->input->phys = "system76_acpi/input0"; 757 754 data->input->id.bustype = BUS_HOST; 758 - data->input->dev.parent = &acpi_dev->dev; 755 + data->input->dev.parent = &pdev->dev; 759 756 input_set_capability(data->input, EV_KEY, KEY_SCREENLOCK); 760 757 761 758 err = input_register_device(data->input); 762 759 if (err) 763 - goto error; 760 + return err; 761 + 762 + err = acpi_dev_install_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, 763 + system76_notify, data); 764 + if (err) 765 + return err; 764 766 765 767 if (data->has_open_ec) { 766 768 err = system76_get_object(data, "NFAN", &data->nfan); ··· 776 768 if (err) 777 769 goto error; 778 770 779 - data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev, 771 + data->therm = devm_hwmon_device_register_with_info(&pdev->dev, 780 772 "system76_acpi", data, &thermal_chip_info, NULL); 781 773 err = PTR_ERR_OR_ZERO(data->therm); 782 774 if (err) ··· 792 784 kfree(data->ntmp); 793 785 kfree(data->nfan); 794 786 } 787 + acpi_dev_remove_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify); 795 788 return err; 796 789 } 797 790 798 - // Remove a System76 ACPI device 799 - static void system76_remove(struct acpi_device *acpi_dev) 791 + // Remove a System76 platform device 792 + static void system76_remove(struct platform_device *pdev) 800 793 { 801 - struct system76_data *data; 802 - 803 - data = acpi_driver_data(acpi_dev); 794 + struct system76_data *data = platform_get_drvdata(pdev); 804 795 805 796 if (data->has_open_ec) { 806 797 system76_battery_exit(); ··· 807 800 kfree(data->ntmp); 808 801 } 809 802 810 - devm_led_classdev_unregister(&acpi_dev->dev, &data->ap_led); 811 - devm_led_classdev_unregister(&acpi_dev->dev, &data->kb_led); 803 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 804 + ACPI_DEVICE_NOTIFY, system76_notify); 812 805 813 806 system76_get(data, "FINI"); 814 807 } 815 808 816 - static struct acpi_driver system76_driver = { 817 - .name = "System76 ACPI Driver", 818 - .class = "hotkey", 819 - .ids = device_ids, 820 - .ops = { 821 - .add = system76_add, 822 - .remove = system76_remove, 823 - .notify = system76_notify, 809 + static struct platform_driver system76_driver = { 810 + .probe = system76_probe, 811 + .remove = system76_remove, 812 + .driver = { 813 + .name = "System76 ACPI Driver", 814 + .acpi_match_table = device_ids, 824 815 }, 825 816 }; 826 - module_acpi_driver(system76_driver); 817 + module_platform_driver(system76_driver); 827 818 828 819 MODULE_DESCRIPTION("System76 ACPI Driver"); 829 820 MODULE_AUTHOR("Jeremy Soller <jeremy@system76.com>");
+26 -17
drivers/platform/x86/topstar-laptop.c
··· 232 232 return 0; 233 233 } 234 234 235 - static void topstar_acpi_notify(struct acpi_device *device, u32 event) 235 + static void topstar_acpi_notify(acpi_handle handle, u32 event, void *data) 236 236 { 237 - struct topstar_laptop *topstar = acpi_driver_data(device); 237 + struct topstar_laptop *topstar = data; 238 238 static bool dup_evnt[2]; 239 239 bool *dup; 240 240 ··· 285 285 {} 286 286 }; 287 287 288 - static int topstar_acpi_add(struct acpi_device *device) 288 + static int topstar_acpi_probe(struct platform_device *pdev) 289 289 { 290 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 290 291 struct topstar_laptop *topstar; 291 292 int err; 292 293 ··· 297 296 if (!topstar) 298 297 return -ENOMEM; 299 298 299 + platform_set_drvdata(pdev, topstar); 300 + 300 301 strscpy(acpi_device_name(device), "Topstar TPSACPI"); 301 302 strscpy(acpi_device_class(device), TOPSTAR_LAPTOP_CLASS); 302 - device->driver_data = topstar; 303 303 topstar->device = device; 304 304 305 305 err = topstar_acpi_init(topstar); ··· 315 313 if (err) 316 314 goto err_platform_exit; 317 315 316 + err = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 317 + topstar_acpi_notify, topstar); 318 + if (err) 319 + goto err_input_exit; 320 + 318 321 if (led_workaround) { 319 322 err = topstar_led_init(topstar); 320 323 if (err) 321 - goto err_input_exit; 324 + goto err_notify_handler_exit; 322 325 } 323 326 324 327 return 0; 325 328 329 + err_notify_handler_exit: 330 + acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, topstar_acpi_notify); 326 331 err_input_exit: 327 332 topstar_input_exit(topstar); 328 333 err_platform_exit: ··· 341 332 return err; 342 333 } 343 334 344 - static void topstar_acpi_remove(struct acpi_device *device) 335 + static void topstar_acpi_remove(struct platform_device *pdev) 345 336 { 346 - struct topstar_laptop *topstar = acpi_driver_data(device); 337 + struct topstar_laptop *topstar = platform_get_drvdata(pdev); 347 338 348 339 if (led_workaround) 349 340 topstar_led_exit(topstar); 350 341 342 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 343 + ACPI_DEVICE_NOTIFY, topstar_acpi_notify); 351 344 topstar_input_exit(topstar); 352 345 topstar_platform_exit(topstar); 353 346 topstar_acpi_exit(topstar); ··· 364 353 }; 365 354 MODULE_DEVICE_TABLE(acpi, topstar_device_ids); 366 355 367 - static struct acpi_driver topstar_acpi_driver = { 368 - .name = "Topstar laptop ACPI driver", 369 - .class = TOPSTAR_LAPTOP_CLASS, 370 - .ids = topstar_device_ids, 371 - .ops = { 372 - .add = topstar_acpi_add, 373 - .remove = topstar_acpi_remove, 374 - .notify = topstar_acpi_notify, 356 + static struct platform_driver topstar_acpi_driver = { 357 + .probe = topstar_acpi_probe, 358 + .remove = topstar_acpi_remove, 359 + .driver = { 360 + .name = "Topstar laptop ACPI driver", 361 + .acpi_match_table = topstar_device_ids, 375 362 }, 376 363 }; 377 364 ··· 381 372 if (ret < 0) 382 373 return ret; 383 374 384 - ret = acpi_bus_register_driver(&topstar_acpi_driver); 375 + ret = platform_driver_register(&topstar_acpi_driver); 385 376 if (ret < 0) 386 377 goto err_driver_unreg; 387 378 ··· 395 386 396 387 static void __exit topstar_laptop_exit(void) 397 388 { 398 - acpi_bus_unregister_driver(&topstar_acpi_driver); 389 + platform_driver_unregister(&topstar_acpi_driver); 399 390 platform_driver_unregister(&topstar_platform_driver); 400 391 } 401 392
+99 -83
drivers/platform/x86/toshiba_acpi.c
··· 44 44 #include <linux/rfkill.h> 45 45 #include <linux/hwmon.h> 46 46 #include <linux/iio/iio.h> 47 + #include <linux/platform_device.h> 47 48 #include <linux/toshiba.h> 48 49 #include <acpi/battery.h> 49 50 #include <acpi/video.h> ··· 224 223 unsigned int cooling_method_supported:1; 225 224 unsigned int battery_charge_mode_supported:1; 226 225 unsigned int sysfs_created:1; 226 + unsigned int notify_handler_installed:1; 227 227 unsigned int special_functions; 228 228 229 229 bool kbd_event_generated; ··· 3195 3193 pr_cont("\n"); 3196 3194 } 3197 3195 3198 - static void toshiba_acpi_remove(struct acpi_device *acpi_dev) 3196 + static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *data) 3199 3197 { 3200 - struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); 3198 + struct toshiba_acpi_dev *dev = data; 3199 + struct acpi_device *acpi_dev = dev->acpi_dev; 3200 + 3201 + switch (event) { 3202 + case 0x80: /* Hotkeys and some system events */ 3203 + /* 3204 + * Machines with this WMI GUID aren't supported due to bugs in 3205 + * their AML. 3206 + * 3207 + * Return silently to avoid triggering a netlink event. 3208 + */ 3209 + if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) 3210 + return; 3211 + toshiba_acpi_process_hotkeys(dev); 3212 + break; 3213 + case 0x81: /* Dock events */ 3214 + case 0x82: 3215 + case 0x83: 3216 + pr_info("Dock event received %x\n", event); 3217 + break; 3218 + case 0x88: /* Thermal events */ 3219 + pr_info("Thermal event received\n"); 3220 + break; 3221 + case 0x8f: /* LID closed */ 3222 + case 0x90: /* LID is closed and Dock has been ejected */ 3223 + break; 3224 + case 0x8c: /* SATA power events */ 3225 + case 0x8b: 3226 + pr_info("SATA power event received %x\n", event); 3227 + break; 3228 + case 0x92: /* Keyboard backlight mode changed */ 3229 + dev->kbd_event_generated = true; 3230 + /* Update sysfs entries */ 3231 + if (sysfs_update_group(&acpi_dev->dev.kobj, 3232 + &toshiba_attr_group)) 3233 + pr_err("Unable to update sysfs entries\n"); 3234 + /* Notify LED subsystem about keyboard backlight change */ 3235 + if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) 3236 + led_classdev_notify_brightness_hw_changed(&dev->kbd_led, 3237 + (dev->kbd_mode == SCI_KBD_MODE_ON) ? 3238 + LED_FULL : LED_OFF); 3239 + break; 3240 + case 0x8e: /* Power button pressed */ 3241 + break; 3242 + case 0x85: /* Unknown */ 3243 + case 0x8d: /* Unknown */ 3244 + case 0x94: /* Unknown */ 3245 + case 0x95: /* Unknown */ 3246 + default: 3247 + pr_info("Unknown event received %x\n", event); 3248 + break; 3249 + } 3250 + 3251 + acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, 3252 + dev_name(&acpi_dev->dev), 3253 + event, (event == 0x80) ? 3254 + dev->last_key_event : 0); 3255 + } 3256 + 3257 + static void toshiba_acpi_remove(struct platform_device *pdev) 3258 + { 3259 + struct toshiba_acpi_dev *dev = platform_get_drvdata(pdev); 3201 3260 3202 3261 misc_deregister(&dev->miscdev); 3203 3262 3204 3263 remove_toshiba_proc_entries(dev); 3264 + 3265 + if (dev->notify_handler_installed) 3266 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 3267 + ACPI_DEVICE_NOTIFY, 3268 + toshiba_acpi_notify); 3205 3269 3206 3270 #if IS_ENABLED(CONFIG_HWMON) 3207 3271 if (dev->hwmon_device) ··· 3307 3239 3308 3240 if (toshiba_acpi) 3309 3241 toshiba_acpi = NULL; 3242 + 3243 + dev_set_drvdata(&dev->acpi_dev->dev, NULL); 3310 3244 3311 3245 kfree(dev); 3312 3246 } ··· 3372 3302 { } 3373 3303 }; 3374 3304 3375 - static int toshiba_acpi_add(struct acpi_device *acpi_dev) 3305 + static int toshiba_acpi_probe(struct platform_device *pdev) 3376 3306 { 3307 + struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev); 3377 3308 struct toshiba_acpi_dev *dev; 3378 3309 const char *hci_method; 3379 3310 u32 dummy; ··· 3408 3337 return ret; 3409 3338 } 3410 3339 3411 - acpi_dev->driver_data = dev; 3340 + platform_set_drvdata(pdev, dev); 3412 3341 dev_set_drvdata(&acpi_dev->dev, dev); 3413 3342 3414 3343 /* Query the BIOS for supported features */ ··· 3439 3368 dev->led_dev.max_brightness = 1; 3440 3369 dev->led_dev.brightness_set = toshiba_illumination_set; 3441 3370 dev->led_dev.brightness_get = toshiba_illumination_get; 3442 - led_classdev_register(&acpi_dev->dev, &dev->led_dev); 3371 + led_classdev_register(&pdev->dev, &dev->led_dev); 3443 3372 } 3444 3373 3445 3374 toshiba_eco_mode_available(dev); ··· 3448 3377 dev->eco_led.max_brightness = 1; 3449 3378 dev->eco_led.brightness_set = toshiba_eco_mode_set_status; 3450 3379 dev->eco_led.brightness_get = toshiba_eco_mode_get_status; 3451 - led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led); 3380 + led_classdev_register(&pdev->dev, &dev->eco_led); 3452 3381 } 3453 3382 3454 3383 toshiba_kbd_illum_available(dev); ··· 3464 3393 dev->kbd_led.max_brightness = 1; 3465 3394 dev->kbd_led.brightness_set = toshiba_kbd_backlight_set; 3466 3395 dev->kbd_led.brightness_get = toshiba_kbd_backlight_get; 3467 - led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led); 3396 + led_classdev_register(&pdev->dev, &dev->kbd_led); 3468 3397 } 3469 3398 3470 3399 ret = toshiba_touchpad_get(dev, &dummy); ··· 3472 3401 3473 3402 toshiba_accelerometer_available(dev); 3474 3403 if (dev->accelerometer_supported) { 3475 - dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev)); 3404 + dev->indio_dev = iio_device_alloc(&pdev->dev, sizeof(*dev)); 3476 3405 if (!dev->indio_dev) { 3477 3406 pr_err("Unable to allocate iio device\n"); 3478 3407 goto iio_error; ··· 3521 3450 #if IS_ENABLED(CONFIG_HWMON) 3522 3451 if (dev->fan_rpm_supported) { 3523 3452 dev->hwmon_device = hwmon_device_register_with_info( 3524 - &dev->acpi_dev->dev, "toshiba_acpi_sensors", NULL, 3453 + &pdev->dev, "toshiba_acpi_sensors", NULL, 3525 3454 &toshiba_acpi_hwmon_chip_info, NULL); 3526 3455 if (IS_ERR(dev->hwmon_device)) { 3527 3456 dev->hwmon_device = NULL; ··· 3548 3477 } 3549 3478 dev->sysfs_created = !ret; 3550 3479 3480 + ret = acpi_dev_install_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, 3481 + toshiba_acpi_notify, dev); 3482 + if (ret) 3483 + goto error; 3484 + 3485 + dev->notify_handler_installed = 1; 3486 + 3551 3487 create_toshiba_proc_entries(dev); 3552 3488 3553 3489 toshiba_acpi = dev; ··· 3569 3491 return 0; 3570 3492 3571 3493 error: 3572 - toshiba_acpi_remove(acpi_dev); 3494 + toshiba_acpi_remove(pdev); 3573 3495 return ret; 3574 - } 3575 - 3576 - static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event) 3577 - { 3578 - struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); 3579 - 3580 - switch (event) { 3581 - case 0x80: /* Hotkeys and some system events */ 3582 - /* 3583 - * Machines with this WMI GUID aren't supported due to bugs in 3584 - * their AML. 3585 - * 3586 - * Return silently to avoid triggering a netlink event. 3587 - */ 3588 - if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) 3589 - return; 3590 - toshiba_acpi_process_hotkeys(dev); 3591 - break; 3592 - case 0x81: /* Dock events */ 3593 - case 0x82: 3594 - case 0x83: 3595 - pr_info("Dock event received %x\n", event); 3596 - break; 3597 - case 0x88: /* Thermal events */ 3598 - pr_info("Thermal event received\n"); 3599 - break; 3600 - case 0x8f: /* LID closed */ 3601 - case 0x90: /* LID is closed and Dock has been ejected */ 3602 - break; 3603 - case 0x8c: /* SATA power events */ 3604 - case 0x8b: 3605 - pr_info("SATA power event received %x\n", event); 3606 - break; 3607 - case 0x92: /* Keyboard backlight mode changed */ 3608 - dev->kbd_event_generated = true; 3609 - /* Update sysfs entries */ 3610 - if (sysfs_update_group(&acpi_dev->dev.kobj, 3611 - &toshiba_attr_group)) 3612 - pr_err("Unable to update sysfs entries\n"); 3613 - /* Notify LED subsystem about keyboard backlight change */ 3614 - if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) 3615 - led_classdev_notify_brightness_hw_changed(&dev->kbd_led, 3616 - (dev->kbd_mode == SCI_KBD_MODE_ON) ? 3617 - LED_FULL : LED_OFF); 3618 - break; 3619 - case 0x8e: /* Power button pressed */ 3620 - break; 3621 - case 0x85: /* Unknown */ 3622 - case 0x8d: /* Unknown */ 3623 - case 0x94: /* Unknown */ 3624 - case 0x95: /* Unknown */ 3625 - default: 3626 - pr_info("Unknown event received %x\n", event); 3627 - break; 3628 - } 3629 - 3630 - acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, 3631 - dev_name(&acpi_dev->dev), 3632 - event, (event == 0x80) ? 3633 - dev->last_key_event : 0); 3634 3496 } 3635 3497 3636 3498 #ifdef CONFIG_PM_SLEEP 3637 3499 static int toshiba_acpi_suspend(struct device *device) 3638 3500 { 3639 - struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device)); 3501 + struct toshiba_acpi_dev *dev = dev_get_drvdata(device); 3640 3502 3641 3503 if (dev->hotkey_dev) { 3642 3504 u32 result; ··· 3591 3573 3592 3574 static int toshiba_acpi_resume(struct device *device) 3593 3575 { 3594 - struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device)); 3576 + struct toshiba_acpi_dev *dev = dev_get_drvdata(device); 3595 3577 3596 3578 if (dev->hotkey_dev) { 3597 3579 if (toshiba_acpi_enable_hotkeys(dev)) ··· 3613 3595 static SIMPLE_DEV_PM_OPS(toshiba_acpi_pm, 3614 3596 toshiba_acpi_suspend, toshiba_acpi_resume); 3615 3597 3616 - static struct acpi_driver toshiba_acpi_driver = { 3617 - .name = "Toshiba ACPI driver", 3618 - .ids = toshiba_device_ids, 3619 - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 3620 - .ops = { 3621 - .add = toshiba_acpi_add, 3622 - .remove = toshiba_acpi_remove, 3623 - .notify = toshiba_acpi_notify, 3598 + static struct platform_driver toshiba_acpi_driver = { 3599 + .probe = toshiba_acpi_probe, 3600 + .remove = toshiba_acpi_remove, 3601 + .driver = { 3602 + .name = "Toshiba ACPI driver", 3603 + .acpi_match_table = toshiba_device_ids, 3604 + .pm = &toshiba_acpi_pm, 3624 3605 }, 3625 - .drv.pm = &toshiba_acpi_pm, 3626 3606 }; 3627 3607 3628 3608 static void __init toshiba_dmi_init(void) ··· 3650 3634 return -ENODEV; 3651 3635 } 3652 3636 3653 - ret = acpi_bus_register_driver(&toshiba_acpi_driver); 3637 + ret = platform_driver_register(&toshiba_acpi_driver); 3654 3638 if (ret) { 3655 3639 pr_err("Failed to register ACPI driver: %d\n", ret); 3656 3640 remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); ··· 3661 3645 3662 3646 static void __exit toshiba_acpi_exit(void) 3663 3647 { 3664 - acpi_bus_unregister_driver(&toshiba_acpi_driver); 3648 + platform_driver_unregister(&toshiba_acpi_driver); 3665 3649 if (toshiba_proc_dir) 3666 3650 remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); 3667 3651 }
+45 -29
drivers/platform/x86/toshiba_bluetooth.c
··· 17 17 #include <linux/types.h> 18 18 #include <linux/acpi.h> 19 19 #include <linux/rfkill.h> 20 + #include <linux/platform_device.h> 20 21 21 22 #define BT_KILLSWITCH_MASK 0x01 22 23 #define BT_PLUGGED_MASK 0x40 ··· 36 35 bool powered; 37 36 }; 38 37 39 - static int toshiba_bt_rfkill_add(struct acpi_device *device); 40 - static void toshiba_bt_rfkill_remove(struct acpi_device *device); 41 - static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event); 38 + static int toshiba_bt_rfkill_probe(struct platform_device *pdev); 39 + static void toshiba_bt_rfkill_remove(struct platform_device *pdev); 40 + static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data); 42 41 43 42 static const struct acpi_device_id bt_device_ids[] = { 44 43 { "TOS6205", 0}, ··· 51 50 #endif 52 51 static SIMPLE_DEV_PM_OPS(toshiba_bt_pm, NULL, toshiba_bt_resume); 53 52 54 - static struct acpi_driver toshiba_bt_rfkill_driver = { 55 - .name = "Toshiba BT", 56 - .class = "Toshiba", 57 - .ids = bt_device_ids, 58 - .ops = { 59 - .add = toshiba_bt_rfkill_add, 60 - .remove = toshiba_bt_rfkill_remove, 61 - .notify = toshiba_bt_rfkill_notify, 62 - }, 63 - .drv.pm = &toshiba_bt_pm, 53 + static struct platform_driver toshiba_bt_rfkill_driver = { 54 + .probe = toshiba_bt_rfkill_probe, 55 + .remove = toshiba_bt_rfkill_remove, 56 + .driver = { 57 + .name = "Toshiba BT", 58 + .acpi_match_table = bt_device_ids, 59 + .pm = &toshiba_bt_pm, 60 + }, 64 61 }; 65 62 66 63 static int toshiba_bluetooth_present(acpi_handle handle) ··· 202 203 }; 203 204 204 205 /* ACPI driver functions */ 205 - static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event) 206 + static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data) 206 207 { 207 - struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); 208 + struct toshiba_bluetooth_dev *bt_dev = data; 208 209 209 210 if (toshiba_bluetooth_sync_status(bt_dev)) 210 211 return; ··· 215 216 #ifdef CONFIG_PM_SLEEP 216 217 static int toshiba_bt_resume(struct device *dev) 217 218 { 218 - struct toshiba_bluetooth_dev *bt_dev; 219 + struct toshiba_bluetooth_dev *bt_dev = dev_get_drvdata(dev); 219 220 int ret; 220 - 221 - bt_dev = acpi_driver_data(to_acpi_device(dev)); 222 221 223 222 ret = toshiba_bluetooth_sync_status(bt_dev); 224 223 if (ret) ··· 228 231 } 229 232 #endif 230 233 231 - static int toshiba_bt_rfkill_add(struct acpi_device *device) 234 + static int toshiba_bt_rfkill_probe(struct platform_device *pdev) 232 235 { 236 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 233 237 struct toshiba_bluetooth_dev *bt_dev; 234 238 int result; 235 239 ··· 244 246 if (!bt_dev) 245 247 return -ENOMEM; 246 248 bt_dev->acpi_dev = device; 247 - device->driver_data = bt_dev; 248 - dev_set_drvdata(&device->dev, bt_dev); 249 + 250 + platform_set_drvdata(pdev, bt_dev); 249 251 250 252 result = toshiba_bluetooth_sync_status(bt_dev); 251 253 if (result) { ··· 254 256 } 255 257 256 258 bt_dev->rfk = rfkill_alloc("Toshiba Bluetooth", 257 - &device->dev, 259 + &pdev->dev, 258 260 RFKILL_TYPE_BLUETOOTH, 259 261 &rfk_ops, 260 262 bt_dev); 261 263 if (!bt_dev->rfk) { 262 264 pr_err("Unable to allocate rfkill device\n"); 263 - kfree(bt_dev); 264 - return -ENOMEM; 265 + result = -ENOMEM; 266 + goto err_free_bt_dev; 265 267 } 266 268 267 269 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); ··· 269 271 result = rfkill_register(bt_dev->rfk); 270 272 if (result) { 271 273 pr_err("Unable to register rfkill device\n"); 272 - rfkill_destroy(bt_dev->rfk); 273 - kfree(bt_dev); 274 + goto err_rfkill_destroy; 274 275 } 275 276 277 + result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 278 + toshiba_bt_rfkill_notify, bt_dev); 279 + if (result) { 280 + pr_err("Unable to register ACPI notify handler\n"); 281 + goto err_rfkill_unregister; 282 + } 283 + 284 + return 0; 285 + 286 + err_rfkill_unregister: 287 + rfkill_unregister(bt_dev->rfk); 288 + err_rfkill_destroy: 289 + rfkill_destroy(bt_dev->rfk); 290 + err_free_bt_dev: 291 + kfree(bt_dev); 276 292 return result; 277 293 } 278 294 279 - static void toshiba_bt_rfkill_remove(struct acpi_device *device) 295 + static void toshiba_bt_rfkill_remove(struct platform_device *pdev) 280 296 { 281 - struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); 297 + struct toshiba_bluetooth_dev *bt_dev = platform_get_drvdata(pdev); 298 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 282 299 283 300 /* clean up */ 301 + acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 302 + toshiba_bt_rfkill_notify); 303 + 284 304 if (bt_dev->rfk) { 285 305 rfkill_unregister(bt_dev->rfk); 286 306 rfkill_destroy(bt_dev->rfk); ··· 309 293 toshiba_bluetooth_disable(device->handle); 310 294 } 311 295 312 - module_acpi_driver(toshiba_bt_rfkill_driver); 296 + module_platform_driver(toshiba_bt_rfkill_driver);
+36 -21
drivers/platform/x86/toshiba_haps.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/types.h> 14 14 #include <linux/acpi.h> 15 + #include <linux/platform_device.h> 15 16 16 17 MODULE_AUTHOR("Azael Avalos <coproscefalo@gmail.com>"); 17 18 MODULE_DESCRIPTION("Toshiba HDD Active Protection Sensor"); ··· 130 129 /* 131 130 * ACPI stuff 132 131 */ 133 - static void toshiba_haps_notify(struct acpi_device *device, u32 event) 132 + static void toshiba_haps_notify(acpi_handle handle, u32 event, void *data) 134 133 { 134 + struct acpi_device *device = data; 135 + 135 136 pr_debug("Received event: 0x%x\n", event); 136 137 137 138 acpi_bus_generate_netlink_event(device->pnp.device_class, ··· 141 138 event, 0); 142 139 } 143 140 144 - static void toshiba_haps_remove(struct acpi_device *device) 141 + static void toshiba_haps_remove(struct platform_device *pdev) 145 142 { 143 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 144 + 145 + acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 146 + toshiba_haps_notify); 147 + 146 148 sysfs_remove_group(&device->dev.kobj, &haps_attr_group); 147 149 148 150 if (toshiba_haps) 149 151 toshiba_haps = NULL; 152 + 153 + dev_set_drvdata(&device->dev, NULL); 150 154 } 151 155 152 156 /* Helper function */ ··· 180 170 return 1; 181 171 } 182 172 183 - static int toshiba_haps_add(struct acpi_device *acpi_dev) 173 + static int toshiba_haps_probe(struct platform_device *pdev) 184 174 { 175 + struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev); 185 176 struct toshiba_haps_dev *haps; 186 177 int ret; 187 178 ··· 194 183 195 184 pr_info("Toshiba HDD Active Protection Sensor device\n"); 196 185 197 - haps = devm_kzalloc(&acpi_dev->dev, sizeof(*haps), GFP_KERNEL); 186 + haps = devm_kzalloc(&pdev->dev, sizeof(*haps), GFP_KERNEL); 198 187 if (!haps) 199 188 return -ENOMEM; 200 189 201 190 haps->acpi_dev = acpi_dev; 202 191 haps->protection_level = 2; 203 - acpi_dev->driver_data = haps; 192 + 204 193 dev_set_drvdata(&acpi_dev->dev, haps); 194 + platform_set_drvdata(pdev, haps); 205 195 206 196 /* Set the protection level, currently at level 2 (Medium) */ 207 197 ret = toshiba_haps_protection_level(acpi_dev->handle, 2); ··· 213 201 if (ret) 214 202 return ret; 215 203 204 + ret = acpi_dev_install_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, 205 + toshiba_haps_notify, acpi_dev); 206 + if (ret) 207 + goto err; 208 + 216 209 toshiba_haps = haps; 217 210 218 211 return 0; 212 + 213 + err: 214 + sysfs_remove_group(&acpi_dev->dev.kobj, &haps_attr_group); 215 + return ret; 219 216 } 220 217 221 218 #ifdef CONFIG_PM_SLEEP 222 219 static int toshiba_haps_suspend(struct device *device) 223 220 { 224 - struct toshiba_haps_dev *haps; 221 + struct toshiba_haps_dev *haps = dev_get_drvdata(device); 225 222 int ret; 226 - 227 - haps = acpi_driver_data(to_acpi_device(device)); 228 223 229 224 /* Deactivate the protection on suspend */ 230 225 ret = toshiba_haps_protection_level(haps->acpi_dev->handle, 0); ··· 241 222 242 223 static int toshiba_haps_resume(struct device *device) 243 224 { 244 - struct toshiba_haps_dev *haps; 225 + struct toshiba_haps_dev *haps = dev_get_drvdata(device); 245 226 int ret; 246 - 247 - haps = acpi_driver_data(to_acpi_device(device)); 248 227 249 228 /* Set the stored protection level */ 250 229 ret = toshiba_haps_protection_level(haps->acpi_dev->handle, ··· 266 249 }; 267 250 MODULE_DEVICE_TABLE(acpi, haps_device_ids); 268 251 269 - static struct acpi_driver toshiba_haps_driver = { 270 - .name = "Toshiba HAPS", 271 - .ids = haps_device_ids, 272 - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 273 - .ops = { 274 - .add = toshiba_haps_add, 275 - .remove = toshiba_haps_remove, 276 - .notify = toshiba_haps_notify, 252 + static struct platform_driver toshiba_haps_driver = { 253 + .probe = toshiba_haps_probe, 254 + .remove = toshiba_haps_remove, 255 + .driver = { 256 + .name = "Toshiba HAPS", 257 + .acpi_match_table = haps_device_ids, 258 + .pm = &toshiba_haps_pm, 277 259 }, 278 - .drv.pm = &toshiba_haps_pm, 279 260 }; 280 261 281 - module_acpi_driver(toshiba_haps_driver); 262 + module_platform_driver(toshiba_haps_driver);
+370 -70
drivers/platform/x86/uniwill/uniwill-acpi.c
··· 110 110 #define EC_ADDR_BAT_CYCLE_COUNT_2 0x04A7 111 111 112 112 #define EC_ADDR_PROJECT_ID 0x0740 113 + #define PROJECT_ID_PH4TRX1 0x12 114 + #define PROJECT_ID_PH6TRX1 0x15 113 115 114 116 #define EC_ADDR_AP_OEM 0x0741 115 117 #define ENABLE_MANUAL_CTRL BIT(0) ··· 268 266 #define BATTERY_CHARGE_FULL_OVER_24H BIT(3) 269 267 #define BATTERY_ERM_STATUS_REACHED BIT(4) 270 268 271 - #define EC_ADDR_CHARGE_PRIO 0x07CC 272 - #define CHARGING_PERFORMANCE BIT(7) 269 + #define EC_ADDR_USB_C_POWER_PRIORITY 0x07CC 270 + #define USB_C_POWER_PRIORITY BIT(7) 273 271 274 272 /* Same bits as EC_ADDR_LIGHTBAR_AC_CTRL except LIGHTBAR_S3_OFF */ 275 273 #define EC_ADDR_LIGHTBAR_BAT_CTRL 0x07E2 ··· 321 319 #define UNIWILL_FEATURE_TOUCHPAD_TOGGLE BIT(2) 322 320 #define UNIWILL_FEATURE_LIGHTBAR BIT(3) 323 321 #define UNIWILL_FEATURE_BATTERY BIT(4) 324 - #define UNIWILL_FEATURE_HWMON BIT(5) 325 - #define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL BIT(6) 322 + #define UNIWILL_FEATURE_CPU_TEMP BIT(5) 323 + #define UNIWILL_FEATURE_GPU_TEMP BIT(6) 324 + #define UNIWILL_FEATURE_PRIMARY_FAN BIT(7) 325 + #define UNIWILL_FEATURE_SECONDARY_FAN BIT(8) 326 + #define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL BIT(9) 327 + #define UNIWILL_FEATURE_USB_C_POWER_PRIORITY BIT(10) 328 + 329 + enum usb_c_power_priority_options { 330 + USB_C_POWER_PRIORITY_CHARGING = 0, 331 + USB_C_POWER_PRIORITY_PERFORMANCE, 332 + }; 326 333 327 334 struct uniwill_data { 328 335 struct device *dev; ··· 351 340 struct mutex input_lock; /* Protects input sequence during notify */ 352 341 struct input_dev *input_device; 353 342 struct notifier_block nb; 343 + struct mutex usb_c_power_priority_lock; /* Protects dependent bit write and state safe */ 344 + enum usb_c_power_priority_options last_usb_c_power_priority_option; 354 345 }; 355 346 356 347 struct uniwill_battery_entry { ··· 440 427 { KE_END } 441 428 }; 442 429 443 - static inline bool uniwill_device_supports(struct uniwill_data *data, 430 + static inline bool uniwill_device_supports(const struct uniwill_data *data, 444 431 unsigned int features) 445 432 { 446 433 return (data->features & features) == features; ··· 537 524 case EC_ADDR_CTGP_DB_CTGP_OFFSET: 538 525 case EC_ADDR_CTGP_DB_TPP_OFFSET: 539 526 case EC_ADDR_CTGP_DB_DB_OFFSET: 527 + case EC_ADDR_USB_C_POWER_PRIORITY: 540 528 return true; 541 529 default: 542 530 return false; ··· 576 562 case EC_ADDR_CTGP_DB_CTGP_OFFSET: 577 563 case EC_ADDR_CTGP_DB_TPP_OFFSET: 578 564 case EC_ADDR_CTGP_DB_DB_OFFSET: 565 + case EC_ADDR_USB_C_POWER_PRIORITY: 579 566 return true; 580 567 default: 581 568 return false; ··· 599 584 case EC_ADDR_TRIGGER: 600 585 case EC_ADDR_SWITCH_STATUS: 601 586 case EC_ADDR_CHARGE_CTRL: 587 + case EC_ADDR_USB_C_POWER_PRIORITY: 602 588 return true; 603 589 default: 604 590 return false; ··· 896 880 return 0; 897 881 } 898 882 883 + static const char * const usb_c_power_priority_text[] = { 884 + [USB_C_POWER_PRIORITY_CHARGING] = "charging", 885 + [USB_C_POWER_PRIORITY_PERFORMANCE] = "performance", 886 + }; 887 + 888 + static const u8 usb_c_power_priority_value[] = { 889 + [USB_C_POWER_PRIORITY_CHARGING] = 0, 890 + [USB_C_POWER_PRIORITY_PERFORMANCE] = USB_C_POWER_PRIORITY, 891 + }; 892 + 893 + static ssize_t usb_c_power_priority_store(struct device *dev, 894 + struct device_attribute *attr, 895 + const char *buf, size_t count) 896 + { 897 + struct uniwill_data *data = dev_get_drvdata(dev); 898 + enum usb_c_power_priority_options option; 899 + unsigned int value; 900 + int ret; 901 + 902 + ret = sysfs_match_string(usb_c_power_priority_text, buf); 903 + if (ret < 0) 904 + return ret; 905 + 906 + option = ret; 907 + value = usb_c_power_priority_value[option]; 908 + 909 + guard(mutex)(&data->usb_c_power_priority_lock); 910 + 911 + ret = regmap_update_bits(data->regmap, EC_ADDR_USB_C_POWER_PRIORITY, 912 + USB_C_POWER_PRIORITY, value); 913 + if (ret < 0) 914 + return ret; 915 + 916 + data->last_usb_c_power_priority_option = option; 917 + 918 + return count; 919 + } 920 + 921 + static ssize_t usb_c_power_priority_show(struct device *dev, 922 + struct device_attribute *attr, 923 + char *buf) 924 + { 925 + struct uniwill_data *data = dev_get_drvdata(dev); 926 + unsigned int value; 927 + int ret; 928 + 929 + ret = regmap_read(data->regmap, EC_ADDR_USB_C_POWER_PRIORITY, &value); 930 + if (ret < 0) 931 + return ret; 932 + 933 + value &= USB_C_POWER_PRIORITY; 934 + 935 + if (usb_c_power_priority_value[USB_C_POWER_PRIORITY_PERFORMANCE] == value) 936 + return sysfs_emit(buf, "%s\n", 937 + usb_c_power_priority_text[USB_C_POWER_PRIORITY_PERFORMANCE]); 938 + 939 + return sysfs_emit(buf, "%s\n", usb_c_power_priority_text[USB_C_POWER_PRIORITY_CHARGING]); 940 + } 941 + 942 + static DEVICE_ATTR_RW(usb_c_power_priority); 943 + 944 + static int usb_c_power_priority_restore(struct uniwill_data *data) 945 + { 946 + unsigned int value; 947 + 948 + value = usb_c_power_priority_value[data->last_usb_c_power_priority_option]; 949 + 950 + guard(mutex)(&data->usb_c_power_priority_lock); 951 + 952 + return regmap_update_bits(data->regmap, EC_ADDR_USB_C_POWER_PRIORITY, 953 + USB_C_POWER_PRIORITY, value); 954 + } 955 + 956 + static int usb_c_power_priority_init(struct uniwill_data *data) 957 + { 958 + unsigned int value; 959 + int ret; 960 + 961 + if (!uniwill_device_supports(data, UNIWILL_FEATURE_USB_C_POWER_PRIORITY)) 962 + return 0; 963 + 964 + ret = devm_mutex_init(data->dev, &data->usb_c_power_priority_lock); 965 + if (ret < 0) 966 + return ret; 967 + 968 + ret = regmap_read(data->regmap, EC_ADDR_USB_C_POWER_PRIORITY, &value); 969 + if (ret < 0) 970 + return ret; 971 + 972 + value &= USB_C_POWER_PRIORITY; 973 + 974 + data->last_usb_c_power_priority_option = 975 + usb_c_power_priority_value[USB_C_POWER_PRIORITY_PERFORMANCE] == value ? 976 + USB_C_POWER_PRIORITY_PERFORMANCE : 977 + USB_C_POWER_PRIORITY_CHARGING; 978 + 979 + return 0; 980 + } 981 + 899 982 static struct attribute *uniwill_attrs[] = { 900 983 /* Keyboard-related */ 901 984 &dev_attr_fn_lock.attr, ··· 1005 890 &dev_attr_breathing_in_suspend.attr, 1006 891 /* Power-management-related */ 1007 892 &dev_attr_ctgp_offset.attr, 893 + &dev_attr_usb_c_power_priority.attr, 1008 894 NULL 1009 895 }; 1010 896 ··· 1040 924 return attr->mode; 1041 925 } 1042 926 927 + if (attr == &dev_attr_usb_c_power_priority.attr) { 928 + if (uniwill_device_supports(data, UNIWILL_FEATURE_USB_C_POWER_PRIORITY)) 929 + return attr->mode; 930 + } 931 + 1043 932 return 0; 1044 933 } 1045 934 ··· 1057 936 &uniwill_group, 1058 937 NULL 1059 938 }; 939 + 940 + static umode_t uniwill_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, 941 + int channel) 942 + { 943 + const struct uniwill_data *data = drvdata; 944 + unsigned int feature; 945 + 946 + switch (type) { 947 + case hwmon_temp: 948 + switch (channel) { 949 + case 0: 950 + feature = UNIWILL_FEATURE_CPU_TEMP; 951 + break; 952 + case 1: 953 + feature = UNIWILL_FEATURE_GPU_TEMP; 954 + break; 955 + default: 956 + return 0; 957 + } 958 + break; 959 + case hwmon_fan: 960 + case hwmon_pwm: 961 + switch (channel) { 962 + case 0: 963 + feature = UNIWILL_FEATURE_PRIMARY_FAN; 964 + break; 965 + case 1: 966 + feature = UNIWILL_FEATURE_SECONDARY_FAN; 967 + break; 968 + default: 969 + return 0; 970 + } 971 + break; 972 + default: 973 + return 0; 974 + } 975 + 976 + if (uniwill_device_supports(data, feature)) 977 + return 0444; 978 + 979 + return 0; 980 + } 1060 981 1061 982 static int uniwill_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, 1062 983 long *val) ··· 1183 1020 } 1184 1021 1185 1022 static const struct hwmon_ops uniwill_ops = { 1186 - .visible = 0444, 1023 + .is_visible = uniwill_is_visible, 1187 1024 .read = uniwill_read, 1188 1025 .read_string = uniwill_read_string, 1189 1026 }; ··· 1211 1048 { 1212 1049 struct device *hdev; 1213 1050 1214 - if (!uniwill_device_supports(data, UNIWILL_FEATURE_HWMON)) 1051 + if (!uniwill_device_supports(data, UNIWILL_FEATURE_CPU_TEMP) && 1052 + !uniwill_device_supports(data, UNIWILL_FEATURE_GPU_TEMP) && 1053 + !uniwill_device_supports(data, UNIWILL_FEATURE_PRIMARY_FAN) && 1054 + !uniwill_device_supports(data, UNIWILL_FEATURE_SECONDARY_FAN)) 1215 1055 return 0; 1216 1056 1217 1057 hdev = devm_hwmon_device_register_with_info(data->dev, "uniwill", data, ··· 1535 1369 1536 1370 return NOTIFY_OK; 1537 1371 case UNIWILL_OSD_DC_ADAPTER_CHANGED: 1538 - /* noop for the time being, will change once charging priority 1539 - * gets implemented. 1540 - */ 1372 + if (!uniwill_device_supports(data, UNIWILL_FEATURE_USB_C_POWER_PRIORITY)) 1373 + return NOTIFY_DONE; 1541 1374 1542 - return NOTIFY_OK; 1375 + return notifier_from_errno(usb_c_power_priority_restore(data)); 1543 1376 case UNIWILL_OSD_FN_LOCK: 1544 1377 if (!uniwill_device_supports(data, UNIWILL_FEATURE_FN_LOCK)) 1545 1378 return NOTIFY_DONE; ··· 1632 1467 return PTR_ERR(regmap); 1633 1468 1634 1469 data->regmap = regmap; 1470 + 1635 1471 ret = devm_mutex_init(&pdev->dev, &data->super_key_lock); 1636 1472 if (ret < 0) 1637 1473 return ret; ··· 1667 1501 return ret; 1668 1502 1669 1503 ret = uniwill_nvidia_ctgp_init(data); 1504 + if (ret < 0) 1505 + return ret; 1506 + 1507 + ret = usb_c_power_priority_init(data); 1670 1508 if (ret < 0) 1671 1509 return ret; 1672 1510 ··· 1803 1633 CTGP_DB_DB_ENABLE | CTGP_DB_CTGP_ENABLE); 1804 1634 } 1805 1635 1636 + static int uniwill_resume_usb_c_power_priority(struct uniwill_data *data) 1637 + { 1638 + if (!uniwill_device_supports(data, UNIWILL_FEATURE_USB_C_POWER_PRIORITY)) 1639 + return 0; 1640 + 1641 + return usb_c_power_priority_restore(data); 1642 + } 1643 + 1806 1644 static int uniwill_resume(struct device *dev) 1807 1645 { 1808 1646 struct uniwill_data *data = dev_get_drvdata(dev); ··· 1834 1656 if (ret < 0) 1835 1657 return ret; 1836 1658 1837 - return uniwill_resume_nvidia_ctgp(data); 1659 + ret = uniwill_resume_nvidia_ctgp(data); 1660 + if (ret < 0) 1661 + return ret; 1662 + 1663 + return uniwill_resume_usb_c_power_priority(data); 1838 1664 } 1839 1665 1840 1666 static DEFINE_SIMPLE_DEV_PM_OPS(uniwill_pm_ops, uniwill_suspend, uniwill_resume); ··· 1864 1682 .shutdown = uniwill_shutdown, 1865 1683 }; 1866 1684 1685 + static struct uniwill_device_descriptor lapqc71a_lapqc71b_descriptor __initdata = { 1686 + .features = UNIWILL_FEATURE_SUPER_KEY | 1687 + UNIWILL_FEATURE_BATTERY | 1688 + UNIWILL_FEATURE_CPU_TEMP | 1689 + UNIWILL_FEATURE_GPU_TEMP | 1690 + UNIWILL_FEATURE_PRIMARY_FAN | 1691 + UNIWILL_FEATURE_SECONDARY_FAN, 1692 + }; 1693 + 1867 1694 static struct uniwill_device_descriptor lapac71h_descriptor __initdata = { 1868 1695 .features = UNIWILL_FEATURE_FN_LOCK | 1869 1696 UNIWILL_FEATURE_SUPER_KEY | 1870 1697 UNIWILL_FEATURE_TOUCHPAD_TOGGLE | 1871 1698 UNIWILL_FEATURE_BATTERY | 1872 - UNIWILL_FEATURE_HWMON, 1699 + UNIWILL_FEATURE_CPU_TEMP | 1700 + UNIWILL_FEATURE_GPU_TEMP | 1701 + UNIWILL_FEATURE_PRIMARY_FAN | 1702 + UNIWILL_FEATURE_SECONDARY_FAN, 1873 1703 }; 1874 1704 1875 1705 static struct uniwill_device_descriptor lapkc71f_descriptor __initdata = { ··· 1890 1696 UNIWILL_FEATURE_TOUCHPAD_TOGGLE | 1891 1697 UNIWILL_FEATURE_LIGHTBAR | 1892 1698 UNIWILL_FEATURE_BATTERY | 1893 - UNIWILL_FEATURE_HWMON, 1699 + UNIWILL_FEATURE_CPU_TEMP | 1700 + UNIWILL_FEATURE_GPU_TEMP | 1701 + UNIWILL_FEATURE_PRIMARY_FAN | 1702 + UNIWILL_FEATURE_SECONDARY_FAN, 1703 + }; 1704 + 1705 + /* 1706 + * The featuresets below reflect somewhat chronological changes: 1707 + * 1 -> 2: UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL is added to the EC firmware. 1708 + * 2 -> 3: UNIWILL_FEATURE_USB_C_POWER_PRIORITY is removed from the EC firmware. 1709 + * Some devices might divert from this timeline. 1710 + */ 1711 + 1712 + static struct uniwill_device_descriptor tux_featureset_1_descriptor __initdata = { 1713 + .features = UNIWILL_FEATURE_FN_LOCK | 1714 + UNIWILL_FEATURE_SUPER_KEY | 1715 + UNIWILL_FEATURE_CPU_TEMP | 1716 + UNIWILL_FEATURE_PRIMARY_FAN | 1717 + UNIWILL_FEATURE_SECONDARY_FAN | 1718 + UNIWILL_FEATURE_USB_C_POWER_PRIORITY, 1719 + }; 1720 + 1721 + static struct uniwill_device_descriptor tux_featureset_1_nvidia_descriptor __initdata = { 1722 + .features = UNIWILL_FEATURE_FN_LOCK | 1723 + UNIWILL_FEATURE_SUPER_KEY | 1724 + UNIWILL_FEATURE_CPU_TEMP | 1725 + UNIWILL_FEATURE_GPU_TEMP | 1726 + UNIWILL_FEATURE_PRIMARY_FAN | 1727 + UNIWILL_FEATURE_SECONDARY_FAN | 1728 + UNIWILL_FEATURE_USB_C_POWER_PRIORITY, 1729 + }; 1730 + 1731 + static struct uniwill_device_descriptor tux_featureset_2_nvidia_descriptor __initdata = { 1732 + .features = UNIWILL_FEATURE_FN_LOCK | 1733 + UNIWILL_FEATURE_SUPER_KEY | 1734 + UNIWILL_FEATURE_CPU_TEMP | 1735 + UNIWILL_FEATURE_GPU_TEMP | 1736 + UNIWILL_FEATURE_PRIMARY_FAN | 1737 + UNIWILL_FEATURE_SECONDARY_FAN | 1738 + UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL | 1739 + UNIWILL_FEATURE_USB_C_POWER_PRIORITY, 1740 + }; 1741 + 1742 + static struct uniwill_device_descriptor tux_featureset_3_descriptor __initdata = { 1743 + .features = UNIWILL_FEATURE_FN_LOCK | 1744 + UNIWILL_FEATURE_SUPER_KEY | 1745 + UNIWILL_FEATURE_CPU_TEMP | 1746 + UNIWILL_FEATURE_PRIMARY_FAN | 1747 + UNIWILL_FEATURE_SECONDARY_FAN, 1748 + }; 1749 + 1750 + static struct uniwill_device_descriptor tux_featureset_3_nvidia_descriptor __initdata = { 1751 + .features = UNIWILL_FEATURE_FN_LOCK | 1752 + UNIWILL_FEATURE_SUPER_KEY | 1753 + UNIWILL_FEATURE_CPU_TEMP | 1754 + UNIWILL_FEATURE_GPU_TEMP | 1755 + UNIWILL_FEATURE_PRIMARY_FAN | 1756 + UNIWILL_FEATURE_SECONDARY_FAN | 1757 + UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL, 1758 + }; 1759 + 1760 + static int phxtxx1_probe(struct uniwill_data *data) 1761 + { 1762 + unsigned int value; 1763 + int ret; 1764 + 1765 + ret = regmap_read(data->regmap, EC_ADDR_PROJECT_ID, &value); 1766 + if (ret < 0) 1767 + return ret; 1768 + 1769 + if (value == PROJECT_ID_PH4TRX1 || value == PROJECT_ID_PH6TRX1) 1770 + data->features |= UNIWILL_FEATURE_SECONDARY_FAN; 1771 + 1772 + return 0; 1773 + }; 1774 + 1775 + static struct uniwill_device_descriptor phxtxx1_descriptor __initdata = { 1776 + .features = UNIWILL_FEATURE_FN_LOCK | 1777 + UNIWILL_FEATURE_SUPER_KEY | 1778 + UNIWILL_FEATURE_CPU_TEMP | 1779 + UNIWILL_FEATURE_PRIMARY_FAN | 1780 + UNIWILL_FEATURE_USB_C_POWER_PRIORITY, 1781 + .probe = phxtxx1_probe, 1894 1782 }; 1895 1783 1896 1784 static int phxarx1_phxaqf1_probe(struct uniwill_data *data) ··· 1985 1709 return ret; 1986 1710 1987 1711 if (value & HAS_GPU) 1988 - data->features |= UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL; 1712 + data->features |= UNIWILL_FEATURE_GPU_TEMP | 1713 + UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL; 1989 1714 1990 1715 return 0; 1991 1716 }; 1992 1717 1993 1718 static struct uniwill_device_descriptor phxarx1_phxaqf1_descriptor __initdata = { 1719 + .features = UNIWILL_FEATURE_FN_LOCK | 1720 + UNIWILL_FEATURE_SUPER_KEY | 1721 + UNIWILL_FEATURE_CPU_TEMP | 1722 + UNIWILL_FEATURE_PRIMARY_FAN | 1723 + UNIWILL_FEATURE_SECONDARY_FAN | 1724 + UNIWILL_FEATURE_USB_C_POWER_PRIORITY, 1994 1725 .probe = phxarx1_phxaqf1_probe, 1995 1726 }; 1996 1727 1997 - static struct uniwill_device_descriptor tux_featureset_1_descriptor __initdata = { 1998 - .features = UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL, 1728 + static struct uniwill_device_descriptor pf5pu1g_descriptor __initdata = { 1729 + .features = UNIWILL_FEATURE_FN_LOCK | 1730 + UNIWILL_FEATURE_SUPER_KEY | 1731 + UNIWILL_FEATURE_CPU_TEMP | 1732 + UNIWILL_FEATURE_PRIMARY_FAN, 1999 1733 }; 2000 - 2001 - static struct uniwill_device_descriptor empty_descriptor __initdata = {}; 2002 1734 2003 1735 static const struct dmi_system_id uniwill_dmi_table[] __initconst = { 2004 1736 { 2005 - .ident = "XMG FUSION 15", 1737 + .ident = "XMG FUSION 15 (L19)", 2006 1738 .matches = { 2007 1739 DMI_MATCH(DMI_SYS_VENDOR, "SchenkerTechnologiesGmbH"), 2008 1740 DMI_EXACT_MATCH(DMI_BOARD_NAME, "LAPQC71A"), 2009 1741 }, 2010 - .driver_data = &empty_descriptor, 1742 + .driver_data = &lapqc71a_lapqc71b_descriptor, 2011 1743 }, 2012 1744 { 2013 - .ident = "XMG FUSION 15", 1745 + .ident = "XMG FUSION 15 (L19)", 2014 1746 .matches = { 2015 1747 DMI_MATCH(DMI_SYS_VENDOR, "SchenkerTechnologiesGmbH"), 2016 1748 DMI_EXACT_MATCH(DMI_BOARD_NAME, "LAPQC71B"), 2017 1749 }, 2018 - .driver_data = &empty_descriptor, 1750 + .driver_data = &lapqc71a_lapqc71b_descriptor, 1751 + }, 1752 + { 1753 + .ident = "XMG FUSION 15 (L19)", 1754 + .matches = { 1755 + DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 1756 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "LAPQC71A"), 1757 + }, 1758 + .driver_data = &lapqc71a_lapqc71b_descriptor, 1759 + }, 1760 + { 1761 + .ident = "XMG FUSION 15 (L19)", 1762 + .matches = { 1763 + DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 1764 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "LAPQC71B"), 1765 + }, 1766 + .driver_data = &lapqc71a_lapqc71b_descriptor, 2019 1767 }, 2020 1768 { 2021 1769 .ident = "Intel NUC x15", ··· 2063 1763 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2064 1764 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PHxTxX1"), 2065 1765 }, 2066 - .driver_data = &empty_descriptor, 1766 + .driver_data = &phxtxx1_descriptor, 2067 1767 }, 2068 1768 { 2069 1769 .ident = "TUXEDO InfinityBook Pro 14 Gen6 Intel", ··· 2071 1771 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2072 1772 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PHxTQx1"), 2073 1773 }, 2074 - .driver_data = &tux_featureset_1_descriptor, 1774 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2075 1775 }, 2076 1776 { 2077 1777 .ident = "TUXEDO InfinityBook Pro 14/16 Gen7 Intel", ··· 2087 1787 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2088 1788 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PH6AG01_PH6AQ71_PH6AQI1"), 2089 1789 }, 2090 - .driver_data = &tux_featureset_1_descriptor, 1790 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2091 1791 }, 2092 1792 { 2093 1793 .ident = "TUXEDO InfinityBook Pro 14/16 Gen8 Intel/Commodore Omnia-Book Pro Gen 8", ··· 2095 1795 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2096 1796 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PH4PRX1_PH6PRX1"), 2097 1797 }, 2098 - .driver_data = &empty_descriptor, 1798 + .driver_data = &tux_featureset_1_descriptor, 2099 1799 }, 2100 1800 { 2101 1801 .ident = "TUXEDO InfinityBook Pro 14 Gen8 Intel/Commodore Omnia-Book Pro Gen 8", ··· 2103 1803 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2104 1804 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PH4PG31"), 2105 1805 }, 2106 - .driver_data = &tux_featureset_1_descriptor, 1806 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2107 1807 }, 2108 1808 { 2109 1809 .ident = "TUXEDO InfinityBook Pro 16 Gen8 Intel", ··· 2111 1811 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2112 1812 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PH6PG01_PH6PG71"), 2113 1813 }, 2114 - .driver_data = &tux_featureset_1_descriptor, 1814 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2115 1815 }, 2116 1816 { 2117 1817 .ident = "TUXEDO InfinityBook Pro 14/15 Gen9 AMD", ··· 2119 1819 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2120 1820 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GXxHRXx"), 2121 1821 }, 2122 - .driver_data = &empty_descriptor, 1822 + .driver_data = &tux_featureset_3_descriptor, 2123 1823 }, 2124 1824 { 2125 1825 .ident = "TUXEDO InfinityBook Pro 14/15 Gen9 Intel/Commodore Omnia-Book 15 Gen9", ··· 2127 1827 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2128 1828 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GXxMRXx"), 2129 1829 }, 2130 - .driver_data = &empty_descriptor, 1830 + .driver_data = &tux_featureset_3_descriptor, 2131 1831 }, 2132 1832 { 2133 1833 .ident = "TUXEDO InfinityBook Pro 14/15 Gen10 AMD", ··· 2135 1835 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2136 1836 DMI_EXACT_MATCH(DMI_BOARD_NAME, "XxHP4NAx"), 2137 1837 }, 2138 - .driver_data = &empty_descriptor, 1838 + .driver_data = &tux_featureset_3_descriptor, 2139 1839 }, 2140 1840 { 2141 1841 .ident = "TUXEDO InfinityBook Pro 14/15 Gen10 AMD", ··· 2143 1843 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2144 1844 DMI_EXACT_MATCH(DMI_BOARD_NAME, "XxKK4NAx_XxSP4NAx"), 2145 1845 }, 2146 - .driver_data = &empty_descriptor, 1846 + .driver_data = &tux_featureset_3_descriptor, 2147 1847 }, 2148 1848 { 2149 1849 .ident = "TUXEDO InfinityBook Pro 15 Gen10 Intel", ··· 2151 1851 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2152 1852 DMI_EXACT_MATCH(DMI_BOARD_NAME, "XxAR4NAx"), 2153 1853 }, 2154 - .driver_data = &empty_descriptor, 1854 + .driver_data = &tux_featureset_3_descriptor, 2155 1855 }, 2156 1856 { 2157 1857 .ident = "TUXEDO InfinityBook Max 15 Gen10 AMD", ··· 2159 1859 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2160 1860 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X5KK45xS_X5SP45xS"), 2161 1861 }, 2162 - .driver_data = &empty_descriptor, 1862 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2163 1863 }, 2164 1864 { 2165 1865 .ident = "TUXEDO InfinityBook Max 16 Gen10 AMD", ··· 2167 1867 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2168 1868 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X6HP45xU"), 2169 1869 }, 2170 - .driver_data = &empty_descriptor, 1870 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2171 1871 }, 2172 1872 { 2173 1873 .ident = "TUXEDO InfinityBook Max 16 Gen10 AMD", ··· 2175 1875 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2176 1876 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X6KK45xU_X6SP45xU"), 2177 1877 }, 2178 - .driver_data = &empty_descriptor, 1878 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2179 1879 }, 2180 1880 { 2181 1881 .ident = "TUXEDO InfinityBook Max 15 Gen10 Intel", ··· 2183 1883 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2184 1884 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X5AR45xS"), 2185 1885 }, 2186 - .driver_data = &empty_descriptor, 1886 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2187 1887 }, 2188 1888 { 2189 1889 .ident = "TUXEDO InfinityBook Max 16 Gen10 Intel", ··· 2191 1891 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2192 1892 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X6AR55xU"), 2193 1893 }, 2194 - .driver_data = &empty_descriptor, 1894 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2195 1895 }, 2196 1896 { 2197 1897 .ident = "TUXEDO Polaris 15 Gen1 AMD", ··· 2199 1899 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2200 1900 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1501A1650TI"), 2201 1901 }, 2202 - .driver_data = &empty_descriptor, 1902 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2203 1903 }, 2204 1904 { 2205 1905 .ident = "TUXEDO Polaris 15 Gen1 AMD", ··· 2207 1907 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2208 1908 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1501A2060"), 2209 1909 }, 2210 - .driver_data = &empty_descriptor, 1910 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2211 1911 }, 2212 1912 { 2213 1913 .ident = "TUXEDO Polaris 17 Gen1 AMD", ··· 2215 1915 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2216 1916 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1701A1650TI"), 2217 1917 }, 2218 - .driver_data = &empty_descriptor, 1918 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2219 1919 }, 2220 1920 { 2221 1921 .ident = "TUXEDO Polaris 17 Gen1 AMD", ··· 2223 1923 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2224 1924 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1701A2060"), 2225 1925 }, 2226 - .driver_data = &empty_descriptor, 1926 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2227 1927 }, 2228 1928 { 2229 1929 .ident = "TUXEDO Polaris 15 Gen1 Intel", ··· 2231 1931 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2232 1932 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1501I1650TI"), 2233 1933 }, 2234 - .driver_data = &empty_descriptor, 1934 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2235 1935 }, 2236 1936 { 2237 1937 .ident = "TUXEDO Polaris 15 Gen1 Intel", ··· 2239 1939 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2240 1940 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1501I2060"), 2241 1941 }, 2242 - .driver_data = &empty_descriptor, 1942 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2243 1943 }, 2244 1944 { 2245 1945 .ident = "TUXEDO Polaris 17 Gen1 Intel", ··· 2247 1947 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2248 1948 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1701I1650TI"), 2249 1949 }, 2250 - .driver_data = &empty_descriptor, 1950 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2251 1951 }, 2252 1952 { 2253 1953 .ident = "TUXEDO Polaris 17 Gen1 Intel", ··· 2255 1955 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2256 1956 DMI_EXACT_MATCH(DMI_BOARD_NAME, "POLARIS1701I2060"), 2257 1957 }, 2258 - .driver_data = &empty_descriptor, 1958 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2259 1959 }, 2260 1960 { 2261 1961 .ident = "TUXEDO Trinity 15 Intel Gen1", ··· 2263 1963 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2264 1964 DMI_EXACT_MATCH(DMI_BOARD_NAME, "TRINITY1501I"), 2265 1965 }, 2266 - .driver_data = &empty_descriptor, 1966 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2267 1967 }, 2268 1968 { 2269 1969 .ident = "TUXEDO Trinity 17 Intel Gen1", ··· 2271 1971 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2272 1972 DMI_EXACT_MATCH(DMI_BOARD_NAME, "TRINITY1701I"), 2273 1973 }, 2274 - .driver_data = &empty_descriptor, 1974 + .driver_data = &tux_featureset_1_nvidia_descriptor, 2275 1975 }, 2276 1976 { 2277 1977 .ident = "TUXEDO Polaris 15/17 Gen2 AMD", ··· 2279 1979 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2280 1980 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxMGxx"), 2281 1981 }, 2282 - .driver_data = &tux_featureset_1_descriptor, 1982 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2283 1983 }, 2284 1984 { 2285 1985 .ident = "TUXEDO Polaris 15/17 Gen2 Intel", ··· 2287 1987 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2288 1988 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxNGxx"), 2289 1989 }, 2290 - .driver_data = &tux_featureset_1_descriptor, 1990 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2291 1991 }, 2292 1992 { 2293 1993 .ident = "TUXEDO Stellaris/Polaris 15/17 Gen3 AMD", ··· 2295 1995 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2296 1996 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxZGxx"), 2297 1997 }, 2298 - .driver_data = &tux_featureset_1_descriptor, 1998 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2299 1999 }, 2300 2000 { 2301 2001 .ident = "TUXEDO Stellaris/Polaris 15/17 Gen3 Intel", ··· 2303 2003 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2304 2004 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxTGxx"), 2305 2005 }, 2306 - .driver_data = &tux_featureset_1_descriptor, 2006 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2307 2007 }, 2308 2008 { 2309 2009 .ident = "TUXEDO Stellaris/Polaris 15/17 Gen4 AMD", ··· 2311 2011 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2312 2012 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxRGxx"), 2313 2013 }, 2314 - .driver_data = &tux_featureset_1_descriptor, 2014 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2315 2015 }, 2316 2016 { 2317 2017 .ident = "TUXEDO Stellaris 15 Gen4 Intel", ··· 2319 2019 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2320 2020 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxAGxx"), 2321 2021 }, 2322 - .driver_data = &tux_featureset_1_descriptor, 2022 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2323 2023 }, 2324 2024 { 2325 2025 .ident = "TUXEDO Polaris 15/17 Gen5 AMD", ··· 2327 2027 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2328 2028 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxXGxx"), 2329 2029 }, 2330 - .driver_data = &tux_featureset_1_descriptor, 2030 + .driver_data = &tux_featureset_2_nvidia_descriptor, 2331 2031 }, 2332 2032 { 2333 2033 .ident = "TUXEDO Stellaris 16 Gen5 AMD", ··· 2335 2035 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2336 2036 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GM6XGxX"), 2337 2037 }, 2338 - .driver_data = &tux_featureset_1_descriptor, 2038 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2339 2039 }, 2340 2040 { 2341 2041 .ident = "TUXEDO Stellaris 16/17 Gen5 Intel/Commodore ORION Gen 5", ··· 2343 2043 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2344 2044 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxPXxx"), 2345 2045 }, 2346 - .driver_data = &tux_featureset_1_descriptor, 2046 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2347 2047 }, 2348 2048 { 2349 2049 .ident = "TUXEDO Stellaris Slim 15 Gen6 AMD", ··· 2351 2051 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2352 2052 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GMxHGxx"), 2353 2053 }, 2354 - .driver_data = &tux_featureset_1_descriptor, 2054 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2355 2055 }, 2356 2056 { 2357 2057 .ident = "TUXEDO Stellaris Slim 15 Gen6 Intel/Commodore ORION Slim 15 Gen6", ··· 2359 2059 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2360 2060 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GM5IXxA"), 2361 2061 }, 2362 - .driver_data = &tux_featureset_1_descriptor, 2062 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2363 2063 }, 2364 2064 { 2365 2065 .ident = "TUXEDO Stellaris 16 Gen6 Intel/Commodore ORION 16 Gen6", ··· 2367 2067 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2368 2068 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GM6IXxB_MB1"), 2369 2069 }, 2370 - .driver_data = &tux_featureset_1_descriptor, 2070 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2371 2071 }, 2372 2072 { 2373 2073 .ident = "TUXEDO Stellaris 16 Gen6 Intel/Commodore ORION 16 Gen6", ··· 2375 2075 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2376 2076 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GM6IXxB_MB2"), 2377 2077 }, 2378 - .driver_data = &tux_featureset_1_descriptor, 2078 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2379 2079 }, 2380 2080 { 2381 2081 .ident = "TUXEDO Stellaris 17 Gen6 Intel/Commodore ORION 17 Gen6", ··· 2383 2083 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2384 2084 DMI_EXACT_MATCH(DMI_BOARD_NAME, "GM7IXxN"), 2385 2085 }, 2386 - .driver_data = &tux_featureset_1_descriptor, 2086 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2387 2087 }, 2388 2088 { 2389 2089 .ident = "TUXEDO Stellaris 16 Gen7 AMD", ··· 2391 2091 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2392 2092 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X6FR5xxY"), 2393 2093 }, 2394 - .driver_data = &tux_featureset_1_descriptor, 2094 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2395 2095 }, 2396 2096 { 2397 2097 .ident = "TUXEDO Stellaris 16 Gen7 Intel", ··· 2399 2099 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2400 2100 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X6AR5xxY"), 2401 2101 }, 2402 - .driver_data = &tux_featureset_1_descriptor, 2102 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2403 2103 }, 2404 2104 { 2405 2105 .ident = "TUXEDO Stellaris 16 Gen7 Intel", ··· 2407 2107 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2408 2108 DMI_EXACT_MATCH(DMI_BOARD_NAME, "X6AR5xxY_mLED"), 2409 2109 }, 2410 - .driver_data = &tux_featureset_1_descriptor, 2110 + .driver_data = &tux_featureset_3_nvidia_descriptor, 2411 2111 }, 2412 2112 { 2413 2113 .ident = "TUXEDO Book BA15 Gen10 AMD", ··· 2415 2115 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2416 2116 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PF5PU1G"), 2417 2117 }, 2418 - .driver_data = &empty_descriptor, 2118 + .driver_data = &pf5pu1g_descriptor, 2419 2119 }, 2420 2120 { 2421 2121 .ident = "TUXEDO Pulse 14 Gen1 AMD", ··· 2423 2123 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2424 2124 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PULSE1401"), 2425 2125 }, 2426 - .driver_data = &empty_descriptor, 2126 + .driver_data = &tux_featureset_1_descriptor, 2427 2127 }, 2428 2128 { 2429 2129 .ident = "TUXEDO Pulse 15 Gen1 AMD", ··· 2431 2131 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2432 2132 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PULSE1501"), 2433 2133 }, 2434 - .driver_data = &empty_descriptor, 2134 + .driver_data = &tux_featureset_1_descriptor, 2435 2135 }, 2436 2136 { 2437 2137 .ident = "TUXEDO Pulse 15 Gen2 AMD", ··· 2439 2139 DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), 2440 2140 DMI_EXACT_MATCH(DMI_BOARD_NAME, "PF5LUXG"), 2441 2141 }, 2442 - .driver_data = &empty_descriptor, 2142 + .driver_data = &tux_featureset_1_descriptor, 2443 2143 }, 2444 2144 { } 2445 2145 };
+1
drivers/platform/x86/uniwill/uniwill-wmi.c
··· 77 77 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 78 78 }, 79 79 .id_table = uniwill_wmi_id_table, 80 + .min_event_size = sizeof(u32), 80 81 .notify = uniwill_wmi_notify, 81 82 .no_singleton = true, 82 83 };
+29 -20
drivers/platform/x86/wireless-hotkey.c
··· 35 35 {"", 0}, 36 36 }; 37 37 38 - static int wireless_input_setup(struct acpi_device *device) 38 + static int wireless_input_setup(struct device *dev) 39 39 { 40 - struct wl_button *button = acpi_driver_data(device); 40 + struct wl_button *button = dev_get_drvdata(dev); 41 41 int err; 42 42 43 43 button->input_dev = input_allocate_device(); 44 44 if (!button->input_dev) 45 45 return -ENOMEM; 46 46 47 - snprintf(button->phys, sizeof(button->phys), "%s/input0", acpi_device_hid(device)); 47 + snprintf(button->phys, sizeof(button->phys), "%s/input0", 48 + acpi_device_hid(ACPI_COMPANION(dev))); 48 49 49 50 button->input_dev->name = "Wireless hotkeys"; 50 51 button->input_dev->phys = button->phys; ··· 64 63 return err; 65 64 } 66 65 67 - static void wireless_input_destroy(struct acpi_device *device) 66 + static void wireless_input_destroy(struct device *dev) 68 67 { 69 - struct wl_button *button = acpi_driver_data(device); 68 + struct wl_button *button = dev_get_drvdata(dev); 70 69 71 70 input_unregister_device(button->input_dev); 72 71 kfree(button); 73 72 } 74 73 75 - static void wl_notify(struct acpi_device *acpi_dev, u32 event) 74 + static void wl_notify(acpi_handle handle, u32 event, void *data) 76 75 { 77 - struct wl_button *button = acpi_driver_data(acpi_dev); 76 + struct wl_button *button = data; 78 77 79 78 if (event != 0x80) { 80 79 pr_info("Received unknown event (0x%x)\n", event); ··· 87 86 input_sync(button->input_dev); 88 87 } 89 88 90 - static int wl_add(struct acpi_device *device) 89 + static int wl_probe(struct platform_device *pdev) 91 90 { 92 91 struct wl_button *button; 93 92 int err; ··· 96 95 if (!button) 97 96 return -ENOMEM; 98 97 99 - device->driver_data = button; 98 + platform_set_drvdata(pdev, button); 100 99 101 - err = wireless_input_setup(device); 100 + err = wireless_input_setup(&pdev->dev); 102 101 if (err) { 103 102 pr_err("Failed to setup wireless hotkeys\n"); 104 103 kfree(button); 104 + return err; 105 + } 106 + err = acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev), 107 + ACPI_DEVICE_NOTIFY, wl_notify, button); 108 + if (err) { 109 + pr_err("Failed to install ACPI notify handler\n"); 110 + wireless_input_destroy(&pdev->dev); 105 111 } 106 112 107 113 return err; 108 114 } 109 115 110 - static void wl_remove(struct acpi_device *device) 116 + static void wl_remove(struct platform_device *pdev) 111 117 { 112 - wireless_input_destroy(device); 118 + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), 119 + ACPI_DEVICE_NOTIFY, wl_notify); 120 + wireless_input_destroy(&pdev->dev); 113 121 } 114 122 115 - static struct acpi_driver wl_driver = { 116 - .name = "wireless-hotkey", 117 - .ids = wl_ids, 118 - .ops = { 119 - .add = wl_add, 120 - .remove = wl_remove, 121 - .notify = wl_notify, 123 + static struct platform_driver wl_driver = { 124 + .probe = wl_probe, 125 + .remove = wl_remove, 126 + .driver = { 127 + .name = "wireless-hotkey", 128 + .acpi_match_table = wl_ids, 122 129 }, 123 130 }; 124 131 125 - module_acpi_driver(wl_driver); 132 + module_platform_driver(wl_driver);
+1 -1
drivers/platform/x86/wmi-bmof.c
··· 62 62 if (!buffer) 63 63 return -ENOMEM; 64 64 65 - ret = wmidev_query_block(wdev, 0, buffer); 65 + ret = wmidev_query_block(wdev, 0, buffer, 0); 66 66 if (ret < 0) 67 67 return ret; 68 68
+1
drivers/platform/x86/xiaomi-wmi.c
··· 83 83 .name = "xiaomi-wmi", 84 84 }, 85 85 .id_table = xiaomi_wmi_id_table, 86 + .min_event_size = 0, 86 87 .probe = xiaomi_wmi_probe, 87 88 .notify_new = xiaomi_wmi_notify, 88 89 .no_singleton = true,
+29 -10
include/linux/intel_vsec.h
··· 29 29 #define INTEL_DVSEC_TABLE_OFFSET(x) ((x) & GENMASK(31, 3)) 30 30 #define TABLE_OFFSET_SHIFT 3 31 31 32 + struct device; 32 33 struct pci_dev; 33 34 struct resource; 35 + 36 + enum intel_vsec_disc_source { 37 + INTEL_VSEC_DISC_PCI, /* PCI, default */ 38 + INTEL_VSEC_DISC_ACPI, /* ACPI */ 39 + }; 34 40 35 41 enum intel_vsec_id { 36 42 VSEC_ID_TELEMETRY = 2, ··· 88 82 * struct pmt_callbacks - Callback infrastructure for PMT devices 89 83 * @read_telem: when specified, called by client driver to access PMT 90 84 * data (instead of direct copy). 91 - * * pdev: PCI device reference for the callback's use 85 + * * dev: device reference for the callback's use 92 86 * * guid: ID of data to acccss 93 87 * * data: buffer for the data to be copied 94 88 * * off: offset into the requested buffer 95 89 * * count: size of buffer 96 90 */ 97 91 struct pmt_callbacks { 98 - int (*read_telem)(struct pci_dev *pdev, u32 guid, u64 *data, loff_t off, u32 count); 92 + int (*read_telem)(struct device *dev, u32 guid, u64 *data, loff_t off, u32 count); 99 93 }; 100 94 101 95 struct vsec_feature_dependency { ··· 108 102 * @parent: parent device in the auxbus chain 109 103 * @headers: list of headers to define the PMT client devices to create 110 104 * @deps: array of feature dependencies 105 + * @acpi_disc: ACPI discovery tables, each entry is two QWORDs 106 + * in little-endian format as defined by the PMT ACPI spec. 107 + * Valid only when @provider == INTEL_VSEC_DISC_ACPI. 108 + * @src: source of discovery table data 111 109 * @priv_data: private data, usable by parent devices, currently a callback 112 110 * @caps: bitmask of PMT capabilities for the given headers 113 111 * @quirks: bitmask of VSEC device quirks ··· 122 112 struct device *parent; 123 113 struct intel_vsec_header **headers; 124 114 const struct vsec_feature_dependency *deps; 115 + u32 (*acpi_disc)[4]; 116 + enum intel_vsec_disc_source src; 125 117 void *priv_data; 126 118 unsigned long caps; 127 119 unsigned long quirks; ··· 134 122 /** 135 123 * struct intel_vsec_device - Auxbus specific device information 136 124 * @auxdev: auxbus device struct for auxbus access 137 - * @pcidev: pci device associated with the device 138 - * @resource: any resources shared by the parent 125 + * @dev: struct device associated with the device 126 + * @resource: PCI discovery resources (BAR windows), one per discovery 127 + * instance. Valid only when @src == INTEL_VSEC_DISC_PCI 128 + * @acpi_disc: ACPI discovery tables, each entry is two QWORDs 129 + * in little-endian format as defined by the PMT ACPI spec. 130 + * Valid only when @src == INTEL_VSEC_DISC_ACPI. 131 + * @src: source of discovery table data 139 132 * @ida: id reference 140 133 * @num_resources: number of resources 141 134 * @id: xarray id ··· 152 135 */ 153 136 struct intel_vsec_device { 154 137 struct auxiliary_device auxdev; 155 - struct pci_dev *pcidev; 138 + struct device *dev; 156 139 struct resource *resource; 140 + u32 (*acpi_disc)[4]; 141 + enum intel_vsec_disc_source src; 157 142 struct ida *ida; 158 143 int num_resources; 159 144 int id; /* xa */ ··· 203 184 struct telemetry_region regions[]; 204 185 }; 205 186 206 - int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, 187 + int intel_vsec_add_aux(struct device *parent, 207 188 struct intel_vsec_device *intel_vsec_dev, 208 189 const char *name); 209 190 ··· 218 199 } 219 200 220 201 #if IS_ENABLED(CONFIG_INTEL_VSEC) 221 - int intel_vsec_register(struct pci_dev *pdev, 222 - struct intel_vsec_platform_info *info); 202 + int intel_vsec_register(struct device *dev, 203 + const struct intel_vsec_platform_info *info); 223 204 int intel_vsec_set_mapping(struct oobmsm_plat_info *plat_info, 224 205 struct intel_vsec_device *vsec_dev); 225 206 struct oobmsm_plat_info *intel_vsec_get_mapping(struct pci_dev *pdev); 226 207 #else 227 - static inline int intel_vsec_register(struct pci_dev *pdev, 228 - struct intel_vsec_platform_info *info) 208 + static inline int intel_vsec_register(struct device *dev, 209 + const struct intel_vsec_platform_info *info) 229 210 { 230 211 return -ENODEV; 231 212 }
+8 -4
include/linux/platform_data/x86/int3472.h
··· 23 23 /* PMIC GPIO Types */ 24 24 #define INT3472_GPIO_TYPE_RESET 0x00 25 25 #define INT3472_GPIO_TYPE_POWERDOWN 0x01 26 + #define INT3472_GPIO_TYPE_STROBE 0x02 26 27 #define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b 27 28 #define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c 28 29 #define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d ··· 33 32 34 33 #define INT3472_PDEV_MAX_NAME_LEN 23 35 34 #define INT3472_MAX_SENSOR_GPIOS 3 35 + #define INT3472_MAX_LEDS 2 36 36 #define INT3472_MAX_REGULATORS 3 37 37 38 38 /* E.g. "dovdd\0" */ ··· 124 122 u8 imgclk_index; 125 123 } clock; 126 124 127 - struct int3472_pled { 125 + struct int3472_led { 128 126 struct led_classdev classdev; 129 127 struct led_lookup_data lookup; 130 128 char name[INT3472_LED_MAX_NAME_LEN]; 131 129 struct gpio_desc *gpio; 132 - } pled; 130 + } leds[INT3472_MAX_LEDS]; 133 131 134 132 struct int3472_discrete_quirks quirks; 135 133 136 134 unsigned int ngpios; /* how many GPIOs have we seen */ 135 + unsigned int n_leds; /* how many LEDs have we registered */ 137 136 unsigned int n_sensor_gpios; /* how many have we mapped to sensor */ 138 137 unsigned int n_regulator_gpios; /* how many have we mapped to a regulator */ 139 138 struct gpiod_lookup_table gpios; ··· 164 161 const char *second_sensor); 165 162 void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472); 166 163 167 - int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio); 168 - void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472); 164 + int skl_int3472_register_led(struct int3472_discrete_device *int3472, struct gpio_desc *gpio, 165 + const char *con_id); 166 + void skl_int3472_unregister_leds(struct int3472_discrete_device *int3472); 169 167 170 168 #endif
+11 -4
include/linux/wmi.h
··· 64 64 size_t src_length); 65 65 66 66 int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id, 67 - const struct wmi_buffer *in, struct wmi_buffer *out); 67 + const struct wmi_buffer *in, struct wmi_buffer *out, size_t min_size); 68 68 69 - int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out); 69 + int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id, 70 + const struct wmi_buffer *in); 71 + 72 + int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out, 73 + size_t min_size); 70 74 71 75 int wmidev_set_block(struct wmi_device *wdev, u8 instance, const struct wmi_buffer *in); 72 76 ··· 87 83 * struct wmi_driver - WMI driver structure 88 84 * @driver: Driver model structure 89 85 * @id_table: List of WMI GUIDs supported by this driver 90 - * @no_notify_data: Driver supports WMI events which provide no event data 86 + * @min_event_size: Minimum event payload size supported by this driver 91 87 * @no_singleton: Driver can be instantiated multiple times 92 88 * @probe: Callback for device binding 93 89 * @remove: Callback for device unbinding ··· 97 93 * 98 94 * This represents WMI drivers which handle WMI devices. The data inside the buffer 99 95 * passed to the @notify_new callback is guaranteed to be aligned on a 8-byte boundary. 96 + * The minimum supported size for said buffer can be specified using @min_event_size. 97 + * WMI drivers that still use the deprecated @notify callback can still set @min_event_size 98 + * to 0 in order to signal that they support WMI events which provide no event data. 100 99 */ 101 100 struct wmi_driver { 102 101 struct device_driver driver; 103 102 const struct wmi_device_id *id_table; 104 - bool no_notify_data; 103 + size_t min_event_size; 105 104 bool no_singleton; 106 105 107 106 int (*probe)(struct wmi_device *wdev, const void *context);
+24 -17
tools/power/x86/intel-speed-select/isst-config.c
··· 16 16 int arg; 17 17 }; 18 18 19 - static const char *version_str = "v1.25"; 19 + static const char *version_str = "v1.26"; 20 20 21 21 static const int supported_api_ver = 3; 22 22 static struct isst_if_platform_info isst_platform_info; ··· 26 26 27 27 static int cpu_model; 28 28 static int cpu_stepping; 29 - static int extended_family; 29 + static int cpu_family; 30 30 31 31 #define MAX_CPUS_IN_ONE_REQ 512 32 32 static short max_target_cpus; ··· 81 81 }; 82 82 83 83 static int read_only; 84 + 85 + static void print_version(void) 86 + { 87 + fprintf(outf, "Version %s\n", version_str); 88 + } 84 89 85 90 static void check_privilege(void) 86 91 { ··· 163 158 164 159 static int is_dmr_plus_platform(void) 165 160 { 166 - if (extended_family == 0x04) 161 + if (cpu_family == 19) 167 162 return 1; 168 163 169 164 return 0; ··· 172 167 static int update_cpu_model(void) 173 168 { 174 169 unsigned int ebx, ecx, edx; 175 - unsigned int fms, family; 170 + unsigned int fms; 176 171 177 172 __cpuid(1, fms, ebx, ecx, edx); 178 - family = (fms >> 8) & 0xf; 179 - extended_family = (fms >> 20) & 0x0f; 173 + cpu_family = (fms >> 8) & 0xf; 174 + if (cpu_family == 0xf) 175 + cpu_family += (fms >> 20) & 0xff; 180 176 cpu_model = (fms >> 4) & 0xf; 181 - if (family == 6 || family == 0xf) 177 + if (cpu_family == 6 || cpu_family == 0xf) 182 178 cpu_model += ((fms >> 16) & 0xf) << 4; 183 179 184 180 cpu_stepping = fms & 0xf; ··· 1143 1137 close(fd); 1144 1138 1145 1139 if (isst_platform_info.api_version > supported_api_ver) { 1140 + print_version(); 1146 1141 printf("Incompatible API versions; Upgrade of tool is required\n"); 1147 - return -1; 1142 + exit(1); 1148 1143 } 1149 1144 1150 1145 set_platform_ops: ··· 1751 1744 return parse_int_file(0, "/sys/devices/system/cpu/intel_pstate/no_turbo"); 1752 1745 } 1753 1746 1747 + #define U32_MAX ((unsigned int)~0U) 1748 + #define S32_MAX ((int)(U32_MAX >> 1)) 1749 + 1754 1750 static void adjust_scaling_max_from_base_freq(int cpu) 1755 1751 { 1756 1752 int base_freq, scaling_max_freq; ··· 1761 1751 scaling_max_freq = parse_int_file(0, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu); 1762 1752 base_freq = get_cpufreq_base_freq(cpu); 1763 1753 if (scaling_max_freq < base_freq || no_turbo()) 1764 - set_cpufreq_scaling_min_max(cpu, 1, base_freq); 1754 + set_cpufreq_scaling_min_max(cpu, 1, S32_MAX); 1765 1755 } 1766 1756 1767 1757 static void adjust_scaling_min_from_base_freq(int cpu) ··· 3201 3191 printf("\tTo get full turbo-freq information dump:\n"); 3202 3192 printf("\t\tintel-speed-select turbo-freq info -l 0\n"); 3203 3193 } 3204 - exit(1); 3205 - } 3206 - 3207 - static void print_version(void) 3208 - { 3209 - fprintf(outf, "Version %s\n", version_str); 3210 3194 exit(0); 3211 3195 } 3212 3196 ··· 3250 3246 } 3251 3247 3252 3248 ret = update_cpu_model(); 3253 - if (ret) 3254 - err(-1, "Invalid CPU model (%d)\n", cpu_model); 3249 + if (ret) { 3250 + fprintf(stderr, "Invalid CPU model (%d)\n", cpu_model); 3251 + exit(1); 3252 + } 3255 3253 printf("Intel(R) Speed Select Technology\n"); 3256 3254 printf("Executing on CPU model:%d[0x%x]\n", cpu_model, cpu_model); 3257 3255 ··· 3317 3311 break; 3318 3312 case 'v': 3319 3313 print_version(); 3314 + exit(0); 3320 3315 break; 3321 3316 case 'b': 3322 3317 oob_mode = 1;