#include <linux/slab.h>
#include <linux/pci.h>
-MODULE_AUTHOR("Victor Krapivin <vik@belcaf.minsk.by>");
+MODULE_AUTHOR("Victor Krapivin");
MODULE_LICENSE("GPL");
/*
*/
static unsigned long ba0_addr;
-static unsigned int *ba0;
-
-static char phys[32];
-static char name[] = "CS416x Gameport";
+static unsigned int __iomem *ba0;
#ifdef CS461X_FULL_MAP
static unsigned long ba1_addr;
static union ba1_t {
struct {
- unsigned int *data0;
- unsigned int *data1;
- unsigned int *pmem;
- unsigned int *reg;
+ unsigned int __iomem *data0;
+ unsigned int __iomem *data1;
+ unsigned int __iomem *pmem;
+ unsigned int __iomem *reg;
} name;
- unsigned int *idx[4];
+ unsigned int __iomem *idx[4];
} ba1;
static void cs461x_poke(unsigned long reg, unsigned int val)
{
- ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff] = val;
+ writel(val, &ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff]);
}
static unsigned int cs461x_peek(unsigned long reg)
{
- return ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff];
+ return readl(&ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff]);
}
#endif
static void cs461x_pokeBA0(unsigned long reg, unsigned int val)
{
- ba0[reg >> 2] = val;
+ writel(val, &ba0[reg >> 2]);
}
static unsigned int cs461x_peekBA0(unsigned long reg)
{
- return ba0[reg >> 2];
+ return readl(&ba0[reg >> 2]);
}
static int cs461x_free(struct pci_dev *pdev)
{
struct gameport *port = pci_get_drvdata(pdev);
- if(port){
+
+ if (port)
gameport_unregister_port(port);
- kfree(port);
- }
+
if (ba0) iounmap(ba0);
#ifdef CS461X_FULL_MAP
if (ba1.name.data0) iounmap(ba1.name.data0);
return -ENOMEM;
}
#else
- if (ba0 == NULL){
+ if (ba0 == NULL) {
cs461x_free(pdev);
return -ENOMEM;
}
#endif
- if (!(port = kmalloc(sizeof(struct gameport), GFP_KERNEL))) {
- printk(KERN_ERR "Memory allocation failed.\n");
+ if (!(port = gameport_allocate_port())) {
+ printk(KERN_ERR "cs461x: Memory allocation failed\n");
cs461x_free(pdev);
return -ENOMEM;
}
- memset(port, 0, sizeof(struct gameport));
pci_set_drvdata(pdev, port);
port->read = cs461x_gameport_read;
port->cooked_read = cs461x_gameport_cooked_read;
- sprintf(phys, "pci%s/gameport0", pci_name(pdev));
-
- port->name = name;
- port->phys = phys;
- port->id.bustype = BUS_PCI;
- port->id.vendor = pdev->vendor;
- port->id.product = pdev->device;
+ gameport_set_name(port, "CS416x");
+ gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev));
+ port->dev.parent = &pdev->dev;
cs461x_pokeBA0(BA0_JSIO, 0xFF); // ?
cs461x_pokeBA0(BA0_JSCTL, JSCTL_SP_MEDIUM_SLOW);
gameport_register_port(port);
- printk(KERN_INFO "gameport: %s on pci%s speed %d kHz\n",
- name, pci_name(pdev), port->speed);
-
return 0;
}
.remove = __devexit_p(cs461x_pci_remove),
};
-int __init cs461x_init(void)
+static int __init cs461x_init(void)
{
- return pci_module_init(&cs461x_pci_driver);
+ return pci_register_driver(&cs461x_pci_driver);
}
-void __exit cs461x_exit(void)
+static void __exit cs461x_exit(void)
{
pci_unregister_driver(&cs461x_pci_driver);
}