public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* kobj_to_dev ?
@ 2004-01-16 23:32 Hollis Blanchard
  2004-01-17  0:17 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Hollis Blanchard @ 2004-01-16 23:32 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Hi Greg, could this be added to device.h:

--- 1.112/include/linux/device.h        Wed Jan  7 23:58:16 2004
+++ edited/include/linux/device.h       Fri Jan 16 17:35:04 2004
@@ -279,6 +279,8 @@
         void    (*release)(struct device * dev);
  };

+#define kobj_to_dev(k) container_of((k), struct device, kobj)
+
  static inline struct device *
  list_to_dev(struct list_head *node)
  {

I'm using it as the following (inspired by find_bus), and it seems like 
it would make sense to put in device.h.

struct vio_dev *vio_find_device(const char *name)
{
	struct kobject *kobj;

	kobj = kset_find_obj(&vio_bus_type.devices, name);
	if (!kobj)
		return NULL;

	return to_vio_dev(kobj_to_dev(kobj));
}

As a side node, since those #defines don't to type-checking, would it 
make sense to name them with both types? E.g. "kobj_to_dev" instead of 
just "to_dev"?

-- 
Hollis Blanchard
IBM Linux Technology Center


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

end of thread, other threads:[~2004-01-20  3:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-16 23:32 kobj_to_dev ? Hollis Blanchard
2004-01-17  0:17 ` Greg KH
2004-01-19 20:26   ` Hollis Blanchard
2004-01-20  0:04     ` Greg KH
2004-01-20  0:25       ` Hollis Blanchard
2004-01-20  0:53         ` Greg KH
2004-01-20  3:18           ` Hollis Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox