[PATCH 2.6] ns558.c check_region -> request_region

From: Marcel Sebek (sebek64_at_post.cz)
Date: 12/31/03

  • Next message: Arnaldo Carvalho de Melo: "Re: IA32 (2.6.0 - 2003-12-29.22.30) - 5 New warnings (gcc 3.2.2)"
    Date:	Wed, 31 Dec 2003 22:58:57 +0100
    To: vojtech@suse.cz
    
    

    This patch modifies ns558.c to use request_region instead of
    check_region:

    diff -urN linux-2.6/drivers/input/gameport/ns558.c linux-2.6-new/drivers/input/gameport/ns558.c
    --- linux-2.6/drivers/input/gameport/ns558.c 2003-08-23 13:57:35.000000000 +0200
    +++ linux-2.6-new/drivers/input/gameport/ns558.c 2003-12-31 22:27:40.000000000 +0100
    @@ -77,7 +77,7 @@
      * No one should be using this address.
      */
     
    - if (check_region(io, 1))
    + if (!request_region(io, 1, "ns558-isa"))
                     return;
     
     /*
    @@ -89,7 +89,8 @@
             outb(~c & ~3, io);
             if (~(u = v = inb(io)) & 3) {
                     outb(c, io);
    - return;
    + i = 0;
    + goto out;
             }
     /*
      * After a trigger, there must be at least some bits changing.
    @@ -99,7 +100,8 @@
     
             if (u == v) {
                     outb(c, io);
    - return;
    + i = 0;
    + goto out;
             }
             wait_ms(3);
     /*
    @@ -110,7 +112,8 @@
             for (i = 0; i < 1000; i++)
                     if ((u ^ inb(io)) & 0xf) {
                             outb(c, io);
    - return;
    + i = 0;
    + goto out;
                     }
     /*
      * And now find the number of mirrors of the port.
    @@ -118,7 +121,7 @@
     
             for (i = 1; i < 5; i++) {
     
    - if (check_region(io & (-1 << i), (1 << i))) /* Don't disturb anyone */
    + if (!request_region(io & (-1 << i), (1 << i), "ns558-isa")) /* Don't disturb anyone */
                             break;
     
                     outb(0xff, io & (-1 << i));
    @@ -126,15 +129,19 @@
                             if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
                     wait_ms(3);
     
    - if (b > 300) /* We allow 30% difference */
    + if (b > 300) { /* We allow 30% difference */
    + release_region(io & (-1 << i), (1 << i));
                             break;
    + }
    +
    + release_region(io & (-1 << (i-1)), (1 << (i-1)));
             }
     
             i--;
     
             if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
                     printk(KERN_ERR "ns558: Memory allocation failed.\n");
    - return;
    + goto out;
             }
                    memset(port, 0, sizeof(struct ns558));
             
    @@ -148,8 +155,6 @@
             sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i));
             sprintf(port->name, "NS558 ISA");
     
    - request_region(io & (-1 << i), (1 << i), "ns558-isa");
    -
             gameport_register_port(&port->gameport);
     
             printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io);
    @@ -157,6 +162,9 @@
             printk(" speed %d kHz\n", port->gameport.speed);
     
             list_add(&port->node, &ns558_list);
    + return;
    +out:
    + release_region(io & (-1 << i), (1 << i));
     }
     
     #ifdef CONFIG_PNP

    -- 
    Marcel Sebek
    jabber: sebek@jabber.cz                     ICQ: 279852819
    linux user number: 307850                 GPG ID: 5F88735E
    GPG FP: 0F01 BAB8 3148 94DB B95D  1FCA 8B63 CA06 5F88 735E
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Arnaldo Carvalho de Melo: "Re: IA32 (2.6.0 - 2003-12-29.22.30) - 5 New warnings (gcc 3.2.2)"

    Relevant Pages

    • Re: [patch] voluntary-preempt-2.6.9-rc1-bk4-R3
      ... > I don't have the serial logging setup yet because I haven't had time ... quite some time to trigger but it does. ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: [BUG] x86_64 pci_map_sg modifies sg list - fails multiple map/unmaps
      ... > Since merging is disabled by default now it won't trigger anyways. ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: 2.6.8-rc1-mm1 "Badness in schedule" on ppc32
      ... > Tried that now but I've been unable to trigger any ... On x86, could you force the PDC202XX_NEW to dump_stack in the function ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: [2.6.7-mm4: OOPS] kernel BUG at mm/mmap.c:1793
      ... Gryaznova" wrote: ... I cannot trigger it here. ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: [2.6.10-rc2] XFS filesystem corruption
      ... The trigger was a bad magic number related to directories... ... send the line "unsubscribe linux-kernel" in ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)