diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2012-07-23 14:05:39 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-16 09:40:28 -0700 |
commit | 07b509b7943e5594f3f228e5b62a49cf6a033709 (patch) | |
tree | 6271fdff08b54ab605cbc666cdcc054d41d3e44a /drivers/misc/mei/main.c | |
parent | 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff) | |
download | op-kernel-dev-07b509b7943e5594f3f228e5b62a49cf6a033709.zip op-kernel-dev-07b509b7943e5594f3f228e5b62a49cf6a033709.tar.gz |
mei: revamp me client search function
me client search functions returns index
into me_client array according me client id
or me client uuid.
1. Add common prefix for the functions mei_me_cl_<>
2. create new function mei_me_cl_by_id that wraps open
coded loops scattered over the code
3. rename mei_find_me_client_index to mei_me_cl_by_uuid
4. rename mei_find_me_client_update_filext to
mei_me_cl_update_filext and updates its parameter names
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 | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 0923302..b0903bd 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -393,10 +393,9 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) { /* Do not allow to read watchdog client */ - i = mei_find_me_client_index(dev, mei_wd_guid); + i = mei_me_cl_by_uuid(dev, &mei_wd_guid); if (i >= 0) { struct mei_me_client *me_client = &dev->me_clients[i]; - if (cl->me_client_id == me_client->client_id) { rets = -EBADF; goto out; @@ -620,22 +619,12 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, rets = -ENODEV; goto unlock_dev; } - for (i = 0; i < dev->me_clients_num; i++) { - if (dev->me_clients[i].client_id == - dev->iamthif_cl.me_client_id) - break; - } - - if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) { + i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id); + if (i < 0) { rets = -ENODEV; goto unlock_dev; } - if (i == dev->me_clients_num || - (dev->me_clients[i].client_id != - dev->iamthif_cl.me_client_id)) { - rets = -ENODEV; - goto unlock_dev; - } else if (length > dev->me_clients[i].props.max_msg_length || + if (length > dev->me_clients[i].props.max_msg_length || length <= 0) { rets = -EMSGSIZE; goto unlock_dev; @@ -688,16 +677,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, cl->me_client_id); goto unlock_dev; } - for (i = 0; i < dev->me_clients_num; i++) { - if (dev->me_clients[i].client_id == - cl->me_client_id) - break; - } - if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) { - rets = -ENODEV; - goto unlock_dev; - } - if (i == dev->me_clients_num) { + i = mei_me_cl_by_id(dev, cl->me_client_id); + if (i < 0) { rets = -ENODEV; goto unlock_dev; } |