Skip to content

Commit

Permalink
sem2mutex: drivers/char/drm/
Browse files Browse the repository at this point in the history
From: Arjan van de Ven <arjan@infradead.org>

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dave Airlie <airlied@linux.ie>
  • Loading branch information
Dave Airlie authored and Dave Airlie committed Feb 2, 2006
1 parent ce60fe0 commit 30e2fb1
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 125 deletions.
5 changes: 3 additions & 2 deletions drivers/char/drm/drmP.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <linux/mm.h>
#include <linux/cdev.h>
#include <linux/mutex.h>
#if defined(__alpha__) || defined(__powerpc__)
#include <asm/pgtable.h> /* For pte_wrprotect */
#endif
Expand Down Expand Up @@ -623,7 +624,7 @@ typedef struct drm_device {
/** \name Locks */
/*@{ */
spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
struct semaphore struct_sem; /**< For others */
struct mutex struct_mutex; /**< For others */
/*@} */

/** \name Usage Counters */
Expand Down Expand Up @@ -658,7 +659,7 @@ typedef struct drm_device {
/*@{ */
drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
int ctx_count; /**< Number of context handles */
struct semaphore ctxlist_sem; /**< For ctxlist */
struct mutex ctxlist_mutex; /**< For ctxlist */

drm_map_t **context_sareas; /**< per-context SAREA's */
int max_context;
Expand Down
20 changes: 10 additions & 10 deletions drivers/char/drm/drm_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int drm_hash_magic(drm_magic_t magic)
* \param magic magic number.
*
* Searches in drm_device::magiclist within all files with the same hash key
* the one with matching magic number, while holding the drm_device::struct_sem
* the one with matching magic number, while holding the drm_device::struct_mutex
* lock.
*/
static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
Expand All @@ -65,14 +65,14 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
drm_magic_entry_t *pt;
int hash = drm_hash_magic(magic);

down(&dev->struct_sem);
mutex_lock(&dev->struct_mutex);
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
if (pt->magic == magic) {
retval = pt->priv;
break;
}
}
up(&dev->struct_sem);
mutex_unlock(&dev->struct_mutex);
return retval;
}

Expand All @@ -85,7 +85,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
*
* Creates a drm_magic_entry structure and appends to the linked list
* associated the magic number hash key in drm_device::magiclist, while holding
* the drm_device::struct_sem lock.
* the drm_device::struct_mutex lock.
*/
static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
drm_magic_t magic)
Expand All @@ -104,15 +104,15 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
entry->priv = priv;
entry->next = NULL;

down(&dev->struct_sem);
mutex_lock(&dev->struct_mutex);
if (dev->magiclist[hash].tail) {
dev->magiclist[hash].tail->next = entry;
dev->magiclist[hash].tail = entry;
} else {
dev->magiclist[hash].head = entry;
dev->magiclist[hash].tail = entry;
}
up(&dev->struct_sem);
mutex_unlock(&dev->struct_mutex);

return 0;
}
Expand All @@ -124,7 +124,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
* \param magic magic number.
*
* Searches and unlinks the entry in drm_device::magiclist with the magic
* number hash key, while holding the drm_device::struct_sem lock.
* number hash key, while holding the drm_device::struct_mutex lock.
*/
static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
{
Expand All @@ -135,7 +135,7 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
DRM_DEBUG("%d\n", magic);
hash = drm_hash_magic(magic);

down(&dev->struct_sem);
mutex_lock(&dev->struct_mutex);
for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
if (pt->magic == magic) {
if (dev->magiclist[hash].head == pt) {
Expand All @@ -147,11 +147,11 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
if (prev) {
prev->next = pt->next;
}
up(&dev->struct_sem);
mutex_unlock(&dev->struct_mutex);
return 0;
}
}
up(&dev->struct_sem);
mutex_unlock(&dev->struct_mutex);

drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);

Expand Down
Loading

0 comments on commit 30e2fb1

Please sign in to comment.