login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
May
»
30
Re: [PATCHv2 26/28] firmware: allow firmware files to be built into kernel image
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Rusty Russell
Subject:
Re: [PATCHv2 26/28] firmware: allow firmware files to be built into kernel image
Date: Thursday, May 29, 2008 - 10:08 pm
On Sunday 25 May 2008 20:23:56 David Woodhouse wrote:
quoted text
> Some drivers have their own hacks to bypass the kernel's firmware loader > and build their firmware into the kernel; this renders those unnecessary. > > Other drivers don't use the firmware loader at all, because they always > want the firmware to be available. This allows them to start using the > firmware loader. > > A third set of drivers already use the firmware loader, but can't be > used without help from userspace, which sometimes requires an initrd. > This allows them to work in a static kernel. > > Signed-off-by: David Woodhouse <dwmw2@infradead.org> > --- > drivers/base/firmware_class.c | 33 +++++++++++++++++++++++++++++++-- > include/asm-generic/vmlinux.lds.h | 7 +++++++ > include/linux/firmware.h | 21 +++++++++++++++++++++ > 3 files changed, 59 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c > index 264b3a2..c09f060 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 = NULL; > +static struct builtin_fw *__end_builtin_fw = NULL; > +#endif > + > static void > fw_load_abort(struct firmware_priv *fw_priv) > { > @@ -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); > } > } > diff --git a/include/asm-generic/vmlinux.lds.h > b/include/asm-generic/vmlinux.lds.h index f054778..8d71a40 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -86,6 +86,13 @@ > VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \ > } \ > \ > + /* Built-in firmware blobs */ \ > + .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \ > + VMLINUX_SYMBOL(__start_builtin_fw) = .; \ > + *(.builtin_fw) \ > + VMLINUX_SYMBOL(__end_builtin_fw) = .; \ > + } \ > + \ > /* RapidIO route ops */ \ > .rio_route : AT(ADDR(.rio_route) - LOAD_OFFSET) { \ > VMLINUX_SYMBOL(__start_rio_route_ops) = .; \ > diff --git a/include/linux/firmware.h b/include/linux/firmware.h > index 5e73f3f..279eaad 100644 > --- a/include/linux/firmware.h > +++ b/include/linux/firmware.h > @@ -1,7 +1,10 @@ > #ifndef _LINUX_FIRMWARE_H > #define _LINUX_FIRMWARE_H > + > #include <linux/module.h> > #include <linux/types.h> > +#include <linux/compiler.h> > + > #define FIRMWARE_NAME_MAX 30 > #define FW_ACTION_NOHOTPLUG 0 > #define FW_ACTION_HOTPLUG 1 > @@ -13,6 +16,24 @@ struct firmware { > > struct device; > > +struct builtin_fw { > + char *name; > + void *data; > + unsigned long size; > +}; > + > +/* We have to play tricks here much like stringify() to get the > + __COUNTER__ macro to be expanded as we want it */ > +#define __fw_concat1(x,y) x##y > +#define __fw_concat(x,y) __fw_concat1(x,y)
Hmm, linux/module.h does this too, perhaps some enthusiast can implement __concat() and use it everywhere. Cheers, Rusty. --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCHv2 00/28] Allow built-in firmware to be accessed by ...
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 01/28] libertas: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 02/28] bluetooth: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 03/28] cyclades: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 04/28] cx25840: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 05/28] myri10ge: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 06/28] vx222: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 07/28] riptide: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 08/28] pcxhr: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 09/28] vx: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 10/28] ueagle-atm: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 11/28] cxacru: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 12/28] aic94xx: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 13/28] zd1201: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 14/28] rt2x00: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 15/28] p54: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 16/28] atmel: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 17/28] irda-usb: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 18/28] cxgb3: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 19/28] bt8xx: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 20/28] ttusb-dec: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 21/28] dvb frontends: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 22/28] cxusb: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 23/28] gp8psk: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 24/28] tuners: treat firmware data as const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 25/28] firmware: make fw->data const
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 26/28] firmware: allow firmware files to be built ...
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE option
, David Woodhouse
, (Sun May 25, 3:23 am)
[PATCHv2 28/28] firmware: convert korg1212 driver to use f ...
, David Woodhouse
, (Sun May 25, 3:23 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, Hans Verkuil
, (Sun May 25, 3:51 am)
Re: [PATCHv2 01/28] libertas: treat firmware data as const
, Alan Cox
, (Sun May 25, 6:06 am)
Re: [PATCHv2 02/28] bluetooth: treat firmware data as const
, Alan Cox
, (Sun May 25, 6:07 am)
Re: [PATCHv2 03/28] cyclades: treat firmware data as const
, Alan Cox
, (Sun May 25, 6:07 am)
Re: [PATCHv2 28/28] firmware: convert korg1212 driver to u ...
, Alan Cox
, (Sun May 25, 6:11 am)
Re: [PATCHv2 22/28] cxusb: treat firmware data as const
, Michael Krufky
, (Sun May 25, 7:14 am)
Re: [PATCHv2 22/28] cxusb: treat firmware data as const
, David Woodhouse
, (Sun May 25, 7:27 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, David Woodhouse
, (Sun May 25, 7:36 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, David Woodhouse
, (Sun May 25, 7:56 am)
Re: [PATCHv2 22/28] cxusb: treat firmware data as const
, David Woodhouse
, (Sun May 25, 8:02 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, Hans Verkuil
, (Sun May 25, 8:04 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, Mike Isely
, (Sun May 25, 8:20 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, Mike Isely
, (Sun May 25, 8:37 am)
Re: [PATCHv2 04/28] cx25840: treat firmware data as const
, Tyler Trafford
, (Sun May 25, 9:16 am)
[PATCHv3 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE option
, David Woodhouse
, (Sun May 25, 10:00 am)
Re: [PATCHv3 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE ...
, David Woodhouse
, (Mon May 26, 1:58 am)
Re: [PATCHv2 28/28] firmware: convert korg1212 driver to u ...
, Yinghai Lu
, (Tue May 27, 11:33 am)
Re: [PATCHv2 28/28] firmware: convert korg1212 driver to u ...
, David Woodhouse
, (Tue May 27, 2:24 pm)
Re: [PATCHv4 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE ...
, David Woodhouse
, (Wed May 28, 4:46 am)
[PATCH 29/28] firmware: Add 'firmware_install' make target
, David Woodhouse
, (Thu May 29, 1:29 am)
[PATCHv2 #ERROR!/28] maestro3: treat firmware data as const
, David Woodhouse
, (Thu May 29, 2:09 am)
[PATCHv2 30/28] firmware: convert maestro3 driver to use f ...
, David Woodhouse
, (Thu May 29, 3:49 am)
[PATCH N/28] ymfpci: treat firmware data as const
, David Woodhouse
, (Thu May 29, 5:21 am)
[PATCH N/28] firmware: convert ymfpci driver to use firmwa ...
, David Woodhouse
, (Thu May 29, 5:23 am)
[PATCH] smctr: use request_firmware()
, David Woodhouse
, (Thu May 29, 6:47 am)
[PATCH] kaweth: use request_firmware()
, David Woodhouse
, (Thu May 29, 7:20 am)
[PATCH] ttusb-budget: use request_firmware()
, David Woodhouse
, (Thu May 29, 10:49 am)
Re: [PATCH] smctr: use request_firmware()
, maximilian attems
, (Thu May 29, 12:30 pm)
Re: [PATCH] smctr: use request_firmware()
, David Woodhouse
, (Thu May 29, 2:02 pm)
Re: [PATCHv2 26/28] firmware: allow firmware files to be b ...
, Rusty Russell
, (Thu May 29, 10:08 pm)
[PATCH] keyspan: use request_firmware()
, David Woodhouse
, (Fri May 30, 4:45 am)
[PATCH] keyspan_pda: use request_firmware()
, David Woodhouse
, (Fri May 30, 5:19 am)
Re: [PATCH] keyspan: use request_firmware()
, Hugh Blemings
, (Fri May 30, 6:54 am)
Re: [PATCH] kaweth: use request_firmware()
, Oliver Neukum
, (Fri May 30, 6:55 am)
Re: [PATCH] kaweth: use request_firmware()
, David Woodhouse
, (Fri May 30, 8:16 am)
Re: [PATCH] kaweth: use request_firmware()
, Marcel Holtmann
, (Fri May 30, 8:26 am)
Re: [PATCH] kaweth: use request_firmware()
, Alan Cox
, (Fri May 30, 8:48 am)
Re: [PATCH] kaweth: use request_firmware()
, Oliver Neukum
, (Fri May 30, 2:02 pm)
Re: [PATCH] kaweth: use request_firmware()
, Alexandre Oliva
, (Fri May 30, 5:00 pm)
Re: [PATCH] kaweth: use request_firmware()
, Marcel Holtmann
, (Fri May 30, 11:51 pm)
Re: [PATCHv2 26/28] firmware: allow firmware files to be b ...
, David Woodhouse
, (Sat May 31, 1:39 am)
Re: [PATCH] kaweth: use request_firmware()
, Alan Cox
, (Sat May 31, 5:35 am)
Re: [PATCH] ttusb-budget: use request_firmware()
, Mauro Carvalho Chehab
, (Fri Jun 13, 12:23 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Mel Gorman
Re: [PATCH 1/4] vmstat: remove zone->lock from walk_zones_in_node
Guenter Roeck
Re: [lm-sensors] Location for thermal drivers
David Woodhouse
Re: RFC: Moving firmware blobs out of the kernel.
Siddha, Suresh B
Re: [PATCH 2.6.21 review I] [11/25] x86: default to physical mode on hotplug CPU k...
Peter Zijlstra
Re: [patch 4/6] mm: merge populate and nopage into fault (fixes nonlinear)
git-commits-head
:
Linux Kernel Mailing List
[MIPS] Fix potential latency problem due to non-atomic cpu_wait.
Linux Kernel Mailing List
USB: rename USB_SPEED_VARIABLE to USB_SPEED_WIRELESS
Linux Kernel Mailing List
lib/vsprintf.c: fix bug omitting minus sign of numbers (module_param)
Linux Kernel Mailing List
[Bluetooth] Initiate authentication during connection establishment
Linux Kernel Mailing List
[POWERPC] 4xx: Add ppc40x_defconfig
linux-netdev
:
MERCEDES
Your mail id has won 950,000.00 in the MERCEDES Benz Online Promo.for claims send:
David Miller
Re: [PATCH] xen/netfront: do not mark packets of length < MSS as GSO
David Miller
Re: skb_segment() questions
Shan Wei
[RFC PATCH net-next 2/5]IPv6:netfilter: Send an ICMPv6 "Fragment Reassembly Timeou...
Stanislaw Gruszka
[PATCH 1/4] bnx2x: use smp_mb() to keep ordering of read write operations
git
:
Nicolas Sebrecht
git-svn died of signal 11 (was "3 failures on test t9100 (svn)")
Junio C Hamano
Re: [PATCH 2/2] Add url.<base>.pushInsteadOf: URL rewriting for push only
Martin Langhoff
Re: [PATCH] GIT commit statistics.
Alexandre Julliard
[PATCH] gitweb: Put back shortlog instead of graphiclog in the project list.
Josh Triplett
[PATCH 2/2] Add url.<base>.pushInsteadOf: URL rewriting for push only
openbsd-misc
:
Taisto Qvist XX
Re: AMD GEODE LX-800 just works with kernel from install42.iso and kernelpanics wi...
Nico Meijer
Re: gOS Develop Kit with VIA pc-1 Processor Platform VIA C7-D
Andreas Bihlmaier
Re: jetway board sensors (Fintek F71805F)
admin
Drive a 2009 car from R799p/m
Antti Harri
Re: how to create a sha256 hash
Colocation donated by:
Syndicate