On 18/12/2024 13:25, Markus Elfring wrote:
+++ b/drivers/gpu/drm/clients/drm_log.c
@@ -0,0 +1,370 @@
+static int drm_log_count_modeset(struct drm_client_dev *client)
+{
+       struct drm_mode_set *mode_set;
+       int count = 0;
+
+       mutex_lock(&client->modeset_mutex);
+       drm_client_for_each_modeset(mode_set, client)
+               count++;
+       mutex_unlock(&client->modeset_mutex);
+       return count;
+}

Under which circumstances would you become interested to apply a statement
like “guard(mutex)(&client->modeset_mutex);”?
https://elixir.bootlin.com/linux/v6.13-rc3/source/include/linux/mutex.h#L201

Ok, I didn't know about this new syntax, thanks for pointing this to me.
Regarding drm_log, I kept the mutex usage simple, as there is only one mutex_lock() and one mutex_unlock() in each function, which means there is not much benefit to use the guard syntax. I will keep that in mind, and if there is a need to have more complex mutex handling, I will probably use this.

Best regards,

--

Jocelyn

Regards,
Markus


Reply via email to