Commit cad1e55d authored by Laura Garcia's avatar Laura Garcia Committed by Greg Kroah-Hartman

[PATCH] firmware_class: s/semaphores/mutexes

Hi, this patch converts semaphores to mutexes for Randy's firmware_class.
Signed-off-by: default avatarLaura Garcia Liebana <nevola@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fd869db6
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include "base.h" #include "base.h"
...@@ -36,7 +36,7 @@ static int loading_timeout = 10; /* In seconds */ ...@@ -36,7 +36,7 @@ static int loading_timeout = 10; /* In seconds */
/* fw_lock could be moved to 'struct firmware_priv' but since it is just /* fw_lock could be moved to 'struct firmware_priv' but since it is just
* guarding for corner cases a global lock should be OK */ * guarding for corner cases a global lock should be OK */
static DECLARE_MUTEX(fw_lock); static DEFINE_MUTEX(fw_lock);
struct firmware_priv { struct firmware_priv {
char fw_id[FIRMWARE_NAME_MAX]; char fw_id[FIRMWARE_NAME_MAX];
...@@ -142,9 +142,9 @@ firmware_loading_store(struct class_device *class_dev, ...@@ -142,9 +142,9 @@ firmware_loading_store(struct class_device *class_dev,
switch (loading) { switch (loading) {
case 1: case 1:
down(&fw_lock); mutex_lock(&fw_lock);
if (!fw_priv->fw) { if (!fw_priv->fw) {
up(&fw_lock); mutex_unlock(&fw_lock);
break; break;
} }
vfree(fw_priv->fw->data); vfree(fw_priv->fw->data);
...@@ -152,7 +152,7 @@ firmware_loading_store(struct class_device *class_dev, ...@@ -152,7 +152,7 @@ firmware_loading_store(struct class_device *class_dev,
fw_priv->fw->size = 0; fw_priv->fw->size = 0;
fw_priv->alloc_size = 0; fw_priv->alloc_size = 0;
set_bit(FW_STATUS_LOADING, &fw_priv->status); set_bit(FW_STATUS_LOADING, &fw_priv->status);
up(&fw_lock); mutex_unlock(&fw_lock);
break; break;
case 0: case 0:
if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) {
...@@ -185,7 +185,7 @@ firmware_data_read(struct kobject *kobj, ...@@ -185,7 +185,7 @@ firmware_data_read(struct kobject *kobj,
struct firmware *fw; struct firmware *fw;
ssize_t ret_count = count; ssize_t ret_count = count;
down(&fw_lock); mutex_lock(&fw_lock);
fw = fw_priv->fw; fw = fw_priv->fw;
if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) { if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) {
ret_count = -ENODEV; ret_count = -ENODEV;
...@@ -200,7 +200,7 @@ firmware_data_read(struct kobject *kobj, ...@@ -200,7 +200,7 @@ firmware_data_read(struct kobject *kobj,
memcpy(buffer, fw->data + offset, ret_count); memcpy(buffer, fw->data + offset, ret_count);
out: out:
up(&fw_lock); mutex_unlock(&fw_lock);
return ret_count; return ret_count;
} }
...@@ -253,7 +253,7 @@ firmware_data_write(struct kobject *kobj, ...@@ -253,7 +253,7 @@ firmware_data_write(struct kobject *kobj,
if (!capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_RAWIO))
return -EPERM; return -EPERM;
down(&fw_lock); mutex_lock(&fw_lock);
fw = fw_priv->fw; fw = fw_priv->fw;
if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) { if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) {
retval = -ENODEV; retval = -ENODEV;
...@@ -268,7 +268,7 @@ firmware_data_write(struct kobject *kobj, ...@@ -268,7 +268,7 @@ firmware_data_write(struct kobject *kobj,
fw->size = max_t(size_t, offset + count, fw->size); fw->size = max_t(size_t, offset + count, fw->size);
retval = count; retval = count;
out: out:
up(&fw_lock); mutex_unlock(&fw_lock);
return retval; return retval;
} }
...@@ -436,14 +436,14 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ...@@ -436,14 +436,14 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
} else } else
wait_for_completion(&fw_priv->completion); wait_for_completion(&fw_priv->completion);
down(&fw_lock); mutex_lock(&fw_lock);
if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) { if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) {
retval = -ENOENT; retval = -ENOENT;
release_firmware(fw_priv->fw); release_firmware(fw_priv->fw);
*firmware_p = NULL; *firmware_p = NULL;
} }
fw_priv->fw = NULL; fw_priv->fw = NULL;
up(&fw_lock); mutex_unlock(&fw_lock);
class_device_unregister(class_dev); class_device_unregister(class_dev);
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment