* [PATCH] return number of devices claimed from acpi_bus_register_driver()
@ 2004-07-29 18:09 Bjorn Helgaas
[not found] ` <200407291209.28801.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2004-07-29 18:09 UTC (permalink / raw)
To: Len Brown; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
pnp_register_driver() and pci_register_driver() return the number of
devices claimed by the driver. This makes acpi_bus_register_driver()
do the same.
All existing callers of acpi_bus_register_driver() either ignore the
return value or check only for negative (error) return values.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
===== drivers/acpi/scan.c 1.28 vs edited =====
--- 1.28/drivers/acpi/scan.c 2004-06-30 09:55:20 -06:00
+++ edited/drivers/acpi/scan.c 2004-07-29 11:43:17 -06:00
@@ -276,6 +276,7 @@
static int acpi_driver_attach(struct acpi_driver * drv)
{
struct list_head * node, * next;
+ int count = 0;
ACPI_FUNCTION_TRACE("acpi_driver_attach");
@@ -290,6 +291,7 @@
if (!acpi_bus_match(dev, drv)) {
if (!acpi_bus_driver_init(dev, drv)) {
atomic_inc(&drv->references);
+ count++;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
drv->name, dev->pnp.bus_id));
}
@@ -297,7 +299,7 @@
spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
- return_VALUE(0);
+ return_VALUE(count);
}
static int acpi_driver_detach(struct acpi_driver * drv)
@@ -328,28 +330,30 @@
* acpi_bus_register_driver
* ------------------------
* Registers a driver with the ACPI bus. Searches the namespace for all
- * devices that match the driver's criteria and binds.
+ * devices that match the driver's criteria and binds. Returns the
+ * number of devices that were claimed by the driver, or a negative
+ * error status for failure.
*/
int
acpi_bus_register_driver (
struct acpi_driver *driver)
{
- int error = 0;
+ int count;
ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
if (acpi_disabled)
return_VALUE(-ENODEV);
- if (driver) {
- spin_lock(&acpi_device_lock);
- list_add_tail(&driver->node, &acpi_bus_drivers);
- spin_unlock(&acpi_device_lock);
- acpi_driver_attach(driver);
- } else
- error = -EINVAL;
+ if (!driver)
+ return_VALUE(-EINVAL);
+
+ spin_lock(&acpi_device_lock);
+ list_add_tail(&driver->node, &acpi_bus_drivers);
+ spin_unlock(&acpi_device_lock);
+ count = acpi_driver_attach(driver);
- return_VALUE(error);
+ return_VALUE(count);
}
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
^ permalink raw reply [flat|nested] 3+ messages in thread[parent not found: <200407291209.28801.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>]
* Re: [PATCH] return number of devices claimed from acpi_bus_register_driver() [not found] ` <200407291209.28801.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org> @ 2004-07-30 17:17 ` Karol Kozimor 2004-08-09 16:26 ` Len Brown 1 sibling, 0 replies; 3+ messages in thread From: Karol Kozimor @ 2004-07-30 17:17 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Len Brown, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Thus wrote Bjorn Helgaas: > pnp_register_driver() and pci_register_driver() return the number of > devices claimed by the driver. This makes acpi_bus_register_driver() > do the same. > > All existing callers of acpi_bus_register_driver() either ignore the > return value or check only for negative (error) return values. I'd like to see that (or something similar) in if possible. The current behaviour of acpi_bus_register_driver() does not allow for a clean solution to back off in case no devices are claimed, thus most acpi drivers will properly load even if there's no matching hardware available. Best regards, -- Karol 'sziwan' Kozimor sziwan-DETuoxkZsSqrDJvtcaxF/A@public.gmane.org ------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] return number of devices claimed from acpi_bus_register_driver() [not found] ` <200407291209.28801.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org> 2004-07-30 17:17 ` Karol Kozimor @ 2004-08-09 16:26 ` Len Brown 1 sibling, 0 replies; 3+ messages in thread From: Len Brown @ 2004-08-09 16:26 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: ACPI Developers Accepted. thanks, -Len On Thu, 2004-07-29 at 14:09, Bjorn Helgaas wrote: > pnp_register_driver() and pci_register_driver() return the number of > devices claimed by the driver. This makes acpi_bus_register_driver() > do the same. > > All existing callers of acpi_bus_register_driver() either ignore the > return value or check only for negative (error) return values. > > Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org> > > ===== drivers/acpi/scan.c 1.28 vs edited ===== > --- 1.28/drivers/acpi/scan.c 2004-06-30 09:55:20 -06:00 > +++ edited/drivers/acpi/scan.c 2004-07-29 11:43:17 -06:00 > @@ -276,6 +276,7 @@ > static int acpi_driver_attach(struct acpi_driver * drv) > { > struct list_head * node, * next; > + int count = 0; > > ACPI_FUNCTION_TRACE("acpi_driver_attach"); > > @@ -290,6 +291,7 @@ > if (!acpi_bus_match(dev, drv)) { > if (!acpi_bus_driver_init(dev, drv)) { > atomic_inc(&drv->references); > + count++; > ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found > driver [%s] for device [%s]\n", > drv->name, > dev->pnp.bus_id)); > } > @@ -297,7 +299,7 @@ > spin_lock(&acpi_device_lock); > } > spin_unlock(&acpi_device_lock); > - return_VALUE(0); > + return_VALUE(count); > } > > static int acpi_driver_detach(struct acpi_driver * drv) > @@ -328,28 +330,30 @@ > * acpi_bus_register_driver > * ------------------------ > * Registers a driver with the ACPI bus. Searches the namespace for > all > - * devices that match the driver's criteria and binds. > + * devices that match the driver's criteria and binds. Returns the > + * number of devices that were claimed by the driver, or a negative > + * error status for failure. > */ > int > acpi_bus_register_driver ( > struct acpi_driver *driver) > { > - int error = 0; > + int count; > > ACPI_FUNCTION_TRACE("acpi_bus_register_driver"); > > if (acpi_disabled) > return_VALUE(-ENODEV); > > - if (driver) { > - spin_lock(&acpi_device_lock); > - list_add_tail(&driver->node, &acpi_bus_drivers); > - spin_unlock(&acpi_device_lock); > - acpi_driver_attach(driver); > - } else > - error = -EINVAL; > + if (!driver) > + return_VALUE(-EINVAL); > + > + spin_lock(&acpi_device_lock); > + list_add_tail(&driver->node, &acpi_bus_drivers); > + spin_unlock(&acpi_device_lock); > + count = acpi_driver_attach(driver); > > - return_VALUE(error); > + return_VALUE(count); > } > > > ------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-08-09 16:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-29 18:09 [PATCH] return number of devices claimed from acpi_bus_register_driver() Bjorn Helgaas
[not found] ` <200407291209.28801.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2004-07-30 17:17 ` Karol Kozimor
2004-08-09 16:26 ` Len Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox