Commit 37e98d9b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

driver core: bus: move lock_class_key into dynamic structure

Move the lock_class_key structure out of struct bus_type and into the
dynamic structure we create already for all bus_types registered with
the kernel.  This saves on static space and removes one more writable
field in struct bus_type.

In the future, the same field can be moved out of the struct class logic
because it shares this same private structure.

Most everyone will never notice this change, as lockdep is not enabled
in real systems so no memory or logic changes are happening for them.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230201083349.4038660-1-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 40b3880d
...@@ -52,6 +52,8 @@ struct subsys_private { ...@@ -52,6 +52,8 @@ struct subsys_private {
struct kset glue_dirs; struct kset glue_dirs;
struct class *class; struct class *class;
struct lock_class_key lock_key;
}; };
#define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj) #define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj)
......
...@@ -154,6 +154,7 @@ static void bus_release(struct kobject *kobj) ...@@ -154,6 +154,7 @@ static void bus_release(struct kobject *kobj)
struct subsys_private *priv = to_subsys_private(kobj); struct subsys_private *priv = to_subsys_private(kobj);
struct bus_type *bus = priv->bus; struct bus_type *bus = priv->bus;
lockdep_unregister_key(&priv->lock_key);
kfree(priv); kfree(priv);
bus->p = NULL; bus->p = NULL;
} }
...@@ -743,7 +744,7 @@ int bus_register(struct bus_type *bus) ...@@ -743,7 +744,7 @@ int bus_register(struct bus_type *bus)
{ {
int retval; int retval;
struct subsys_private *priv; struct subsys_private *priv;
struct lock_class_key *key = &bus->lock_key; struct lock_class_key *key;
priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL); priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL);
if (!priv) if (!priv)
...@@ -785,6 +786,8 @@ int bus_register(struct bus_type *bus) ...@@ -785,6 +786,8 @@ int bus_register(struct bus_type *bus)
} }
INIT_LIST_HEAD(&priv->interfaces); INIT_LIST_HEAD(&priv->interfaces);
key = &priv->lock_key;
lockdep_register_key(key);
__mutex_init(&priv->mutex, "subsys mutex", key); __mutex_init(&priv->mutex, "subsys mutex", key);
klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put); klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put);
klist_init(&priv->klist_drivers, NULL, NULL); klist_init(&priv->klist_drivers, NULL, NULL);
......
...@@ -112,7 +112,6 @@ struct bus_type { ...@@ -112,7 +112,6 @@ struct bus_type {
const struct iommu_ops *iommu_ops; const struct iommu_ops *iommu_ops;
struct subsys_private *p; struct subsys_private *p;
struct lock_class_key lock_key;
bool need_parent_lock; bool need_parent_lock;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment