X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fpcmcia%2Fi82365.c;h=e9b5eb3ad2e547ebe2f077660012839e008845eb;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=561974efbe63dc31fe75af576110bd13594fbe78;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 561974efb..e9b5eb3ad 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -48,9 +48,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -96,7 +96,7 @@ static inline int _check_irq(int irq, int flags) /* Parameters that can be set with 'insmod' */ /* Default base address for i82365sl and other ISA chips */ -static int i365_base = 0x3e0; +static unsigned long i365_base = 0x3e0; /* Should we probe at 0x3e2 for an extra ISA controller? */ static int extra_sockets = 0; /* Specify a socket number to ignore */ @@ -130,11 +130,11 @@ static int async_clock = -1; static int cable_mode = -1; static int wakeup = 0; -module_param(i365_base, int, 0444); +module_param(i365_base, ulong, 0444); module_param(ignore, int, 0444); module_param(extra_sockets, int, 0444); module_param(irq_mask, int, 0444); -module_param_array(irq_list, int, irq_list_count, 0444); +module_param_array(irq_list, int, &irq_list_count, 0444); module_param(cs_irq, int, 0444); module_param(async_clock, int, 0444); module_param(cable_mode, int, 0444); @@ -167,7 +167,7 @@ struct i82365_socket { u_short type, flags; struct pcmcia_socket socket; unsigned int number; - ioaddr_t ioaddr; + kio_addr_t ioaddr; u_short psock; u_char cs_irq, intr; union { @@ -186,7 +186,7 @@ static struct i82365_socket socket[8] = { #define I365_MASK 0xdeb8 /* irq 15,14,12,11,10,9,7,5,4,3 */ static int grab_irq; -static spinlock_t isa_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(isa_lock); #define ISA_LOCK(n, f) spin_lock_irqsave(&isa_lock, f) #define ISA_UNLOCK(n, f) spin_unlock_irqrestore(&isa_lock, f) @@ -208,6 +208,7 @@ typedef enum pcic_id { #define IS_UNKNOWN 0x0400 #define IS_VG_PWR 0x0800 #define IS_DF_PWR 0x1000 +#define IS_REGISTERED 0x2000 #define IS_ALIVE 0x8000 typedef struct pcic_t { @@ -233,14 +234,14 @@ static pcic_t pcic[] = { /*====================================================================*/ -static spinlock_t bus_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(bus_lock); static u_char i365_get(u_short sock, u_short reg) { unsigned long flags; spin_lock_irqsave(&bus_lock,flags); { - ioaddr_t port = socket[sock].ioaddr; + kio_addr_t port = socket[sock].ioaddr; u_char val; reg = I365_REG(socket[sock].psock, reg); outb(reg, port); val = inb(port+1); @@ -254,7 +255,7 @@ static void i365_set(u_short sock, u_short reg, u_char data) unsigned long flags; spin_lock_irqsave(&bus_lock,flags); { - ioaddr_t port = socket[sock].ioaddr; + kio_addr_t port = socket[sock].ioaddr; u_char val = I365_REG(socket[sock].psock, reg); outb(val, port); outb(data, port+1); spin_unlock_irqrestore(&bus_lock,flags); @@ -589,7 +590,7 @@ static int to_cycles(int ns) /*====================================================================*/ -static int __init identify(u_short port, u_short sock) +static int __init identify(kio_addr_t port, u_short sock) { u_char val; int type = -1; @@ -660,7 +661,7 @@ static int __init identify(u_short port, u_short sock) static int __init is_alive(u_short sock) { u_char stat; - u_short start, stop; + kio_addr_t start, stop; stat = i365_get(sock, I365_STATUS); start = i365_get_pair(sock, I365_IO(0)+I365_W_START); @@ -677,7 +678,7 @@ static int __init is_alive(u_short sock) /*====================================================================*/ -static void __init add_socket(u_short port, int psock, int type) +static void __init add_socket(kio_addr_t port, int psock, int type) { socket[sockets].ioaddr = port; socket[sockets].psock = psock; @@ -699,7 +700,7 @@ static void __init add_pcic(int ns, int type) if (base == 0) printk("\n"); printk(KERN_INFO " %s", pcic[type].name); - printk(" ISA-to-PCMCIA at port %#x ofs 0x%02x", + printk(" ISA-to-PCMCIA at port %#lx ofs 0x%02x", t->ioaddr, t->psock*0x40); printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : "")); @@ -773,7 +774,7 @@ static struct pnp_dev *i82365_pnpdev; static void __init isa_probe(void) { int i, j, sock, k, ns, id; - ioaddr_t port; + kio_addr_t port; #ifdef CONFIG_PNP struct isapnp_device_id *devid; struct pnp_dev *dev; @@ -804,7 +805,7 @@ static void __init isa_probe(void) if (check_region(i365_base, 2) != 0) { if (sockets == 0) - printk("port conflict at %#x\n", i365_base); + printk("port conflict at %#lx\n", i365_base); return; } @@ -1127,7 +1128,7 @@ static int i365_set_io_map(u_short sock, struct pccard_io_map *io) u_char map, ioctl; debug(1, "SetIOMap(%d, %d, %#2.2x, %d ns, " - "%#4.4x-%#4.4x)\n", sock, io->map, io->flags, + "%#lx-%#lx)\n", sock, io->map, io->flags, io->speed, io->start, io->stop); map = io->map; if ((map > 1) || (io->start > 0xffff) || (io->stop > 0xffff) || @@ -1156,8 +1157,8 @@ static int i365_set_mem_map(u_short sock, struct pccard_mem_map *mem) u_short base, i; u_char map; - debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, %#5.5lx-%#5.5" - "lx, %#5.5x)\n", sock, mem->map, mem->flags, mem->speed, + debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, %#lx-%#lx, " + "%#x)\n", sock, mem->map, mem->flags, mem->speed, mem->res->start, mem->res->end, mem->card_start); map = mem->map; @@ -1400,14 +1401,13 @@ static int __init init_i82365(void) for (i = 0; i < sockets; i++) { socket[i].socket.dev.dev = &i82365_device.dev; socket[i].socket.ops = &pcic_operations; + socket[i].socket.resource_ops = &pccard_nonstatic_ops; socket[i].socket.owner = THIS_MODULE; socket[i].number = i; - ret = pcmcia_register_socket(&socket[i].socket); - if (ret && i--) { - for (; i>= 0; i--) - pcmcia_unregister_socket(&socket[i].socket); - break; - } + ret = pcmcia_register_socket(&socket[i].socket); + if (!ret) + socket[i].flags |= IS_REGISTERED; + #if 0 /* driver model ordering issue */ class_device_create_file(&socket[i].socket.dev, &class_device_attr_info); @@ -1434,7 +1434,8 @@ static void __exit exit_i82365(void) int i; for (i = 0; i < sockets; i++) { - pcmcia_unregister_socket(&socket[i].socket); + if (socket[i].flags & IS_REGISTERED) + pcmcia_unregister_socket(&socket[i].socket); } platform_device_unregister(&i82365_device); if (poll_interval != 0) @@ -1446,7 +1447,7 @@ static void __exit exit_i82365(void) i365_set(i, I365_CSCINT, 0); release_region(socket[i].ioaddr, 2); } -#ifdef __ISAPNP__ +#ifdef CONFIG_PNP if (i82365_pnpdev) pnp_disable_dev(i82365_pnpdev); #endif