public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH 4/5] kobject: kset_uevent_ops: make name() callback take a const *
Date: Mon, 21 Nov 2022 10:46:48 +0100	[thread overview]
Message-ID: <20221121094649.1556002-4-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20221121094649.1556002-1-gregkh@linuxfoundation.org>

The name() callback in struct kset_uevent_ops does not modify the
kobject passed into it, so make the pointer const to enforce this
restriction.  When doing so, fix up the single existing name() callback
to have the correct signature to preserve the build.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/core.c     | 4 ++--
 include/linux/kobject.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 005a2b092f3e..a3e14143ec0c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2376,9 +2376,9 @@ static int dev_uevent_filter(const struct kobject *kobj)
 	return 0;
 }
 
-static const char *dev_uevent_name(struct kobject *kobj)
+static const char *dev_uevent_name(const struct kobject *kobj)
 {
-	struct device *dev = kobj_to_dev(kobj);
+	const struct device *dev = kobj_to_dev(kobj);
 
 	if (dev->bus)
 		return dev->bus->name;
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 640f59d4b3de..58a5b75612e3 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -136,7 +136,7 @@ struct kobj_uevent_env {
 
 struct kset_uevent_ops {
 	int (* const filter)(const struct kobject *kobj);
-	const char *(* const name)(struct kobject *kobj);
+	const char *(* const name)(const struct kobject *kobj);
 	int (* const uevent)(struct kobject *kobj, struct kobj_uevent_env *env);
 };
 
-- 
2.38.1


  parent reply	other threads:[~2022-11-21  9:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21  9:46 [PATCH 1/5] kobject: make kobject_get_ownership() take a constant kobject * Greg Kroah-Hartman
2022-11-21  9:46 ` [PATCH 2/5] kobject: make kobject_namespace take a const * Greg Kroah-Hartman
2022-11-21 11:49   ` Rafael J. Wysocki
2022-11-21  9:46 ` [PATCH 3/5] kobject: kset_uevent_ops: make filter() callback " Greg Kroah-Hartman
2022-11-21  9:51   ` [Linaro-mm-sig] " Christian König
2022-11-21 11:49   ` Rafael J. Wysocki
2022-11-21  9:46 ` Greg Kroah-Hartman [this message]
2022-11-21 11:50   ` [PATCH 4/5] kobject: kset_uevent_ops: make name() " Rafael J. Wysocki
2022-11-21  9:46 ` [PATCH 5/5] driver core: pass a const * into of_device_uevent() Greg Kroah-Hartman
2022-11-22 21:22   ` Rob Herring
2022-11-23  9:57     ` Greg Kroah-Hartman
2022-11-21 10:53 ` [PATCH 1/5] kobject: make kobject_get_ownership() take a constant kobject * Nikolay Aleksandrov
2022-11-21 11:48 ` Rafael J. Wysocki
2022-11-21 20:18 ` Jakub Kicinski

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=20221121094649.1556002-4-gregkh@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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