* [PATCH] ibmasm: add missing pci_enable_device()
@ 2004-08-04 21:32 Bjorn Helgaas
2004-08-09 17:18 ` Max Asbock
0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2004-08-04 21:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: amax, linux-kernel
I don't have this hardware, so this has not been tested.
Add pci_enable_device()/pci_disable_device(). In the past, drivers
often worked without this, but it is now required in order to route
PCI interrupts correctly.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
===== drivers/misc/ibmasm/module.c 1.2 vs edited =====
--- 1.2/drivers/misc/ibmasm/module.c 2004-05-14 06:00:50 -06:00
+++ edited/drivers/misc/ibmasm/module.c 2004-08-04 13:15:46 -06:00
@@ -62,10 +62,17 @@
int result = -ENOMEM;
struct service_processor *sp;
+ if (pci_enable_device(pdev)) {
+ printk(KERN_ERR "%s: can't enable PCI device at %s\n",
+ DRIVER_NAME, pci_name(pdev));
+ return -ENODEV;
+ }
+
sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
if (sp == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
- return result;
+ result = -ENOMEM;
+ goto error_kmalloc;
}
memset(sp, 0, sizeof(struct service_processor));
@@ -148,6 +155,8 @@
ibmasm_event_buffer_exit(sp);
error_eventbuffer:
kfree(sp);
+error_kmalloc:
+ pci_disable_device(pdev);
return result;
}
@@ -166,6 +175,7 @@
iounmap(sp->base_address);
ibmasm_event_buffer_exit(sp);
kfree(sp);
+ pci_disable_device(pdev);
}
static struct pci_device_id ibmasm_pci_table[] =
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmasm: add missing pci_enable_device()
2004-08-04 21:32 Bjorn Helgaas
@ 2004-08-09 17:18 ` Max Asbock
2004-08-09 17:28 ` Bjorn Helgaas
0 siblings, 1 reply; 5+ messages in thread
From: Max Asbock @ 2004-08-09 17:18 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Andrew Morton, linux-kernel
I tested this on the hardware. It works fine.
Is there any reason we shouldn't use dev_err() for the pci_enable error
message like in the other messages?
regards,
max
On Wed, 2004-08-04 at 14:32, Bjorn Helgaas wrote:
> I don't have this hardware, so this has not been tested.
>
>
> Add pci_enable_device()/pci_disable_device(). In the past, drivers
> often worked without this, but it is now required in order to route
> PCI interrupts correctly.
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
>
> ===== drivers/misc/ibmasm/module.c 1.2 vs edited =====
> --- 1.2/drivers/misc/ibmasm/module.c 2004-05-14 06:00:50 -06:00
> +++ edited/drivers/misc/ibmasm/module.c 2004-08-04 13:15:46 -06:00
> @@ -62,10 +62,17 @@
> int result = -ENOMEM;
> struct service_processor *sp;
>
> + if (pci_enable_device(pdev)) {
> + printk(KERN_ERR "%s: can't enable PCI device at %s\n",
> + DRIVER_NAME, pci_name(pdev));
> + return -ENODEV;
> + }
> +
> sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
> if (sp == NULL) {
> dev_err(&pdev->dev, "Failed to allocate memory\n");
> - return result;
> + result = -ENOMEM;
> + goto error_kmalloc;
> }
> memset(sp, 0, sizeof(struct service_processor));
>
> @@ -148,6 +155,8 @@
> ibmasm_event_buffer_exit(sp);
> error_eventbuffer:
> kfree(sp);
> +error_kmalloc:
> + pci_disable_device(pdev);
>
> return result;
> }
> @@ -166,6 +175,7 @@
> iounmap(sp->base_address);
> ibmasm_event_buffer_exit(sp);
> kfree(sp);
> + pci_disable_device(pdev);
> }
>
> static struct pci_device_id ibmasm_pci_table[] =
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmasm: add missing pci_enable_device()
2004-08-09 17:18 ` Max Asbock
@ 2004-08-09 17:28 ` Bjorn Helgaas
2004-08-09 22:27 ` Francois Romieu
0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2004-08-09 17:28 UTC (permalink / raw)
To: Max Asbock; +Cc: Andrew Morton, linux-kernel
On Monday 09 August 2004 11:18 am, Max Asbock wrote:
> I tested this on the hardware. It works fine.
> Is there any reason we shouldn't use dev_err() for the pci_enable error
> message like in the other messages?
That would probably be fine, too. ISTR looking at one case where the
printk wrapper wouldn't work quite right if pci_enable_device() failed.
But dev_err() looks like it should work fine.
> regards,
> max
>
> On Wed, 2004-08-04 at 14:32, Bjorn Helgaas wrote:
> > I don't have this hardware, so this has not been tested.
> >
> >
> > Add pci_enable_device()/pci_disable_device(). In the past, drivers
> > often worked without this, but it is now required in order to route
> > PCI interrupts correctly.
> >
> > Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
> >
> > ===== drivers/misc/ibmasm/module.c 1.2 vs edited =====
> > --- 1.2/drivers/misc/ibmasm/module.c 2004-05-14 06:00:50 -06:00
> > +++ edited/drivers/misc/ibmasm/module.c 2004-08-04 13:15:46 -06:00
> > @@ -62,10 +62,17 @@
> > int result = -ENOMEM;
> > struct service_processor *sp;
> >
> > + if (pci_enable_device(pdev)) {
> > + printk(KERN_ERR "%s: can't enable PCI device at %s\n",
> > + DRIVER_NAME, pci_name(pdev));
> > + return -ENODEV;
> > + }
> > +
> > sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
> > if (sp == NULL) {
> > dev_err(&pdev->dev, "Failed to allocate memory\n");
> > - return result;
> > + result = -ENOMEM;
> > + goto error_kmalloc;
> > }
> > memset(sp, 0, sizeof(struct service_processor));
> >
> > @@ -148,6 +155,8 @@
> > ibmasm_event_buffer_exit(sp);
> > error_eventbuffer:
> > kfree(sp);
> > +error_kmalloc:
> > + pci_disable_device(pdev);
> >
> > return result;
> > }
> > @@ -166,6 +175,7 @@
> > iounmap(sp->base_address);
> > ibmasm_event_buffer_exit(sp);
> > kfree(sp);
> > + pci_disable_device(pdev);
> > }
> >
> > static struct pci_device_id ibmasm_pci_table[] =
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
> >
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmasm: add missing pci_enable_device()
2004-08-09 17:28 ` Bjorn Helgaas
@ 2004-08-09 22:27 ` Francois Romieu
0 siblings, 0 replies; 5+ messages in thread
From: Francois Romieu @ 2004-08-09 22:27 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Max Asbock, Andrew Morton, linux-kernel
Bjorn Helgaas <bjorn.helgaas@hp.com> :
[...]
> > > ===== drivers/misc/ibmasm/module.c 1.2 vs edited =====
> > > --- 1.2/drivers/misc/ibmasm/module.c 2004-05-14 06:00:50 -06:00
> > > +++ edited/drivers/misc/ibmasm/module.c 2004-08-04 13:15:46 -06:00
> > > @@ -62,10 +62,17 @@
> > > int result = -ENOMEM;
> > > struct service_processor *sp;
> > >
> > > + if (pci_enable_device(pdev)) {
> > > + printk(KERN_ERR "%s: can't enable PCI device at %s\n",
> > > + DRIVER_NAME, pci_name(pdev));
> > > + return -ENODEV;
Btw, pci_enable_device returns a perfectly fine status code. There is no
reason to override it ('result = pci_enable_device(...' and you can even
remove the previous ENOMEM initialization).
[...]
> > > sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
> > > if (sp == NULL) {
> > > dev_err(&pdev->dev, "Failed to allocate memory\n");
> > > - return result;
> > > + result = -ENOMEM;
> > > + goto error_kmalloc;
You may consider calling it err_pci_disable (or such). This way:
- one can check that the kmalloc is preceeded by a pci_enable;
- one can locally check that the unroll path does its job
(error_pci_disable is followed by a pci_disable_xxx -> makes sense).
--
Ueimor
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmasm: add missing pci_enable_device()
[not found] <200408242224.i7OMOs1H029517@hera.kernel.org>
@ 2004-08-25 0:43 ` Jeff Garzik
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2004-08-25 0:43 UTC (permalink / raw)
Cc: Linux Kernel Mailing List
Linux Kernel Mailing List wrote:
> diff -Nru a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
> --- a/drivers/misc/ibmasm/module.c 2004-08-24 15:25:05 -07:00
> +++ b/drivers/misc/ibmasm/module.c 2004-08-24 15:25:05 -07:00
> @@ -62,10 +62,17 @@
> int result = -ENOMEM;
> struct service_processor *sp;
>
> + if (pci_enable_device(pdev)) {
> + printk(KERN_ERR "%s: can't enable PCI device at %s\n",
> + DRIVER_NAME, pci_name(pdev));
> + return -ENODEV;
> + }
Another [minor] bug in this series of changes: you should propagate the
return value of pci_enable_device(), not make up your own.
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-08-25 0:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200408242224.i7OMOs1H029517@hera.kernel.org>
2004-08-25 0:43 ` [PATCH] ibmasm: add missing pci_enable_device() Jeff Garzik
2004-08-04 21:32 Bjorn Helgaas
2004-08-09 17:18 ` Max Asbock
2004-08-09 17:28 ` Bjorn Helgaas
2004-08-09 22:27 ` Francois Romieu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox