2009-10-17 20:32:29

by Stas Sergeev

[permalink] [raw]
Subject: [patch] fix driver_register() return value

Hi Greg.

In this patch:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=16dc42e018c2868211b4928f20a957c0c216126c
the check was added for another
driver to already claim the same
device on the same bus. But the
returned error code was wrong:
to modprobe, the -EEXIST means
that _this_ driver is already
installed. It therefore doesn't
produce the needed error message
when _another_ driver is trying
to register for the same device.
Returning -EBUSY fixes the problem.

Signed-off-by: Stas Sergeev <[email protected]>


Attachments:
drv_busy.diff (403.00 B)

2009-10-17 20:46:40

by Greg KH

[permalink] [raw]
Subject: Re: [patch] fix driver_register() return value

On Sun, Oct 18, 2009 at 12:31:38AM +0400, Stas Sergeev wrote:
> Hi Greg.
>
> In this patch:
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=16dc42e018c2868211b4928f20a957c0c216126c
> the check was added for another
> driver to already claim the same
> device on the same bus. But the
> returned error code was wrong:
> to modprobe, the -EEXIST means
> that _this_ driver is already
> installed. It therefore doesn't
> produce the needed error message
> when _another_ driver is trying
> to register for the same device.
> Returning -EBUSY fixes the problem.
>
> Signed-off-by: Stas Sergeev <[email protected]>

Does this cause problems with the way things now are? If so, what are
they? Does this change need to be backported to older -stable kernels?

thanks,

greg k-h

2009-10-17 20:58:51

by Stas Sergeev

[permalink] [raw]
Subject: Re: [patch] fix driver_register() return value

18.10.2009 00:46, Greg KH wrote:
>> Returning -EBUSY fixes the problem.
>> Signed-off-by: Stas Sergeev<[email protected]>
> Does this cause problems with the way things now are? If so, what are
> they?
They are simple.
Suppose the pcspkr driver was loaded
by the udev. Then someone types:
modprobe snd-pcsp
and that doesn't print anything, so
he thinks the snd-pcsp was loaded and
asks me why there is no sound. :)
Only by typing "dmesg" you can see what
actually happened, but it would be better
to have that from modprobe too.

> Does this change need to be backported to older -stable kernels?
I think it can't hurt.

2009-10-27 00:00:10

by Greg KH

[permalink] [raw]
Subject: patch driver-core-fix-driver_register-return-value.patch added to gregkh-2.6 tree


This is a note to let you know that I've just added the patch titled

Subject: Driver core: fix driver_register() return value

to my gregkh-2.6 tree. Its filename is

driver-core-fix-driver_register-return-value.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From [email protected] Mon Oct 26 16:00:03 2009
From: Stas Sergeev <[email protected]>
Date: Sun, 18 Oct 2009 00:31:38 +0400
Subject: Driver core: fix driver_register() return value
To: Greg KH <[email protected]>
Cc: Linux kernel <[email protected]>
Message-ID: <[email protected]>

In this patch:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=16dc42e018c2868211b4928f20a957c0c216126c
the check was added for another driver to already claim the same device
on the same bus. But the returned error code was wrong: to modprobe, the
-EEXIST means that _this_ driver is already installed. It therefore
doesn't produce the needed error message when _another_ driver is trying
to register for the same device. Returning -EBUSY fixes the problem.

Signed-off-by: Stas Sergeev <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
drivers/base/driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -236,7 +236,7 @@ int driver_register(struct device_driver
put_driver(other);
printk(KERN_ERR "Error: Driver '%s' is already registered, "
"aborting...\n", drv->name);
- return -EEXIST;
+ return -EBUSY;
}

ret = bus_add_driver(drv);