diff options
author | Luis R. Rodriguez <mcgrof@kernel.org> | 2017-01-23 11:11:10 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-25 05:52:34 -0500 |
commit | 061132d2b9c9504a9f314dcd73f6483a7d8cd1e8 (patch) | |
tree | 0fe6e0c7820ae1d7619c0a8dc1e3fb6ff53c5a6d /lib/test_firmware.c | |
parent | eb67bc3ffd1796e198fc923da2ba15beb7965529 (diff) |
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/test_firmware.c')
-rw-r--r-- | lib/test_firmware.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/test_firmware.c b/lib/test_firmware.c index 38cc188c4d3c..09371b0a9baf 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c | |||
@@ -126,11 +126,56 @@ out: | |||
126 | } | 126 | } |
127 | static DEVICE_ATTR_WO(trigger_async_request); | 127 | static DEVICE_ATTR_WO(trigger_async_request); |
128 | 128 | ||
129 | static ssize_t trigger_custom_fallback_store(struct device *dev, | ||
130 | struct device_attribute *attr, | ||
131 | const char *buf, size_t count) | ||
132 | { | ||
133 | int rc; | ||
134 | char *name; | ||
135 | |||
136 | name = kstrndup(buf, count, GFP_KERNEL); | ||
137 | if (!name) | ||
138 | return -ENOSPC; | ||
139 | |||
140 | pr_info("loading '%s' using custom fallback mechanism\n", name); | ||
141 | |||
142 | mutex_lock(&test_fw_mutex); | ||
143 | release_firmware(test_firmware); | ||
144 | test_firmware = NULL; | ||
145 | rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG, name, | ||
146 | dev, GFP_KERNEL, NULL, | ||
147 | trigger_async_request_cb); | ||
148 | if (rc) { | ||
149 | pr_info("async load of '%s' failed: %d\n", name, rc); | ||
150 | kfree(name); | ||
151 | goto out; | ||
152 | } | ||
153 | /* Free 'name' ASAP, to test for race conditions */ | ||
154 | kfree(name); | ||
155 | |||
156 | wait_for_completion(&async_fw_done); | ||
157 | |||
158 | if (test_firmware) { | ||
159 | pr_info("loaded: %zu\n", test_firmware->size); | ||
160 | rc = count; | ||
161 | } else { | ||
162 | pr_err("failed to async load firmware\n"); | ||
163 | rc = -ENODEV; | ||
164 | } | ||
165 | |||
166 | out: | ||
167 | mutex_unlock(&test_fw_mutex); | ||
168 | |||
169 | return rc; | ||
170 | } | ||
171 | static DEVICE_ATTR_WO(trigger_custom_fallback); | ||
172 | |||
129 | #define TEST_FW_DEV_ATTR(name) &dev_attr_##name.attr | 173 | #define TEST_FW_DEV_ATTR(name) &dev_attr_##name.attr |
130 | 174 | ||
131 | static struct attribute *test_dev_attrs[] = { | 175 | static struct attribute *test_dev_attrs[] = { |
132 | TEST_FW_DEV_ATTR(trigger_request), | 176 | TEST_FW_DEV_ATTR(trigger_request), |
133 | TEST_FW_DEV_ATTR(trigger_async_request), | 177 | TEST_FW_DEV_ATTR(trigger_async_request), |
178 | TEST_FW_DEV_ATTR(trigger_custom_fallback), | ||
134 | NULL, | 179 | NULL, |
135 | }; | 180 | }; |
136 | 181 | ||