All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] allow to register interfaces after devices
@ 2002-11-26 21:22 Martin Waitz
  2002-11-28  3:48 ` Patrick Mochel
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Waitz @ 2002-11-26 21:22 UTC (permalink / raw)
  To: Patrick Mochel; +Cc: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2821 bytes --]

hi :)


i had a problem some of my code that registered a interface for cpu_devclass
was being run after cpu devices got added to the class.

current code only adds those devices to the interface that are
added after registering the interface.
this patch changes it by walking all devices that are already registered
to intf->devclass.


--- linux-2.5/drivers/base/intf.c       2002-11-26 21:41:00.000000000 +0100
+++ linux/drivers/base/intf.c   2002-11-26 21:41:00.000000000 +0100
@@ -35,17 +35,36 @@
 int interface_register(struct device_interface * intf)
 {
        struct device_class * cls = get_devclass(intf->devclass);
-       int error = 0;
+       struct list_head * drv_node;
+
+       if (!cls) {
+               return -EINVAL;
+       }
 
-       if (cls) {
-               pr_debug("register interface '%s' with class '%s'\n",
-                        intf->name,cls->name);
-               strncpy(intf->kobj.name,intf->name,KOBJ_NAME_LEN);
-               intf->kobj.subsys = &cls->subsys;
-               kobject_register(&intf->kobj);
-       } else
-               error = -EINVAL;
-       return error;
+       pr_debug("register interface '%s' with class '%s'\n",
+                intf->name,cls->name);
+       strncpy(intf->kobj.name,intf->name,KOBJ_NAME_LEN);
+       intf->kobj.subsys = &cls->subsys;
+       kobject_register(&intf->kobj);
+
+       /* walk all devices already registered to intf->devclass */
+       list_for_each(drv_node, &cls->drivers) {
+               struct device_driver * driver =
+                       container_of(drv_node,struct device_driver,class_list);
+               struct list_head * dev_node;
+
+               list_for_each(dev_node, &driver->devices) {
+                       int error;
+                       struct device * dev =
+                               container_of(dev_node,struct device,driver_list);
+                       error = intf->add_device(dev);
+                       if (error)
+                               pr_debug("%s:%s: adding '%s' failed: %d\n",
+                                        cls->name,intf->name,dev->name,error);
+               }
+       }
+
+       return 0;
 }
 
 void interface_unregister(struct device_interface * intf)


-- 
CU,		  / Friedrich-Alexander University Erlangen, Germany
Martin Waitz	//  [Tali on IRCnet]  [tali.home.pages.de] _________
______________/// - - - - - - - - - - - - - - - - - - - - ///
dies ist eine manuell generierte mail, sie beinhaltet    //
tippfehler und ist auch ohne grossbuchstaben gueltig.   /
			    -
Wer bereit ist, grundlegende Freiheiten aufzugeben, um sich 
kurzfristige Sicherheit zu verschaffen, der hat weder Freiheit 
noch Sicherheit verdient.
			Benjamin Franklin  (1706 - 1790)

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] allow to register interfaces after devices
  2002-11-26 21:22 [PATCH] allow to register interfaces after devices Martin Waitz
@ 2002-11-28  3:48 ` Patrick Mochel
  0 siblings, 0 replies; 2+ messages in thread
From: Patrick Mochel @ 2002-11-28  3:48 UTC (permalink / raw)
  To: Martin Waitz; +Cc: Linux Kernel Mailing List


On Tue, 26 Nov 2002, Martin Waitz wrote:

> hi :)
> 
> 
> i had a problem some of my code that registered a interface for cpu_devclass
> was being run after cpu devices got added to the class.
> 
> current code only adds those devices to the interface that are
> added after registering the interface.
> this patch changes it by walking all devices that are already registered
> to intf->devclass.

Yeah, the interface code has a lot of crap in it. Thanks for the patch; 
I'll integrate it, and be making more changes on top of it.

Thanks,

	-pat


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-28  3:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-26 21:22 [PATCH] allow to register interfaces after devices Martin Waitz
2002-11-28  3:48 ` Patrick Mochel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.