It is currently Thu, 29 Oct 2020 13:06:44 GMT



 
Author Message
 misc_register() fix (was Re: Linux 2.4.2ac8

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) {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at   http://www.**-**.com/
Please read the FAQ at   http://www.**-**.com/



 Tue, 19 Aug 2003 19:10:04 GMT   
 misc_register() fix (was Re: Linux 2.4.2ac8

See earlier patch.

- Show quoted text -

This is fine as well, and possibly more readable.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 Tue, 19 Aug 2003 19:10:04 GMT   
 misc_register() fix (was Re: Linux 2.4.2ac8

On 03.02 Tigran Aivazian wrote:

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:jamagal...@able.es                                          $> more beer

Linux werewolf 2.4.2-ac7 #1 SMP Fri Mar 2 02:36:23 CET 2001 i686

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



 Tue, 19 Aug 2003 19:20:03 GMT   
 misc_register() fix (was Re: Linux 2.4.2ac8

On 03.02 Tigran Aivazian wrote:

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:jamagal...@able.es                                          $> more beer

Linux werewolf 2.4.2-ac8 #2 SMP Fri Mar 2 12:12:45 CET 2001 i686

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



 Tue, 19 Aug 2003 22:40:04 GMT   
 
   [ 5 post ] 

Similar Threads

1. Linux 2.4.2ac8

2. I AM GONNA PUKE - I AM GONNA PUKE - I AM GONNA PUKE - I AM GONNA PUKE - I AM GONNA PUKE - I AM GONNA PUKE - I AM GONNA PUKE -

3. 2.4.2ac8 lost char devices

4. I am preparing to teach a Linux class and I am soliciting advice

5. remove devfs hack from misc_register

6. Janitor: misc_register() can fail, even in drivers/char/upd4990.c

7. TRIVIAL II: 2.5.6-pre3. misc_register/request_region


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software