From 03dcede2199a649c1190a135aaf6c70af4ed5a28 Mon Sep 17 00:00:00 2001 From: Philipp Stanner Date: Tue, 28 Jan 2025 11:11:57 +0100 Subject: [PATCH 1/3] HID: intel-thc-hid: Remove deprecated PCI API calls intel-thc-hid reintroduced the already deprecated PCI API functions pcim_iomap_table(), pcim_iomap_regions(), pcim_iounmap_regions(), none of which should be used anymore. Furthermore, calling managed (pcim_*) functions in remove() and probe() for cleanup is not necessary, since the managed functions clean up automatically. Replace / remove the deprecated functions. Fixes: 61bb2714dc3a1 ("HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C driver skeleton") Signed-off-by: Philipp Stanner Reviewed-by: Even Xu Signed-off-by: Jiri Kosina --- .../intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 14 +++++--------- .../intel-thc-hid/intel-quickspi/pci-quickspi.c | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c index 2de93f4a25ca..fa51155ebe39 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c @@ -557,20 +557,19 @@ static int quicki2c_probe(struct pci_dev *pdev, pci_set_master(pdev); - ret = pcim_iomap_regions(pdev, BIT(0), KBUILD_MODNAME); + mem_addr = pcim_iomap_region(pdev, 0, KBUILD_MODNAME); + ret = PTR_ERR_OR_ZERO(mem_addr); if (ret) { dev_err_once(&pdev->dev, "Failed to get PCI regions, ret = %d.\n", ret); goto disable_pci_device; } - mem_addr = pcim_iomap_table(pdev)[0]; - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (ret) { ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (ret) { dev_err_once(&pdev->dev, "No usable DMA configuration %d\n", ret); - goto unmap_io_region; + goto disable_pci_device; } } @@ -578,7 +577,7 @@ static int quicki2c_probe(struct pci_dev *pdev, if (ret < 0) { dev_err_once(&pdev->dev, "Failed to allocate IRQ vectors. ret = %d\n", ret); - goto unmap_io_region; + goto disable_pci_device; } pdev->irq = pci_irq_vector(pdev, 0); @@ -587,7 +586,7 @@ static int quicki2c_probe(struct pci_dev *pdev, if (IS_ERR(qcdev)) { dev_err_once(&pdev->dev, "QuickI2C device init failed\n"); ret = PTR_ERR(qcdev); - goto unmap_io_region; + goto disable_pci_device; } pci_set_drvdata(pdev, qcdev); @@ -666,8 +665,6 @@ static int quicki2c_probe(struct pci_dev *pdev, quicki2c_dma_deinit(qcdev); dev_deinit: quicki2c_dev_deinit(qcdev); -unmap_io_region: - pcim_iounmap_regions(pdev, BIT(0)); disable_pci_device: pci_clear_master(pdev); @@ -697,7 +694,6 @@ static void quicki2c_remove(struct pci_dev *pdev) quicki2c_dev_deinit(qcdev); - pcim_iounmap_regions(pdev, BIT(0)); pci_clear_master(pdev); } diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c index 4641e818dfa4..514b199cb884 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c @@ -575,20 +575,19 @@ static int quickspi_probe(struct pci_dev *pdev, pci_set_master(pdev); - ret = pcim_iomap_regions(pdev, BIT(0), KBUILD_MODNAME); + mem_addr = pcim_iomap_region(pdev, 0, KBUILD_MODNAME); + ret = PTR_ERR_OR_ZERO(mem_addr); if (ret) { dev_err(&pdev->dev, "Failed to get PCI regions, ret = %d.\n", ret); goto disable_pci_device; } - mem_addr = pcim_iomap_table(pdev)[0]; - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (ret) { ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (ret) { dev_err(&pdev->dev, "No usable DMA configuration %d\n", ret); - goto unmap_io_region; + goto disable_pci_device; } } @@ -596,7 +595,7 @@ static int quickspi_probe(struct pci_dev *pdev, if (ret < 0) { dev_err(&pdev->dev, "Failed to allocate IRQ vectors. ret = %d\n", ret); - goto unmap_io_region; + goto disable_pci_device; } pdev->irq = pci_irq_vector(pdev, 0); @@ -605,7 +604,7 @@ static int quickspi_probe(struct pci_dev *pdev, if (IS_ERR(qsdev)) { dev_err(&pdev->dev, "QuickSPI device init failed\n"); ret = PTR_ERR(qsdev); - goto unmap_io_region; + goto disable_pci_device; } pci_set_drvdata(pdev, qsdev); @@ -668,8 +667,6 @@ static int quickspi_probe(struct pci_dev *pdev, quickspi_dma_deinit(qsdev); dev_deinit: quickspi_dev_deinit(qsdev); -unmap_io_region: - pcim_iounmap_regions(pdev, BIT(0)); disable_pci_device: pci_clear_master(pdev); @@ -699,7 +696,6 @@ static void quickspi_remove(struct pci_dev *pdev) quickspi_dev_deinit(qsdev); - pcim_iounmap_regions(pdev, BIT(0)); pci_clear_master(pdev); } From d05c76fceb096b4423745856325d72c048d681e4 Mon Sep 17 00:00:00 2001 From: Even Xu Date: Thu, 13 Feb 2025 10:40:21 +0800 Subject: [PATCH 2/3] Hid: Intel-thc-hid: Intel-thc: Fix "dubious: !x | !y" issue Change to use "||" to make it more readable and avoid miss understanding. Signed-off-by: Even Xu Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202501292144.eFDq4ovr-lkp@intel.com Signed-off-by: Jiri Kosina --- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c index eb23bea77686..8f97e71df7f4 100644 --- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c @@ -295,7 +295,7 @@ static void release_dma_buffers(struct thc_device *dev, return; for (i = 0; i < config->prd_tbl_num; i++) { - if (!config->sgls[i] | !config->sgls_nent[i]) + if (!config->sgls[i] || !config->sgls_nent[i]) continue; dma_unmap_sg(dev->dev, config->sgls[i], From f97455f936f17fa5fa3fe8430b1731ba5c799189 Mon Sep 17 00:00:00 2001 From: Even Xu Date: Wed, 5 Mar 2025 11:33:30 +0800 Subject: [PATCH 3/3] HID: Intel-thc-hid: Intel-quickspi: Correct device state names gramatically Correct quickspi device state name and change the list order to follow device state working flow. Signed-off-by: Even Xu Signed-off-by: Jiri Kosina --- drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c | 2 +- drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h | 4 ++-- drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c index 514b199cb884..1f97f87960bd 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c @@ -426,7 +426,7 @@ static struct quickspi_device *quickspi_dev_init(struct pci_dev *pdev, void __io thc_interrupt_enable(qsdev->thc_hw, true); - qsdev->state = QUICKSPI_INITED; + qsdev->state = QUICKSPI_INITIATED; return qsdev; } diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h index 75179bb26767..6fdf674b21c5 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h @@ -57,9 +57,9 @@ enum quickspi_dev_state { QUICKSPI_NONE, + QUICKSPI_INITIATED, QUICKSPI_RESETING, - QUICKSPI_RESETED, - QUICKSPI_INITED, + QUICKSPI_RESET, QUICKSPI_ENABLED, QUICKSPI_DISABLED, }; diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c index 7373238ceb18..935a6684926c 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c @@ -333,7 +333,7 @@ int reset_tic(struct quickspi_device *qsdev) return -EINVAL; } - qsdev->state = QUICKSPI_RESETED; + qsdev->state = QUICKSPI_RESET; ret = quickspi_get_device_descriptor(qsdev); if (ret)