lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
PATCH v2 1/1 lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
From: Mauro Carvalho Chehab <[email protected]>
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 <[email protected]>
Signed-off-by Mauro Carvalho Chehab <[email protected]>
---
v2: added some missing includes
--- lib/igt_kmod.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- lib/igt_sysfs.c | 52 -------------------------------------------- lib/igt_sysfs.h | 1 - 3 files changed, 56 insertions(+), 54 deletions(-)
lib/igt_kmod.c +56 -1
@@ -22,13 +22,16 @@*/ #include <ctype.h> -#include <signal.h> +#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> +#include <signal.h> #include <stdlib.h> #include <string.h> #include <sys/utsname.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include "assembler/brw_compat.h" /* [un]likely() */
@@ -437,6 +440,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;
lib/igt_sysfs.c +0 -52
58 lines not on this page · raw message
lib/igt_sysfs.h +0 -1
@@ -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);/**
Signature · 1 line
2.41.0