[igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
Mauro Carvalho Chehab
mauro.chehab at linux.intel.com
Wed Oct 25 09:18:41 UTC 2023
From: Mauro Carvalho Chehab <mchehab at kernel.org>
This unbind function is now used only inside igt_kmod, and
should be called only via igt_always_unload_audio_driver(),
which does other required steps to unbind the audio driver.
So, move it to igt_kmod and make it static.
Suggested-by: Andrzej Hajda <andrzej.hajda at intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
lib/igt_kmod.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_sysfs.c | 52 -------------------------------------------------
lib/igt_sysfs.h | 1 -
3 files changed, 52 insertions(+), 53 deletions(-)
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 4785d724aec8..55a9de4d725c 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -437,6 +437,58 @@ igt_intel_driver_load(const char *opts, const char *driver)
return 0;
}
+/**
+ * kick_snd_hda_intel:
+ *
+ * This function unbinds the snd_hda_intel driver so the module cand be
+ * unloaded.
+ *
+ */
+static void kick_snd_hda_intel(void)
+{
+ DIR *dir;
+ struct dirent *snd_hda;
+ int fd; size_t len;
+
+ const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
+ const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
+ const char *devid = "0000:";
+
+ fd = open(path, O_WRONLY);
+ if (fd < 0) {
+ return;
+ }
+
+ dir = opendir(dpath);
+ if (!dir)
+ goto out;
+
+ len = strlen(devid);
+ while ((snd_hda = readdir(dir))) {
+ struct stat st;
+ char fpath[PATH_MAX];
+
+ if (*snd_hda->d_name == '.')
+ continue;
+
+ snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
+ if (lstat(fpath, &st))
+ continue;
+
+ if (!S_ISLNK(st.st_mode))
+ continue;
+
+ if (!strncmp(devid, snd_hda->d_name, len)) {
+ igt_ignore_warn(write(fd, snd_hda->d_name,
+ strlen(snd_hda->d_name)));
+ }
+ }
+
+ closedir(dir);
+out:
+ close(fd);
+}
+
static int igt_always_unload_audio_driver(char **who)
{
int ret;
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 83182020b498..567b4f6d5f03 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -856,58 +856,6 @@ void bind_fbcon(bool enable)
bind_con("frame buffer device", enable);
}
-/**
- * kick_snd_hda_intel:
- *
- * This functions unbinds the snd_hda_intel driver so the module cand be
- * unloaded.
- *
- */
-void kick_snd_hda_intel(void)
-{
- DIR *dir;
- struct dirent *snd_hda;
- int fd; size_t len;
-
- const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
- const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
- const char *devid = "0000:";
-
- fd = open(path, O_WRONLY);
- if (fd < 0) {
- return;
- }
-
- dir = opendir(dpath);
- if (!dir)
- goto out;
-
- len = strlen(devid);
- while ((snd_hda = readdir(dir))) {
- struct stat st;
- char fpath[PATH_MAX];
-
- if (*snd_hda->d_name == '.')
- continue;
-
- snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
- if (lstat(fpath, &st))
- continue;
-
- if (!S_ISLNK(st.st_mode))
- continue;
-
- if (!strncmp(devid, snd_hda->d_name, len)) {
- igt_ignore_warn(write(fd, snd_hda->d_name,
- strlen(snd_hda->d_name)));
- }
- }
-
- closedir(dir);
-out:
- close(fd);
-}
-
static int fbcon_cursor_blink_fd = -1;
static char fbcon_cursor_blink_prev_value[2];
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 0087c03b706a..e804cf8e109d 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -135,7 +135,6 @@ bool __igt_sysfs_set_boolean(int dir, const char *attr, bool value);
void igt_sysfs_set_boolean(int dir, const char *attr, bool value);
void bind_fbcon(bool enable);
-void kick_snd_hda_intel(void);
void fbcon_blink_enable(bool enable);
/**
--
2.41.0
More information about the igt-dev
mailing list