@@ -941,6 +941,57 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid)
941
941
ihid -> ops -> shutdown_tail (ihid -> ops );
942
942
}
943
943
944
+ static int i2c_hid_core_suspend (struct i2c_hid * ihid )
945
+ {
946
+ struct i2c_client * client = ihid -> client ;
947
+ struct hid_device * hid = ihid -> hid ;
948
+ int ret ;
949
+
950
+ ret = hid_driver_suspend (hid , PMSG_SUSPEND );
951
+ if (ret < 0 )
952
+ return ret ;
953
+
954
+ /* Save some power */
955
+ i2c_hid_set_power (ihid , I2C_HID_PWR_SLEEP );
956
+
957
+ disable_irq (client -> irq );
958
+
959
+ if (!device_may_wakeup (& client -> dev ))
960
+ i2c_hid_core_power_down (ihid );
961
+
962
+ return 0 ;
963
+ }
964
+
965
+ static int i2c_hid_core_resume (struct i2c_hid * ihid )
966
+ {
967
+ struct i2c_client * client = ihid -> client ;
968
+ struct hid_device * hid = ihid -> hid ;
969
+ int ret ;
970
+
971
+ if (!device_may_wakeup (& client -> dev ))
972
+ i2c_hid_core_power_up (ihid );
973
+
974
+ enable_irq (client -> irq );
975
+
976
+ /* Instead of resetting device, simply powers the device on. This
977
+ * solves "incomplete reports" on Raydium devices 2386:3118 and
978
+ * 2386:4B33 and fixes various SIS touchscreens no longer sending
979
+ * data after a suspend/resume.
980
+ *
981
+ * However some ALPS touchpads generate IRQ storm without reset, so
982
+ * let's still reset them here.
983
+ */
984
+ if (ihid -> quirks & I2C_HID_QUIRK_RESET_ON_RESUME )
985
+ ret = i2c_hid_hwreset (ihid );
986
+ else
987
+ ret = i2c_hid_set_power (ihid , I2C_HID_PWR_ON );
988
+
989
+ if (ret )
990
+ return ret ;
991
+
992
+ return hid_driver_reset_resume (hid );
993
+ }
994
+
944
995
/**
945
996
* i2c_hid_core_initial_power_up() - First time power up of the i2c-hid device.
946
997
* @ihid: The ihid object created during probe.
@@ -1115,61 +1166,24 @@ void i2c_hid_core_shutdown(struct i2c_client *client)
1115
1166
}
1116
1167
EXPORT_SYMBOL_GPL (i2c_hid_core_shutdown );
1117
1168
1118
- static int i2c_hid_core_suspend (struct device * dev )
1169
+ static int i2c_hid_core_pm_suspend (struct device * dev )
1119
1170
{
1120
1171
struct i2c_client * client = to_i2c_client (dev );
1121
1172
struct i2c_hid * ihid = i2c_get_clientdata (client );
1122
- struct hid_device * hid = ihid -> hid ;
1123
- int ret ;
1124
-
1125
- ret = hid_driver_suspend (hid , PMSG_SUSPEND );
1126
- if (ret < 0 )
1127
- return ret ;
1128
1173
1129
- /* Save some power */
1130
- i2c_hid_set_power (ihid , I2C_HID_PWR_SLEEP );
1131
-
1132
- disable_irq (client -> irq );
1133
-
1134
- if (!device_may_wakeup (& client -> dev ))
1135
- i2c_hid_core_power_down (ihid );
1136
-
1137
- return 0 ;
1174
+ return i2c_hid_core_suspend (ihid );
1138
1175
}
1139
1176
1140
- static int i2c_hid_core_resume (struct device * dev )
1177
+ static int i2c_hid_core_pm_resume (struct device * dev )
1141
1178
{
1142
- int ret ;
1143
1179
struct i2c_client * client = to_i2c_client (dev );
1144
1180
struct i2c_hid * ihid = i2c_get_clientdata (client );
1145
- struct hid_device * hid = ihid -> hid ;
1146
1181
1147
- if (!device_may_wakeup (& client -> dev ))
1148
- i2c_hid_core_power_up (ihid );
1149
-
1150
- enable_irq (client -> irq );
1151
-
1152
- /* Instead of resetting device, simply powers the device on. This
1153
- * solves "incomplete reports" on Raydium devices 2386:3118 and
1154
- * 2386:4B33 and fixes various SIS touchscreens no longer sending
1155
- * data after a suspend/resume.
1156
- *
1157
- * However some ALPS touchpads generate IRQ storm without reset, so
1158
- * let's still reset them here.
1159
- */
1160
- if (ihid -> quirks & I2C_HID_QUIRK_RESET_ON_RESUME )
1161
- ret = i2c_hid_hwreset (ihid );
1162
- else
1163
- ret = i2c_hid_set_power (ihid , I2C_HID_PWR_ON );
1164
-
1165
- if (ret )
1166
- return ret ;
1167
-
1168
- return hid_driver_reset_resume (hid );
1182
+ return i2c_hid_core_resume (ihid );
1169
1183
}
1170
1184
1171
1185
const struct dev_pm_ops i2c_hid_core_pm = {
1172
- SYSTEM_SLEEP_PM_OPS (i2c_hid_core_suspend , i2c_hid_core_resume )
1186
+ SYSTEM_SLEEP_PM_OPS (i2c_hid_core_pm_suspend , i2c_hid_core_pm_resume )
1173
1187
};
1174
1188
EXPORT_SYMBOL_GPL (i2c_hid_core_pm );
1175
1189
0 commit comments