[PATCH i-g-t 03/10] lib/igt_kmod: Simplify igt_kmod_unbind()
Francois Dugast
francois.dugast at intel.com
Mon Apr 14 10:59:05 UTC 2025
On Thu, Apr 10, 2025 at 03:48:32PM -0700, Lucas De Marchi wrote:
> There's no need to open the symlink and go to the driver/ dir. That will
> only brings us back to the same directory we are on.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
Reviewed-by: Francois Dugast <francois.dugast at intel.com>
> ---
> lib/igt_kmod.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index ecc74e0fe..a1e39a429 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -672,7 +672,6 @@ int igt_kmod_unbind(const char *mod_name, const char *pci_device)
> return 0;
>
> while ((de = readdir(dir))) {
> - int devfd;
> bool ret;
>
> if (de->d_type != DT_LNK || !isdigit(de->d_name[0]))
> @@ -681,13 +680,8 @@ int igt_kmod_unbind(const char *mod_name, const char *pci_device)
> if (pci_device && strcmp(pci_device, de->d_name) != 0)
> continue;
>
> - devfd = openat(dirfd(dir), de->d_name, O_RDONLY | O_CLOEXEC);
> - igt_assert(devfd >= 0);
> -
> - ret = igt_sysfs_set(devfd, "driver/unbind", de->d_name);
> + ret = igt_sysfs_set(dirfd(dir), "unbind", de->d_name);
> igt_assert(ret);
> -
> - close(devfd);
> }
>
> closedir(dir);
>
> --
> 2.49.0
>
More information about the igt-dev
mailing list