* [PATCH] link errors with internal calls to devexit functions
@ 2002-01-09 4:40 Jason Thomas
0 siblings, 0 replies; 8+ messages in thread
From: Jason Thomas @ 2002-01-09 4:40 UTC (permalink / raw)
To: linux-kernel
Marcelo, Heres my second attempt at a patch to fix these compile time
issues can you check it over and possibly include it in your next
release.
diff -ur linux-2.4.18-pre2.orig/drivers/media/video/bttv-driver.c linux-2.4.18-pre2/drivers/media/video/bttv-driver.c
--- linux-2.4.18-pre2.orig/drivers/media/video/bttv-driver.c Sat Dec 22 13:39:39 2001
+++ linux-2.4.18-pre2/drivers/media/video/bttv-driver.c Wed Jan 9 13:25:18 2002
@@ -2820,11 +2820,10 @@
* Scan for a Bt848 card, request the irq and map the io memory
*/
-static void __devexit bttv_remove(struct pci_dev *pci_dev)
+static void bttv_remove_card(struct bttv *btv)
{
u8 command;
int j;
- struct bttv *btv = pci_get_drvdata(pci_dev);
if (bttv_verbose)
printk("bttv%d: unloading\n",btv->nr);
@@ -2890,10 +2889,18 @@
btv->shutdown=1;
wake_up(&btv->gpioq);
- pci_set_drvdata(pci_dev, NULL);
return;
}
+static void __devexit bttv_remove(struct pci_dev *pci_dev)
+{
+ struct bttv *btv = pci_get_drvdata(pci_dev);
+
+ if (btv) {
+ bttv_remove_card(btv);
+ pci_set_drvdata(pci_dev, NULL);
+ }
+}
static int __devinit bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
{
@@ -2992,7 +2999,7 @@
pci_set_drvdata(dev,btv);
if(init_bt848(btv) < 0) {
- bttv_remove(dev);
+ bttv_remove_card(btv);
return -EIO;
}
bttv_num++;
diff -ur linux-2.4.18-pre2.orig/drivers/usb/usb-uhci.c linux-2.4.18-pre2/drivers/usb/usb-uhci.c
--- linux-2.4.18-pre2.orig/drivers/usb/usb-uhci.c Sat Dec 22 13:39:39 2001
+++ linux-2.4.18-pre2/drivers/usb/usb-uhci.c Wed Jan 9 14:11:19 2002
@@ -2845,10 +2845,9 @@
s->running = 1;
}
-_static void __devexit
-uhci_pci_remove (struct pci_dev *dev)
+_static void
+uhci_pci_remove_card (uhci_t *s)
{
- uhci_t *s = pci_get_drvdata(dev);
struct usb_device *root_hub = s->bus->root_hub;
s->running = 0; // Don't allow submit_urb
@@ -2868,7 +2867,17 @@
free_irq (s->irq, s);
usb_free_bus (s->bus);
cleanup_skel (s);
- kfree (s);
+}
+
+_static void __devexit
+uhci_pci_remove (struct pci_dev *dev)
+{
+ uhci_t *s = pci_get_drvdata(dev);
+
+ if (s) {
+ uhci_pci_remove_card(s);
+ kfree (s);
+ }
}
_static int __init uhci_start_usb (uhci_t *s)
@@ -3001,7 +3010,8 @@
s->irq = irq;
if(uhci_start_usb (s) < 0) {
- uhci_pci_remove(dev);
+ uhci_pci_remove_card(s);
+ kfree(s);
return -1;
}
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH] link errors with internal calls to devexit functions
@ 2001-12-22 2:57 Jason Thomas
2001-12-22 5:05 ` Keith Owens
2001-12-25 17:56 ` Legacy Fishtank
0 siblings, 2 replies; 8+ messages in thread
From: Jason Thomas @ 2001-12-22 2:57 UTC (permalink / raw)
To: linux-kernel
please CC me I'm not on the list.
This patch against 2.4.17 fixes internal calls to devexit functions (which
is bypasses the devexit_p wrapper) in drivers/media/video/bttv-driver.c and
drivers/usb/usb-uhci.c, they are the only two I found.
diff -ur linux-2.4.17.orig/drivers/media/video/bttv-driver.c linux-2.4.17/drivers/media/video/bttv-driver.c
--- linux-2.4.17.orig/drivers/media/video/bttv-driver.c Sat Dec 22 13:39:39 2001
+++ linux-2.4.17/drivers/media/video/bttv-driver.c Sat Dec 22 13:46:02 2001
@@ -2992,7 +2992,9 @@
pci_set_drvdata(dev,btv);
if(init_bt848(btv) < 0) {
+#if defined(MODULE) || defined(CONFIG_HOTPLUG)
bttv_remove(dev);
+#endif
return -EIO;
}
bttv_num++;
diff -ur linux-2.4.17.orig/drivers/usb/usb-uhci.c linux-2.4.17/drivers/usb/usb-uhci.c
--- linux-2.4.17.orig/drivers/usb/usb-uhci.c Sat Dec 22 13:39:39 2001
+++ linux-2.4.17/drivers/usb/usb-uhci.c Sat Dec 22 13:46:38 2001
@@ -3001,7 +3001,9 @@
s->irq = irq;
if(uhci_start_usb (s) < 0) {
+#if defined(MODULE) || defined(CONFIG_HOTPLUG)
uhci_pci_remove(dev);
+#endif
return -1;
}
--
Jason Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] link errors with internal calls to devexit functions
2001-12-22 2:57 Jason Thomas
@ 2001-12-22 5:05 ` Keith Owens
2001-12-22 5:26 ` Andrew Morton
` (2 more replies)
2001-12-25 17:56 ` Legacy Fishtank
1 sibling, 3 replies; 8+ messages in thread
From: Keith Owens @ 2001-12-22 5:05 UTC (permalink / raw)
To: Jason Thomas; +Cc: linux-kernel
On Sat, 22 Dec 2001 13:57:25 +1100,
Jason Thomas <jason@topic.com.au> wrote:
>please CC me I'm not on the list.
>
>This patch against 2.4.17 fixes internal calls to devexit functions (which
>is bypasses the devexit_p wrapper) in drivers/media/video/bttv-driver.c and
>drivers/usb/usb-uhci.c, they are the only two I found.
>
>diff -ur linux-2.4.17.orig/drivers/media/video/bttv-driver.c linux-2.4.17/drivers/media/video/bttv-driver.c
>--- linux-2.4.17.orig/drivers/media/video/bttv-driver.c Sat Dec 22 13:39:39 2001
>+++ linux-2.4.17/drivers/media/video/bttv-driver.c Sat Dec 22 13:46:02 2001
>@@ -2992,7 +2992,9 @@
> pci_set_drvdata(dev,btv);
>
> if(init_bt848(btv) < 0) {
>+#if defined(MODULE) || defined(CONFIG_HOTPLUG)
> bttv_remove(dev);
>+#endif
> return -EIO;
> }
> bttv_num++;
>diff -ur linux-2.4.17.orig/drivers/usb/usb-uhci.c linux-2.4.17/drivers/usb/usb-uhci.c
>--- linux-2.4.17.orig/drivers/usb/usb-uhci.c Sat Dec 22 13:39:39 2001
>+++ linux-2.4.17/drivers/usb/usb-uhci.c Sat Dec 22 13:46:38 2001
>@@ -3001,7 +3001,9 @@
> s->irq = irq;
>
> if(uhci_start_usb (s) < 0) {
>+#if defined(MODULE) || defined(CONFIG_HOTPLUG)
> uhci_pci_remove(dev);
>+#endif
> return -1;
> }
I don't like #if defined(MODULE) || defined(CONFIG_HOTPLUG) in open
code. If the rules for what gets discarded change (again) then those
ifdefs will be out of sync. That is why __devexit_p() is a wrapper, it
is defined once and only has to be changed once when the rules change.
Define a __devexit_call wrapper in include/linux/init.h at the same
place that __devexit_p is defined and use the wrapper around the calls.
Untested.
#if defined(MODULE) || defined(CONFIG_HOTPLUG)
#define __devexit_p(x) x
#define __devexit_call(x) x
#else
#define __devexit_call(x) do { } while (0)
#define __devexit_p(x) NULL
#endif
__devexit_call(bttv_remove(dev));
__devexit_call(uhci_pci_remove(dev));
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] link errors with internal calls to devexit functions
2001-12-22 5:05 ` Keith Owens
@ 2001-12-22 5:26 ` Andrew Morton
2001-12-22 9:04 ` Kai Germaschewski
2001-12-25 17:59 ` Legacy Fishtank
2 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2001-12-22 5:26 UTC (permalink / raw)
To: Keith Owens; +Cc: Jason Thomas, linux-kernel
Keith Owens wrote:
>
> __devexit_call(bttv_remove(dev));
> __devexit_call(uhci_pci_remove(dev));
This may break the drivers. They both call the remove
function on the init path, when something failed.
I believe the correct fix here is to simply remove __devinit altogether
from the definition of both those functions.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link errors with internal calls to devexit functions
2001-12-22 5:05 ` Keith Owens
2001-12-22 5:26 ` Andrew Morton
@ 2001-12-22 9:04 ` Kai Germaschewski
2001-12-22 9:13 ` Keith Owens
2001-12-25 17:59 ` Legacy Fishtank
2 siblings, 1 reply; 8+ messages in thread
From: Kai Germaschewski @ 2001-12-22 9:04 UTC (permalink / raw)
To: Keith Owens; +Cc: Jason Thomas, linux-kernel
On Sat, 22 Dec 2001, Keith Owens wrote:
> >diff -ur linux-2.4.17.orig/drivers/media/video/bttv-driver.c linux-2.4.17/drivers/media/video/bttv-driver.c
> >--- linux-2.4.17.orig/drivers/media/video/bttv-driver.c Sat Dec 22 13:39:39 2001
> >+++ linux-2.4.17/drivers/media/video/bttv-driver.c Sat Dec 22 13:46:02 2001
> >@@ -2992,7 +2992,9 @@
> > pci_set_drvdata(dev,btv);
> >
> > if(init_bt848(btv) < 0) {
> >+#if defined(MODULE) || defined(CONFIG_HOTPLUG)
> > bttv_remove(dev);
> >+#endif
> > return -EIO;
> > }
> > bttv_num++;
> I don't like #if defined(MODULE) || defined(CONFIG_HOTPLUG) in open
> code. If the rules for what gets discarded change (again) then those
> ifdefs will be out of sync. That is why __devexit_p() is a wrapper, it
> is defined once and only has to be changed once when the rules change.
>
> Define a __devexit_call wrapper in include/linux/init.h at the same
> place that __devexit_p is defined and use the wrapper around the calls.
> Untested.
I'd rather think that the patch (and the original code) is broken, as it
seems we call an __devexit function from an init function. So
the correct fix is to remove the __devexit attribute from the offending
functions.
--Kai
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] link errors with internal calls to devexit functions
2001-12-22 9:04 ` Kai Germaschewski
@ 2001-12-22 9:13 ` Keith Owens
0 siblings, 0 replies; 8+ messages in thread
From: Keith Owens @ 2001-12-22 9:13 UTC (permalink / raw)
To: Kai Germaschewski; +Cc: Jason Thomas, linux-kernel
On Sat, 22 Dec 2001 10:04:19 +0100 (CET),
Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> wrote:
>I'd rather think that the patch (and the original code) is broken, as it
>seems we call an __devexit function from an init function. So
>the correct fix is to remove the __devexit attribute from the offending
>functions.
Andrew Morton said the same thing and I agree. The code is broken, no
amount of fancy wrappers will fix that. This is the perfect example of
why the new binutils are good, they are catching broken code.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link errors with internal calls to devexit functions
2001-12-22 5:05 ` Keith Owens
2001-12-22 5:26 ` Andrew Morton
2001-12-22 9:04 ` Kai Germaschewski
@ 2001-12-25 17:59 ` Legacy Fishtank
2 siblings, 0 replies; 8+ messages in thread
From: Legacy Fishtank @ 2001-12-25 17:59 UTC (permalink / raw)
To: Keith Owens; +Cc: Jason Thomas, linux-kernel
On Sat, Dec 22, 2001 at 04:05:43PM +1100, Keith Owens wrote:
> >--- linux-2.4.17.orig/drivers/media/video/bttv-driver.c Sat Dec 22 13:39:39 2001
> >+++ linux-2.4.17/drivers/media/video/bttv-driver.c Sat Dec 22 13:46:02 2001
> >@@ -2992,7 +2992,9 @@
> > pci_set_drvdata(dev,btv);
> >
> > if(init_bt848(btv) < 0) {
> >+#if defined(MODULE) || defined(CONFIG_HOTPLUG)
> > bttv_remove(dev);
> >+#endif
> I don't like #if defined(MODULE) || defined(CONFIG_HOTPLUG) in open
> code.
1000.0% agreed
> __devexit_call(bttv_remove(dev));
> __devexit_call(uhci_pci_remove(dev));
ug... Just use plain logic: if a function is called from non-devexit
code, it should not be marked devexit. That's the bug, we don't need
new API crud.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link errors with internal calls to devexit functions
2001-12-22 2:57 Jason Thomas
2001-12-22 5:05 ` Keith Owens
@ 2001-12-25 17:56 ` Legacy Fishtank
1 sibling, 0 replies; 8+ messages in thread
From: Legacy Fishtank @ 2001-12-25 17:56 UTC (permalink / raw)
To: Jason Thomas; +Cc: linux-kernel
On Sat, Dec 22, 2001 at 01:57:25PM +1100, Jason Thomas wrote:
> please CC me I'm not on the list.
>
> This patch against 2.4.17 fixes internal calls to devexit functions (which
> is bypasses the devexit_p wrapper) in drivers/media/video/bttv-driver.c and
> drivers/usb/usb-uhci.c, they are the only two I found.
>
> diff -ur linux-2.4.17.orig/drivers/media/video/bttv-driver.c linux-2.4.17/drivers/media/video/bttv-driver.c
> --- linux-2.4.17.orig/drivers/media/video/bttv-driver.c Sat Dec 22 13:39:39 2001
> +++ linux-2.4.17/drivers/media/video/bttv-driver.c Sat Dec 22 13:46:02 2001
> @@ -2992,7 +2992,9 @@
> pci_set_drvdata(dev,btv);
>
> if(init_bt848(btv) < 0) {
> +#if defined(MODULE) || defined(CONFIG_HOTPLUG)
> bttv_remove(dev);
> +#endif
These changes are incorrect... if a remove function is called during the
init phase it should never have been marked __devexit in the first
place.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-01-09 4:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-09 4:40 [PATCH] link errors with internal calls to devexit functions Jason Thomas
-- strict thread matches above, loose matches on Subject: below --
2001-12-22 2:57 Jason Thomas
2001-12-22 5:05 ` Keith Owens
2001-12-22 5:26 ` Andrew Morton
2001-12-22 9:04 ` Kai Germaschewski
2001-12-22 9:13 ` Keith Owens
2001-12-25 17:59 ` Legacy Fishtank
2001-12-25 17:56 ` Legacy Fishtank
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox