* [patch-2.4.2-ac8] misc_register() fix (was Re: Linux 2.4.2ac8
[not found] <Pine.LNX.4.21.0103021010570.1338-100000@penguin.homenet>
@ 2001-03-02 10:55 ` Tigran Aivazian
2001-03-02 11:03 ` Philipp Rumpf
2001-03-02 11:07 ` [OT] style-curiosity J . A . Magallon
0 siblings, 2 replies; 4+ messages in thread
From: Tigran Aivazian @ 2001-03-02 10:55 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
On Fri, 2 Mar 2001, Tigran Aivazian wrote:
> On Thu, 1 Mar 2001, Alan Cox wrote:
> > 2.4.2-ac8
> > o Stop two people claiming the same misc dev id (Philipp Rumpf)
>
> is this what has broken misc devi registration on my machine? I have two
> misc devices -- microcode and psaux -- now (ac8) I get none, /proc/misc is
> empty. Also, on boot gpm generates an "oops" from gpm.c(968) saying
> "/dev/mouse: No such device"
Hi Alan,
here is the fix, tested, it works fine. The only unsatisfactory thing is
that we do an extra if() on each iteration making misc_register()
typically a few instructions slower. I will think a few minutes on how to
make the old version work (i.e. I suspect it was just an incorrect walking
of the misc_list in ac8).
Regards,
Tigran
--- linux/drivers/char/misc.c.0 Fri Mar 2 09:35:01 2001
+++ linux/drivers/char/misc.c Fri Mar 2 10:01:17 2001
@@ -175,14 +175,16 @@
if (misc->next || misc->prev)
return -EBUSY;
+
down(&misc_sem);
- c = misc_list.next;
- while ((c != &misc_list) && (c->minor != misc->minor))
+ c = misc_list.next;
+ while (c != &misc_list) {
+ if (c->minor == misc->minor) {
+ up(&misc_sem);
+ return -EBUSY;
+ }
c = c->next;
- if (c == &misc_list) {
- up(&misc_sem);
- return -EBUSY;
}
if (misc->minor == MISC_DYNAMIC_MINOR) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch-2.4.2-ac8] misc_register() fix (was Re: Linux 2.4.2ac8
2001-03-02 10:55 ` [patch-2.4.2-ac8] misc_register() fix (was Re: Linux 2.4.2ac8 Tigran Aivazian
@ 2001-03-02 11:03 ` Philipp Rumpf
2001-03-02 11:07 ` [OT] style-curiosity J . A . Magallon
1 sibling, 0 replies; 4+ messages in thread
From: Philipp Rumpf @ 2001-03-02 11:03 UTC (permalink / raw)
To: Tigran Aivazian; +Cc: Alan Cox, linux-kernel
On Fri, Mar 02, 2001 at 10:55:39AM +0000, Tigran Aivazian wrote:
> On Fri, 2 Mar 2001, Tigran Aivazian wrote:
> > On Thu, 1 Mar 2001, Alan Cox wrote:
> > > 2.4.2-ac8
> > > o Stop two people claiming the same misc dev id (Philipp Rumpf)
> >
> > is this what has broken misc devi registration on my machine? I have two
> > misc devices -- microcode and psaux -- now (ac8) I get none, /proc/misc is
> > empty. Also, on boot gpm generates an "oops" from gpm.c(968) saying
> > "/dev/mouse: No such device"
>
> Hi Alan,
>
> here is the fix, tested, it works fine. The only unsatisfactory thing is
> that we do an extra if() on each iteration making misc_register()
> typically a few instructions slower. I will think a few minutes on how to
> make the old version work (i.e. I suspect it was just an incorrect walking
> of the misc_list in ac8).
See earlier patch.
> --- linux/drivers/char/misc.c.0 Fri Mar 2 09:35:01 2001
> +++ linux/drivers/char/misc.c Fri Mar 2 10:01:17 2001
> @@ -175,14 +175,16 @@
>
> if (misc->next || misc->prev)
> return -EBUSY;
> +
> down(&misc_sem);
> - c = misc_list.next;
>
> - while ((c != &misc_list) && (c->minor != misc->minor))
> + c = misc_list.next;
> + while (c != &misc_list) {
> + if (c->minor == misc->minor) {
> + up(&misc_sem);
> + return -EBUSY;
> + }
> c = c->next;
> - if (c == &misc_list) {
> - up(&misc_sem);
> - return -EBUSY;
> }
>
> if (misc->minor == MISC_DYNAMIC_MINOR) {
This is fine as well, and possibly more readable.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [OT] style-curiosity
2001-03-02 10:55 ` [patch-2.4.2-ac8] misc_register() fix (was Re: Linux 2.4.2ac8 Tigran Aivazian
2001-03-02 11:03 ` Philipp Rumpf
@ 2001-03-02 11:07 ` J . A . Magallon
[not found] ` <Pine.LNX.4.21.0103021223160.1338-100000@penguin.homenet>
1 sibling, 1 reply; 4+ messages in thread
From: J . A . Magallon @ 2001-03-02 11:07 UTC (permalink / raw)
To: Tigran Aivazian; +Cc: linux-kernel
On 03.02 Tigran Aivazian wrote:
> + c = misc_list.next;
> + while (c != &misc_list) {
> + if (c->minor == misc->minor) {
> + up(&misc_sem);
> + return -EBUSY;
> + }
> c = c->next;
> - if (c == &misc_list) {
> - up(&misc_sem);
> - return -EBUSY;
> }
Just a matter of style and curiosity.
Would you kernel programmers consider this 'bad C' (I usually see this
much more clear...)
for (c = misc_list.next; c != &misc_list; c = c->next)
{
if (c->minor == misc->minor) {
up(&misc_sem);
return -EBUSY;
}
}
Has any effect on output assembly ?
--
J.A. Magallon $> cd pub
mailto:jamagallon@able.es $> more beer
Linux werewolf 2.4.2-ac7 #1 SMP Fri Mar 2 02:36:23 CET 2001 i686
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OT] style-curiosity
[not found] ` <Pine.LNX.4.21.0103021223160.1338-100000@penguin.homenet>
@ 2001-03-02 14:31 ` J . A . Magallon
0 siblings, 0 replies; 4+ messages in thread
From: J . A . Magallon @ 2001-03-02 14:31 UTC (permalink / raw)
To: Tigran Aivazian; +Cc: linux-kernel
On 03.02 Tigran Aivazian wrote:
> On Fri, 2 Mar 2001, J . A . Magallon wrote:
> > for (c = misc_list.next; c != &misc_list; c = c->next)
> > {
> > if (c->minor == misc->minor) {
> > up(&misc_sem);
> > return -EBUSY;
> > }
> > }
>
> the above is good but the below is better:
>
> for (c = misc_list.next; c != &misc_list; c = c->next)
> if (c->minor == misc->minor) {
> up(&misc_sem);
> return -EBUSY;
> }
>
I have suffered so many bugs coming from bad grouping that I always put
the braces even if they are not needed.
--
J.A. Magallon $> cd pub
mailto:jamagallon@able.es $> more beer
Linux werewolf 2.4.2-ac8 #2 SMP Fri Mar 2 12:12:45 CET 2001 i686
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-03-02 14:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.4.21.0103021010570.1338-100000@penguin.homenet>
2001-03-02 10:55 ` [patch-2.4.2-ac8] misc_register() fix (was Re: Linux 2.4.2ac8 Tigran Aivazian
2001-03-02 11:03 ` Philipp Rumpf
2001-03-02 11:07 ` [OT] style-curiosity J . A . Magallon
[not found] ` <Pine.LNX.4.21.0103021223160.1338-100000@penguin.homenet>
2001-03-02 14:31 ` J . A . Magallon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.