Lines Matching refs:cldev
272 ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf, in mei_cldev_send_vtag() argument
275 struct mei_cl *cl = cldev->cl; in mei_cldev_send_vtag()
295 ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf, in mei_cldev_send_vtag_timeout() argument
298 struct mei_cl *cl = cldev->cl; in mei_cldev_send_vtag_timeout()
317 ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length, in mei_cldev_recv_vtag() argument
320 struct mei_cl *cl = cldev->cl; in mei_cldev_recv_vtag()
339 ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf, in mei_cldev_recv_nonblock_vtag() argument
342 struct mei_cl *cl = cldev->cl; in mei_cldev_recv_nonblock_vtag()
360 ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, in mei_cldev_recv_timeout() argument
363 return mei_cldev_recv_vtag_timeout(cldev, buf, length, NULL, timeout); in mei_cldev_recv_timeout()
381 ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, in mei_cldev_recv_vtag_timeout() argument
384 struct mei_cl *cl = cldev->cl; in mei_cldev_recv_vtag_timeout()
401 ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length) in mei_cldev_send() argument
403 return mei_cldev_send_vtag(cldev, buf, length, 0); in mei_cldev_send()
419 ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf, size_t length, in mei_cldev_send_timeout() argument
422 return mei_cldev_send_vtag_timeout(cldev, buf, length, 0, timeout); in mei_cldev_send_timeout()
435 ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length) in mei_cldev_recv() argument
437 return mei_cldev_recv_vtag(cldev, buf, length, NULL); in mei_cldev_recv()
451 ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf, in mei_cldev_recv_nonblock() argument
454 return mei_cldev_recv_nonblock_vtag(cldev, buf, length, NULL); in mei_cldev_recv_nonblock()
465 struct mei_cl_device *cldev; in mei_cl_bus_rx_work() local
468 cldev = container_of(work, struct mei_cl_device, rx_work); in mei_cl_bus_rx_work()
470 bus = cldev->bus; in mei_cl_bus_rx_work()
472 if (cldev->rx_cb) in mei_cl_bus_rx_work()
473 cldev->rx_cb(cldev); in mei_cl_bus_rx_work()
476 if (mei_cl_is_connected(cldev->cl)) in mei_cl_bus_rx_work()
477 mei_cl_read_start(cldev->cl, mei_cl_mtu(cldev->cl), NULL); in mei_cl_bus_rx_work()
488 struct mei_cl_device *cldev; in mei_cl_bus_notif_work() local
490 cldev = container_of(work, struct mei_cl_device, notif_work); in mei_cl_bus_notif_work()
492 if (cldev->notif_cb) in mei_cl_bus_notif_work()
493 cldev->notif_cb(cldev); in mei_cl_bus_notif_work()
506 struct mei_cl_device *cldev = cl->cldev; in mei_cl_bus_notify_event() local
508 if (!cldev || !cldev->notif_cb) in mei_cl_bus_notify_event()
514 schedule_work(&cldev->notif_work); in mei_cl_bus_notify_event()
531 struct mei_cl_device *cldev = cl->cldev; in mei_cl_bus_rx_event() local
533 if (!cldev || !cldev->rx_cb) in mei_cl_bus_rx_event()
536 schedule_work(&cldev->rx_work); in mei_cl_bus_rx_event()
551 int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb) in mei_cldev_register_rx_cb() argument
553 struct mei_device *bus = cldev->bus; in mei_cldev_register_rx_cb()
558 if (cldev->rx_cb) in mei_cldev_register_rx_cb()
561 cldev->rx_cb = rx_cb; in mei_cldev_register_rx_cb()
562 INIT_WORK(&cldev->rx_work, mei_cl_bus_rx_work); in mei_cldev_register_rx_cb()
565 if (mei_cl_is_connected(cldev->cl)) in mei_cldev_register_rx_cb()
566 ret = mei_cl_read_start(cldev->cl, mei_cl_mtu(cldev->cl), NULL); in mei_cldev_register_rx_cb()
571 cancel_work_sync(&cldev->rx_work); in mei_cldev_register_rx_cb()
572 cldev->rx_cb = NULL; in mei_cldev_register_rx_cb()
590 int mei_cldev_register_notif_cb(struct mei_cl_device *cldev, in mei_cldev_register_notif_cb() argument
593 struct mei_device *bus = cldev->bus; in mei_cldev_register_notif_cb()
599 if (cldev->notif_cb) in mei_cldev_register_notif_cb()
602 cldev->notif_cb = notif_cb; in mei_cldev_register_notif_cb()
603 INIT_WORK(&cldev->notif_work, mei_cl_bus_notif_work); in mei_cldev_register_notif_cb()
606 ret = mei_cl_notify_request(cldev->cl, NULL, 1); in mei_cldev_register_notif_cb()
609 cancel_work_sync(&cldev->notif_work); in mei_cldev_register_notif_cb()
610 cldev->notif_cb = NULL; in mei_cldev_register_notif_cb()
625 void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev) in mei_cldev_get_drvdata() argument
627 return dev_get_drvdata(&cldev->dev); in mei_cldev_get_drvdata()
637 void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data) in mei_cldev_set_drvdata() argument
639 dev_set_drvdata(&cldev->dev, data); in mei_cldev_set_drvdata()
650 const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev) in mei_cldev_uuid() argument
652 return mei_me_cl_uuid(cldev->me_cl); in mei_cldev_uuid()
663 u8 mei_cldev_ver(const struct mei_cl_device *cldev) in mei_cldev_ver() argument
665 return mei_me_cl_ver(cldev->me_cl); in mei_cldev_ver()
676 bool mei_cldev_enabled(const struct mei_cl_device *cldev) in mei_cldev_enabled() argument
678 return mei_cl_is_connected(cldev->cl); in mei_cldev_enabled()
690 static bool mei_cl_bus_module_get(struct mei_cl_device *cldev) in mei_cl_bus_module_get() argument
692 return try_module_get(cldev->bus->dev->driver->owner); in mei_cl_bus_module_get()
700 static void mei_cl_bus_module_put(struct mei_cl_device *cldev) in mei_cl_bus_module_put() argument
702 module_put(cldev->bus->dev->driver->owner); in mei_cl_bus_module_put()
728 static int mei_cl_bus_vtag_alloc(struct mei_cl_device *cldev) in mei_cl_bus_vtag_alloc() argument
730 struct mei_cl *cl = cldev->cl; in mei_cl_bus_vtag_alloc()
754 static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) in mei_cl_bus_vtag_free() argument
756 struct mei_cl *cl = cldev->cl; in mei_cl_bus_vtag_free()
767 void *mei_cldev_dma_map(struct mei_cl_device *cldev, u8 buffer_id, size_t size) in mei_cldev_dma_map() argument
773 if (!cldev || !buffer_id || !size) in mei_cldev_dma_map()
777 dev_err(&cldev->dev, "Map size should be aligned to %lu\n", in mei_cldev_dma_map()
782 cl = cldev->cl; in mei_cldev_dma_map()
783 bus = cldev->bus; in mei_cldev_dma_map()
791 cl->cldev = cldev; in mei_cldev_dma_map()
805 int mei_cldev_dma_unmap(struct mei_cl_device *cldev) in mei_cldev_dma_unmap() argument
811 if (!cldev) in mei_cldev_dma_unmap()
814 cl = cldev->cl; in mei_cldev_dma_unmap()
815 bus = cldev->bus; in mei_cldev_dma_unmap()
835 int mei_cldev_enable(struct mei_cl_device *cldev) in mei_cldev_enable() argument
837 struct mei_device *bus = cldev->bus; in mei_cldev_enable()
841 cl = cldev->cl; in mei_cldev_enable()
849 cl->cldev = cldev; in mei_cldev_enable()
857 if (!mei_me_cl_is_active(cldev->me_cl)) { in mei_cldev_enable()
858 dev_err(&cldev->dev, "me client is not active\n"); in mei_cldev_enable()
863 ret = mei_cl_bus_vtag_alloc(cldev); in mei_cldev_enable()
867 ret = mei_cl_connect(cl, cldev->me_cl, NULL); in mei_cldev_enable()
869 dev_err(&cldev->dev, "cannot connect\n"); in mei_cldev_enable()
870 mei_cl_bus_vtag_free(cldev); in mei_cldev_enable()
889 static void mei_cldev_unregister_callbacks(struct mei_cl_device *cldev) in mei_cldev_unregister_callbacks() argument
891 if (cldev->rx_cb) { in mei_cldev_unregister_callbacks()
892 cancel_work_sync(&cldev->rx_work); in mei_cldev_unregister_callbacks()
893 cldev->rx_cb = NULL; in mei_cldev_unregister_callbacks()
896 if (cldev->notif_cb) { in mei_cldev_unregister_callbacks()
897 cancel_work_sync(&cldev->notif_work); in mei_cldev_unregister_callbacks()
898 cldev->notif_cb = NULL; in mei_cldev_unregister_callbacks()
910 int mei_cldev_disable(struct mei_cl_device *cldev) in mei_cldev_disable() argument
916 if (!cldev) in mei_cldev_disable()
919 cl = cldev->cl; in mei_cldev_disable()
921 bus = cldev->bus; in mei_cldev_disable()
923 mei_cldev_unregister_callbacks(cldev); in mei_cldev_disable()
927 mei_cl_bus_vtag_free(cldev); in mei_cldev_disable()
966 ssize_t mei_cldev_send_gsc_command(struct mei_cl_device *cldev, in mei_cldev_send_gsc_command() argument
984 if (!cldev || !sg_in || !sg_out) in mei_cldev_send_gsc_command()
987 cl = cldev->cl; in mei_cldev_send_gsc_command()
988 bus = cldev->bus; in mei_cldev_send_gsc_command()
1085 struct mei_cl_device_id *mei_cl_device_find(const struct mei_cl_device *cldev, in mei_cl_device_find() argument
1093 uuid = mei_me_cl_uuid(cldev->me_cl); in mei_cl_device_find()
1094 version = mei_me_cl_ver(cldev->me_cl); in mei_cl_device_find()
1101 if (cldev->name[0]) in mei_cl_device_find()
1102 if (strncmp(cldev->name, id->name, in mei_cl_device_find()
1129 const struct mei_cl_device *cldev = to_mei_cl_device(dev); in mei_cl_device_match() local
1133 if (!cldev->do_match) in mei_cl_device_match()
1139 found_id = mei_cl_device_find(cldev, cldrv); in mei_cl_device_match()
1155 struct mei_cl_device *cldev; in mei_cl_device_probe() local
1160 cldev = to_mei_cl_device(dev); in mei_cl_device_probe()
1166 id = mei_cl_device_find(cldev, cldrv); in mei_cl_device_probe()
1170 if (!mei_cl_bus_module_get(cldev)) { in mei_cl_device_probe()
1171 dev_err(&cldev->dev, "get hw module failed"); in mei_cl_device_probe()
1175 ret = cldrv->probe(cldev, id); in mei_cl_device_probe()
1177 mei_cl_bus_module_put(cldev); in mei_cl_device_probe()
1194 struct mei_cl_device *cldev = to_mei_cl_device(dev); in mei_cl_device_remove() local
1198 cldrv->remove(cldev); in mei_cl_device_remove()
1200 mei_cldev_unregister_callbacks(cldev); in mei_cl_device_remove()
1202 mei_cl_bus_module_put(cldev); in mei_cl_device_remove()
1209 struct mei_cl_device *cldev = to_mei_cl_device(dev); in name_show() local
1211 return scnprintf(buf, PAGE_SIZE, "%s", cldev->name); in name_show()
1218 struct mei_cl_device *cldev = to_mei_cl_device(dev); in uuid_show() local
1219 const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl); in uuid_show()
1228 struct mei_cl_device *cldev = to_mei_cl_device(dev); in version_show() local
1229 u8 version = mei_me_cl_ver(cldev->me_cl); in version_show()
1238 struct mei_cl_device *cldev = to_mei_cl_device(dev); in modalias_show() local
1239 const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl); in modalias_show()
1240 u8 version = mei_me_cl_ver(cldev->me_cl); in modalias_show()
1243 cldev->name, uuid, version); in modalias_show()
1250 struct mei_cl_device *cldev = to_mei_cl_device(dev); in max_conn_show() local
1251 u8 maxconn = mei_me_cl_max_conn(cldev->me_cl); in max_conn_show()
1260 struct mei_cl_device *cldev = to_mei_cl_device(dev); in fixed_show() local
1261 u8 fixed = mei_me_cl_fixed(cldev->me_cl); in fixed_show()
1270 struct mei_cl_device *cldev = to_mei_cl_device(dev); in vtag_show() local
1271 bool vt = mei_me_cl_vt(cldev->me_cl); in vtag_show()
1280 struct mei_cl_device *cldev = to_mei_cl_device(dev); in max_len_show() local
1281 u32 maxlen = mei_me_cl_max_len(cldev->me_cl); in max_len_show()
1310 const struct mei_cl_device *cldev = to_mei_cl_device(dev); in mei_cl_device_uevent() local
1311 const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl); in mei_cl_device_uevent()
1312 u8 version = mei_me_cl_ver(cldev->me_cl); in mei_cl_device_uevent()
1320 if (add_uevent_var(env, "MEI_CL_NAME=%s", cldev->name)) in mei_cl_device_uevent()
1324 cldev->name, uuid, version)) in mei_cl_device_uevent()
1355 struct mei_cl_device *cldev = to_mei_cl_device(dev); in mei_cl_bus_dev_release() local
1357 mei_cl_flush_queues(cldev->cl, NULL); in mei_cl_bus_dev_release()
1358 mei_me_cl_put(cldev->me_cl); in mei_cl_bus_dev_release()
1359 mei_dev_bus_put(cldev->bus); in mei_cl_bus_dev_release()
1360 kfree(cldev->cl); in mei_cl_bus_dev_release()
1361 kfree(cldev); in mei_cl_bus_dev_release()
1375 static inline void mei_cl_bus_set_name(struct mei_cl_device *cldev) in mei_cl_bus_set_name() argument
1377 dev_set_name(&cldev->dev, "%s-%pUl", in mei_cl_bus_set_name()
1378 dev_name(cldev->bus->dev), in mei_cl_bus_set_name()
1379 mei_me_cl_uuid(cldev->me_cl)); in mei_cl_bus_set_name()
1393 struct mei_cl_device *cldev; in mei_cl_bus_dev_alloc() local
1396 cldev = kzalloc(sizeof(*cldev), GFP_KERNEL); in mei_cl_bus_dev_alloc()
1397 if (!cldev) in mei_cl_bus_dev_alloc()
1402 kfree(cldev); in mei_cl_bus_dev_alloc()
1406 device_initialize(&cldev->dev); in mei_cl_bus_dev_alloc()
1407 cldev->dev.parent = bus->dev; in mei_cl_bus_dev_alloc()
1408 cldev->dev.bus = &mei_cl_bus_type; in mei_cl_bus_dev_alloc()
1409 cldev->dev.type = &mei_cl_device_type; in mei_cl_bus_dev_alloc()
1410 cldev->bus = mei_dev_bus_get(bus); in mei_cl_bus_dev_alloc()
1411 cldev->me_cl = mei_me_cl_get(me_cl); in mei_cl_bus_dev_alloc()
1412 cldev->cl = cl; in mei_cl_bus_dev_alloc()
1413 mei_cl_bus_set_name(cldev); in mei_cl_bus_dev_alloc()
1414 cldev->is_added = 0; in mei_cl_bus_dev_alloc()
1415 INIT_LIST_HEAD(&cldev->bus_list); in mei_cl_bus_dev_alloc()
1416 device_enable_async_suspend(&cldev->dev); in mei_cl_bus_dev_alloc()
1418 return cldev; in mei_cl_bus_dev_alloc()
1431 struct mei_cl_device *cldev) in mei_cl_bus_dev_setup() argument
1433 cldev->do_match = 1; in mei_cl_bus_dev_setup()
1434 mei_cl_bus_dev_fixup(cldev); in mei_cl_bus_dev_setup()
1437 if (cldev->do_match) in mei_cl_bus_dev_setup()
1438 mei_cl_bus_set_name(cldev); in mei_cl_bus_dev_setup()
1440 return cldev->do_match == 1; in mei_cl_bus_dev_setup()
1450 static int mei_cl_bus_dev_add(struct mei_cl_device *cldev) in mei_cl_bus_dev_add() argument
1454 dev_dbg(cldev->bus->dev, "adding %pUL:%02X\n", in mei_cl_bus_dev_add()
1455 mei_me_cl_uuid(cldev->me_cl), in mei_cl_bus_dev_add()
1456 mei_me_cl_ver(cldev->me_cl)); in mei_cl_bus_dev_add()
1457 ret = device_add(&cldev->dev); in mei_cl_bus_dev_add()
1459 cldev->is_added = 1; in mei_cl_bus_dev_add()
1469 static void mei_cl_bus_dev_stop(struct mei_cl_device *cldev) in mei_cl_bus_dev_stop() argument
1471 cldev->do_match = 0; in mei_cl_bus_dev_stop()
1472 if (cldev->is_added) in mei_cl_bus_dev_stop()
1473 device_release_driver(&cldev->dev); in mei_cl_bus_dev_stop()
1483 static void mei_cl_bus_dev_destroy(struct mei_cl_device *cldev) in mei_cl_bus_dev_destroy() argument
1486 WARN_ON(!mutex_is_locked(&cldev->bus->cl_bus_lock)); in mei_cl_bus_dev_destroy()
1488 if (!cldev->is_added) in mei_cl_bus_dev_destroy()
1491 device_del(&cldev->dev); in mei_cl_bus_dev_destroy()
1493 list_del_init(&cldev->bus_list); in mei_cl_bus_dev_destroy()
1495 cldev->is_added = 0; in mei_cl_bus_dev_destroy()
1496 put_device(&cldev->dev); in mei_cl_bus_dev_destroy()
1504 static void mei_cl_bus_remove_device(struct mei_cl_device *cldev) in mei_cl_bus_remove_device() argument
1506 mei_cl_bus_dev_stop(cldev); in mei_cl_bus_remove_device()
1507 mei_cl_bus_dev_destroy(cldev); in mei_cl_bus_remove_device()
1517 struct mei_cl_device *cldev, *next; in mei_cl_bus_remove_devices() local
1520 list_for_each_entry_safe(cldev, next, &bus->device_list, bus_list) in mei_cl_bus_remove_devices()
1521 mei_cl_bus_remove_device(cldev); in mei_cl_bus_remove_devices()
1538 struct mei_cl_device *cldev; in mei_cl_bus_dev_init() local
1547 cldev = mei_cl_bus_dev_alloc(bus, me_cl); in mei_cl_bus_dev_init()
1548 if (!cldev) in mei_cl_bus_dev_init()
1552 list_add_tail(&cldev->bus_list, &bus->device_list); in mei_cl_bus_dev_init()
1564 struct mei_cl_device *cldev, *n; in mei_cl_bus_rescan() local
1574 list_for_each_entry_safe(cldev, n, &bus->device_list, bus_list) { in mei_cl_bus_rescan()
1576 if (!mei_me_cl_is_active(cldev->me_cl)) { in mei_cl_bus_rescan()
1577 mei_cl_bus_remove_device(cldev); in mei_cl_bus_rescan()
1581 if (cldev->is_added) in mei_cl_bus_rescan()
1584 if (mei_cl_bus_dev_setup(bus, cldev)) in mei_cl_bus_rescan()
1585 mei_cl_bus_dev_add(cldev); in mei_cl_bus_rescan()
1587 list_del_init(&cldev->bus_list); in mei_cl_bus_rescan()
1588 put_device(&cldev->dev); in mei_cl_bus_rescan()