26
26
#include <linux/delay.h>
27
27
#include <linux/slab.h>
28
28
#include <linux/pm.h>
29
- #include <linux/pm_runtime.h>
30
29
#include <linux/device.h>
31
30
#include <linux/wait.h>
32
31
#include <linux/err.h>
48
47
/* quirks to control the device */
49
48
#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0)
50
49
#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1)
51
- #define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2)
52
- #define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3)
53
50
#define I2C_HID_QUIRK_BOGUS_IRQ BIT(4)
54
51
55
52
/* flags */
@@ -172,14 +169,7 @@ static const struct i2c_hid_quirks {
172
169
{ USB_VENDOR_ID_WEIDA , HID_ANY_ID ,
173
170
I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
174
171
{ I2C_VENDOR_ID_HANTICK , I2C_PRODUCT_ID_HANTICK_5288 ,
175
- I2C_HID_QUIRK_NO_IRQ_AFTER_RESET |
176
- I2C_HID_QUIRK_NO_RUNTIME_PM },
177
- { I2C_VENDOR_ID_RAYDIUM , I2C_PRODUCT_ID_RAYDIUM_4B33 ,
178
- I2C_HID_QUIRK_DELAY_AFTER_SLEEP },
179
- { USB_VENDOR_ID_LG , I2C_DEVICE_ID_LG_8001 ,
180
- I2C_HID_QUIRK_NO_RUNTIME_PM },
181
- { I2C_VENDOR_ID_GOODIX , I2C_DEVICE_ID_GOODIX_01F0 ,
182
- I2C_HID_QUIRK_NO_RUNTIME_PM },
172
+ I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
183
173
{ USB_VENDOR_ID_ELAN , HID_ANY_ID ,
184
174
I2C_HID_QUIRK_BOGUS_IRQ },
185
175
{ 0 , 0 }
@@ -397,7 +387,6 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
397
387
{
398
388
struct i2c_hid * ihid = i2c_get_clientdata (client );
399
389
int ret ;
400
- unsigned long now , delay ;
401
390
402
391
i2c_hid_dbg (ihid , "%s\n" , __func__ );
403
392
@@ -415,22 +404,9 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
415
404
goto set_pwr_exit ;
416
405
}
417
406
418
- if (ihid -> quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP &&
419
- power_state == I2C_HID_PWR_ON ) {
420
- now = jiffies ;
421
- if (time_after (ihid -> sleep_delay , now )) {
422
- delay = jiffies_to_usecs (ihid -> sleep_delay - now );
423
- usleep_range (delay , delay + 1 );
424
- }
425
- }
426
-
427
407
ret = __i2c_hid_command (client , & hid_set_power_cmd , power_state ,
428
408
0 , NULL , 0 , NULL , 0 );
429
409
430
- if (ihid -> quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP &&
431
- power_state == I2C_HID_PWR_SLEEP )
432
- ihid -> sleep_delay = jiffies + msecs_to_jiffies (20 );
433
-
434
410
if (ret )
435
411
dev_err (& client -> dev , "failed to change power setting.\n" );
436
412
@@ -791,11 +767,6 @@ static int i2c_hid_open(struct hid_device *hid)
791
767
{
792
768
struct i2c_client * client = hid -> driver_data ;
793
769
struct i2c_hid * ihid = i2c_get_clientdata (client );
794
- int ret = 0 ;
795
-
796
- ret = pm_runtime_get_sync (& client -> dev );
797
- if (ret < 0 )
798
- return ret ;
799
770
800
771
set_bit (I2C_HID_STARTED , & ihid -> flags );
801
772
return 0 ;
@@ -807,27 +778,6 @@ static void i2c_hid_close(struct hid_device *hid)
807
778
struct i2c_hid * ihid = i2c_get_clientdata (client );
808
779
809
780
clear_bit (I2C_HID_STARTED , & ihid -> flags );
810
-
811
- /* Save some power */
812
- pm_runtime_put (& client -> dev );
813
- }
814
-
815
- static int i2c_hid_power (struct hid_device * hid , int lvl )
816
- {
817
- struct i2c_client * client = hid -> driver_data ;
818
- struct i2c_hid * ihid = i2c_get_clientdata (client );
819
-
820
- i2c_hid_dbg (ihid , "%s lvl:%d\n" , __func__ , lvl );
821
-
822
- switch (lvl ) {
823
- case PM_HINT_FULLON :
824
- pm_runtime_get_sync (& client -> dev );
825
- break ;
826
- case PM_HINT_NORMAL :
827
- pm_runtime_put (& client -> dev );
828
- break ;
829
- }
830
- return 0 ;
831
781
}
832
782
833
783
struct hid_ll_driver i2c_hid_ll_driver = {
@@ -836,7 +786,6 @@ struct hid_ll_driver i2c_hid_ll_driver = {
836
786
.stop = i2c_hid_stop ,
837
787
.open = i2c_hid_open ,
838
788
.close = i2c_hid_close ,
839
- .power = i2c_hid_power ,
840
789
.output_report = i2c_hid_output_report ,
841
790
.raw_request = i2c_hid_raw_request ,
842
791
};
@@ -1104,26 +1053,23 @@ static int i2c_hid_probe(struct i2c_client *client,
1104
1053
1105
1054
i2c_hid_acpi_fix_up_power (& client -> dev );
1106
1055
1107
- pm_runtime_get_noresume (& client -> dev );
1108
- pm_runtime_set_active (& client -> dev );
1109
- pm_runtime_enable (& client -> dev );
1110
1056
device_enable_async_suspend (& client -> dev );
1111
1057
1112
1058
/* Make sure there is something at this address */
1113
1059
ret = i2c_smbus_read_byte (client );
1114
1060
if (ret < 0 ) {
1115
1061
dev_dbg (& client -> dev , "nothing at this address: %d\n" , ret );
1116
1062
ret = - ENXIO ;
1117
- goto err_pm ;
1063
+ goto err_regulator ;
1118
1064
}
1119
1065
1120
1066
ret = i2c_hid_fetch_hid_descriptor (ihid );
1121
1067
if (ret < 0 )
1122
- goto err_pm ;
1068
+ goto err_regulator ;
1123
1069
1124
1070
ret = i2c_hid_init_irq (client );
1125
1071
if (ret < 0 )
1126
- goto err_pm ;
1072
+ goto err_regulator ;
1127
1073
1128
1074
hid = hid_allocate_device ();
1129
1075
if (IS_ERR (hid )) {
@@ -1154,9 +1100,6 @@ static int i2c_hid_probe(struct i2c_client *client,
1154
1100
goto err_mem_free ;
1155
1101
}
1156
1102
1157
- if (!(ihid -> quirks & I2C_HID_QUIRK_NO_RUNTIME_PM ))
1158
- pm_runtime_put (& client -> dev );
1159
-
1160
1103
return 0 ;
1161
1104
1162
1105
err_mem_free :
@@ -1165,10 +1108,6 @@ static int i2c_hid_probe(struct i2c_client *client,
1165
1108
err_irq :
1166
1109
free_irq (client -> irq , ihid );
1167
1110
1168
- err_pm :
1169
- pm_runtime_put_noidle (& client -> dev );
1170
- pm_runtime_disable (& client -> dev );
1171
-
1172
1111
err_regulator :
1173
1112
regulator_bulk_disable (ARRAY_SIZE (ihid -> pdata .supplies ),
1174
1113
ihid -> pdata .supplies );
@@ -1181,12 +1120,6 @@ static int i2c_hid_remove(struct i2c_client *client)
1181
1120
struct i2c_hid * ihid = i2c_get_clientdata (client );
1182
1121
struct hid_device * hid ;
1183
1122
1184
- if (!(ihid -> quirks & I2C_HID_QUIRK_NO_RUNTIME_PM ))
1185
- pm_runtime_get_sync (& client -> dev );
1186
- pm_runtime_disable (& client -> dev );
1187
- pm_runtime_set_suspended (& client -> dev );
1188
- pm_runtime_put_noidle (& client -> dev );
1189
-
1190
1123
hid = ihid -> hid ;
1191
1124
hid_destroy_device (hid );
1192
1125
@@ -1219,25 +1152,15 @@ static int i2c_hid_suspend(struct device *dev)
1219
1152
int wake_status ;
1220
1153
1221
1154
if (hid -> driver && hid -> driver -> suspend ) {
1222
- /*
1223
- * Wake up the device so that IO issues in
1224
- * HID driver's suspend code can succeed.
1225
- */
1226
- ret = pm_runtime_resume (dev );
1227
- if (ret < 0 )
1228
- return ret ;
1229
-
1230
1155
ret = hid -> driver -> suspend (hid , PMSG_SUSPEND );
1231
1156
if (ret < 0 )
1232
1157
return ret ;
1233
1158
}
1234
1159
1235
- if (!pm_runtime_suspended (dev )) {
1236
- /* Save some power */
1237
- i2c_hid_set_power (client , I2C_HID_PWR_SLEEP );
1160
+ /* Save some power */
1161
+ i2c_hid_set_power (client , I2C_HID_PWR_SLEEP );
1238
1162
1239
- disable_irq (client -> irq );
1240
- }
1163
+ disable_irq (client -> irq );
1241
1164
1242
1165
if (device_may_wakeup (& client -> dev )) {
1243
1166
wake_status = enable_irq_wake (client -> irq );
@@ -1279,11 +1202,6 @@ static int i2c_hid_resume(struct device *dev)
1279
1202
wake_status );
1280
1203
}
1281
1204
1282
- /* We'll resume to full power */
1283
- pm_runtime_disable (dev );
1284
- pm_runtime_set_active (dev );
1285
- pm_runtime_enable (dev );
1286
-
1287
1205
enable_irq (client -> irq );
1288
1206
1289
1207
/* Instead of resetting device, simply powers the device on. This
@@ -1304,30 +1222,8 @@ static int i2c_hid_resume(struct device *dev)
1304
1222
}
1305
1223
#endif
1306
1224
1307
- #ifdef CONFIG_PM
1308
- static int i2c_hid_runtime_suspend (struct device * dev )
1309
- {
1310
- struct i2c_client * client = to_i2c_client (dev );
1311
-
1312
- i2c_hid_set_power (client , I2C_HID_PWR_SLEEP );
1313
- disable_irq (client -> irq );
1314
- return 0 ;
1315
- }
1316
-
1317
- static int i2c_hid_runtime_resume (struct device * dev )
1318
- {
1319
- struct i2c_client * client = to_i2c_client (dev );
1320
-
1321
- enable_irq (client -> irq );
1322
- i2c_hid_set_power (client , I2C_HID_PWR_ON );
1323
- return 0 ;
1324
- }
1325
- #endif
1326
-
1327
1225
static const struct dev_pm_ops i2c_hid_pm = {
1328
1226
SET_SYSTEM_SLEEP_PM_OPS (i2c_hid_suspend , i2c_hid_resume )
1329
- SET_RUNTIME_PM_OPS (i2c_hid_runtime_suspend , i2c_hid_runtime_resume ,
1330
- NULL )
1331
1227
};
1332
1228
1333
1229
static const struct i2c_device_id i2c_hid_id_table [] = {
0 commit comments