mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] misc: keba: cp500: use pcim_enable_device()
Date: Mon, 13 Jul 2026 19:50:25 -0700	[thread overview]
Message-ID: <20260714025025.2055506-1-rosenp@gmail.com> (raw)

Switch from pci_enable_device() to pcim_enable_device() so the PCI device
is automatically disabled on probe error and driver removal. Drop the now
redundant manual pci_disable_device() and pci_clear_master() calls, since
pcim's release path clears bus mastering and disables the device.

Assisted-by: opencode:hy3-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/misc/keba/cp500.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/misc/keba/cp500.c b/drivers/misc/keba/cp500.c
index 6c65fbf22e75..c2ca63e40814 100644
--- a/drivers/misc/keba/cp500.c
+++ b/drivers/misc/keba/cp500.c
@@ -887,7 +887,7 @@ static int cp500_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 	else
 		return -ENODEV;
 
-	ret = pci_enable_device(pci_dev);
+	ret = pcim_enable_device(pci_dev);
 	if (ret)
 		return ret;
 	pci_set_master(pci_dev);
@@ -896,18 +896,15 @@ static int cp500_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 	startup.end = startup.start + cp500->devs->startup.size - 1;
 	cp500->system_startup_addr = devm_ioremap_resource(&pci_dev->dev,
 							   &startup);
-	if (IS_ERR(cp500->system_startup_addr)) {
-		ret = PTR_ERR(cp500->system_startup_addr);
-		goto out_disable;
-	}
+	if (IS_ERR(cp500->system_startup_addr))
+		return PTR_ERR(cp500->system_startup_addr);
 
 	cp500->msix_num = pci_alloc_irq_vectors(pci_dev, CP500_NUM_MSIX_NO_MMI,
 						CP500_NUM_MSIX, PCI_IRQ_MSIX);
 	if (cp500->msix_num < CP500_NUM_MSIX_NO_MMI) {
 		dev_err(&pci_dev->dev,
 			"Hardware does not support enough MSI-X interrupts\n");
-		ret = -ENODEV;
-		goto out_disable;
+		return -ENODEV;
 	}
 
 	cp500_vers = ioread32(cp500->system_startup_addr + CP500_VERSION_REG);
@@ -937,9 +934,6 @@ static int cp500_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 	nvmem_unregister_notifier(&cp500->nvmem_notifier);
 out_free_irq:
 	pci_free_irq_vectors(pci_dev);
-out_disable:
-	pci_clear_master(pci_dev);
-	pci_disable_device(pci_dev);
 
 	return ret;
 }
@@ -962,9 +956,6 @@ static void cp500_remove(struct pci_dev *pci_dev)
 	pci_set_drvdata(pci_dev, 0);
 
 	pci_free_irq_vectors(pci_dev);
-
-	pci_clear_master(pci_dev);
-	pci_disable_device(pci_dev);
 }
 
 static struct pci_device_id cp500_ids[] = {
-- 
2.55.0


                 reply	other threads:[~2026-07-14  2:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260714025025.2055506-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®