diff options
author | Ming Lei <ming.lei@canonical.com> | 2012-11-03 05:47:58 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-14 18:07:18 -0500 |
commit | 27602842060484b564cd725241b402b0bddfb830 (patch) | |
tree | 62bc5aa301675cde89a7543d169b38e62df1bcd3 /drivers/base/firmware_class.c | |
parent | 60dac5e284fe99751e3beefe1a9cc7a0771ad73c (diff) |
firmware loader: introduce module parameter to customize(v4) fw search path
This patch introduces one module parameter of 'path' in firmware_class
to support customizing firmware image search path, so that people can
use its own firmware path if the default built-in paths can't meet their
demand[1], and the typical usage is passing the below from kernel command
parameter when 'firmware_class' is built in kernel:
firmware_class.path=$CUSTOMIZED_PATH
[1], https://lkml.org/lkml/2012/10/11/337
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/firmware_class.c')
-rw-r--r-- | drivers/base/firmware_class.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 4b04ec4bd2f0..7888af7941a0 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -269,13 +269,23 @@ static void fw_free_buf(struct firmware_buf *buf) | |||
269 | } | 269 | } |
270 | 270 | ||
271 | /* direct firmware loading support */ | 271 | /* direct firmware loading support */ |
272 | static const char *fw_path[] = { | 272 | static char fw_path_para[256]; |
273 | static const char * const fw_path[] = { | ||
274 | fw_path_para, | ||
273 | "/lib/firmware/updates/" UTS_RELEASE, | 275 | "/lib/firmware/updates/" UTS_RELEASE, |
274 | "/lib/firmware/updates", | 276 | "/lib/firmware/updates", |
275 | "/lib/firmware/" UTS_RELEASE, | 277 | "/lib/firmware/" UTS_RELEASE, |
276 | "/lib/firmware" | 278 | "/lib/firmware" |
277 | }; | 279 | }; |
278 | 280 | ||
281 | /* | ||
282 | * Typical usage is that passing 'firmware_class.path=$CUSTOMIZED_PATH' | ||
283 | * from kernel command line because firmware_class is generally built in | ||
284 | * kernel instead of module. | ||
285 | */ | ||
286 | module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); | ||
287 | MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); | ||
288 | |||
279 | /* Don't inline this: 'struct kstat' is biggish */ | 289 | /* Don't inline this: 'struct kstat' is biggish */ |
280 | static noinline_for_stack long fw_file_size(struct file *file) | 290 | static noinline_for_stack long fw_file_size(struct file *file) |
281 | { | 291 | { |
@@ -317,6 +327,11 @@ static bool fw_get_filesystem_firmware(struct firmware_buf *buf) | |||
317 | 327 | ||
318 | for (i = 0; i < ARRAY_SIZE(fw_path); i++) { | 328 | for (i = 0; i < ARRAY_SIZE(fw_path); i++) { |
319 | struct file *file; | 329 | struct file *file; |
330 | |||
331 | /* skip the unset customized path */ | ||
332 | if (!fw_path[i][0]) | ||
333 | continue; | ||
334 | |||
320 | snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id); | 335 | snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id); |
321 | 336 | ||
322 | file = filp_open(path, O_RDONLY, 0); | 337 | file = filp_open(path, O_RDONLY, 0); |