[PATCH i-g-t 07/10] lib/igt_kmod: Add rebind abstraction

Kamil Konieczny kamil.konieczny at linux.intel.com
Mon Apr 14 18:07:22 UTC 2025


Hi Lucas,
On 2025-04-10 at 15:48:36 -0700, Lucas De Marchi wrote:
> Abstract the "set one file in the drivers dir" and share the
> implementation with unbind/rebind.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
>  lib/igt_kmod.c | 11 +++++++++++
>  lib/igt_kmod.h |  2 ++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index 14b6b957a..6d7f5705c 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -665,6 +665,17 @@ int igt_kmod_bind(const char *mod_name, const char *pci_device)
>  	return ret;
>  }
>  
> +/**
> + * igt_kmod_rebind: Unbind driver from devices and bind it again
> + * @mod_name: name of the module to rebind
> + * @pci_device: device to rebind to
> + */
> +int igt_kmod_rebind(const char *mod_name, const char *pci_device)
> +{
> +	return igt_kmod_unbind(mod_name, pci_device) ||
> +		igt_kmod_bind(mod_name, pci_device);

What if after unbind the bind is still there?

Regards,
Kamil

> +}
> +
>  /**
>   * igt_intel_driver_unload:
>   *
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index e3a4ce671..905070897 100644
> --- a/lib/igt_kmod.h
> +++ b/lib/igt_kmod.h
> @@ -39,6 +39,8 @@ int igt_kmod_unload(const char *mod_name);
>  int igt_kmod_unbind(const char *mod_name, const char *pci_device);
>  __attribute__((nonnull)) int igt_kmod_bind(const char *mod_name,
>  					   const char *pci_device);
> +__attribute__((nonnull)) int igt_kmod_rebind(const char *mod_name,
> +					     const char *pci_device);
>  
>  int igt_audio_driver_unload(char **whom);
>  
> 
> -- 
> 2.49.0
> 


More information about the igt-dev mailing list