forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/misc/tifm_7xx1.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * tifm_7xx1.c - TI FlashMedia driver
34 *
45 * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
106 */
117
128 #include <linux/tifm.h>
....@@ -194,7 +190,7 @@
194190 spin_unlock_irqrestore(&fm->lock, flags);
195191 }
196192 if (sock)
197
- tifm_free_device(&sock->dev);
193
+ put_device(&sock->dev);
198194 }
199195 spin_lock_irqsave(&fm->lock, flags);
200196 }
....@@ -211,10 +207,9 @@
211207 spin_unlock_irqrestore(&fm->lock, flags);
212208 }
213209
214
-#ifdef CONFIG_PM
215
-
216
-static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
210
+static int __maybe_unused tifm_7xx1_suspend(struct device *dev_d)
217211 {
212
+ struct pci_dev *dev = to_pci_dev(dev_d);
218213 struct tifm_adapter *fm = pci_get_drvdata(dev);
219214 int cnt;
220215
....@@ -225,15 +220,13 @@
225220 tifm_7xx1_sock_power_off(fm->sockets[cnt]->addr);
226221 }
227222
228
- pci_save_state(dev);
229
- pci_enable_wake(dev, pci_choose_state(dev, state), 0);
230
- pci_disable_device(dev);
231
- pci_set_power_state(dev, pci_choose_state(dev, state));
223
+ device_wakeup_disable(dev_d);
232224 return 0;
233225 }
234226
235
-static int tifm_7xx1_resume(struct pci_dev *dev)
227
+static int __maybe_unused tifm_7xx1_resume(struct device *dev_d)
236228 {
229
+ struct pci_dev *dev = to_pci_dev(dev_d);
237230 struct tifm_adapter *fm = pci_get_drvdata(dev);
238231 int rc;
239232 unsigned long timeout;
....@@ -246,11 +239,6 @@
246239 if (WARN_ON(fm->num_sockets > ARRAY_SIZE(new_ids)))
247240 return -ENXIO;
248241
249
- pci_set_power_state(dev, PCI_D0);
250
- pci_restore_state(dev);
251
- rc = pci_enable_device(dev);
252
- if (rc)
253
- return rc;
254242 pci_set_master(dev);
255243
256244 dev_dbg(&dev->dev, "resuming host\n");
....@@ -300,13 +288,6 @@
300288
301289 return 0;
302290 }
303
-
304
-#else
305
-
306
-#define tifm_7xx1_suspend NULL
307
-#define tifm_7xx1_resume NULL
308
-
309
-#endif /* CONFIG_PM */
310291
311292 static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm,
312293 struct tifm_dev *sock)
....@@ -403,7 +384,6 @@
403384 fm->eject = tifm_7xx1_dummy_eject;
404385 fm->has_ms_pif = tifm_7xx1_dummy_has_ms_pif;
405386 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
406
- mmiowb();
407387 free_irq(dev->irq, fm);
408388
409389 tifm_remove_adapter(fm);
....@@ -429,13 +409,14 @@
429409 { }
430410 };
431411
412
+static SIMPLE_DEV_PM_OPS(tifm_7xx1_pm_ops, tifm_7xx1_suspend, tifm_7xx1_resume);
413
+
432414 static struct pci_driver tifm_7xx1_driver = {
433415 .name = DRIVER_NAME,
434416 .id_table = tifm_7xx1_pci_tbl,
435417 .probe = tifm_7xx1_probe,
436418 .remove = tifm_7xx1_remove,
437
- .suspend = tifm_7xx1_suspend,
438
- .resume = tifm_7xx1_resume,
419
+ .driver.pm = &tifm_7xx1_pm_ops,
439420 };
440421
441422 module_pci_driver(tifm_7xx1_driver);