aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/mei/client.c')
-rw-r--r--drivers/misc/mei/client.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 8103d94facb8..d566dd880eb0 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -258,54 +258,61 @@ struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl)
258 return NULL; 258 return NULL;
259} 259}
260 260
261 261/** mei_cl_link: allocte host id in the host map
262/**
263 * mei_me_cl_link - create link between host and me clinet and add
264 * me_cl to the list
265 *
266 * @cl: link between me and host client assocated with opened file descriptor
267 * @uuid: uuid of ME client
268 * @client_id: id of the host client
269 * 262 *
270 * returns ME client index if ME client 263 * @cl - host client
264 * @id - fixed host id or -1 for genereting one
265 * returns 0 on success
271 * -EINVAL on incorrect values 266 * -EINVAL on incorrect values
272 * -ENONET if client not found 267 * -ENONET if client not found
273 */ 268 */
274int mei_cl_link_me(struct mei_cl *cl, const uuid_le *uuid, u8 host_cl_id) 269int mei_cl_link(struct mei_cl *cl, int id)
275{ 270{
276 struct mei_device *dev; 271 struct mei_device *dev;
277 int i;
278 272
279 if (WARN_ON(!cl || !cl->dev || !uuid)) 273 if (WARN_ON(!cl || !cl->dev))
280 return -EINVAL; 274 return -EINVAL;
281 275
282 dev = cl->dev; 276 dev = cl->dev;
283 277
284 /* check for valid client id */ 278 /* If Id is not asigned get one*/
285 i = mei_me_cl_by_uuid(dev, uuid); 279 if (id == MEI_HOST_CLIENT_ID_ANY)
286 if (i >= 0) { 280 id = find_first_zero_bit(dev->host_clients_map,
287 cl->me_client_id = dev->me_clients[i].client_id; 281 MEI_CLIENTS_MAX);
288 cl->state = MEI_FILE_CONNECTING;
289 cl->host_client_id = host_cl_id;
290 282
291 list_add_tail(&cl->link, &dev->file_list); 283 if (id >= MEI_CLIENTS_MAX) {
292 return (u8)i; 284 dev_err(&dev->pdev->dev, "id exceded %d", MEI_CLIENTS_MAX) ;
285 return -ENOENT;
293 } 286 }
294 287
295 return -ENOENT; 288 dev->open_handle_count++;
289
290 cl->host_client_id = id;
291 list_add_tail(&cl->link, &dev->file_list);
292
293 set_bit(id, dev->host_clients_map);
294
295 cl->state = MEI_FILE_INITIALIZING;
296
297 dev_dbg(&dev->pdev->dev, "link cl host id = %d\n", cl->host_client_id);
298 return 0;
296} 299}
300
297/** 301/**
298 * mei_cl_unlink - remove me_cl from the list 302 * mei_cl_unlink - remove me_cl from the list
299 * 303 *
300 * @dev: the device structure 304 * @dev: the device structure
301 * @host_client_id: host client id to be removed
302 */ 305 */
303int mei_cl_unlink(struct mei_cl *cl) 306int mei_cl_unlink(struct mei_cl *cl)
304{ 307{
305 struct mei_device *dev; 308 struct mei_device *dev;
306 struct mei_cl *pos, *next; 309 struct mei_cl *pos, *next;
307 310
308 if (WARN_ON(!cl || !cl->dev)) 311 /* don't shout on error exit path */
312 if (!cl)
313 return 0;
314
315 if (WARN_ON(!cl->dev))
309 return -EINVAL; 316 return -EINVAL;
310 317
311 dev = cl->dev; 318 dev = cl->dev;