.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * jmb38x_ms.c - JMicron jmb38x MemoryStick card reader |
---|
3 | 4 | * |
---|
4 | 5 | * 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 | | - * |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/spinlock.h> |
---|
.. | .. |
---|
259 | 255 | case 3: |
---|
260 | 256 | host->io_word[0] |= buf[off + 2] << 16; |
---|
261 | 257 | host->io_pos++; |
---|
| 258 | + fallthrough; |
---|
262 | 259 | case 2: |
---|
263 | 260 | host->io_word[0] |= buf[off + 1] << 8; |
---|
264 | 261 | host->io_pos++; |
---|
| 262 | + fallthrough; |
---|
265 | 263 | case 1: |
---|
266 | 264 | host->io_word[0] |= buf[off]; |
---|
267 | 265 | host->io_pos++; |
---|
.. | .. |
---|
316 | 314 | } |
---|
317 | 315 | |
---|
318 | 316 | while (length) { |
---|
319 | | - unsigned int uninitialized_var(p_off); |
---|
| 317 | + unsigned int p_off; |
---|
320 | 318 | |
---|
321 | 319 | if (host->req->long_data) { |
---|
322 | 320 | pg = nth_page(sg_page(&host->req->sg), |
---|
.. | .. |
---|
368 | 366 | static int jmb38x_ms_issue_cmd(struct memstick_host *msh) |
---|
369 | 367 | { |
---|
370 | 368 | struct jmb38x_ms_host *host = memstick_priv(msh); |
---|
371 | | - unsigned char *data; |
---|
372 | 369 | unsigned int data_len, cmd, t_val; |
---|
373 | 370 | |
---|
374 | 371 | if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { |
---|
.. | .. |
---|
399 | 396 | else |
---|
400 | 397 | cmd |= TPC_WAIT_INT; |
---|
401 | 398 | } |
---|
402 | | - |
---|
403 | | - data = host->req->data; |
---|
404 | 399 | |
---|
405 | 400 | if (!no_dma) |
---|
406 | 401 | host->cmd_flags |= DMA_DATA; |
---|
.. | .. |
---|
438 | 433 | writel(((1 << 16) & BLOCK_COUNT_MASK) |
---|
439 | 434 | | (data_len & BLOCK_SIZE_MASK), |
---|
440 | 435 | 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; |
---|
445 | 440 | |
---|
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); |
---|
448 | 443 | } else { |
---|
449 | 444 | cmd &= ~(TPC_DATA_SEL | 0xf); |
---|
450 | 445 | host->cmd_flags |= REG_DATA; |
---|
.. | .. |
---|
644 | 639 | writel(HOST_CONTROL_RESET_REQ | HOST_CONTROL_CLOCK_EN |
---|
645 | 640 | | readl(host->addr + HOST_CONTROL), |
---|
646 | 641 | host->addr + HOST_CONTROL); |
---|
647 | | - mmiowb(); |
---|
648 | 642 | |
---|
649 | 643 | for (cnt = 0; cnt < 20; ++cnt) { |
---|
650 | 644 | if (!(HOST_CONTROL_RESET_REQ |
---|
.. | .. |
---|
659 | 653 | writel(HOST_CONTROL_RESET | HOST_CONTROL_CLOCK_EN |
---|
660 | 654 | | readl(host->addr + HOST_CONTROL), |
---|
661 | 655 | host->addr + HOST_CONTROL); |
---|
662 | | - mmiowb(); |
---|
663 | 656 | |
---|
664 | 657 | for (cnt = 0; cnt < 20; ++cnt) { |
---|
665 | 658 | if (!(HOST_CONTROL_RESET |
---|
.. | .. |
---|
672 | 665 | return -EIO; |
---|
673 | 666 | |
---|
674 | 667 | reset_ok: |
---|
675 | | - mmiowb(); |
---|
676 | 668 | writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE); |
---|
677 | 669 | writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE); |
---|
678 | 670 | return 0; |
---|
.. | .. |
---|
801 | 793 | return 0; |
---|
802 | 794 | } |
---|
803 | 795 | |
---|
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) |
---|
807 | 797 | { |
---|
808 | | - struct jmb38x_ms *jm = pci_get_drvdata(dev); |
---|
| 798 | + struct jmb38x_ms *jm = dev_get_drvdata(dev); |
---|
| 799 | + |
---|
809 | 800 | int cnt; |
---|
810 | 801 | |
---|
811 | 802 | for (cnt = 0; cnt < jm->host_cnt; ++cnt) { |
---|
.. | .. |
---|
814 | 805 | memstick_suspend_host(jm->hosts[cnt]); |
---|
815 | 806 | } |
---|
816 | 807 | |
---|
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 | + |
---|
821 | 810 | return 0; |
---|
822 | 811 | } |
---|
823 | 812 | |
---|
824 | | -static int jmb38x_ms_resume(struct pci_dev *dev) |
---|
| 813 | +static int __maybe_unused jmb38x_ms_resume(struct device *dev) |
---|
825 | 814 | { |
---|
826 | | - struct jmb38x_ms *jm = pci_get_drvdata(dev); |
---|
| 815 | + struct jmb38x_ms *jm = dev_get_drvdata(dev); |
---|
827 | 816 | int rc; |
---|
828 | 817 | |
---|
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); |
---|
837 | 819 | |
---|
838 | 820 | for (rc = 0; rc < jm->host_cnt; ++rc) { |
---|
839 | 821 | if (!jm->hosts[rc]) |
---|
.. | .. |
---|
845 | 827 | return 0; |
---|
846 | 828 | } |
---|
847 | 829 | |
---|
848 | | -#else |
---|
849 | | - |
---|
850 | | -#define jmb38x_ms_suspend NULL |
---|
851 | | -#define jmb38x_ms_resume NULL |
---|
852 | | - |
---|
853 | | -#endif /* CONFIG_PM */ |
---|
854 | | - |
---|
855 | 830 | static int jmb38x_ms_count_slots(struct pci_dev *pdev) |
---|
856 | 831 | { |
---|
857 | 832 | int cnt, rc = 0; |
---|
858 | 833 | |
---|
859 | | - for (cnt = 0; cnt < PCI_ROM_RESOURCE; ++cnt) { |
---|
| 834 | + for (cnt = 0; cnt < PCI_STD_NUM_BARS; ++cnt) { |
---|
860 | 835 | if (!(IORESOURCE_MEM & pci_resource_flags(pdev, cnt))) |
---|
861 | 836 | break; |
---|
862 | 837 | |
---|
.. | .. |
---|
1009 | 984 | tasklet_kill(&host->notify); |
---|
1010 | 985 | writel(0, host->addr + INT_SIGNAL_ENABLE); |
---|
1011 | 986 | writel(0, host->addr + INT_STATUS_ENABLE); |
---|
1012 | | - mmiowb(); |
---|
1013 | 987 | dev_dbg(&jm->pdev->dev, "interrupts off\n"); |
---|
1014 | 988 | spin_lock_irqsave(&host->lock, flags); |
---|
1015 | 989 | if (host->req) { |
---|
.. | .. |
---|
1039 | 1013 | { } |
---|
1040 | 1014 | }; |
---|
1041 | 1015 | |
---|
| 1016 | +static SIMPLE_DEV_PM_OPS(jmb38x_ms_pm_ops, jmb38x_ms_suspend, jmb38x_ms_resume); |
---|
| 1017 | + |
---|
1042 | 1018 | static struct pci_driver jmb38x_ms_driver = { |
---|
1043 | 1019 | .name = DRIVER_NAME, |
---|
1044 | 1020 | .id_table = jmb38x_ms_id_tbl, |
---|
1045 | 1021 | .probe = jmb38x_ms_probe, |
---|
1046 | 1022 | .remove = jmb38x_ms_remove, |
---|
1047 | | - .suspend = jmb38x_ms_suspend, |
---|
1048 | | - .resume = jmb38x_ms_resume |
---|
| 1023 | + .driver.pm = &jmb38x_ms_pm_ops, |
---|
1049 | 1024 | }; |
---|
1050 | 1025 | |
---|
1051 | 1026 | module_pci_driver(jmb38x_ms_driver); |
---|