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>hifive-unleashed-5.1
parent
bcb9bd18e3
commit
e177123f0c
|
@ -86,7 +86,6 @@ static int loading_timeout = 60; /* In seconds */
|
||||||
static DEFINE_MUTEX(fw_lock);
|
static DEFINE_MUTEX(fw_lock);
|
||||||
|
|
||||||
struct firmware_priv {
|
struct firmware_priv {
|
||||||
char *fw_id;
|
|
||||||
struct completion completion;
|
struct completion completion;
|
||||||
struct bin_attribute attr_data;
|
struct bin_attribute attr_data;
|
||||||
struct firmware *fw;
|
struct firmware *fw;
|
||||||
|
@ -94,9 +93,9 @@ struct firmware_priv {
|
||||||
struct page **pages;
|
struct page **pages;
|
||||||
int nr_pages;
|
int nr_pages;
|
||||||
int page_array_size;
|
int page_array_size;
|
||||||
const char *vdata;
|
|
||||||
struct timer_list timeout;
|
struct timer_list timeout;
|
||||||
bool nowait;
|
bool nowait;
|
||||||
|
char fw_id[];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -153,7 +152,6 @@ static void fw_dev_release(struct device *dev)
|
||||||
for (i = 0; i < fw_priv->nr_pages; i++)
|
for (i = 0; i < fw_priv->nr_pages; i++)
|
||||||
__free_page(fw_priv->pages[i]);
|
__free_page(fw_priv->pages[i]);
|
||||||
kfree(fw_priv->pages);
|
kfree(fw_priv->pages);
|
||||||
kfree(fw_priv->fw_id);
|
|
||||||
kfree(fw_priv);
|
kfree(fw_priv);
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
|
|
||||||
|
@ -437,8 +435,8 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
|
||||||
struct device *device)
|
struct device *device)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv),
|
struct firmware_priv *fw_priv =
|
||||||
GFP_KERNEL);
|
kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL);
|
||||||
struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL);
|
struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL);
|
||||||
|
|
||||||
*dev_p = NULL;
|
*dev_p = NULL;
|
||||||
|
@ -449,16 +447,9 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
|
||||||
goto error_kfree;
|
goto error_kfree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strcpy(fw_priv->fw_id, fw_name);
|
||||||
init_completion(&fw_priv->completion);
|
init_completion(&fw_priv->completion);
|
||||||
fw_priv->attr_data = firmware_attr_data_tmpl;
|
fw_priv->attr_data = firmware_attr_data_tmpl;
|
||||||
fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL);
|
|
||||||
if (!fw_priv->fw_id) {
|
|
||||||
dev_err(device, "%s: Firmware name allocation failed\n",
|
|
||||||
__func__);
|
|
||||||
retval = -ENOMEM;
|
|
||||||
goto error_kfree;
|
|
||||||
}
|
|
||||||
|
|
||||||
fw_priv->timeout.function = firmware_class_timeout;
|
fw_priv->timeout.function = firmware_class_timeout;
|
||||||
fw_priv->timeout.data = (u_long) fw_priv;
|
fw_priv->timeout.data = (u_long) fw_priv;
|
||||||
init_timer(&fw_priv->timeout);
|
init_timer(&fw_priv->timeout);
|
||||||
|
|
Loading…
Reference in New Issue