projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] uml: use LIST_HEAD where possible
[firefly-linux-kernel-4.4.55.git]
/
arch
/
um
/
drivers
/
mconsole_kern.c
diff --git
a/arch/um/drivers/mconsole_kern.c
b/arch/um/drivers/mconsole_kern.c
index 832d5c766ca88b717623a83b855882fcf646b0df..a5a683d6fc5cbe1c0e6b610910b48dc90728d105 100644
(file)
--- a/
arch/um/drivers/mconsole_kern.c
+++ b/
arch/um/drivers/mconsole_kern.c
@@
-337,13
+337,15
@@
void mconsole_stop(struct mc_request *req)
mconsole_reply(req, "", 0, 0);
}
mconsole_reply(req, "", 0, 0);
}
-/* This list is populated by __initcall routines. */
-
+static DEFINE_SPINLOCK(mc_devices_lock);
static LIST_HEAD(mconsole_devices);
void mconsole_register_dev(struct mc_device *new)
{
static LIST_HEAD(mconsole_devices);
void mconsole_register_dev(struct mc_device *new)
{
+ spin_lock(&mc_devices_lock);
+ BUG_ON(!list_empty(&new->list));
list_add(&new->list, &mconsole_devices);
list_add(&new->list, &mconsole_devices);
+ spin_unlock(&mc_devices_lock);
}
static struct mc_device *mconsole_find_dev(char *name)
}
static struct mc_device *mconsole_find_dev(char *name)
@@
-367,8
+369,9
@@
struct unplugged_pages {
void *pages[UNPLUGGED_PER_PAGE];
};
void *pages[UNPLUGGED_PER_PAGE];
};
+static DECLARE_MUTEX(plug_mem_mutex);
static unsigned long long unplugged_pages_count = 0;
static unsigned long long unplugged_pages_count = 0;
-static
struct list_head unplugged_pages = LIST_HEAD_INIT
(unplugged_pages);
+static
LIST_HEAD
(unplugged_pages);
static int unplug_index = UNPLUGGED_PER_PAGE;
static int mem_config(char *str, char **error_out)
static int unplug_index = UNPLUGGED_PER_PAGE;
static int mem_config(char *str, char **error_out)
@@
-402,6
+405,7
@@
static int mem_config(char *str, char **error_out)
diff /= PAGE_SIZE;
diff /= PAGE_SIZE;
+ down(&plug_mem_mutex);
for(i = 0; i < diff; i++){
struct unplugged_pages *unplugged;
void *addr;
for(i = 0; i < diff; i++){
struct unplugged_pages *unplugged;
void *addr;
@@
-447,7
+451,7
@@
static int mem_config(char *str, char **error_out)
printk("Failed to release memory - "
"errno = %d\n", err);
*error_out = "Failed to release memory";
printk("Failed to release memory - "
"errno = %d\n", err);
*error_out = "Failed to release memory";
- goto out;
+ goto out
_unlock
;
}
unplugged->pages[unplug_index++] = addr;
}
}
unplugged->pages[unplug_index++] = addr;
}
@@
-457,6
+461,8
@@
static int mem_config(char *str, char **error_out)
}
err = 0;
}
err = 0;
+out_unlock:
+ up(&plug_mem_mutex);
out:
return err;
}
out:
return err;
}
@@
-487,6
+493,7
@@
static int mem_remove(int n, char **error_out)
}
static struct mc_device mem_mc = {
}
static struct mc_device mem_mc = {
+ .list = LIST_HEAD_INIT(mem_mc.list),
.name = "mem",
.config = mem_config,
.get_config = mem_get_config,
.name = "mem",
.config = mem_config,
.get_config = mem_get_config,
@@
-629,7
+636,7
@@
struct mconsole_output {
struct mc_request *req;
};
struct mc_request *req;
};
-static DEFINE_SPINLOCK(c
onsole
_lock);
+static DEFINE_SPINLOCK(c
lient
_lock);
static LIST_HEAD(clients);
static char console_buf[MCONSOLE_MAX_DATA];
static int console_index = 0;
static LIST_HEAD(clients);
static char console_buf[MCONSOLE_MAX_DATA];
static int console_index = 0;
@@
-684,16
+691,18
@@
static void with_console(struct mc_request *req, void (*proc)(void *),
unsigned long flags;
entry.req = req;
unsigned long flags;
entry.req = req;
+ spin_lock_irqsave(&client_lock, flags);
list_add(&entry.list, &clients);
list_add(&entry.list, &clients);
- spin_
lock_irqsave(&console
_lock, flags);
+ spin_
unlock_irqrestore(&client
_lock, flags);
(*proc)(arg);
mconsole_reply_len(req, console_buf, console_index, 0, 0);
console_index = 0;
(*proc)(arg);
mconsole_reply_len(req, console_buf, console_index, 0, 0);
console_index = 0;
- spin_
unlock_irqrestore(&console
_lock, flags);
+ spin_
lock_irqsave(&client
_lock, flags);
list_del(&entry.list);
list_del(&entry.list);
+ spin_unlock_irqrestore(&client_lock, flags);
}
#ifdef CONFIG_MAGIC_SYSRQ
}
#ifdef CONFIG_MAGIC_SYSRQ