From 7c71448b8aa80123fc521563d5f7c63a099d97ab Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 22 Jan 2008 18:17:41 -0500 Subject: class: move driver core specific parts to a private structure This moves the portions of struct class that are dynamic (kobject and lock and lists) out of the main structure and into a dynamic, private, structure. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index 2c9ae43e221..0ec372a6776 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -36,6 +36,33 @@ struct driver_private { }; #define to_driver(obj) container_of(obj, struct driver_private, kobj) + +/** + * struct class_private - structure to hold the private to the driver core portions of the class structure. + * + * @subsys - the struct kset that defines this class. This is the main kobject + * @children - list of class_devices associated with this class + * @devices - list of devices associated with this class + * @interfaces - list of class_interfaces associated with this class + * @class_dirs - + * @sem - semaphore to protect the children, devices, and interfaces lists. + * @class - pointer back to the struct class that this structure is associated + * with. + * + * This structure is the one that is the actual kobject allowing struct + * class to be statically allocated safely. Nothing outside of the driver + * core should ever touch these fields. + */ +struct class_private { + struct kset subsys; + struct list_head devices; + struct list_head interfaces; + struct kset class_dirs; + struct semaphore sem; + struct class *class; +}; +#define to_class(obj) container_of(obj, struct class_private, subsys.kobj) + /* initialisation functions */ extern int devices_init(void); extern int buses_init(void); -- cgit From 97ae69fdbaa71a8f7dbc20bf10fb349d1759152f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 28 May 2008 09:28:39 -0700 Subject: class: rename "devices" to "class_devices" in internal class structure This renames the struct class "devices" field to be "class_devices" to make things easier when struct bus_type and struct class merge in the future. It also makes grepping for fields easier as well. Based on an idea from Kay. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index 0ec372a6776..586c4ca7025 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -42,7 +42,7 @@ struct driver_private { * * @subsys - the struct kset that defines this class. This is the main kobject * @children - list of class_devices associated with this class - * @devices - list of devices associated with this class + * @class_devices - list of devices associated with this class * @interfaces - list of class_interfaces associated with this class * @class_dirs - * @sem - semaphore to protect the children, devices, and interfaces lists. @@ -55,7 +55,7 @@ struct driver_private { */ struct class_private { struct kset subsys; - struct list_head devices; + struct list_head class_devices; struct list_head interfaces; struct kset class_dirs; struct semaphore sem; -- cgit From 184f1f779d5a2e62de4a0b34842ddf8546beca8f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 28 May 2008 09:28:39 -0700 Subject: class: rename "interfaces" to "class_interfaces" in internal class structure This renames the struct class "interfaces" field to be "class_interfaces" to make things easier when struct bus_type and struct class merge in the future. It also makes grepping for fields easier as well. Based on an idea from Kay. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index 586c4ca7025..670b95a1a51 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -43,7 +43,7 @@ struct driver_private { * @subsys - the struct kset that defines this class. This is the main kobject * @children - list of class_devices associated with this class * @class_devices - list of devices associated with this class - * @interfaces - list of class_interfaces associated with this class + * @class_interfaces - list of class_interfaces associated with this class * @class_dirs - * @sem - semaphore to protect the children, devices, and interfaces lists. * @class - pointer back to the struct class that this structure is associated @@ -56,7 +56,7 @@ struct driver_private { struct class_private { struct kset subsys; struct list_head class_devices; - struct list_head interfaces; + struct list_head class_interfaces; struct kset class_dirs; struct semaphore sem; struct class *class; -- cgit From 1fbfee6c6dc0f4a4c587b6b163ee79643fc9aaa7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 28 May 2008 09:28:39 -0700 Subject: class: rename "subsys" to "class_subsys" in internal class structure This renames the struct class "subsys" field to be "class_subsys" to make things easier when struct bus_type and struct class merge in the future. It also makes grepping for fields easier as well. Based on an idea from Kay. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index 670b95a1a51..a77d4bd2ea6 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -40,7 +40,7 @@ struct driver_private { /** * struct class_private - structure to hold the private to the driver core portions of the class structure. * - * @subsys - the struct kset that defines this class. This is the main kobject + * @class_subsys - the struct kset that defines this class. This is the main kobject * @children - list of class_devices associated with this class * @class_devices - list of devices associated with this class * @class_interfaces - list of class_interfaces associated with this class @@ -54,14 +54,15 @@ struct driver_private { * core should ever touch these fields. */ struct class_private { - struct kset subsys; + struct kset class_subsys; struct list_head class_devices; struct list_head class_interfaces; struct kset class_dirs; struct semaphore sem; struct class *class; }; -#define to_class(obj) container_of(obj, struct class_private, subsys.kobj) +#define to_class(obj) \ + container_of(obj, struct class_private, class_subsys.kobj) /* initialisation functions */ extern int devices_init(void); -- cgit From d9a0157328507c5f563e16a583cd0a063854aebb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 28 May 2008 09:28:39 -0700 Subject: class: rename "sem" to "class_sem" in internal class structure This renames the struct class "sem" field to be "class_sem" to make things easier when struct bus_type and struct class merge in the future. It also makes grepping for fields easier as well. Based on an idea from Kay. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index a77d4bd2ea6..4435732437a 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -45,7 +45,7 @@ struct driver_private { * @class_devices - list of devices associated with this class * @class_interfaces - list of class_interfaces associated with this class * @class_dirs - - * @sem - semaphore to protect the children, devices, and interfaces lists. + * @class_sem - semaphore to protect the children, devices, and interfaces lists. * @class - pointer back to the struct class that this structure is associated * with. * @@ -58,7 +58,7 @@ struct class_private { struct list_head class_devices; struct list_head class_interfaces; struct kset class_dirs; - struct semaphore sem; + struct semaphore class_sem; struct class *class; }; #define to_class(obj) \ -- cgit From 1e41250863cd4de5ffa0678c405d001ca5b62796 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 28 May 2008 09:28:39 -0700 Subject: class: fix docbook comments for class_private structure Removes a field that has been deleted, and adds a description fo the class_dirs field which was previously undocumented. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index 4435732437a..c035dc23266 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -41,10 +41,9 @@ struct driver_private { * struct class_private - structure to hold the private to the driver core portions of the class structure. * * @class_subsys - the struct kset that defines this class. This is the main kobject - * @children - list of class_devices associated with this class * @class_devices - list of devices associated with this class * @class_interfaces - list of class_interfaces associated with this class - * @class_dirs - + * @class_dirs - "glue" directory for virtual devices associated with this class * @class_sem - semaphore to protect the children, devices, and interfaces lists. * @class - pointer back to the struct class that this structure is associated * with. -- cgit From f75b1c60fc1e53c4004a79ea0be071aa3318cdcc Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 28 May 2008 09:28:39 -0700 Subject: class: change internal semaphore to a mutex Now that the lockdep infrastructure in the class core is in place, we should be able to properly change the internal class semaphore to be a mutex. David wrote the original patch, and Greg fixed it up to apply properly due to all of the recent changes in this area. From: Dave Young Cc: Matthew Wilcox Cc: Kay Sievers Cc: Andrew Morton Cc: James Bottomley Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/base/base.h') diff --git a/drivers/base/base.h b/drivers/base/base.h index c035dc23266..31dc0cd84af 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -44,7 +44,7 @@ struct driver_private { * @class_devices - list of devices associated with this class * @class_interfaces - list of class_interfaces associated with this class * @class_dirs - "glue" directory for virtual devices associated with this class - * @class_sem - semaphore to protect the children, devices, and interfaces lists. + * @class_mutex - mutex to protect the children, devices, and interfaces lists. * @class - pointer back to the struct class that this structure is associated * with. * @@ -57,7 +57,7 @@ struct class_private { struct list_head class_devices; struct list_head class_interfaces; struct kset class_dirs; - struct semaphore class_sem; + struct mutex class_mutex; struct class *class; }; #define to_class(obj) \ -- cgit