[PATCH v3 08/13] drm/xe/configfs: Use guard() for dev->lock
Bhadane, Dnyaneshwar
dnyaneshwar.bhadane at intel.com
Tue Aug 12 10:23:19 UTC 2025
> -----Original Message-----
> From: De Marchi, Lucas <lucas.demarchi at intel.com>
> Sent: Friday, August 8, 2025 11:00 PM
> To: intel-xe at lists.freedesktop.org
> Cc: De Marchi, Lucas <lucas.demarchi at intel.com>; Kumar, Prashanth
> <prashanth.kumar at intel.com>; Bhadane, Dnyaneshwar
> <dnyaneshwar.bhadane at intel.com>
> Subject: [PATCH v3 08/13] drm/xe/configfs: Use guard() for dev->lock
>
> Instead of the manual lock()/unlock() pattern, use guard() which will make
> things easier for handling errors or early returns.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
LGTM,
Reviewed-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane at intel.com>
> ---
> drivers/gpu/drm/xe/xe_configfs.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_configfs.c
> b/drivers/gpu/drm/xe/xe_configfs.c
> index 8cf6b1375b7d4..4c2d4ff6a70f5 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
> @@ -5,6 +5,7 @@
>
> #include <linux/bitops.h>
> #include <linux/configfs.h>
> +#include <linux/cleanup.h>
> #include <linux/find.h>
> #include <linux/init.h>
> #include <linux/module.h>
> @@ -164,9 +165,8 @@ static ssize_t survivability_mode_store(struct
> config_item *item, const char *pa
> if (ret)
> return ret;
>
> - mutex_lock(&dev->lock);
> + guard(mutex)(&dev->lock);
> dev->config.survivability_mode = survivability_mode;
> - mutex_unlock(&dev->lock);
>
> return len;
> }
> @@ -248,9 +248,8 @@ static ssize_t engines_allowed_store(struct
> config_item *item, const char *page,
> val |= mask;
> }
>
> - mutex_lock(&dev->lock);
> + guard(mutex)(&dev->lock);
> dev->config.engines_allowed = val;
> - mutex_unlock(&dev->lock);
>
> return len;
> }
> @@ -272,9 +271,8 @@ static ssize_t enable_psmi_store(struct config_item
> *item, const char *page, siz
> if (ret)
> return ret;
>
> - mutex_lock(&dev->lock);
> + guard(mutex)(&dev->lock);
> dev->config.enable_psmi = val;
> - mutex_unlock(&dev->lock);
>
> return len;
> }
> @@ -454,9 +452,8 @@ void xe_configfs_clear_survivability_mode(struct
> pci_dev *pdev)
> if (!dev)
> return;
>
> - mutex_lock(&dev->lock);
> + guard(mutex)(&dev->lock);
> dev->config.survivability_mode = 0;
> - mutex_unlock(&dev->lock);
>
> config_group_put(&dev->group);
> }
>
> --
> 2.50.1
More information about the Intel-xe
mailing list