~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/input/gameport/emu10k1-gp.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        int size;
47
47
};
48
48
 
49
 
static struct pci_device_id emu_tbl[] = {
 
49
static const struct pci_device_id emu_tbl[] = {
50
50
 
51
51
        { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
52
52
        { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
59
59
 
60
60
static int __devinit emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
61
61
{
62
 
        int ioport, iolen;
63
62
        struct emu *emu;
64
63
        struct gameport *port;
65
 
 
66
 
        if (pci_enable_device(pdev))
67
 
                return -EBUSY;
68
 
 
69
 
        ioport = pci_resource_start(pdev, 0);
70
 
        iolen = pci_resource_len(pdev, 0);
71
 
 
72
 
        if (!request_region(ioport, iolen, "emu10k1-gp"))
73
 
                return -EBUSY;
 
64
        int error;
74
65
 
75
66
        emu = kzalloc(sizeof(struct emu), GFP_KERNEL);
76
67
        port = gameport_allocate_port();
77
68
        if (!emu || !port) {
78
69
                printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");
79
 
                release_region(ioport, iolen);
80
 
                kfree(emu);
81
 
                gameport_free_port(port);
82
 
                return -ENOMEM;
 
70
                error = -ENOMEM;
 
71
                goto err_out_free;
83
72
        }
84
73
 
85
 
        emu->io = ioport;
86
 
        emu->size = iolen;
 
74
        error = pci_enable_device(pdev);
 
75
        if (error)
 
76
                goto err_out_free;
 
77
 
 
78
        emu->io = pci_resource_start(pdev, 0);
 
79
        emu->size = pci_resource_len(pdev, 0);
 
80
 
87
81
        emu->dev = pdev;
88
82
        emu->gameport = port;
89
83
 
90
84
        gameport_set_name(port, "EMU10K1");
91
85
        gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev));
92
86
        port->dev.parent = &pdev->dev;
93
 
        port->io = ioport;
 
87
        port->io = emu->io;
 
88
 
 
89
        if (!request_region(emu->io, emu->size, "emu10k1-gp")) {
 
90
                printk(KERN_ERR "emu10k1-gp: unable to grab region 0x%x-0x%x\n",
 
91
                        emu->io, emu->io + emu->size - 1);
 
92
                error = -EBUSY;
 
93
                goto err_out_disable_dev;
 
94
        }
94
95
 
95
96
        pci_set_drvdata(pdev, emu);
96
97
 
97
98
        gameport_register_port(port);
98
99
 
99
100
        return 0;
 
101
 
 
102
 err_out_disable_dev:
 
103
        pci_disable_device(pdev);
 
104
 err_out_free:
 
105
        gameport_free_port(port);
 
106
        kfree(emu);
 
107
        return error;
100
108
}
101
109
 
102
110
static void __devexit emu_remove(struct pci_dev *pdev)
106
114
        gameport_unregister_port(emu->gameport);
107
115
        release_region(emu->io, emu->size);
108
116
        kfree(emu);
 
117
 
 
118
        pci_disable_device(pdev);
109
119
}
110
120
 
111
121
static struct pci_driver emu_driver = {