diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2015-02-10 11:39:44 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-02 06:37:00 +0300 |
commit | 03b8d3419fdfc02d1984a0db51c8b74426e12605 (patch) | |
tree | 740b43b278842ad3d88c47e1b707616e4c2c4a1a /drivers/misc/mei/main.c | |
parent | bca67d681c4864b74fa5fae9ee47e562d1e272b1 (diff) | |
download | linux-03b8d3419fdfc02d1984a0db51c8b74426e12605.tar.xz |
mei: add mei_cl_alloc_linked function
Add convenient wrapper mei_cl_alloc_linked
to simplify error handling
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/main.c')
-rw-r--r-- | drivers/misc/mei/main.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 369de0a070f1..10fc3a6a1574 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -59,24 +59,18 @@ static int mei_open(struct inode *inode, struct file *file) mutex_lock(&dev->device_lock); - cl = NULL; - - err = -ENODEV; if (dev->dev_state != MEI_DEV_ENABLED) { dev_dbg(dev->dev, "dev_state != MEI_ENABLED dev_state = %s\n", mei_dev_state_str(dev->dev_state)); + err = -ENODEV; goto err_unlock; } - err = -ENOMEM; - cl = mei_cl_allocate(dev); - if (!cl) - goto err_unlock; - - /* open_handle_count check is handled in the mei_cl_link */ - err = mei_cl_link(cl, MEI_HOST_CLIENT_ID_ANY); - if (err) + cl = mei_cl_alloc_linked(dev, MEI_HOST_CLIENT_ID_ANY); + if (IS_ERR(cl)) { + err = PTR_ERR(cl); goto err_unlock; + } file->private_data = cl; @@ -86,7 +80,6 @@ static int mei_open(struct inode *inode, struct file *file) err_unlock: mutex_unlock(&dev->device_lock); - kfree(cl); return err; } |