[PATCH i-g-t 04/10] lib/igt_kmod: Use igt_kmod_unbind() to kick snd_hda_intel
Kamil Konieczny
kamil.konieczny at linux.intel.com
Mon Apr 14 18:04:22 UTC 2025
Hi Lucas,
On 2025-04-10 at 15:48:33 -0700, Lucas De Marchi wrote:
> No need for the extra function now that the generic igt_kmod_unbind()
> can be used.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
LGTM
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
> lib/igt_kmod.c | 56 +++-----------------------------------------------------
> 1 file changed, 3 insertions(+), 53 deletions(-)
>
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index a1e39a429..3f5f93f37 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -495,58 +495,6 @@ 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 can 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;
> @@ -579,7 +527,9 @@ static int igt_always_unload_audio_driver(char **who)
> ret = pipewire_pulse_start_reserve();
> if (ret)
> igt_warn("Failed to notify pipewire_pulse\n");
> - kick_snd_hda_intel();
> +
> + igt_kmod_unbind("snd_hda_intel", NULL);
> +
> ret = igt_kmod_unload(*m);
> pipewire_pulse_stop_reserve();
> if (ret) {
>
> --
> 2.49.0
>
More information about the igt-dev
mailing list