diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-03-14 03:49:23 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-21 12:37:30 -0400 |
commit | e177123f0c2d77ed2fde724ca352166ca9464619 (patch) | |
tree | 4028292609b20e1d65eb2f8ff9e6e5be608a04c9 /drivers/base/firmware_class.c | |
parent | bcb9bd18e397eabe14b45f4dc4283359ab148d79 (diff) |
firmware loader: do not allocate firmare id separately
fw_id has the same life time as firmware_priv so it makes sense to move
it into firmware_priv structure instead of allocating separately.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/firmware_class.c')
-rw-r--r-- | drivers/base/firmware_class.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index c378a355bed..d98e424675c 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -86,7 +86,6 @@ static int loading_timeout = 60; /* In seconds */ | |||
86 | static DEFINE_MUTEX(fw_lock); | 86 | static DEFINE_MUTEX(fw_lock); |
87 | 87 | ||
88 | struct firmware_priv { | 88 | struct firmware_priv { |
89 | char *fw_id; | ||
90 | struct completion completion; | 89 | struct completion completion; |
91 | struct bin_attribute attr_data; | 90 | struct bin_attribute attr_data; |
92 | struct firmware *fw; | 91 | struct firmware *fw; |
@@ -94,9 +93,9 @@ struct firmware_priv { | |||
94 | struct page **pages; | 93 | struct page **pages; |
95 | int nr_pages; | 94 | int nr_pages; |
96 | int page_array_size; | 95 | int page_array_size; |
97 | const char *vdata; | ||
98 | struct timer_list timeout; | 96 | struct timer_list timeout; |
99 | bool nowait; | 97 | bool nowait; |
98 | char fw_id[]; | ||
100 | }; | 99 | }; |
101 | 100 | ||
102 | static void | 101 | static void |
@@ -153,7 +152,6 @@ static void fw_dev_release(struct device *dev) | |||
153 | for (i = 0; i < fw_priv->nr_pages; i++) | 152 | for (i = 0; i < fw_priv->nr_pages; i++) |
154 | __free_page(fw_priv->pages[i]); | 153 | __free_page(fw_priv->pages[i]); |
155 | kfree(fw_priv->pages); | 154 | kfree(fw_priv->pages); |
156 | kfree(fw_priv->fw_id); | ||
157 | kfree(fw_priv); | 155 | kfree(fw_priv); |
158 | kfree(dev); | 156 | kfree(dev); |
159 | 157 | ||
@@ -437,8 +435,8 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
437 | struct device *device) | 435 | struct device *device) |
438 | { | 436 | { |
439 | int retval; | 437 | int retval; |
440 | struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), | 438 | struct firmware_priv *fw_priv = |
441 | GFP_KERNEL); | 439 | kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); |
442 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); | 440 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); |
443 | 441 | ||
444 | *dev_p = NULL; | 442 | *dev_p = NULL; |
@@ -449,16 +447,9 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
449 | goto error_kfree; | 447 | goto error_kfree; |
450 | } | 448 | } |
451 | 449 | ||
450 | strcpy(fw_priv->fw_id, fw_name); | ||
452 | init_completion(&fw_priv->completion); | 451 | init_completion(&fw_priv->completion); |
453 | fw_priv->attr_data = firmware_attr_data_tmpl; | 452 | fw_priv->attr_data = firmware_attr_data_tmpl; |
454 | fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); | ||
455 | if (!fw_priv->fw_id) { | ||
456 | dev_err(device, "%s: Firmware name allocation failed\n", | ||
457 | __func__); | ||
458 | retval = -ENOMEM; | ||
459 | goto error_kfree; | ||
460 | } | ||
461 | |||
462 | fw_priv->timeout.function = firmware_class_timeout; | 453 | fw_priv->timeout.function = firmware_class_timeout; |
463 | fw_priv->timeout.data = (u_long) fw_priv; | 454 | fw_priv->timeout.data = (u_long) fw_priv; |
464 | init_timer(&fw_priv->timeout); | 455 | init_timer(&fw_priv->timeout); |