request_firmware() backport to 2.4 kernels
Subsystems (3)
PATCH 1/1 request_firmware() backport to 2.4 kernels
Hi everyone,
Now that request_firmware() is on it's way to the main 2.5 tree, it is time to consider what should be done for 2.4 kernels.
At least Pavel's spectrum24 driver would be ready for submission if this functionality was available, and I hope to get orinoco_usb stable enough for 2.4 inclusion before 2.6 comes out, which also needs such functionality.
Notes on the attached patch:
---------------------------
- 99% compatible with 2.5 implementation both on the kernel's and hotplug's sides. The other 1% is:
- To kernel code: the 'device' argument is 'char *' instead of 'struct device *'.
- To hotplug: the prefix for $DEVPATH is /proc/ instead of /sys/
- Doesn't modify any existing code.
- Uses procfs in place of sysfs.
Please comment
Manuel
Signature · 6 lines
--- Manuel Estrada Sainz <[email protected]> <[email protected]> <[email protected]> ------------------------ <[email protected]> ------------------- Let us have the serenity to accept the things we cannot change, courage to change the things we can, and wisdom to know the difference.
Documentation/Configure.help +6 -0
@@ -26525,6 +26525,12 @@ If unsure, say N. +Hotplug firmware loading support (EXPERIMENTAL) +CONFIG_FW_LOADER + This option is provided for the case where no in-kernel-tree modules require + hotplug firmware loading support, but a module built outside the kernel tree + does. + # # A couple of things I keep forgetting: # capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,
include/linux/firmware.h +20 -0
@@ -0,0 +1,20 @@ +#ifndef _LINUX_FIRMWARE_H +#define _LINUX_FIRMWARE_H +#include <linux/module.h> +#include <linux/types.h> +#define FIRMWARE_NAME_MAX 30 +struct firmware { +size_t size; +u8 *data; +}; +int request_firmware (const struct firmware **fw,const char *name, +const char *device); +int request_firmware_nowait ( +struct module *module, +const char *name,const char *device,void *context, +void (*cont)(const struct firmware *fw,void *context)); +/* On 2.5 'device' is 'struct device *' */ + +void release_firmware (const struct firmware *fw); +void register_firmware (const char *name,const u8 *data,size_t size); +#endif
lib/Config.in +4 -0
@@ -35,4 +35,8 @@ fi fi +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + tristate 'Hotplug firmware loading support (EXPERIMENTAL)' CONFIG_FW_LOADER +fi + endmenu
lib/Makefile +3 -1
@@ -8,11 +8,13 @@ L_TARGET := lib.a -export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o rbtree.o +export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o rbtree.o \ + firmware_class.o obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \ bust_spinlocks.o rbtree.o dump_stack.o +obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
lib/firmware_class.c +566 -0
566 lines not on this page · raw message
Review
Quoted 11 lines · Manuel Estrada Sainz
(quoted diff) +11
-0+ if (device) { + envp[i++] = scratch; + scratch += sprintf(scratch, "DEVPATH=/driver/firmware/%s", + device) + 1; + } + + envp[i++] = scratch; + scratch += sprintf(scratch, "ACTION=%s", verb) + 1; + + envp[i++] = scratch; + scratch += sprintf(scratch, "FIRMWARE=%s", name) + 1;
Ingo Oeser wisely suggested using snprintf in some of this cases, attached goes an updated patch and an incremental patch for easier reading.
Have a nice day
Manuel
Signature · 6 lines
--- Manuel Estrada Sainz <[email protected]> <[email protected]> <[email protected]> ------------------------ <[email protected]> ------------------- Let us have the serenity to accept the things we cannot change, courage to change the things we can, and wisdom to know the difference.
lib/firmware_class.c +4 -3
@@ -123,15 +123,16 @@if (device) { envp[i++] = scratch; - scratch +=sprintf (scratch,"DEVPATH=/driver/firmware/%s" , - device) +1 ; + scratch +=snprintf (scratch,FIRMWARE_NAME_MAX , +"DEVPATH=/driver/firmware/%s" , device) +1 ; } envp[i++] = scratch; scratch +=sprintf (scratch,"ACTION=%s" , verb) +1 ; envp[i++] = scratch; - scratch +=sprintf (scratch,"FIRMWARE=%s" , name) +1 ; + scratch +=snprintf (scratch,FIRMWARE_NAME_MAX , +"FIRMWARE=%s" , name) +1 ; envp[i++] =0 ;
Documentation/Configure.help +6 -0
@@ -26542,6 +26542,12 @@ If unsure, say N. +Hotplug firmware loading support (EXPERIMENTAL) +CONFIG_FW_LOADER + This option is provided for the case where no in-kernel-tree modules require + hotplug firmware loading support, but a module built outside the kernel tree + does. + NatSemi SCx200 support CONFIG_SCx200 This provides basic support for the National Semiconductor SCx200
include/linux/firmware.h +20 -0
@@ -0,0 +1,20 @@ +#ifndef _LINUX_FIRMWARE_H +#define _LINUX_FIRMWARE_H +#include <linux/module.h> +#include <linux/types.h> +#define FIRMWARE_NAME_MAX 30 +struct firmware { +size_t size; +u8 *data; +}; +int request_firmware (const struct firmware **fw,const char *name, +const char *device); +int request_firmware_nowait ( +struct module *module, +const char *name,const char *device,void *context, +void (*cont)(const struct firmware *fw,void *context)); +/* On 2.5 'device' is 'struct device *' */ + +void release_firmware (const struct firmware *fw); +void register_firmware (const char *name,const u8 *data,size_t size); +#endif
lib/Config.in +4 -0
@@ -35,4 +35,8 @@ fi fi +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + tristate 'Hotplug firmware loading support (EXPERIMENTAL)' CONFIG_FW_LOADER +fi + endmenu
lib/Makefile +3 -1
@@ -8,11 +8,13 @@ L_TARGET := lib.a -export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o rbtree.o +export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o rbtree.o \ + firmware_class.o obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \ bust_spinlocks.o rbtree.o dump_stack.o +obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
lib/firmware_class.c +567 -0
567 lines not on this page · raw message
Quoted 2 lines · Manuel Estrada Sainz
Please comment
Looks sane to me, nice job.
greg k-h