Commit 7068cb07 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge branch 'driver-core-linus' into driver-core-next

This resolves the merge issues with drivers/base/firmware_class.c

Thanks to Ming Lei for the patch and hints on how to resolve it.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parents bb07b00b 87597936
...@@ -452,13 +452,30 @@ static struct firmware_priv *to_firmware_priv(struct device *dev) ...@@ -452,13 +452,30 @@ static struct firmware_priv *to_firmware_priv(struct device *dev)
return container_of(dev, struct firmware_priv, dev); return container_of(dev, struct firmware_priv, dev);
} }
static void fw_load_abort(struct firmware_buf *buf) static void __fw_load_abort(struct firmware_buf *buf)
{ {
/*
* There is a small window in which user can write to 'loading'
* between loading done and disappearance of 'loading'
*/
if (test_bit(FW_STATUS_DONE, &buf->status))
return;
list_del_init(&buf->pending_list); list_del_init(&buf->pending_list);
set_bit(FW_STATUS_ABORT, &buf->status); set_bit(FW_STATUS_ABORT, &buf->status);
complete_all(&buf->completion); complete_all(&buf->completion);
} }
static void fw_load_abort(struct firmware_priv *fw_priv)
{
struct firmware_buf *buf = fw_priv->buf;
__fw_load_abort(buf);
/* avoid user action after loading abort */
fw_priv->buf = NULL;
}
#define is_fw_load_aborted(buf) \ #define is_fw_load_aborted(buf) \
test_bit(FW_STATUS_ABORT, &(buf)->status) test_bit(FW_STATUS_ABORT, &(buf)->status)
...@@ -470,7 +487,7 @@ static int fw_shutdown_notify(struct notifier_block *unused1, ...@@ -470,7 +487,7 @@ static int fw_shutdown_notify(struct notifier_block *unused1,
{ {
mutex_lock(&fw_lock); mutex_lock(&fw_lock);
while (!list_empty(&pending_fw_head)) while (!list_empty(&pending_fw_head))
fw_load_abort(list_first_entry(&pending_fw_head, __fw_load_abort(list_first_entry(&pending_fw_head,
struct firmware_buf, struct firmware_buf,
pending_list)); pending_list));
mutex_unlock(&fw_lock); mutex_unlock(&fw_lock);
...@@ -550,7 +567,12 @@ static ssize_t firmware_loading_show(struct device *dev, ...@@ -550,7 +567,12 @@ static ssize_t firmware_loading_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware_priv *fw_priv = to_firmware_priv(dev);
int loading = test_bit(FW_STATUS_LOADING, &fw_priv->buf->status); int loading = 0;
mutex_lock(&fw_lock);
if (fw_priv->buf)
loading = test_bit(FW_STATUS_LOADING, &fw_priv->buf->status);
mutex_unlock(&fw_lock);
return sprintf(buf, "%d\n", loading); return sprintf(buf, "%d\n", loading);
} }
...@@ -592,12 +614,12 @@ static ssize_t firmware_loading_store(struct device *dev, ...@@ -592,12 +614,12 @@ static ssize_t firmware_loading_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware_priv *fw_priv = to_firmware_priv(dev);
struct firmware_buf *fw_buf = fw_priv->buf; struct firmware_buf *fw_buf;
int loading = simple_strtol(buf, NULL, 10); int loading = simple_strtol(buf, NULL, 10);
int i; int i;
mutex_lock(&fw_lock); mutex_lock(&fw_lock);
fw_buf = fw_priv->buf;
if (!fw_buf) if (!fw_buf)
goto out; goto out;
...@@ -635,7 +657,7 @@ static ssize_t firmware_loading_store(struct device *dev, ...@@ -635,7 +657,7 @@ static ssize_t firmware_loading_store(struct device *dev,
dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading); dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
/* fallthrough */ /* fallthrough */
case -1: case -1:
fw_load_abort(fw_buf); fw_load_abort(fw_priv);
break; break;
} }
out: out:
...@@ -703,7 +725,7 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) ...@@ -703,7 +725,7 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
new_pages = kmalloc(new_array_size * sizeof(void *), new_pages = kmalloc(new_array_size * sizeof(void *),
GFP_KERNEL); GFP_KERNEL);
if (!new_pages) { if (!new_pages) {
fw_load_abort(buf); fw_load_abort(fw_priv);
return -ENOMEM; return -ENOMEM;
} }
memcpy(new_pages, buf->pages, memcpy(new_pages, buf->pages,
...@@ -720,7 +742,7 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) ...@@ -720,7 +742,7 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
alloc_page(GFP_KERNEL | __GFP_HIGHMEM); alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
if (!buf->pages[buf->nr_pages]) { if (!buf->pages[buf->nr_pages]) {
fw_load_abort(buf); fw_load_abort(fw_priv);
return -ENOMEM; return -ENOMEM;
} }
buf->nr_pages++; buf->nr_pages++;
...@@ -800,11 +822,7 @@ static void firmware_class_timeout_work(struct work_struct *work) ...@@ -800,11 +822,7 @@ static void firmware_class_timeout_work(struct work_struct *work)
struct firmware_priv, timeout_work.work); struct firmware_priv, timeout_work.work);
mutex_lock(&fw_lock); mutex_lock(&fw_lock);
if (test_bit(FW_STATUS_DONE, &(fw_priv->buf->status))) { fw_load_abort(fw_priv);
mutex_unlock(&fw_lock);
return;
}
fw_load_abort(fw_priv->buf);
mutex_unlock(&fw_lock); mutex_unlock(&fw_lock);
} }
...@@ -886,8 +904,6 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent, ...@@ -886,8 +904,6 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
cancel_delayed_work_sync(&fw_priv->timeout_work); cancel_delayed_work_sync(&fw_priv->timeout_work);
fw_priv->buf = NULL;
device_remove_file(f_dev, &dev_attr_loading); device_remove_file(f_dev, &dev_attr_loading);
err_del_bin_attr: err_del_bin_attr:
device_remove_bin_file(f_dev, &firmware_attr_data); device_remove_bin_file(f_dev, &firmware_attr_data);
...@@ -922,7 +938,7 @@ static void kill_requests_without_uevent(void) ...@@ -922,7 +938,7 @@ static void kill_requests_without_uevent(void)
mutex_lock(&fw_lock); mutex_lock(&fw_lock);
list_for_each_entry_safe(buf, next, &pending_fw_head, pending_list) { list_for_each_entry_safe(buf, next, &pending_fw_head, pending_list) {
if (!buf->need_uevent) if (!buf->need_uevent)
fw_load_abort(buf); __fw_load_abort(buf);
} }
mutex_unlock(&fw_lock); mutex_unlock(&fw_lock);
} }
......
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