@@ -1167,21 +1167,18 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev)
1167
1167
*/
1168
1168
}
1169
1169
1170
- #ifdef CONFIG_PM
1171
-
1172
1170
/**
1173
1171
* sta2x11_vip_suspend - set device into power save mode
1174
- * @pdev: PCI device
1175
- * @state: new state of device
1172
+ * @dev_d: PCI device
1176
1173
*
1177
1174
* all relevant registers are saved and an attempt to set a new state is made.
1178
1175
*
1179
1176
* return value: 0 always indicate success,
1180
1177
* even if device could not be disabled. (workaround for hardware problem)
1181
1178
*/
1182
- static int sta2x11_vip_suspend (struct pci_dev * pdev , pm_message_t state )
1179
+ static int __maybe_unused sta2x11_vip_suspend (struct device * dev_d )
1183
1180
{
1184
- struct v4l2_device * v4l2_dev = pci_get_drvdata ( pdev );
1181
+ struct v4l2_device * v4l2_dev = dev_get_drvdata ( dev_d );
1185
1182
struct sta2x11_vip * vip =
1186
1183
container_of (v4l2_dev , struct sta2x11_vip , v4l2_dev );
1187
1184
unsigned long flags ;
@@ -1198,61 +1195,32 @@ static int sta2x11_vip_suspend(struct pci_dev *pdev, pm_message_t state)
1198
1195
vip -> register_save_area [SAVE_COUNT + IRQ_COUNT + i ] =
1199
1196
reg_read (vip , registers_to_save [i ]);
1200
1197
spin_unlock_irqrestore (& vip -> slock , flags );
1201
- /* save pci state */
1202
- pci_save_state (pdev );
1203
- if (pci_set_power_state (pdev , pci_choose_state (pdev , state ))) {
1204
- /*
1205
- * do not call pci_disable_device on sta2x11 because it
1206
- * break all other Bus masters on this EP
1207
- */
1208
- vip -> disabled = 1 ;
1209
- }
1198
+
1199
+ vip -> disabled = 1 ;
1210
1200
1211
1201
pr_info ("VIP: suspend\n" );
1212
1202
return 0 ;
1213
1203
}
1214
1204
1215
1205
/**
1216
1206
* sta2x11_vip_resume - resume device operation
1217
- * @pdev : PCI device
1218
- *
1219
- * re-enable device, set PCI state to powered and restore registers.
1220
- * resume normal device operation afterwards.
1207
+ * @dev_d : PCI device
1221
1208
*
1222
1209
* return value: 0, no error.
1223
1210
*
1224
1211
* other, could not set device to power on state.
1225
1212
*/
1226
- static int sta2x11_vip_resume (struct pci_dev * pdev )
1213
+ static int __maybe_unused sta2x11_vip_resume (struct device * dev_d )
1227
1214
{
1228
- struct v4l2_device * v4l2_dev = pci_get_drvdata ( pdev );
1215
+ struct v4l2_device * v4l2_dev = dev_get_drvdata ( dev_d );
1229
1216
struct sta2x11_vip * vip =
1230
1217
container_of (v4l2_dev , struct sta2x11_vip , v4l2_dev );
1231
1218
unsigned long flags ;
1232
- int ret , i ;
1219
+ int i ;
1233
1220
1234
1221
pr_info ("VIP: resume\n" );
1235
- /* restore pci state */
1236
- if (vip -> disabled ) {
1237
- ret = pci_enable_device (pdev );
1238
- if (ret ) {
1239
- pr_warn ("VIP: Can't enable device.\n" );
1240
- return ret ;
1241
- }
1242
- vip -> disabled = 0 ;
1243
- }
1244
- ret = pci_set_power_state (pdev , PCI_D0 );
1245
- if (ret ) {
1246
- /*
1247
- * do not call pci_disable_device on sta2x11 because it
1248
- * break all other Bus masters on this EP
1249
- */
1250
- pr_warn ("VIP: Can't enable device.\n" );
1251
- vip -> disabled = 1 ;
1252
- return ret ;
1253
- }
1254
1222
1255
- pci_restore_state ( pdev ) ;
1223
+ vip -> disabled = 0 ;
1256
1224
1257
1225
spin_lock_irqsave (& vip -> slock , flags );
1258
1226
for (i = 1 ; i < SAVE_COUNT ; i ++ )
@@ -1266,22 +1234,21 @@ static int sta2x11_vip_resume(struct pci_dev *pdev)
1266
1234
return 0 ;
1267
1235
}
1268
1236
1269
- #endif
1270
-
1271
1237
static const struct pci_device_id sta2x11_vip_pci_tbl [] = {
1272
1238
{PCI_DEVICE (PCI_VENDOR_ID_STMICRO , PCI_DEVICE_ID_STMICRO_VIP )},
1273
1239
{0 ,}
1274
1240
};
1275
1241
1242
+ static SIMPLE_DEV_PM_OPS (sta2x11_vip_pm_ops ,
1243
+ sta2x11_vip_suspend ,
1244
+ sta2x11_vip_resume ) ;
1245
+
1276
1246
static struct pci_driver sta2x11_vip_driver = {
1277
1247
.name = KBUILD_MODNAME ,
1278
1248
.probe = sta2x11_vip_init_one ,
1279
1249
.remove = sta2x11_vip_remove_one ,
1280
1250
.id_table = sta2x11_vip_pci_tbl ,
1281
- #ifdef CONFIG_PM
1282
- .suspend = sta2x11_vip_suspend ,
1283
- .resume = sta2x11_vip_resume ,
1284
- #endif
1251
+ .driver .pm = & sta2x11_vip_pm_ops ,
1285
1252
};
1286
1253
1287
1254
static int __init sta2x11_vip_init_module (void )
0 commit comments