From d1f1052c520452494db548b1a701cd9020b5903e Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 25 Dec 2014 15:07:04 -0800 Subject: device: Change dev_ logging functions to return void No caller or macro uses the return value so make all the functions return void. Compiled x86 allyesconfig and defconfig w/o CONFIG_PRINTK Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/base/core.c b/drivers/base/core.c index 97e2baf6e5d8..07304a3b9ee2 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2080,54 +2080,47 @@ int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL(dev_printk_emit); -static int __dev_printk(const char *level, const struct device *dev, +static void __dev_printk(const char *level, const struct device *dev, struct va_format *vaf) { - if (!dev) - return printk("%s(NULL device *): %pV", level, vaf); - - return dev_printk_emit(level[1] - '0', dev, - "%s %s: %pV", - dev_driver_string(dev), dev_name(dev), vaf); + if (dev) + dev_printk_emit(level[1] - '0', dev, "%s %s: %pV", + dev_driver_string(dev), dev_name(dev), vaf); + else + printk("%s(NULL device *): %pV", level, vaf); } -int dev_printk(const char *level, const struct device *dev, - const char *fmt, ...) +void dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) { struct va_format vaf; va_list args; - int r; va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; - r = __dev_printk(level, dev, &vaf); + __dev_printk(level, dev, &vaf); va_end(args); - - return r; } EXPORT_SYMBOL(dev_printk); #define define_dev_printk_level(func, kern_level) \ -int func(const struct device *dev, const char *fmt, ...) \ +void func(const struct device *dev, const char *fmt, ...) \ { \ struct va_format vaf; \ va_list args; \ - int r; \ \ va_start(args, fmt); \ \ vaf.fmt = fmt; \ vaf.va = &args; \ \ - r = __dev_printk(kern_level, dev, &vaf); \ + __dev_printk(kern_level, dev, &vaf); \ \ va_end(args); \ - \ - return r; \ } \ EXPORT_SYMBOL(func); -- cgit v1.2.3-70-g09d2 From 3c1556b287b89686fc7b4a210b82174938bb8a02 Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Wed, 3 Dec 2014 22:46:37 +0100 Subject: firmware: Correct function name in comment Use the correct function name in the kernel-doc comment above it. Signed-off-by: Borislav Petkov Acked-by: Ming Lei Signed-off-by: Greg Kroah-Hartman --- drivers/base/firmware_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 58470c395301..96d994a35372 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -1194,7 +1194,7 @@ request_firmware(const struct firmware **firmware_p, const char *name, EXPORT_SYMBOL(request_firmware); /** - * request_firmware: - load firmware directly without usermode helper + * request_firmware_direct: - load firmware directly without usermode helper * @firmware_p: pointer to firmware image * @name: name of firmware file * @device: device for which firmware is being loaded -- cgit v1.2.3-70-g09d2 From 0cb64249ca50033ec22e63582837f94202c63d9f Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Tue, 13 Jan 2015 00:01:35 +0800 Subject: firmware_loader: abort request if wait_for_completion is interrupted If current request is interrupted by signal, such as 'ctrl + c', this request has to be aborted for the following reasons: - the buf need to be removed from pending list - same requests from other contexts need to be completed Reported-by: Sasha Levin Signed-off-by: Ming Lei Signed-off-by: Greg Kroah-Hartman --- drivers/base/firmware_class.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 96d994a35372..5870ec35efe6 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -927,6 +927,13 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, retval = wait_for_completion_interruptible(&buf->completion); cancel_delayed_work_sync(&fw_priv->timeout_work); + + if (retval == -ERESTARTSYS) { + mutex_lock(&fw_lock); + fw_load_abort(fw_priv); + mutex_unlock(&fw_lock); + } + if (is_fw_load_aborted(buf)) retval = -EAGAIN; else if (!buf->data) -- cgit v1.2.3-70-g09d2 From 68ff2a00dbf590dc9483c20f85fd1f1faa054604 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Tue, 13 Jan 2015 00:02:01 +0800 Subject: firmware_loader: handle timeout via wait_for_completion_interruptible_timeout() It is simpler to handle timeout by wait_for_completion_interruptible_timeout(), so remove previous delay work for timeout. Signed-off-by: Ming Lei Signed-off-by: Greg Kroah-Hartman --- drivers/base/firmware_class.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 5870ec35efe6..60ac9c3f7f48 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -94,7 +94,7 @@ static int loading_timeout = 60; /* In seconds */ static inline long firmware_loading_timeout(void) { - return loading_timeout > 0 ? loading_timeout * HZ : MAX_SCHEDULE_TIMEOUT; + return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET; } /* firmware behavior options */ @@ -446,7 +446,6 @@ static int fw_add_devm_name(struct device *dev, const char *name) */ #ifdef CONFIG_FW_LOADER_USER_HELPER struct firmware_priv { - struct delayed_work timeout_work; bool nowait; struct device dev; struct firmware_buf *buf; @@ -836,16 +835,6 @@ static struct bin_attribute firmware_attr_data = { .write = firmware_data_write, }; -static void firmware_class_timeout_work(struct work_struct *work) -{ - struct firmware_priv *fw_priv = container_of(work, - struct firmware_priv, timeout_work.work); - - mutex_lock(&fw_lock); - fw_load_abort(fw_priv); - mutex_unlock(&fw_lock); -} - static struct firmware_priv * fw_create_instance(struct firmware *firmware, const char *fw_name, struct device *device, unsigned int opt_flags) @@ -862,9 +851,6 @@ fw_create_instance(struct firmware *firmware, const char *fw_name, fw_priv->nowait = !!(opt_flags & FW_OPT_NOWAIT); fw_priv->fw = firmware; - INIT_DELAYED_WORK(&fw_priv->timeout_work, - firmware_class_timeout_work); - f_dev = &fw_priv->dev; device_initialize(f_dev); @@ -917,18 +903,14 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, buf->need_uevent = true; dev_set_uevent_suppress(f_dev, false); dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id); - if (timeout != MAX_SCHEDULE_TIMEOUT) - queue_delayed_work(system_power_efficient_wq, - &fw_priv->timeout_work, timeout); - kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); + } else { + timeout = MAX_JIFFY_OFFSET; } - retval = wait_for_completion_interruptible(&buf->completion); - - cancel_delayed_work_sync(&fw_priv->timeout_work); - - if (retval == -ERESTARTSYS) { + retval = wait_for_completion_interruptible_timeout(&buf->completion, + timeout); + if (retval == -ERESTARTSYS || !retval) { mutex_lock(&fw_lock); fw_load_abort(fw_priv); mutex_unlock(&fw_lock); -- cgit v1.2.3-70-g09d2