mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	 Linus Walleij <linus.walleij@linaro.org>,
	 Bartosz Golaszewski <brgl@bgdev.pl>,
	Kent Gibson <warthog618@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH v2 1/2] driver core: class: expose the class kobject
Date: Tue, 15 Oct 2024 10:00:23 +0200	[thread overview]
Message-ID: <20241015-gpio-class-mountpoint-v2-1-7709301876ef@linaro.org> (raw)
In-Reply-To: <20241015-gpio-class-mountpoint-v2-0-7709301876ef@linaro.org>

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Export the address of the /sys/class kobject to users that need to
chain off of it by means other than calling register_class(). This will
be used by the GPIO subsystem to provide a backward compatibility
mount-point for the GPIO sysfs class once it's disabled.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/base/class.c         | 6 ++++++
 include/linux/device/class.h | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index cb5359235c70..68474aff53df 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -23,6 +23,9 @@
 /* /sys/class */
 static struct kset *class_kset;
 
+struct kobject *class_kobj;
+EXPORT_SYMBOL_GPL(class_kobj);
+
 #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
 
 /**
@@ -668,5 +671,8 @@ int __init classes_init(void)
 	class_kset = kset_create_and_add("class", NULL, NULL);
 	if (!class_kset)
 		return -ENOMEM;
+
+	class_kobj = &class_kset->kobj;
+
 	return 0;
 }
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index 518c9c83d64b..898f7948293d 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -69,6 +69,12 @@ struct class {
 	const struct dev_pm_ops *pm;
 };
 
+/*
+ * Global /sys/class kobject for creating sub-groups by means other than
+ * class_register().
+ */
+extern struct kobject *class_kobj;
+
 struct class_dev_iter {
 	struct klist_iter		ki;
 	const struct device_type	*type;

-- 
2.43.0


  reply	other threads:[~2024-10-15  8:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15  8:00 [PATCH v2 0/2] gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disabled Bartosz Golaszewski
2024-10-15  8:00 ` Bartosz Golaszewski [this message]
2024-10-15  9:24   ` [PATCH v2 1/2] driver core: class: expose the class kobject Greg Kroah-Hartman
2024-10-15  8:00 ` [PATCH v2 2/2] gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disabled Bartosz Golaszewski
2024-10-15  9:27   ` Greg Kroah-Hartman
2024-10-15  9:29 ` [PATCH v2 0/2] " Greg Kroah-Hartman
2024-10-15 12:11   ` Bartosz Golaszewski
2024-10-15 12:46     ` Greg Kroah-Hartman
2024-10-15 17:52       ` Bartosz Golaszewski
2024-10-16  7:02         ` Greg Kroah-Hartman
2024-10-16  8:49           ` Bartosz Golaszewski
2024-10-16  9:12             ` Greg Kroah-Hartman
2024-11-12 10:04       ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241015-gpio-class-mountpoint-v2-1-7709301876ef@linaro.org \
    --to=brgl@bgdev.pl \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®