Skip to contentSkip to conversation

request_firmware_examples

PATCH In review Victor Hugo 5 participants 5 messages Sep 7, 2006 – Sep 15, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 request_firmware_examples

My e-mail client should die a horrible death--

Sorry Andrew, lets try this again

---

Documentation/firmware_class/firmware_example.c 2006-09-06 00:57:45.000000000 -0700 renamed from Documentation/firmware_class/firmware_example.c 1969-12-31 16:00:00.000000000 -0800 +68 -0
diff -Nur linux-2.6.17.11/Documentation/firmware_class/firmware_example.c linux/Documentation/firmware_class/firmware_example.c
@@ -0,0 +1,68 @@
+/*
+ * firmware_example.c -
+ *
+ * Copyright (c) 2006 Victor Hugo <[email protected]>
+ * Based on firmware_sample_driver.c by Manuel Estrada Sainz
+ * Sample code on how to use request_firmware() from drivers.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/string.h>
+#include <linux/firmware.h>
+
+static void sample_firmware_load(char *firmware, int size)
+{
+       u8 *buf = kmalloc(size + 1, GFP_KERNEL);
+       memcpy(buf, firmware, size);
+       buf[size] = '\0';
+       printk(KERN_INFO "firmware_example: Firmware: %s\n", buf);
+       kfree(buf);
+}
+
+static void sample_probe(struct device *dev)
+{
+       /* uses the default method to get the firmware */
+       const struct firmware *fw_entry;
+       printk(KERN_INFO "firmware_example: ghost device inserted\n");
+
+       if (request_firmware(&fw_entry, "sample_firware.bin", dev) != 0) {
+               printk(KERN_ERR "firmware_example: Firmware not available\n");
+               return;
+       }
+
+       sample_firmware_load(fw_entry->data, fw_entry->size);
+
+       release_firmware(fw_entry);
+
+       /* finish setting up the device */
+}
+
+static void ghost_release(struct device *dev)
+{
+       printk(KERN_DEBUG "firmware_example : ghost device released\n");
+}
+
+static struct device ghost_device = {
+       .bus_id = "ghost0",
+       .release = ghost_release
+};
+
+static int __init sample_init(void)
+{
+       device_register(&ghost_device);
+       sample_probe(&ghost_device);
+       return 0;
+}
+static void __exit sample_exit(void)
+{
+       device_unregister(&ghost_device);
+}
+
+module_init(sample_init);
+module_exit(sample_exit);
+
+MODULE_LICENSE("GPL");
Documentation/firmware_class/firmware_nowait_example.c 2006-09-06 00:58:06.000000000 -0700 renamed from Documentation/firmware_class/firmware_nowait_example.c 1969-12-31 16:00:00.000000000 -0800 +83 -0

83 lines not on this page · raw message

Documentation/firmware_class/firmware_sample_driver.c 1969-12-31 16:00:00.000000000 -0800 renamed from Documentation/firmware_class/firmware_sample_driver.c 2006-08-23 14:16:33.000000000 -0700 +0 -115

115 lines not on this page · raw message

#1 lore raw
Quoted 1 line · On Thu, 07 Sep 2006 16:25:45 -0700 Victor Hugo <[email protected]> wrote:

My e-mail client should die a horrible death--

It would have plenty of company in the graveyard.

Quoted 1 line

Sorry Andrew, lets try this again

It's wordwrapped and included no changelog.

#2 lore raw

Hallo, Victor Hugo

Quoted 2 lines · Andrew Morton

On Thu, 07 Sep 2006 16:25:45 -0700
Victor Hugo <[email protected]> wrote:

...

Quoted 3 lines
Quoted 1 line

Sorry Andrew, lets try this again

It's wordwrapped and included no changelog.

He-ha-he.
Can not send you writings to yourself to check, poor man ?!

Once again my (yet ENOPATCH) proposition: make things easy ! Help with this, if you _can_ code
<http://permalink.gmane.org/gmane.linux.debian.devel.kernel/21781> !!!

P.S. I think guy without ENOPATCH must be better in that, what he does....

-o--=O`C /. .\ (+)
#oo'L O o |
<___=E M ^-- | (you're barking up the wrong tree)

#4 lore raw
In reply to Victor Hugo

Ar Iau, 2006-09-07 am 16:25 -0700, ysgrifennodd Victor Hugo:

Review

Quoted 2 lines
(quoted diff) +2 -0
+       u8 *buf = kmalloc(size + 1, GFP_KERNEL);
+       memcpy(buf, firmware, size);

NAK. Out of memory check please.

#3 lore raw
In reply to Andrew Morton
Quoted 10 lines · On Thu, 7 Sep 2006 16:31:04 -0700 Andrew Morton wrote:
Quoted 1 line · On Thu, 07 Sep 2006 16:25:45 -0700 Victor Hugo <[email protected]> wrote:

My e-mail client should die a horrible death--

It would have plenty of company in the graveyard.

Quoted 1 line

Sorry Andrew, lets try this again

It's wordwrapped and included no changelog.

Victor,

thunderbird can be used successfully (without using attachments) if you want/are willing to jump thru some hoops.

See http://mbligh.org/linuxdocs/Email/Clients/Thunderbird . or use pine, mutt, sylpheed, etc.

---
~Randy