summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2008-07-14 15:49:04 -0700
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-14 15:51:11 -0700
commit751851af7aae9b8bd5a60b3897209081fbc18b2b (patch)
tree5cb8dbb71d691a760da61e319796800ee42cc1c5 /drivers/base
parenta41eebab7537890409ea9dfe0fcda9b5fbdb090d (diff)
parentd71792ac3d48df6693f7b339e02494efc27036c3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Conflicts: sound/pci/Kconfig
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/Kconfig64
-rw-r--r--drivers/base/firmware_class.c35
2 files changed, 96 insertions, 3 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index d7da109c24fd..d47482fa1d21 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -34,6 +34,70 @@ config FW_LOADER
require userspace firmware loading support, but a module built outside
the kernel tree does.
+config FIRMWARE_IN_KERNEL
+ bool "Include in-kernel firmware blobs in kernel binary"
+ depends on FW_LOADER
+ default y
+ help
+ The kernel source tree includes a number of firmware 'blobs'
+ which are used by various drivers. The recommended way to
+ use these is to run "make firmware_install" and to copy the
+ resulting binary files created in usr/lib/firmware directory
+ of the kernel tree to the /lib/firmware on your system so
+ that they can be loaded by userspace helpers on request.
+
+ Enabling this option will build each required firmware blob
+ into the kernel directly, where request_firmware() will find
+ them without having to call out to userspace. This may be
+ useful if your root file system requires a device which uses
+ such firmware, and do not wish to use an initrd.
+
+ This single option controls the inclusion of firmware for
+ every driver which usees request_firmare() and ships its
+ firmware in the kernel source tree, to avoid a proliferation
+ of 'Include firmware for xxx device' options.
+
+ Say 'N' and let firmware be loaded from userspace.
+
+config EXTRA_FIRMWARE
+ string "External firmware blobs to build into the kernel binary"
+ depends on FW_LOADER
+ help
+ This option allows firmware to be built into the kernel, for the
+ cases where the user either cannot or doesn't want to provide it from
+ userspace at runtime (for example, when the firmware in question is
+ required for accessing the boot device, and the user doesn't want to
+ use an initrd).
+
+ This option is a string, and takes the (space-separated) names of the
+ firmware files -- the same names which appear in MODULE_FIRMWARE()
+ and request_firmware() in the source. These files should exist under
+ the directory specified by the EXTRA_FIRMWARE_DIR option, which is
+ by default the firmware/ subdirectory of the kernel source tree.
+
+ So, for example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin",
+ copy the usb8388.bin file into the firmware/ directory, and build the
+ kernel. Then any request_firmware("usb8388.bin") will be
+ satisfied internally without needing to call out to userspace.
+
+ WARNING: If you include additional firmware files into your binary
+ kernel image which are not available under the terms of the GPL,
+ then it may be a violation of the GPL to distribute the resulting
+ image -- since it combines both GPL and non-GPL work. You should
+ consult a lawyer of your own before distributing such an image.
+
+config EXTRA_FIRMWARE_DIR
+ string "Firmware blobs root directory"
+ depends on EXTRA_FIRMWARE != ""
+ default "firmware"
+ help
+ This option controls the directory in which the kernel build system
+ looks for the firmware files listed in the EXTRA_FIRMWARE option.
+ The default is the firmware/ directory in the kernel source tree,
+ but by changing this option you can point it elsewhere, such as
+ the /lib/firmware/ directory or another separate directory
+ containing firmware files.
+
config DEBUG_DRIVER
bool "Driver Core verbose debug messages"
depends on DEBUG_KERNEL
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 9fd4a8534146..b0be1d18fee2 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -49,6 +49,14 @@ struct firmware_priv {
struct timer_list timeout;
};
+#ifdef CONFIG_FW_LOADER
+extern struct builtin_fw __start_builtin_fw[];
+extern struct builtin_fw __end_builtin_fw[];
+#else /* Module case. Avoid ifdefs later; it'll all optimise out */
+static struct builtin_fw *__start_builtin_fw;
+static struct builtin_fw *__end_builtin_fw;
+#endif
+
static void
fw_load_abort(struct firmware_priv *fw_priv)
{
@@ -257,7 +265,7 @@ firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr,
if (retval)
goto out;
- memcpy(fw->data + offset, buffer, count);
+ memcpy((u8 *)fw->data + offset, buffer, count);
fw->size = max_t(size_t, offset + count, fw->size);
retval = count;
@@ -391,13 +399,12 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
struct device *f_dev;
struct firmware_priv *fw_priv;
struct firmware *firmware;
+ struct builtin_fw *builtin;
int retval;
if (!firmware_p)
return -EINVAL;
- printk(KERN_INFO "firmware: requesting %s\n", name);
-
*firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
if (!firmware) {
printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n",
@@ -406,6 +413,20 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
goto out;
}
+ for (builtin = __start_builtin_fw; builtin != __end_builtin_fw;
+ builtin++) {
+ if (strcmp(name, builtin->name))
+ continue;
+ printk(KERN_INFO "firmware: using built-in firmware %s\n",
+ name);
+ firmware->size = builtin->size;
+ firmware->data = builtin->data;
+ return 0;
+ }
+
+ if (uevent)
+ printk(KERN_INFO "firmware: requesting %s\n", name);
+
retval = fw_setup_device(firmware, &f_dev, name, device, uevent);
if (retval)
goto error_kfree_fw;
@@ -473,8 +494,16 @@ request_firmware(const struct firmware **firmware_p, const char *name,
void
release_firmware(const struct firmware *fw)
{
+ struct builtin_fw *builtin;
+
if (fw) {
+ for (builtin = __start_builtin_fw; builtin != __end_builtin_fw;
+ builtin++) {
+ if (fw->data == builtin->data)
+ goto free_fw;
+ }
vfree(fw->data);
+ free_fw:
kfree(fw);
}
}