From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Kai Vehmanen <kai.vehmanen@intel.com>,
intel-gfx@lists.freedesktop.org,
Lucas De Marchi <lucas.demarchi@intel.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
David Airlie <airlied@linux.ie>,
mauro.chehab@intel.com, Dan Williams <dan.j.williams@intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-modules@vger.kernel.org,
Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Subject: [Intel-gfx] [PATCH 1/2] module: add a function to add module references
Date: Fri, 29 Apr 2022 07:31:15 +0100 [thread overview]
Message-ID: <a078eb2e46d00ec59c8a91ea0afa5190730c9e58.1651212016.git.mchehab@kernel.org> (raw)
In-Reply-To: <cover.1651212016.git.mchehab@kernel.org>
Sometimes, device drivers are bound using indirect references,
which is not visible when looking at /proc/modules or lsmod.
Add a function to allow setting up module references for such
cases.
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
See [PATCH 0/2] at: https://lore.kernel.org/all/cover.1651212016.git.mchehab@kernel.org/
include/linux/module.h | 7 +++++++
kernel/module/main.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/linux/module.h b/include/linux/module.h
index 46d4d5f2516e..be74f807e41d 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -596,6 +596,8 @@ static inline bool within_module(unsigned long addr, const struct module *mod)
/* Search for module by name: must be in a RCU-sched critical section. */
struct module *find_module(const char *name);
+int module_add_named_dependency(const char *name, struct module *this);
+
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
symnum out of range. */
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
@@ -772,6 +774,11 @@ static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *
return -ERANGE;
}
+static inline int module_add_named_dependency(const char *name, struct module *this)
+{
+ return 0;
+}
+
static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
char *type, char *name,
char *module_name, int *exported)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 05a42d8fcd7a..dbd577ccc38c 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -631,6 +631,37 @@ static int ref_module(struct module *a, struct module *b)
return 0;
}
+int module_add_named_dependency(const char *name, struct module *this)
+{
+ struct module *mod;
+ int ret;
+
+ if (!name || !this || !this->name) {
+ return -EINVAL;
+ }
+
+ mutex_lock(&module_mutex);
+ mod = find_module(name);
+ if (!mod) {
+ ret = -EINVAL;
+ goto ret;
+ }
+
+ ret = ref_module(this, mod);
+ if (ret)
+ goto ret;
+
+#ifdef CONFIG_MODULE_UNLOAD
+ ret = sysfs_create_link(mod->holders_dir,
+ &this->mkobj.kobj, this->name);
+#endif
+
+ret:
+ mutex_unlock(&module_mutex);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(module_add_named_dependency);
+
/* Clear the unload stuff of the module. */
static void module_unload_free(struct module *mod)
{
--
2.35.1
next prev parent reply other threads:[~2022-04-29 6:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 6:31 [Intel-gfx] [PATCH 0/2] Let userspace know when snd-hda-intel needs i915 Mauro Carvalho Chehab
2022-04-29 6:31 ` Mauro Carvalho Chehab [this message]
2022-04-29 7:54 ` [Intel-gfx] [PATCH 1/2] module: add a function to add module references Daniel Vetter
2022-04-29 8:07 ` Mauro Carvalho Chehab
2022-04-29 8:30 ` Greg KH
2022-04-29 9:15 ` Mauro Carvalho Chehab
2022-04-29 10:10 ` Greg KH
2022-04-29 10:23 ` Mauro Carvalho Chehab
2022-04-29 10:36 ` Greg KH
2022-05-04 8:49 ` Daniel Vetter
2022-04-29 15:52 ` Lucas De Marchi
2022-04-29 6:31 ` [Intel-gfx] [PATCH 2/2] ALSA: hda - identify when audio is provided by a video driver Mauro Carvalho Chehab
2022-04-29 6:56 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Let userspace know when snd-hda-intel needs i915 Patchwork
2022-04-29 6:56 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-04-29 7:19 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-04-29 8:40 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
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=a078eb2e46d00ec59c8a91ea0afa5190730c9e58.1651212016.git.mchehab@kernel.org \
--to=mchehab@kernel.org \
--cc=airlied@linux.ie \
--cc=dan.j.williams@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kai.vehmanen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=mauro.chehab@intel.com \
--cc=mcgrof@kernel.org \
--cc=pierre-louis.bossart@intel.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