@@ -1028,6 +1028,7 @@ struct sony_sc {
1028
1028
struct led_classdev * leds [MAX_LEDS ];
1029
1029
unsigned long quirks ;
1030
1030
struct work_struct state_worker ;
1031
+ void (* send_output_report )(struct sony_sc * );
1031
1032
struct power_supply * battery ;
1032
1033
struct power_supply_desc battery_desc ;
1033
1034
int device_id ;
@@ -1789,7 +1790,7 @@ static int sony_leds_init(struct sony_sc *sc)
1789
1790
return ret ;
1790
1791
}
1791
1792
1792
- static void sixaxis_state_worker (struct work_struct * work )
1793
+ static void sixaxis_send_output_report (struct sony_sc * sc )
1793
1794
{
1794
1795
static const union sixaxis_output_report_01 default_report = {
1795
1796
.buf = {
@@ -1803,7 +1804,6 @@ static void sixaxis_state_worker(struct work_struct *work)
1803
1804
0x00 , 0x00 , 0x00 , 0x00 , 0x00
1804
1805
}
1805
1806
};
1806
- struct sony_sc * sc = container_of (work , struct sony_sc , state_worker );
1807
1807
struct sixaxis_output_report * report =
1808
1808
(struct sixaxis_output_report * )sc -> output_report_dmabuf ;
1809
1809
int n ;
@@ -1846,9 +1846,8 @@ static void sixaxis_state_worker(struct work_struct *work)
1846
1846
HID_OUTPUT_REPORT , HID_REQ_SET_REPORT );
1847
1847
}
1848
1848
1849
- static void dualshock4_state_worker (struct work_struct * work )
1849
+ static void dualshock4_send_output_report (struct sony_sc * sc )
1850
1850
{
1851
- struct sony_sc * sc = container_of (work , struct sony_sc , state_worker );
1852
1851
struct hid_device * hdev = sc -> hdev ;
1853
1852
__u8 * buf = sc -> output_report_dmabuf ;
1854
1853
int offset ;
@@ -1893,9 +1892,8 @@ static void dualshock4_state_worker(struct work_struct *work)
1893
1892
HID_OUTPUT_REPORT , HID_REQ_SET_REPORT );
1894
1893
}
1895
1894
1896
- static void motion_state_worker (struct work_struct * work )
1895
+ static void motion_send_output_report (struct sony_sc * sc )
1897
1896
{
1898
- struct sony_sc * sc = container_of (work , struct sony_sc , state_worker );
1899
1897
struct hid_device * hdev = sc -> hdev ;
1900
1898
struct motion_output_report_02 * report =
1901
1899
(struct motion_output_report_02 * )sc -> output_report_dmabuf ;
@@ -1914,6 +1912,12 @@ static void motion_state_worker(struct work_struct *work)
1914
1912
hid_hw_output_report (hdev , (__u8 * )report , MOTION_REPORT_0x02_SIZE );
1915
1913
}
1916
1914
1915
+ static void sony_state_worker (struct work_struct * work )
1916
+ {
1917
+ struct sony_sc * sc = container_of (work , struct sony_sc , state_worker );
1918
+ sc -> send_output_report (sc );
1919
+ }
1920
+
1917
1921
static int sony_allocate_output_report (struct sony_sc * sc )
1918
1922
{
1919
1923
if ((sc -> quirks & SIXAXIS_CONTROLLER ) ||
@@ -2241,11 +2245,13 @@ static void sony_release_device_id(struct sony_sc *sc)
2241
2245
}
2242
2246
}
2243
2247
2244
- static inline void sony_init_work (struct sony_sc * sc ,
2245
- void ( * worker )(struct work_struct * ))
2248
+ static inline void sony_init_output_report (struct sony_sc * sc ,
2249
+ void ( * send_output_report )(struct sony_sc * ))
2246
2250
{
2251
+ sc -> send_output_report = send_output_report ;
2252
+
2247
2253
if (!sc -> worker_initialized )
2248
- INIT_WORK (& sc -> state_worker , worker );
2254
+ INIT_WORK (& sc -> state_worker , sony_state_worker );
2249
2255
2250
2256
sc -> worker_initialized = 1 ;
2251
2257
}
@@ -2319,7 +2325,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
2319
2325
hdev -> quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP ;
2320
2326
hdev -> quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID ;
2321
2327
ret = sixaxis_set_operational_usb (hdev );
2322
- sony_init_work (sc , sixaxis_state_worker );
2328
+ sony_init_output_report (sc , sixaxis_send_output_report );
2323
2329
} else if ((sc -> quirks & SIXAXIS_CONTROLLER_BT ) ||
2324
2330
(sc -> quirks & NAVIGATION_CONTROLLER_BT )) {
2325
2331
/*
@@ -2328,7 +2334,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
2328
2334
*/
2329
2335
hdev -> quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP ;
2330
2336
ret = sixaxis_set_operational_bt (hdev );
2331
- sony_init_work (sc , sixaxis_state_worker );
2337
+ sony_init_output_report (sc , sixaxis_send_output_report );
2332
2338
} else if (sc -> quirks & DUALSHOCK4_CONTROLLER ) {
2333
2339
if (sc -> quirks & DUALSHOCK4_CONTROLLER_BT ) {
2334
2340
/*
@@ -2343,9 +2349,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
2343
2349
}
2344
2350
}
2345
2351
2346
- sony_init_work (sc , dualshock4_state_worker );
2352
+ sony_init_output_report (sc , dualshock4_send_output_report );
2347
2353
} else if (sc -> quirks & MOTION_CONTROLLER ) {
2348
- sony_init_work (sc , motion_state_worker );
2354
+ sony_init_output_report (sc , motion_send_output_report );
2349
2355
} else {
2350
2356
ret = 0 ;
2351
2357
}
0 commit comments