]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
power: sequencing: pcie-m2: Improve PCI device ID check
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Tue, 19 May 2026 08:55:58 +0000 (14:25 +0530)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 8 Jun 2026 07:47:55 +0000 (09:47 +0200)
Instead of hardcoding the PCI device check, use pci_match_id() to check for
the known IDs using the pwrseq_m2_pci_ids[] array.

This makes adding support for new devices easier.

Tested-by: Wei Deng <wei.deng@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260519-pwrseq-m2-bt-v3-3-b39dc2ae3966@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/power/sequencing/pwrseq-pcie-m2.c

index 469e130330faaa3c1702a8db563d7e10643f60df..038271207a27e486920d0f41842a9805d685f500 100644 (file)
@@ -343,6 +343,11 @@ static void pwrseq_pcie_m2_remove_serdev(struct pwrseq_pcie_m2_ctx *ctx,
        mutex_unlock(&ctx->list_lock);
 }
 
+static const struct pci_device_id pwrseq_m2_pci_ids[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x1107) },
+       { } /* Sentinel */
+};
+
 static int pwrseq_pcie_m2_notify(struct notifier_block *nb, unsigned long action,
                              void *data)
 {
@@ -362,16 +367,14 @@ static int pwrseq_pcie_m2_notify(struct notifier_block *nb, unsigned long action
 
        switch (action) {
        case BUS_NOTIFY_ADD_DEVICE:
-               /* Create serdev device for WCN7850 */
-               if (pdev->vendor == PCI_VENDOR_ID_QCOM && pdev->device == 0x1107) {
+               if (pci_match_id(pwrseq_m2_pci_ids, pdev)) {
                        ret = pwrseq_pcie_m2_create_serdev(ctx, pdev);
                        if (ret)
                                return notifier_from_errno(ret);
                }
                break;
        case BUS_NOTIFY_REMOVED_DEVICE:
-               /* Destroy serdev device for WCN7850 */
-               if (pdev->vendor == PCI_VENDOR_ID_QCOM && pdev->device == 0x1107)
+               if (pci_match_id(pwrseq_m2_pci_ids, pdev))
                        pwrseq_pcie_m2_remove_serdev(ctx, pdev);
 
                break;