Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298605
b: refs/heads/master
c: 811fa40
h: refs/heads/master
i:
  298603: 956e85e
v: v3
  • Loading branch information
Rafael J. Wysocki committed Mar 28, 2012
1 parent 320c2d0 commit 05b8d1a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe2e39d8782d885755139304d8dba0b3e5bfa878
refs/heads/master: 811fa4004485dec8977176bf605a5b0508ee206c
58 changes: 41 additions & 17 deletions trunk/drivers/base/firmware_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static void firmware_class_timeout(u_long data)
}

static struct firmware_priv *
fw_create_instance(struct firmware *firmware, const char *fw_name,
fw_create_instance(const struct firmware *firmware, const char *fw_name,
struct device *device, bool uevent, bool nowait)
{
struct firmware_priv *fw_priv;
Expand All @@ -449,7 +449,7 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
goto err_out;
}

fw_priv->fw = firmware;
fw_priv->fw = (struct firmware *)firmware;
fw_priv->nowait = nowait;
strcpy(fw_priv->fw_id, fw_name);
init_completion(&fw_priv->completion);
Expand Down Expand Up @@ -510,13 +510,10 @@ static void fw_destroy_instance(struct firmware_priv *fw_priv)
device_unregister(f_dev);
}

static int _request_firmware(const struct firmware **firmware_p,
const char *name, struct device *device,
bool uevent, bool nowait)
static int _request_firmware_prepare(const struct firmware **firmware_p,
const char *name, struct device *device)
{
struct firmware_priv *fw_priv;
struct firmware *firmware;
int retval = 0;

if (!firmware_p)
return -EINVAL;
Expand All @@ -533,10 +530,26 @@ static int _request_firmware(const struct firmware **firmware_p,
return 0;
}

return 1;
}

static void _request_firmware_cleanup(const struct firmware **firmware_p)
{
release_firmware(*firmware_p);
*firmware_p = NULL;
}

static int _request_firmware(const struct firmware *firmware,
const char *name, struct device *device,
bool uevent, bool nowait)
{
struct firmware_priv *fw_priv;
int retval;

retval = usermodehelper_read_trylock();
if (WARN_ON(retval)) {
dev_err(device, "firmware: %s will not be loaded\n", name);
goto out_nolock;
return retval;
}

if (uevent)
Expand Down Expand Up @@ -572,13 +585,6 @@ static int _request_firmware(const struct firmware **firmware_p,

out:
usermodehelper_read_unlock();

out_nolock:
if (retval) {
release_firmware(firmware);
*firmware_p = NULL;
}

return retval;
}

Expand All @@ -601,7 +607,17 @@ int
request_firmware(const struct firmware **firmware_p, const char *name,
struct device *device)
{
return _request_firmware(firmware_p, name, device, true, false);
int ret;

ret = _request_firmware_prepare(firmware_p, name, device);
if (ret <= 0)
return ret;

ret = _request_firmware(*firmware_p, name, device, true, false);
if (ret)
_request_firmware_cleanup(firmware_p);

return ret;
}

/**
Expand Down Expand Up @@ -639,8 +655,16 @@ static int request_firmware_work_func(void *arg)
return 0;
}

ret = _request_firmware(&fw, fw_work->name, fw_work->device,
ret = _request_firmware_prepare(&fw, fw_work->name, fw_work->device);
if (ret <= 0)
goto out;

ret = _request_firmware(fw, fw_work->name, fw_work->device,
fw_work->uevent, true);
if (ret)
_request_firmware_cleanup(&fw);

out:
fw_work->cont(fw, fw_work->context);

module_put(fw_work->module);
Expand Down

0 comments on commit 05b8d1a

Please sign in to comment.