hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/memstick/host/jmb38x_ms.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * jmb38x_ms.c - JMicron jmb38x MemoryStick card reader
34 *
45 * Copyright (C) 2008 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/spinlock.h>
....@@ -259,9 +255,11 @@
259255 case 3:
260256 host->io_word[0] |= buf[off + 2] << 16;
261257 host->io_pos++;
258
+ fallthrough;
262259 case 2:
263260 host->io_word[0] |= buf[off + 1] << 8;
264261 host->io_pos++;
262
+ fallthrough;
265263 case 1:
266264 host->io_word[0] |= buf[off];
267265 host->io_pos++;
....@@ -316,7 +314,7 @@
316314 }
317315
318316 while (length) {
319
- unsigned int uninitialized_var(p_off);
317
+ unsigned int p_off;
320318
321319 if (host->req->long_data) {
322320 pg = nth_page(sg_page(&host->req->sg),
....@@ -368,7 +366,6 @@
368366 static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
369367 {
370368 struct jmb38x_ms_host *host = memstick_priv(msh);
371
- unsigned char *data;
372369 unsigned int data_len, cmd, t_val;
373370
374371 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) {
....@@ -399,8 +396,6 @@
399396 else
400397 cmd |= TPC_WAIT_INT;
401398 }
402
-
403
- data = host->req->data;
404399
405400 if (!no_dma)
406401 host->cmd_flags |= DMA_DATA;
....@@ -438,13 +433,13 @@
438433 writel(((1 << 16) & BLOCK_COUNT_MASK)
439434 | (data_len & BLOCK_SIZE_MASK),
440435 host->addr + BLOCK);
441
- t_val = readl(host->addr + INT_STATUS_ENABLE);
442
- t_val |= host->req->data_dir == READ
443
- ? INT_STATUS_FIFO_RRDY
444
- : INT_STATUS_FIFO_WRDY;
436
+ t_val = readl(host->addr + INT_STATUS_ENABLE);
437
+ t_val |= host->req->data_dir == READ
438
+ ? INT_STATUS_FIFO_RRDY
439
+ : INT_STATUS_FIFO_WRDY;
445440
446
- writel(t_val, host->addr + INT_STATUS_ENABLE);
447
- writel(t_val, host->addr + INT_SIGNAL_ENABLE);
441
+ writel(t_val, host->addr + INT_STATUS_ENABLE);
442
+ writel(t_val, host->addr + INT_SIGNAL_ENABLE);
448443 } else {
449444 cmd &= ~(TPC_DATA_SEL | 0xf);
450445 host->cmd_flags |= REG_DATA;
....@@ -644,7 +639,6 @@
644639 writel(HOST_CONTROL_RESET_REQ | HOST_CONTROL_CLOCK_EN
645640 | readl(host->addr + HOST_CONTROL),
646641 host->addr + HOST_CONTROL);
647
- mmiowb();
648642
649643 for (cnt = 0; cnt < 20; ++cnt) {
650644 if (!(HOST_CONTROL_RESET_REQ
....@@ -659,7 +653,6 @@
659653 writel(HOST_CONTROL_RESET | HOST_CONTROL_CLOCK_EN
660654 | readl(host->addr + HOST_CONTROL),
661655 host->addr + HOST_CONTROL);
662
- mmiowb();
663656
664657 for (cnt = 0; cnt < 20; ++cnt) {
665658 if (!(HOST_CONTROL_RESET
....@@ -672,7 +665,6 @@
672665 return -EIO;
673666
674667 reset_ok:
675
- mmiowb();
676668 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE);
677669 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE);
678670 return 0;
....@@ -801,11 +793,10 @@
801793 return 0;
802794 }
803795
804
-#ifdef CONFIG_PM
805
-
806
-static int jmb38x_ms_suspend(struct pci_dev *dev, pm_message_t state)
796
+static int __maybe_unused jmb38x_ms_suspend(struct device *dev)
807797 {
808
- struct jmb38x_ms *jm = pci_get_drvdata(dev);
798
+ struct jmb38x_ms *jm = dev_get_drvdata(dev);
799
+
809800 int cnt;
810801
811802 for (cnt = 0; cnt < jm->host_cnt; ++cnt) {
....@@ -814,26 +805,17 @@
814805 memstick_suspend_host(jm->hosts[cnt]);
815806 }
816807
817
- pci_save_state(dev);
818
- pci_enable_wake(dev, pci_choose_state(dev, state), 0);
819
- pci_disable_device(dev);
820
- pci_set_power_state(dev, pci_choose_state(dev, state));
808
+ device_wakeup_disable(dev);
809
+
821810 return 0;
822811 }
823812
824
-static int jmb38x_ms_resume(struct pci_dev *dev)
813
+static int __maybe_unused jmb38x_ms_resume(struct device *dev)
825814 {
826
- struct jmb38x_ms *jm = pci_get_drvdata(dev);
815
+ struct jmb38x_ms *jm = dev_get_drvdata(dev);
827816 int rc;
828817
829
- pci_set_power_state(dev, PCI_D0);
830
- pci_restore_state(dev);
831
- rc = pci_enable_device(dev);
832
- if (rc)
833
- return rc;
834
- pci_set_master(dev);
835
-
836
- jmb38x_ms_pmos(dev, 1);
818
+ jmb38x_ms_pmos(to_pci_dev(dev), 1);
837819
838820 for (rc = 0; rc < jm->host_cnt; ++rc) {
839821 if (!jm->hosts[rc])
....@@ -845,18 +827,11 @@
845827 return 0;
846828 }
847829
848
-#else
849
-
850
-#define jmb38x_ms_suspend NULL
851
-#define jmb38x_ms_resume NULL
852
-
853
-#endif /* CONFIG_PM */
854
-
855830 static int jmb38x_ms_count_slots(struct pci_dev *pdev)
856831 {
857832 int cnt, rc = 0;
858833
859
- for (cnt = 0; cnt < PCI_ROM_RESOURCE; ++cnt) {
834
+ for (cnt = 0; cnt < PCI_STD_NUM_BARS; ++cnt) {
860835 if (!(IORESOURCE_MEM & pci_resource_flags(pdev, cnt)))
861836 break;
862837
....@@ -1009,7 +984,6 @@
1009984 tasklet_kill(&host->notify);
1010985 writel(0, host->addr + INT_SIGNAL_ENABLE);
1011986 writel(0, host->addr + INT_STATUS_ENABLE);
1012
- mmiowb();
1013987 dev_dbg(&jm->pdev->dev, "interrupts off\n");
1014988 spin_lock_irqsave(&host->lock, flags);
1015989 if (host->req) {
....@@ -1039,13 +1013,14 @@
10391013 { }
10401014 };
10411015
1016
+static SIMPLE_DEV_PM_OPS(jmb38x_ms_pm_ops, jmb38x_ms_suspend, jmb38x_ms_resume);
1017
+
10421018 static struct pci_driver jmb38x_ms_driver = {
10431019 .name = DRIVER_NAME,
10441020 .id_table = jmb38x_ms_id_tbl,
10451021 .probe = jmb38x_ms_probe,
10461022 .remove = jmb38x_ms_remove,
1047
- .suspend = jmb38x_ms_suspend,
1048
- .resume = jmb38x_ms_resume
1023
+ .driver.pm = &jmb38x_ms_pm_ops,
10491024 };
10501025
10511026 module_pci_driver(jmb38x_ms_driver);