From: Michal Rokos <michal@rokos.info>
To: linux-kernel@vger.kernel.org
Subject: Re: avoiding pci_disable_device()...
Date: Mon, 14 Feb 2005 11:43:02 +0100 [thread overview]
Message-ID: <200502141143.02205.michal@rokos.info> (raw)
Hello,
> Currently, in almost every PCI driver, if pci_request_regions() fails --
> indicating another driver is using the hardware -- then
> pci_disable_device() is called on the error path, disabling a device
> that another driver is using
>
> To call this "rather rude" is an understatement :)
I believe this is needed for natsemi to be inline with $SUBJ.
Signed-off-by: Michal Rokos <michal@rokos.info>
--- linux-2.6/drivers/net/natsemi.c 2005-02-14 11:34:53.000000000 +0100
+++ linux-2.6-mr/drivers/net/natsemi.c 2005-02-14 11:36:00.000000000 +0100
@@ -811,6 +811,7 @@
void __iomem *ioaddr;
const int pcibar = 1; /* PCI base address register */
int prev_eedata;
+ int pci_dev_busy = 0;
u32 tmp;
/* when built into the kernel, we only print version if device is found */
@@ -821,7 +822,13 @@
#endif
i = pci_enable_device(pdev);
- if (i) return i;
+ if (i) goto out;
+
+ i = pci_request_regions(pdev, DRV_NAME);
+ if (i) {
+ pci_dev_busy = 1;
+ goto err_pci_request_regions;
+ }
/* natsemi has a non-standard PM control register
* in PCI config space. Some boards apparently need
@@ -843,15 +850,13 @@
pci_set_master(pdev);
dev = alloc_etherdev(sizeof (struct netdev_private));
- if (!dev)
- return -ENOMEM;
+ if (!dev) {
+ i = -ENOMEM;
+ goto err_alloc_etherdev;
+ }
SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &pdev->dev);
- i = pci_request_regions(pdev, DRV_NAME);
- if (i)
- goto err_pci_request_regions;
-
ioaddr = ioremap(iostart, iosize);
if (!ioaddr) {
i = -ENOMEM;
@@ -992,15 +997,20 @@
}
return 0;
- err_register_netdev:
+err_register_netdev:
iounmap(ioaddr);
- err_ioremap:
- pci_release_regions(pdev);
+err_ioremap:
pci_set_drvdata(pdev, NULL);
-
- err_pci_request_regions:
free_netdev(dev);
+
+err_alloc_etherdev:
+ pci_release_regions(pdev);
+
+err_pci_request_regions:
+ if (!pci_dev_busy)
+ pci_disable_device(pdev);
+out:
return i;
}
next reply other threads:[~2005-02-14 10:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-14 10:43 Michal Rokos [this message]
2005-02-14 11:08 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2005-02-14 1:42 Jeff Garzik
2005-02-14 19:06 ` Greg KH
2005-02-14 18:08 ` Alan Cox
2005-02-14 19:24 ` Takashi Iwai
2005-02-14 19:34 ` Greg KH
2005-02-14 19:50 ` Takashi Iwai
2005-02-14 19:54 ` Jeff Garzik
2005-02-14 19:51 ` Jeff Garzik
2005-02-14 19:58 ` Roland Dreier
2005-02-14 20:00 ` Jeff Garzik
2005-02-14 21:42 ` Roland Dreier
2005-02-14 22:25 ` Jeff Garzik
2005-02-14 22:46 ` Roland Dreier
2005-02-17 23:07 ` Greg KH
2005-02-14 20:02 ` Arjan van de Ven
2005-02-15 2:05 ` Jeff Garzik
2005-02-16 11:27 ` Takashi Iwai
2005-02-16 13:44 ` Alan Cox
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=200502141143.02205.michal@rokos.info \
--to=michal@rokos.info \
--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
Powered by JetHome