Adds the transport interfaces for various LJCA sub-module drivers
to communicate with LJCA hardware. The sub-modules of LJCA can use
ljca_transfer() to issue a transfer between host and hardware. And
ljca_register_event_cb is exported to LJCA sub-module drivers for
hardware event subscription.
Signed-off-by: Ye Xiang <xiang.ye@xxxxxxxxx>
---
+
+int ljca_register_event_cb(struct ljca *ljca, ljca_event_cb_t event_cb, void *context)
+{
+ struct ljca_event_cb_entry *entry, *iter;
+ struct ljca_stub *stub;
+ unsigned long flags;
+ int ret;
+
+ stub = ljca_stub_find(ljca->dev, ljca->type);
+ if (IS_ERR(stub))
+ return PTR_ERR(stub);
+
+ entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ if (!entry)
+ return -ENOMEM;
+
+ entry->notify = event_cb;
+ entry->context = context;
+ entry->id = ljca->id;
+
+ spin_lock_irqsave(&stub->event_cb_lock, flags);
+
+ list_for_each_entry(iter, &stub->event_entrys, list) {
+ if (iter->id == ljca->id) {
+ ret = -EBUSY;
+ break;
+ }
+ }
+
+ if (!ret)
+ list_add_tail(&entry->list, &stub->event_entrys);
+
+ spin_unlock_irqrestore(&stub->event_cb_lock, flags);
+
+ if (ret)
+ kfree(entry);
+
+ return ret;
+}
+EXPORT_SYMBOL_NS_GPL(ljca_register_event_cb, LJCA);