lkml.org 
[lkml]   [2002]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] i82092 PCMCIA driver cleanup
Hi,

attached patch contains some minor changes to i82092.c PCMCIA driver:
- MODULE_DEVICE_TABLE() added;
- request_region() and pci_enable_device() return value checks added;
- some printk() cleanups.

Untested, but compiles and looks correct.

Best regards.

--
Andrey Panin | Embedded systems software engineer
pazke@orbita1.ru | PGP key: wwwkeys.eu.pgp.netdiff -urN -X /usr/share/dontdiff linux.vanilla/drivers/pcmcia/i82092.c linux/drivers/pcmcia/i82092.c
--- linux.vanilla/drivers/pcmcia/i82092.c Tue Dec 4 12:44:22 2001
+++ linux/drivers/pcmcia/i82092.c Fri Mar 8 23:25:11 2002
@@ -37,6 +37,7 @@
},
{}
};
+MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);

static struct pci_driver i82092aa_pci_drv = {
name: "i82092aa",
@@ -91,42 +92,41 @@
static int __init i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
unsigned char configbyte;
- int i;
+ int i, ret;

enter("i82092aa_pci_probe");

- if (pci_enable_device(dev))
- return -EIO;
+ if ((ret = pci_enable_device(dev)))
+ return ret;

pci_read_config_byte(dev, 0x40, &configbyte); /* PCI Configuration Control */
switch(configbyte&6) {
case 0:
- printk(KERN_INFO "i82092aa: configured as a 2 socket device.\n");
socket_count = 2;
break;
case 2:
- printk(KERN_INFO "i82092aa: configured as a 1 socket device.\n");
socket_count = 1;
break;
case 4:
case 6:
- printk(KERN_INFO "i82092aa: configured as a 4 socket device.\n");
socket_count = 4;
break;

default:
printk(KERN_ERR "i82092aa: Oops, you did something we didn't think of.\n");
- return -EIO;
- break;
+ ret = -EIO;
+ goto err_out_disable;
+ }
+ printk(KERN_INFO "i82092aa: configured as a %d socket device.\n", socket_count);
+
+ if (request_region(pci_resource_start(dev, 0), 2, "i82092aa")) {
+ ret = -EBUSY;
+ goto err_out_disable;
}

for (i = 0;i<socket_count;i++) {
sockets[i].card_state = 1; /* 1 = present but empty */
- sockets[i].io_base = (dev->resource[0].start & ~1);
- if (sockets[i].io_base > 0)
- request_region(sockets[i].io_base, 2, "i82092aa");
-
-
+ sockets[i].io_base = pci_resource_start(dev, 0);
sockets[i].cap.features |= SS_CAP_PCCARD;
sockets[i].cap.map_size = 0x1000;
sockets[i].cap.irq_mask = 0;
@@ -144,20 +144,28 @@
configbyte = 0xFF; /* bitmask, one bit per event, 1 = PCI interrupt, 0 = ISA interrupt */
pci_write_config_byte(dev, 0x50, configbyte); /* PCI Interrupt Routing Register */

-
/* Register the interrupt handler */
dprintk(KERN_DEBUG "Requesting interrupt %i \n",dev->irq);
- if (request_irq(dev->irq, i82092aa_interrupt, SA_SHIRQ, "i82092aa", i82092aa_interrupt)) {
+ if ((ret = request_irq(dev->irq, i82092aa_interrupt, SA_SHIRQ, "i82092aa", i82092aa_interrupt))) {
printk(KERN_ERR "i82092aa: Failed to register IRQ %d, aborting\n", dev->irq);
- return -EIO;
+ goto err_out_free_res;
}

-
- if (register_ss_entry(socket_count, &i82092aa_operations) != 0)
- printk(KERN_NOTICE "i82092aa: register_ss_entry() failed\n");
+ if ((ret = register_ss_entry(socket_count, &i82092aa_operations) != 0)) {
+ printk(KERN_ERR "i82092aa: register_ss_entry() failed\n");
+ goto err_out_free_irq;
+ }

leave("i82092aa_pci_probe");
return 0;
+
+err_out_free_irq:
+ free_irq(dev->irq, i82092aa_interrupt);
+err_out_free_res:
+ release_region(pci_resource_start(dev, 0), 2);
+err_out_disable:
+ pci_disable_device(dev);
+ return ret;
}

static void __exit i82092aa_pci_remove(struct pci_dev *dev)[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 13:21    [W:0.035 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site