Lines Matching refs:u

112 	} u;  member
129 struct xenbus_file_priv *u = filp->private_data; in xenbus_file_read() local
134 mutex_lock(&u->reply_mutex); in xenbus_file_read()
136 while (list_empty(&u->read_buffers)) { in xenbus_file_read()
137 mutex_unlock(&u->reply_mutex); in xenbus_file_read()
141 ret = wait_event_interruptible(u->read_waitq, in xenbus_file_read()
142 !list_empty(&u->read_buffers)); in xenbus_file_read()
145 mutex_lock(&u->reply_mutex); in xenbus_file_read()
148 rb = list_entry(u->read_buffers.next, struct read_buffer, list); in xenbus_file_read()
168 if (list_empty(&u->read_buffers)) in xenbus_file_read()
170 rb = list_entry(u->read_buffers.next, in xenbus_file_read()
178 mutex_unlock(&u->reply_mutex); in xenbus_file_read()
308 struct xenbus_file_priv *u; in xenbus_worker() local
313 u = container_of(wq, struct xenbus_file_priv, wq); in xenbus_worker()
320 list_for_each_entry_safe(trans, tmp, &u->transactions, list) { in xenbus_worker()
326 list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) { in xenbus_worker()
332 list_for_each_entry_safe(rb, tmp_rb, &u->read_buffers, list) { in xenbus_worker()
336 kfree(u); in xenbus_worker()
341 struct xenbus_file_priv *u; in xenbus_file_free() local
347 u = container_of(kref, struct xenbus_file_priv, kref); in xenbus_file_free()
348 schedule_work(&u->wq); in xenbus_file_free()
352 struct xenbus_file_priv *u, uint32_t tx_id) in xenbus_get_transaction() argument
356 list_for_each_entry(trans, &u->transactions, list) in xenbus_get_transaction()
365 struct xenbus_file_priv *u = req->par; in xenbus_dev_queue_reply() local
372 mutex_lock(&u->msgbuffer_mutex); in xenbus_dev_queue_reply()
375 trans = xenbus_get_transaction(u, 0); in xenbus_dev_queue_reply()
387 trans = xenbus_get_transaction(u, req->msg.tx_id); in xenbus_dev_queue_reply()
394 mutex_unlock(&u->msgbuffer_mutex); in xenbus_dev_queue_reply()
396 mutex_lock(&u->reply_mutex); in xenbus_dev_queue_reply()
401 list_splice_tail(&staging_q, &u->read_buffers); in xenbus_dev_queue_reply()
402 wake_up(&u->read_waitq); in xenbus_dev_queue_reply()
406 mutex_unlock(&u->reply_mutex); in xenbus_dev_queue_reply()
411 kref_put(&u->kref, xenbus_file_free); in xenbus_dev_queue_reply()
416 mutex_unlock(&u->msgbuffer_mutex); in xenbus_dev_queue_reply()
419 static int xenbus_command_reply(struct xenbus_file_priv *u, in xenbus_command_reply() argument
428 msg.hdr = u->u.msg; in xenbus_command_reply()
435 mutex_lock(&u->reply_mutex); in xenbus_command_reply()
436 rc = queue_reply(&u->read_buffers, &msg, sizeof(msg.hdr) + msg.hdr.len); in xenbus_command_reply()
437 wake_up(&u->read_waitq); in xenbus_command_reply()
438 mutex_unlock(&u->reply_mutex); in xenbus_command_reply()
441 kref_put(&u->kref, xenbus_file_free); in xenbus_command_reply()
447 struct xenbus_file_priv *u) in xenbus_write_transaction() argument
454 } *msg = (void *)u->u.buffer; in xenbus_write_transaction()
463 list_add(&trans->list, &u->transactions); in xenbus_write_transaction()
465 !xenbus_get_transaction(u, msg->hdr.tx_id)) in xenbus_write_transaction()
466 return xenbus_command_reply(u, XS_ERROR, "ENOENT"); in xenbus_write_transaction()
470 return xenbus_command_reply(u, XS_ERROR, "EINVAL"); in xenbus_write_transaction()
472 trans = xenbus_get_transaction(u, msg->hdr.tx_id); in xenbus_write_transaction()
477 return xenbus_command_reply(u, XS_ERROR, in xenbus_write_transaction()
480 return xenbus_command_reply(u, in xenbus_write_transaction()
486 rc = xenbus_dev_request_and_reply(&msg->hdr, u); in xenbus_write_transaction()
496 static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u) in xenbus_write_watch() argument
502 path = u->u.buffer + sizeof(u->u.msg); in xenbus_write_watch()
503 token = memchr(path, 0, u->u.msg.len); in xenbus_write_watch()
505 rc = xenbus_command_reply(u, XS_ERROR, "EINVAL"); in xenbus_write_watch()
509 if (memchr(token, 0, u->u.msg.len - (token - path)) == NULL) { in xenbus_write_watch()
510 rc = xenbus_command_reply(u, XS_ERROR, "EINVAL"); in xenbus_write_watch()
522 watch->dev_data = u; in xenbus_write_watch()
530 list_add(&watch->list, &u->watches); in xenbus_write_watch()
532 list_for_each_entry(watch, &u->watches, list) { in xenbus_write_watch()
544 rc = xenbus_command_reply(u, msg_type, "OK"); in xenbus_write_watch()
554 struct xenbus_file_priv *u = filp->private_data; in xenbus_file_write() local
574 mutex_lock(&u->msgbuffer_mutex); in xenbus_file_write()
581 if (len > sizeof(u->u.buffer) - u->len) { in xenbus_file_write()
583 u->len = 0; in xenbus_file_write()
588 ret = copy_from_user(u->u.buffer + u->len, ubuf, len); in xenbus_file_write()
599 u->len += len; in xenbus_file_write()
602 if (u->len < sizeof(u->u.msg)) in xenbus_file_write()
607 if ((sizeof(u->u.msg) + u->u.msg.len) > sizeof(u->u.buffer)) { in xenbus_file_write()
609 u->len = 0; in xenbus_file_write()
613 if (u->len < (sizeof(u->u.msg) + u->u.msg.len)) in xenbus_file_write()
620 kref_get(&u->kref); in xenbus_file_write()
622 msg_type = u->u.msg.type; in xenbus_file_write()
628 ret = xenbus_write_watch(msg_type, u); in xenbus_file_write()
633 ret = xenbus_write_transaction(msg_type, u); in xenbus_file_write()
638 kref_put(&u->kref, xenbus_file_free); in xenbus_file_write()
642 u->len = 0; in xenbus_file_write()
645 mutex_unlock(&u->msgbuffer_mutex); in xenbus_file_write()
651 struct xenbus_file_priv *u; in xenbus_file_open() local
658 u = kzalloc(sizeof(*u), GFP_KERNEL); in xenbus_file_open()
659 if (u == NULL) in xenbus_file_open()
662 kref_init(&u->kref); in xenbus_file_open()
664 INIT_LIST_HEAD(&u->transactions); in xenbus_file_open()
665 INIT_LIST_HEAD(&u->watches); in xenbus_file_open()
666 INIT_LIST_HEAD(&u->read_buffers); in xenbus_file_open()
667 init_waitqueue_head(&u->read_waitq); in xenbus_file_open()
668 INIT_WORK(&u->wq, xenbus_worker); in xenbus_file_open()
670 mutex_init(&u->reply_mutex); in xenbus_file_open()
671 mutex_init(&u->msgbuffer_mutex); in xenbus_file_open()
673 filp->private_data = u; in xenbus_file_open()
680 struct xenbus_file_priv *u = filp->private_data; in xenbus_file_release() local
682 kref_put(&u->kref, xenbus_file_free); in xenbus_file_release()
689 struct xenbus_file_priv *u = file->private_data; in xenbus_file_poll() local
691 poll_wait(file, &u->read_waitq, wait); in xenbus_file_poll()
692 if (!list_empty(&u->read_buffers)) in xenbus_file_poll()