Lines Matching +full:num +full:- +full:strings

110 	xs_suspend_active--;  in xs_suspend_exit()
119 req->type = req->msg.type; in xs_request_enter()
129 if (req->type == XS_TRANSACTION_START && !req->user_req) in xs_request_enter()
142 xs_state_users--; in xs_request_exit()
143 if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) || in xs_request_exit()
144 (req->type == XS_TRANSACTION_END && !req->user_req && in xs_request_exit()
145 !WARN_ON_ONCE(req->msg.type == XS_ERROR && in xs_request_exit()
146 !strcmp(req->body, "ENOENT")))) in xs_request_exit()
147 xs_state_users--; in xs_request_exit()
159 if (i == ARRAY_SIZE(xsd_errors) - 1) { in get_error()
194 if (req->state == xb_req_state_got_reply || !xenbus_ok()) { in test_reply()
195 /* read req->state before all other fields */ in test_reply()
200 /* Make sure to reread req->state each time. */ in test_reply()
209 wait_event(req->wq, test_reply(req)); in read_reply()
213 * If we are in the process of being shut-down there is in read_reply()
214 * no point of trying to contact XenBus - it is either in read_reply()
218 return ERR_PTR(-EIO); in read_reply()
219 if (req->err) in read_reply()
220 return ERR_PTR(req->err); in read_reply()
222 } while (req->state != xb_req_state_got_reply); in read_reply()
224 return req->body; in read_reply()
231 req->msg = *msg; in xs_send()
232 req->err = 0; in xs_send()
233 req->state = xb_req_state_queued; in xs_send()
234 init_waitqueue_head(&req->wq); in xs_send()
237 req->caller_req_id = req->msg.req_id; in xs_send()
238 req->msg.req_id = xs_request_enter(req); in xs_send()
241 list_add_tail(&req->list, &xb_write_list); in xs_send()
257 msg->type = req->msg.type; in xs_wait_for_reply()
258 msg->len = req->msg.len; in xs_wait_for_reply()
261 if (req->state == xb_req_state_queued || in xs_wait_for_reply()
262 req->state == xb_req_state_wait_reply) in xs_wait_for_reply()
263 req->state = xb_req_state_aborted; in xs_wait_for_reply()
273 wake_up(&req->wq); in xs_wake_up()
283 return -ENOMEM; in xenbus_dev_request_and_reply()
286 vec->iov_len = msg->len; in xenbus_dev_request_and_reply()
287 vec->iov_base = msg + 1; in xenbus_dev_request_and_reply()
289 req->vec = vec; in xenbus_dev_request_and_reply()
290 req->num_vecs = 1; in xenbus_dev_request_and_reply()
291 req->cb = xenbus_dev_queue_reply; in xenbus_dev_request_and_reply()
292 req->par = par; in xenbus_dev_request_and_reply()
293 req->user_req = true; in xenbus_dev_request_and_reply()
316 return ERR_PTR(-ENOMEM); in xs_talkv()
318 req->vec = iovec; in xs_talkv()
319 req->num_vecs = num_vecs; in xs_talkv()
320 req->cb = xs_wake_up; in xs_talkv()
321 req->user_req = false; in xs_talkv()
342 return ERR_PTR(-err); in xs_talkv()
349 return ERR_PTR(-EINVAL); in xs_talkv()
376 static unsigned int count_strings(const char *strings, unsigned int len) in count_strings() argument
378 unsigned int num; in count_strings() local
381 for (p = strings, num = 0; p < strings + len; p += strlen(p) + 1) in count_strings()
382 num++; in count_strings()
384 return num; in count_strings()
396 return (!buffer) ? ERR_PTR(-ENOMEM) : buffer; in join()
399 static char **split(char *strings, unsigned int len, unsigned int *num) in split() argument
403 /* Count the strings. */ in split()
404 *num = count_strings(strings, len); in split()
407 ret = kmalloc(*num * sizeof(char *) + len, GFP_NOIO | __GFP_HIGH); in split()
409 kfree(strings); in split()
410 return ERR_PTR(-ENOMEM); in split()
412 memcpy(&ret[*num], strings, len); in split()
413 kfree(strings); in split()
415 strings = (char *)&ret[*num]; in split()
416 for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1) in split()
417 ret[(*num)++] = p; in split()
423 const char *dir, const char *node, unsigned int *num) in xenbus_directory() argument
425 char *strings, *path; in xenbus_directory() local
432 strings = xs_single(t, XS_DIRECTORY, path, &len); in xenbus_directory()
434 if (IS_ERR(strings)) in xenbus_directory()
435 return (char **)strings; in xenbus_directory()
437 return split(strings, len, num); in xenbus_directory()
477 * Returns -err on failure.
545 t->id = simple_strtoul(id_str, NULL, 0); in xenbus_transaction_start()
567 /* Single read and scanf: returns -errno or num scanned. */
585 return -ERANGE; in xenbus_scanf()
605 /* Single printf and write: returns -errno or 0. */
618 return -ENOMEM; in xenbus_printf()
628 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
648 ret = -EINVAL; in xenbus_gather()
699 if (count_strings(event->body, event->len) != 2) { in xs_watch_msg()
701 return -EINVAL; in xs_watch_msg()
703 event->path = (const char *)event->body; in xs_watch_msg()
704 event->token = (const char *)strchr(event->body, '\0') + 1; in xs_watch_msg()
707 event->handle = find_watch(event->token); in xs_watch_msg()
708 if (event->handle != NULL && in xs_watch_msg()
709 (!event->handle->will_handle || in xs_watch_msg()
710 event->handle->will_handle(event->handle, in xs_watch_msg()
711 event->path, event->token))) { in xs_watch_msg()
713 list_add_tail(&event->list, &watch_events); in xs_watch_msg()
714 event->handle->nr_pending++; in xs_watch_msg()
728 * control/platform-feature-xs_reset_watches.
755 "platform-feature-xs_reset_watches", 0)) in xs_reset_watches()
759 if (err && err != -EEXIST) in xs_reset_watches()
772 watch->nr_pending = 0; in register_xenbus_watch()
778 list_add(&watch->list, &watches); in register_xenbus_watch()
781 err = xs_watch(watch->node, token); in register_xenbus_watch()
785 list_del(&watch->list); in register_xenbus_watch()
807 list_del(&watch->list); in unregister_xenbus_watch()
810 err = xs_unwatch(watch->node, token); in unregister_xenbus_watch()
812 pr_warn("Failed to release watch %s: %i\n", watch->node, err); in unregister_xenbus_watch()
818 if (current->pid != xenwatch_pid) in unregister_xenbus_watch()
823 if (watch->nr_pending) { in unregister_xenbus_watch()
825 if (event->handle != watch) in unregister_xenbus_watch()
827 list_del(&event->list); in unregister_xenbus_watch()
830 watch->nr_pending = 0; in unregister_xenbus_watch()
834 if (current->pid != xenwatch_pid) in unregister_xenbus_watch()
861 xs_watch(watch->node, token); in xs_resume()
879 xenwatch_pid = current->pid; in xenwatch_thread()
894 list_del(&event->list); in xenwatch_thread()
895 event->handle->nr_pending--; in xenwatch_thread()
900 event->handle->callback(event->handle, event->path, in xenwatch_thread()
901 event->token); in xenwatch_thread()
925 wake_up(&req->wq); in xs_reboot_notify()
927 wake_up(&req->wq); in xs_reboot_notify()