summaryrefslogtreecommitdiffstats
path: root/drivers/base/base.h
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-08 12:13:10 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-09 10:42:57 +0100
commit789be03a600842ef461968cc5a2d458f51f319b2 (patch)
tree931ba69e3827398471652589432ab138a0f0584e /drivers/base/base.h
parentmtd: mtdpart: Don't create platform device that'll never probe (diff)
downloadlinux-789be03a600842ef461968cc5a2d458f51f319b2.tar.xz
linux-789be03a600842ef461968cc5a2d458f51f319b2.zip
driver core: add local subsys_get and subsys_put functions
We need to control the reference count of the subsys private structure instead of directly manipulating the kset reference count of it, so wrap that logic up in a subsys_get() and subsys_put() function to make it more obvious as to what is happening. Cc: "Rafael J. Wysocki" <rafael@kernel.org> Link: https://lore.kernel.org/r/20230208111330.439504-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/base.h')
-rw-r--r--drivers/base/base.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 0e806f641079..9e06c18c7a64 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -57,6 +57,19 @@ struct subsys_private {
};
#define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj)
+static inline struct subsys_private *subsys_get(struct subsys_private *sp)
+{
+ if (sp)
+ kset_get(&sp->subsys);
+ return sp;
+}
+
+static inline void subsys_put(struct subsys_private *sp)
+{
+ if (sp)
+ kset_put(&sp->subsys);
+}
+
struct driver_private {
struct kobject kobj;
struct klist klist_devices;