[PATCH i-g-t 07/10] lib/igt_kmod: Add rebind abstraction
Lucas De Marchi
lucas.demarchi at intel.com
Thu Apr 17 03:38:20 UTC 2025
On Tue, Apr 15, 2025 at 11:19:48AM +0530, Riana Tauro wrote:
>Hi Lucas
>
>On 4/11/2025 4:18 AM, 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)
>Why not have a void function? Not using the return value anywhere
>Also unbind always returns 0 and asserts for errors
as a lib, we should rather return int and let the caller know when to
assert, which belongs to the test. Migrating the assert to the caller is
left for later.
Lucas De Marchi
>
>Thanks
>Riana> +{
>>+ return igt_kmod_unbind(mod_name, pci_device) ||
>>+ igt_kmod_bind(mod_name, pci_device);
>>+}
>>+
>> /**
>> * 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);
>>
>
More information about the igt-dev
mailing list