* [PATCH 1/2] firmware: Convert firmware path setup from an array to a list
@ 2012-10-09 22:49 Dimitris Papastamos
0 siblings, 0 replies; 4+ messages in thread
From: Dimitris Papastamos @ 2012-10-09 22:49 UTC (permalink / raw)
To: linux-kernel
In preparation to support dynamic listing/updating of firmware
paths via procfs, this patch converts the firmware path configuration
from an array to a list.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
drivers/base/firmware_class.c | 72 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 8154145..2153eab 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -36,13 +36,13 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
MODULE_DESCRIPTION("Multi purpose firmware loading support");
MODULE_LICENSE("GPL");
-static const char *fw_path[] = {
- "/lib/firmware/updates/" UTS_RELEASE,
- "/lib/firmware/updates",
- "/lib/firmware/" UTS_RELEASE,
- "/lib/firmware"
+struct fw_path_rec {
+ const char *name;
+ struct list_head list;
};
+static LIST_HEAD(fw_path_list);
+
/* Don't inline this: 'struct kstat' is biggish */
static noinline long fw_file_size(struct file *file)
{
@@ -78,13 +78,14 @@ static bool fw_read_file_contents(struct file *file, struct firmware *fw)
static bool fw_get_filesystem_firmware(struct firmware *fw, const char *name)
{
- int i;
bool success = false;
char *path = __getname();
+ struct fw_path_rec *fwp;
- for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
+ list_for_each_entry(fwp, &fw_path_list, list) {
struct file *file;
- snprintf(path, PATH_MAX, "%s/%s", fw_path[i], name);
+ snprintf(path, PATH_MAX, "%s/%s", fwp->name,
+ name);
file = filp_open(path, O_RDONLY, 0);
if (IS_ERR(file))
@@ -1385,6 +1386,50 @@ static int fw_cache_piggyback_on_request(const char *name)
}
#endif
+static void fw_free_path_list(void)
+{
+ struct fw_path_rec *fwp;
+
+ while (!list_empty(&fw_path_list)) {
+ fwp = list_first_entry(&fw_path_list,
+ struct fw_path_rec,
+ list);
+ kfree(fwp->name);
+ list_del(&fwp->list);
+ kfree(fwp);
+ }
+}
+
+static int fw_populate_path_list(void)
+{
+ int i;
+ struct fw_path_rec *fwp;
+ static const char *fw_path[] = {
+ "/lib/firmware/updates/" UTS_RELEASE,
+ "/lib/firmware/updates",
+ "/lib/firmware/" UTS_RELEASE,
+ "/lib/firmware"
+ };
+
+ for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
+ fwp = kmalloc(sizeof(*fwp), GFP_KERNEL);
+ if (!fwp)
+ goto err_fwp_alloc;
+ fwp->name = kstrdup(fw_path[i], GFP_KERNEL);
+ if (!fwp->name)
+ goto err_fwp_name_alloc;
+ list_add_tail(&fwp->list, &fw_path_list);
+ }
+
+ return 0;
+
+err_fwp_name_alloc:
+ kfree(fwp);
+err_fwp_alloc:
+ fw_free_path_list();
+ return -ENOMEM;
+}
+
static void __init fw_cache_init(void)
{
spin_lock_init(&fw_cache.lock);
@@ -1409,7 +1454,17 @@ static void __init fw_cache_init(void)
static int __init firmware_class_init(void)
{
+ int ret;
+
fw_cache_init();
+
+ ret = fw_populate_path_list();
+ if (ret < 0) {
+ pr_err("%s: Failed to populate firmware path list: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
return class_register(&firmware_class);
}
@@ -1419,6 +1474,7 @@ static void __exit firmware_class_exit(void)
unregister_syscore_ops(&fw_syscore_ops);
unregister_pm_notifier(&fw_cache.pm_notify);
#endif
+ fw_free_path_list();
class_unregister(&firmware_class);
}
--
1.7.12.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 0/2] Expose firmware paths via procfs
@ 2012-10-10 10:56 Dimitris Papastamos
2012-10-10 10:56 ` [PATCH 1/2] firmware: Convert firmware path setup from an array to a list Dimitris Papastamos
0 siblings, 1 reply; 4+ messages in thread
From: Dimitris Papastamos @ 2012-10-10 10:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Ming Lei, Greg Kroah-Hartman
Hi all, sorry missed the relevant CCs before. This patch set
adds support for exposing the firmware paths via procfs. I've added
an entry named /proc/fw_path which is a whitespace separated list
of firmware paths.
Once I have some time I hope to also send out a patch that allows
the user to dynamically configure these paths.
Dimitris Papastamos (2):
firmware: Convert firmware path setup from an array to a list
firmware: Add /proc/fw_path entry to list the firmware paths
drivers/base/firmware_class.c | 127 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 119 insertions(+), 8 deletions(-)
--
1.7.12.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] firmware: Convert firmware path setup from an array to a list
2012-10-10 10:56 [PATCH 0/2] Expose firmware paths via procfs Dimitris Papastamos
@ 2012-10-10 10:56 ` Dimitris Papastamos
2012-10-22 15:42 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Dimitris Papastamos @ 2012-10-10 10:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Ming Lei, Greg Kroah-Hartman
In preparation to support dynamic listing/updating of firmware
paths via procfs, this patch converts the firmware path configuration
from an array to a list.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
drivers/base/firmware_class.c | 72 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 8154145..2153eab 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -36,13 +36,13 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
MODULE_DESCRIPTION("Multi purpose firmware loading support");
MODULE_LICENSE("GPL");
-static const char *fw_path[] = {
- "/lib/firmware/updates/" UTS_RELEASE,
- "/lib/firmware/updates",
- "/lib/firmware/" UTS_RELEASE,
- "/lib/firmware"
+struct fw_path_rec {
+ const char *name;
+ struct list_head list;
};
+static LIST_HEAD(fw_path_list);
+
/* Don't inline this: 'struct kstat' is biggish */
static noinline long fw_file_size(struct file *file)
{
@@ -78,13 +78,14 @@ static bool fw_read_file_contents(struct file *file, struct firmware *fw)
static bool fw_get_filesystem_firmware(struct firmware *fw, const char *name)
{
- int i;
bool success = false;
char *path = __getname();
+ struct fw_path_rec *fwp;
- for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
+ list_for_each_entry(fwp, &fw_path_list, list) {
struct file *file;
- snprintf(path, PATH_MAX, "%s/%s", fw_path[i], name);
+ snprintf(path, PATH_MAX, "%s/%s", fwp->name,
+ name);
file = filp_open(path, O_RDONLY, 0);
if (IS_ERR(file))
@@ -1385,6 +1386,50 @@ static int fw_cache_piggyback_on_request(const char *name)
}
#endif
+static void fw_free_path_list(void)
+{
+ struct fw_path_rec *fwp;
+
+ while (!list_empty(&fw_path_list)) {
+ fwp = list_first_entry(&fw_path_list,
+ struct fw_path_rec,
+ list);
+ kfree(fwp->name);
+ list_del(&fwp->list);
+ kfree(fwp);
+ }
+}
+
+static int fw_populate_path_list(void)
+{
+ int i;
+ struct fw_path_rec *fwp;
+ static const char *fw_path[] = {
+ "/lib/firmware/updates/" UTS_RELEASE,
+ "/lib/firmware/updates",
+ "/lib/firmware/" UTS_RELEASE,
+ "/lib/firmware"
+ };
+
+ for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
+ fwp = kmalloc(sizeof(*fwp), GFP_KERNEL);
+ if (!fwp)
+ goto err_fwp_alloc;
+ fwp->name = kstrdup(fw_path[i], GFP_KERNEL);
+ if (!fwp->name)
+ goto err_fwp_name_alloc;
+ list_add_tail(&fwp->list, &fw_path_list);
+ }
+
+ return 0;
+
+err_fwp_name_alloc:
+ kfree(fwp);
+err_fwp_alloc:
+ fw_free_path_list();
+ return -ENOMEM;
+}
+
static void __init fw_cache_init(void)
{
spin_lock_init(&fw_cache.lock);
@@ -1409,7 +1454,17 @@ static void __init fw_cache_init(void)
static int __init firmware_class_init(void)
{
+ int ret;
+
fw_cache_init();
+
+ ret = fw_populate_path_list();
+ if (ret < 0) {
+ pr_err("%s: Failed to populate firmware path list: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
return class_register(&firmware_class);
}
@@ -1419,6 +1474,7 @@ static void __exit firmware_class_exit(void)
unregister_syscore_ops(&fw_syscore_ops);
unregister_pm_notifier(&fw_cache.pm_notify);
#endif
+ fw_free_path_list();
class_unregister(&firmware_class);
}
--
1.7.12.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] firmware: Convert firmware path setup from an array to a list
2012-10-10 10:56 ` [PATCH 1/2] firmware: Convert firmware path setup from an array to a list Dimitris Papastamos
@ 2012-10-22 15:42 ` Greg Kroah-Hartman
2012-10-23 9:43 ` Dimitris Papastamos
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2012-10-22 15:42 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: linux-kernel, Ming Lei
On Wed, Oct 10, 2012 at 11:56:24AM +0100, Dimitris Papastamos wrote:
> In preparation to support dynamic listing/updating of firmware
> paths via procfs, this patch converts the firmware path configuration
> from an array to a list.
>
> Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
This series doesn't apply anymore due to changes in this code from Ming.
Can you redo it against the my staging-linus branch, or the next
linux-next release, so that I can apply them?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] firmware: Convert firmware path setup from an array to a list
2012-10-22 15:42 ` Greg Kroah-Hartman
@ 2012-10-23 9:43 ` Dimitris Papastamos
0 siblings, 0 replies; 4+ messages in thread
From: Dimitris Papastamos @ 2012-10-23 9:43 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, Ming Lei
On Mon, Oct 22, 2012 at 08:42:02AM -0700, Greg Kroah-Hartman wrote:
> On Wed, Oct 10, 2012 at 11:56:24AM +0100, Dimitris Papastamos wrote:
> > In preparation to support dynamic listing/updating of firmware
> > paths via procfs, this patch converts the firmware path configuration
> > from an array to a list.
> >
> > Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
>
> This series doesn't apply anymore due to changes in this code from Ming.
> Can you redo it against the my staging-linus branch, or the next
> linux-next release, so that I can apply them?
>
> thanks,
>
> greg k-h
Hi, I've not had time to implement this properly as discussed in the thread.
Should the current changes on top of Ming's changes nevertheless?
Thanks,
Dimitris
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-23 9:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-09 22:49 [PATCH 1/2] firmware: Convert firmware path setup from an array to a list Dimitris Papastamos
-- strict thread matches above, loose matches on Subject: below --
2012-10-10 10:56 [PATCH 0/2] Expose firmware paths via procfs Dimitris Papastamos
2012-10-10 10:56 ` [PATCH 1/2] firmware: Convert firmware path setup from an array to a list Dimitris Papastamos
2012-10-22 15:42 ` Greg Kroah-Hartman
2012-10-23 9:43 ` Dimitris Papastamos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox