public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcus Meissner <Marcus.Meissner@caldera.de>
To: Jeff Garzik <jgarzik@mandrakesoft.com>
Cc: Marcus Meissner <Marcus.Meissner@caldera.de>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] es1371 pci fix/cleanup
Date: Mon, 23 Apr 2001 18:06:53 +0200	[thread overview]
Message-ID: <20010423180653.A16759@caldera.de> (raw)
In-Reply-To: <20010423175158.A15604@caldera.de> <3AE45121.926C4B51@mandrakesoft.com>
In-Reply-To: <3AE45121.926C4B51@mandrakesoft.com>; from jgarzik@mandrakesoft.com on Mon, Apr 23, 2001 at 11:58:25AM -0400

On Mon, Apr 23, 2001 at 11:58:25AM -0400, Jeff Garzik wrote:
> Marcus Meissner wrote:
> > 
> > Hi,
> > 
> > This moves pci_enable_device in the es1371 driver before any resource
> > access and also replaces the RSRCISIOREGION by just pci_resource_flags
> > as suggested by Jeff.
> > 
> > Tested and verified.

> Looks ok except error returns.
> 
> pci_enable_device - obtain its return value, and return that.
> 
> no IORESOURCE_IO or pcidev->irq==0 - I guess -ENODEV would be
> appropriate.  (basically look at errno.h and make a judgement call which
> error best fits the situation)

Hmm, I think I spotted all places in the probe function. I also return
-ENODEV in case we can't request_region() or request_irq().

Some drivers use EBUSY, some ENOMEM, some ENODEV there, is there
any standard return value?

Ciao, Marcus

Index: drivers/sound/es1371.c
===================================================================
RCS file: /build/mm/work/repository/linux-mm/drivers/sound/es1371.c,v
retrieving revision 1.7
diff -u -r1.7 es1371.c
--- drivers/sound/es1371.c	2001/04/17 17:26:05	1.7
+++ drivers/sound/es1371.c	2001/04/23 16:03:34
@@ -2771,22 +2771,22 @@
 	{ SOUND_MIXER_WRITE_IGAIN, 0x4040 }
 };
 
-#define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \
-				 (pci_resource_flags((dev), (num)) & IORESOURCE_IO))
-
 static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
 {
 	struct es1371_state *s;
 	mm_segment_t fs;
-	int i, val;
+	int i, val, res = -1;
 	unsigned long tmo;
 	signed long tmo2;
 	unsigned int cssr;
+
+	if ((res=pci_enable_device(pcidev)))
+		return res;
 
-	if (!RSRCISIOREGION(pcidev, 0))
-		return -1;
+	if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_IO))
+		return -ENODEV;
 	if (pcidev->irq == 0) 
-		return -1;
+		return -ENODEV;
 	i = pci_set_dma_mask(pcidev, 0xffffffff);
 	if (i) {
 		printk(KERN_WARNING "es1371: architecture does not support 32bit PCI busmaster DMA\n");
@@ -2794,7 +2794,7 @@
 	}
 	if (!(s = kmalloc(sizeof(struct es1371_state), GFP_KERNEL))) {
 		printk(KERN_WARNING PFX "out of memory\n");
-		return -1;
+		return -ENOMEM;
 	}
 	memset(s, 0, sizeof(struct es1371_state));
 	init_waitqueue_head(&s->dma_adc.wait);
@@ -2822,8 +2822,6 @@
 		printk(KERN_ERR PFX "io ports %#lx-%#lx in use\n", s->io, s->io+ES1371_EXTENT-1);
 		goto err_region;
 	}
-	if (pci_enable_device(pcidev))
-		goto err_irq;
 	if (request_irq(s->irq, es1371_interrupt, SA_SHIRQ, "es1371", s)) {
 		printk(KERN_ERR PFX "irq %u in use\n", s->irq);
 		goto err_irq;
@@ -2964,7 +2962,7 @@
 	release_region(s->io, ES1371_EXTENT);
  err_region:
 	kfree(s);
-	return -1;
+	return -ENODEV;
 }
 
 static void __devinit es1371_remove(struct pci_dev *dev)

  reply	other threads:[~2001-04-23 16:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-23 15:51 [PATCH] es1371 pci fix/cleanup Marcus Meissner
2001-04-23 15:58 ` Jeff Garzik
2001-04-23 16:06   ` Marcus Meissner [this message]
2001-04-23 16:11     ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010423180653.A16759@caldera.de \
    --to=marcus.meissner@caldera.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jgarzik@mandrakesoft.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox