summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@kernel.org>2017-01-23 08:11:10 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-25 11:52:34 +0100
commit061132d2b9c9504a9f314dcd73f6483a7d8cd1e8 (patch)
tree0fe6e0c7820ae1d7619c0a8dc1e3fb6ff53c5a6d /lib
parenteb67bc3ffd1796e198fc923da2ba15beb7965529 (diff)
downloadop-kernel-dev-061132d2b9c9504a9f314dcd73f6483a7d8cd1e8.zip
op-kernel-dev-061132d2b9c9504a9f314dcd73f6483a7d8cd1e8.tar.gz
test_firmware: add test custom fallback trigger
We have no custom fallback mechanism test interface. Provide one. This tests both the custom fallback mechanism and cancelling the it. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/test_firmware.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index 38cc188..09371b0 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -126,11 +126,56 @@ out:
}
static DEVICE_ATTR_WO(trigger_async_request);
+static ssize_t trigger_custom_fallback_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int rc;
+ char *name;
+
+ name = kstrndup(buf, count, GFP_KERNEL);
+ if (!name)
+ return -ENOSPC;
+
+ pr_info("loading '%s' using custom fallback mechanism\n", name);
+
+ mutex_lock(&test_fw_mutex);
+ release_firmware(test_firmware);
+ test_firmware = NULL;
+ rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG, name,
+ dev, GFP_KERNEL, NULL,
+ trigger_async_request_cb);
+ if (rc) {
+ pr_info("async load of '%s' failed: %d\n", name, rc);
+ kfree(name);
+ goto out;
+ }
+ /* Free 'name' ASAP, to test for race conditions */
+ kfree(name);
+
+ wait_for_completion(&async_fw_done);
+
+ if (test_firmware) {
+ pr_info("loaded: %zu\n", test_firmware->size);
+ rc = count;
+ } else {
+ pr_err("failed to async load firmware\n");
+ rc = -ENODEV;
+ }
+
+out:
+ mutex_unlock(&test_fw_mutex);
+
+ return rc;
+}
+static DEVICE_ATTR_WO(trigger_custom_fallback);
+
#define TEST_FW_DEV_ATTR(name) &dev_attr_##name.attr
static struct attribute *test_dev_attrs[] = {
TEST_FW_DEV_ATTR(trigger_request),
TEST_FW_DEV_ATTR(trigger_async_request),
+ TEST_FW_DEV_ATTR(trigger_custom_fallback),
NULL,
};
OpenPOWER on IntegriCloud