File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -2396,6 +2396,9 @@ int hid_hw_open(struct hid_device *hdev)
2396
2396
ret = hdev -> ll_driver -> open (hdev );
2397
2397
if (ret )
2398
2398
hdev -> ll_open_count -- ;
2399
+
2400
+ if (hdev -> driver -> on_hid_hw_open )
2401
+ hdev -> driver -> on_hid_hw_open (hdev );
2399
2402
}
2400
2403
2401
2404
mutex_unlock (& hdev -> ll_open_lock );
@@ -2415,8 +2418,12 @@ EXPORT_SYMBOL_GPL(hid_hw_open);
2415
2418
void hid_hw_close (struct hid_device * hdev )
2416
2419
{
2417
2420
mutex_lock (& hdev -> ll_open_lock );
2418
- if (!-- hdev -> ll_open_count )
2421
+ if (!-- hdev -> ll_open_count ) {
2419
2422
hdev -> ll_driver -> close (hdev );
2423
+
2424
+ if (hdev -> driver -> on_hid_hw_close )
2425
+ hdev -> driver -> on_hid_hw_close (hdev );
2426
+ }
2420
2427
mutex_unlock (& hdev -> ll_open_lock );
2421
2428
}
2422
2429
EXPORT_SYMBOL_GPL (hid_hw_close );
Original file line number Diff line number Diff line change @@ -1887,6 +1887,16 @@ static void mt_remove(struct hid_device *hdev)
1887
1887
hid_hw_stop (hdev );
1888
1888
}
1889
1889
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
+
1890
1900
/*
1891
1901
* This list contains only:
1892
1902
* - VID/PID of products not working with the default multitouch handling
@@ -2354,5 +2364,7 @@ static struct hid_driver mt_driver = {
2354
2364
.suspend = pm_ptr (mt_suspend ),
2355
2365
.reset_resume = pm_ptr (mt_reset_resume ),
2356
2366
.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 ,
2357
2369
};
2358
2370
module_hid_driver (mt_driver );
Original file line number Diff line number Diff line change @@ -795,6 +795,8 @@ struct hid_usage_id {
795
795
* @suspend: invoked on suspend (NULL means nop)
796
796
* @resume: invoked on resume if device was not reset (NULL means nop)
797
797
* @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)
798
800
*
799
801
* probe should return -errno on error, or 0 on success. During probe,
800
802
* input will not be passed to raw_event unless hid_device_io_start is
@@ -850,6 +852,8 @@ struct hid_driver {
850
852
int (* suspend )(struct hid_device * hdev , pm_message_t message );
851
853
int (* resume )(struct hid_device * hdev );
852
854
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 );
853
857
854
858
/* private: */
855
859
struct device_driver driver ;
You can’t perform that action at this time.
0 commit comments