bus.c (4234a6deb5ab04e50cfd6d72761345727bd2de21) bus.c (e46980a10a76ec3282dd6832c1974b880acd23d3)
1/*
2 * Intel Management Engine Interface (Intel MEI) Linux driver
3 * Copyright (c) 2012-2013, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *

--- 139 unchanged lines hidden (view full) ---

148 list_for_each_entry_safe(cl, next, &dev->device_list, device_link) {
149 if (!uuid_le_cmp(uuid, cl->device_uuid))
150 return cl;
151 }
152
153 return NULL;
154}
155struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
1/*
2 * Intel Management Engine Interface (Intel MEI) Linux driver
3 * Copyright (c) 2012-2013, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *

--- 139 unchanged lines hidden (view full) ---

148 list_for_each_entry_safe(cl, next, &dev->device_list, device_link) {
149 if (!uuid_le_cmp(uuid, cl->device_uuid))
150 return cl;
151 }
152
153 return NULL;
154}
155struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
156 uuid_le uuid, char *name)
156 uuid_le uuid, char *name,
157 struct mei_cl_ops *ops)
157{
158 struct mei_cl_device *device;
159 struct mei_cl *cl;
160 int status;
161
162 cl = mei_bus_find_mei_cl_by_uuid(dev, uuid);
163 if (cl == NULL)
164 return NULL;
165
166 device = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL);
167 if (!device)
168 return NULL;
169
170 device->cl = cl;
158{
159 struct mei_cl_device *device;
160 struct mei_cl *cl;
161 int status;
162
163 cl = mei_bus_find_mei_cl_by_uuid(dev, uuid);
164 if (cl == NULL)
165 return NULL;
166
167 device = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL);
168 if (!device)
169 return NULL;
170
171 device->cl = cl;
172 device->ops = ops;
171
172 device->dev.parent = &dev->pdev->dev;
173 device->dev.bus = &mei_cl_bus_type;
174 device->dev.type = &mei_cl_device_type;
175
176 dev_set_name(&device->dev, "%s", name);
177
178 status = device_register(&device->dev);

--- 224 unchanged lines hidden (view full) ---

403EXPORT_SYMBOL_GPL(mei_cl_get_drvdata);
404
405void mei_cl_set_drvdata(struct mei_cl_device *device, void *data)
406{
407 dev_set_drvdata(&device->dev, data);
408}
409EXPORT_SYMBOL_GPL(mei_cl_set_drvdata);
410
173
174 device->dev.parent = &dev->pdev->dev;
175 device->dev.bus = &mei_cl_bus_type;
176 device->dev.type = &mei_cl_device_type;
177
178 dev_set_name(&device->dev, "%s", name);
179
180 status = device_register(&device->dev);

--- 224 unchanged lines hidden (view full) ---

405EXPORT_SYMBOL_GPL(mei_cl_get_drvdata);
406
407void mei_cl_set_drvdata(struct mei_cl_device *device, void *data)
408{
409 dev_set_drvdata(&device->dev, data);
410}
411EXPORT_SYMBOL_GPL(mei_cl_set_drvdata);
412
413int mei_cl_enable_device(struct mei_cl_device *device)
414{
415 int err;
416 struct mei_device *dev;
417 struct mei_cl *cl = device->cl;
418
419 if (cl == NULL)
420 return -ENODEV;
421
422 dev = cl->dev;
423
424 mutex_lock(&dev->device_lock);
425
426 cl->state = MEI_FILE_CONNECTING;
427
428 err = mei_cl_connect(cl, NULL);
429 if (err < 0) {
430 mutex_unlock(&dev->device_lock);
431 dev_err(&dev->pdev->dev, "Could not connect to the ME client");
432
433 return err;
434 }
435
436 mutex_unlock(&dev->device_lock);
437
438 if (device->event_cb && !cl->read_cb)
439 mei_cl_read_start(device->cl);
440
441 if (!device->ops || !device->ops->enable)
442 return 0;
443
444 return device->ops->enable(device);
445}
446EXPORT_SYMBOL_GPL(mei_cl_enable_device);
447
448int mei_cl_disable_device(struct mei_cl_device *device)
449{
450 int err;
451 struct mei_device *dev;
452 struct mei_cl *cl = device->cl;
453
454 if (cl == NULL)
455 return -ENODEV;
456
457 dev = cl->dev;
458
459 mutex_lock(&dev->device_lock);
460
461 if (cl->state != MEI_FILE_CONNECTED) {
462 mutex_unlock(&dev->device_lock);
463 dev_err(&dev->pdev->dev, "Already disconnected");
464
465 return 0;
466 }
467
468 cl->state = MEI_FILE_DISCONNECTING;
469
470 err = mei_cl_disconnect(cl);
471 if (err < 0) {
472 mutex_unlock(&dev->device_lock);
473 dev_err(&dev->pdev->dev,
474 "Could not disconnect from the ME client");
475
476 return err;
477 }
478
479 /* Flush queues and remove any pending read */
480 mei_cl_flush_queues(cl);
481
482 if (cl->read_cb) {
483 struct mei_cl_cb *cb = NULL;
484
485 cb = mei_cl_find_read_cb(cl);
486 /* Remove entry from read list */
487 if (cb)
488 list_del(&cb->list);
489
490 cb = cl->read_cb;
491 cl->read_cb = NULL;
492
493 if (cb) {
494 mei_io_cb_free(cb);
495 cb = NULL;
496 }
497 }
498
499 mutex_unlock(&dev->device_lock);
500
501 if (!device->ops || !device->ops->disable)
502 return 0;
503
504 return device->ops->disable(device);
505}
506EXPORT_SYMBOL_GPL(mei_cl_disable_device);
507
411void mei_cl_bus_rx_event(struct mei_cl *cl)
412{
413 struct mei_cl_device *device = cl->device;
414
415 if (!device || !device->event_cb)
416 return;
417
418 set_bit(MEI_CL_EVENT_RX, &device->events);

--- 13 unchanged lines hidden ---
508void mei_cl_bus_rx_event(struct mei_cl *cl)
509{
510 struct mei_cl_device *device = cl->device;
511
512 if (!device || !device->event_cb)
513 return;
514
515 set_bit(MEI_CL_EVENT_RX, &device->events);

--- 13 unchanged lines hidden ---