Skip to content

Commit c48228c

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.16/core' into for-linus
- power management improvement for multitouch devices (Werner Sembach)
2 parents 6920d96 + 6a9e76f commit c48228c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

drivers/hid/hid-core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,9 @@ int hid_hw_open(struct hid_device *hdev)
23962396
ret = hdev->ll_driver->open(hdev);
23972397
if (ret)
23982398
hdev->ll_open_count--;
2399+
2400+
if (hdev->driver->on_hid_hw_open)
2401+
hdev->driver->on_hid_hw_open(hdev);
23992402
}
24002403

24012404
mutex_unlock(&hdev->ll_open_lock);
@@ -2415,8 +2418,12 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
24152418
void hid_hw_close(struct hid_device *hdev)
24162419
{
24172420
mutex_lock(&hdev->ll_open_lock);
2418-
if (!--hdev->ll_open_count)
2421+
if (!--hdev->ll_open_count) {
24192422
hdev->ll_driver->close(hdev);
2423+
2424+
if (hdev->driver->on_hid_hw_close)
2425+
hdev->driver->on_hid_hw_close(hdev);
2426+
}
24202427
mutex_unlock(&hdev->ll_open_lock);
24212428
}
24222429
EXPORT_SYMBOL_GPL(hid_hw_close);

drivers/hid/hid-multitouch.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,16 @@ static void mt_remove(struct hid_device *hdev)
18871887
hid_hw_stop(hdev);
18881888
}
18891889

1890+
static void mt_on_hid_hw_open(struct hid_device *hdev)
1891+
{
1892+
mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL);
1893+
}
1894+
1895+
static void mt_on_hid_hw_close(struct hid_device *hdev)
1896+
{
1897+
mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE);
1898+
}
1899+
18901900
/*
18911901
* This list contains only:
18921902
* - VID/PID of products not working with the default multitouch handling
@@ -2354,5 +2364,7 @@ static struct hid_driver mt_driver = {
23542364
.suspend = pm_ptr(mt_suspend),
23552365
.reset_resume = pm_ptr(mt_reset_resume),
23562366
.resume = pm_ptr(mt_resume),
2367+
.on_hid_hw_open = mt_on_hid_hw_open,
2368+
.on_hid_hw_close = mt_on_hid_hw_close,
23572369
};
23582370
module_hid_driver(mt_driver);

include/linux/hid.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ struct hid_usage_id {
795795
* @suspend: invoked on suspend (NULL means nop)
796796
* @resume: invoked on resume if device was not reset (NULL means nop)
797797
* @reset_resume: invoked on resume if device was reset (NULL means nop)
798+
* @on_hid_hw_open: invoked when hid core opens first instance (NULL means nop)
799+
* @on_hid_hw_close: invoked when hid core closes last instance (NULL means nop)
798800
*
799801
* probe should return -errno on error, or 0 on success. During probe,
800802
* input will not be passed to raw_event unless hid_device_io_start is
@@ -850,6 +852,8 @@ struct hid_driver {
850852
int (*suspend)(struct hid_device *hdev, pm_message_t message);
851853
int (*resume)(struct hid_device *hdev);
852854
int (*reset_resume)(struct hid_device *hdev);
855+
void (*on_hid_hw_open)(struct hid_device *hdev);
856+
void (*on_hid_hw_close)(struct hid_device *hdev);
853857

854858
/* private: */
855859
struct device_driver driver;

0 commit comments

Comments
 (0)