Lines Matching refs:rp

106     mon_text_read_wait(struct mon_reader_text *rp, struct file *file);
107 static void mon_text_read_head_t(struct mon_reader_text *rp,
109 static void mon_text_read_head_u(struct mon_reader_text *rp,
111 static void mon_text_read_statset(struct mon_reader_text *rp,
113 static void mon_text_read_intstat(struct mon_reader_text *rp,
115 static void mon_text_read_isostat(struct mon_reader_text *rp,
117 static void mon_text_read_isodesc(struct mon_reader_text *rp,
119 static void mon_text_read_data(struct mon_reader_text *rp,
193 static void mon_text_event(struct mon_reader_text *rp, struct urb *urb, in mon_text_event() argument
204 if (rp->nevents >= EVENT_MAX || in mon_text_event()
205 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) { in mon_text_event()
206 rp->r.m_bus->cnt_text_lost++; in mon_text_event()
250 ep->setup_flag = mon_text_get_setup(ep, urb, ev_type, rp->r.m_bus); in mon_text_event()
252 rp->r.m_bus); in mon_text_event()
254 rp->nevents++; in mon_text_event()
255 list_add_tail(&ep->e_link, &rp->e_list); in mon_text_event()
256 wake_up(&rp->wait); in mon_text_event()
261 struct mon_reader_text *rp = data; in mon_text_submit() local
262 mon_text_event(rp, urb, 'S', -EINPROGRESS); in mon_text_submit()
267 struct mon_reader_text *rp = data; in mon_text_complete() local
268 mon_text_event(rp, urb, 'C', status); in mon_text_complete()
273 struct mon_reader_text *rp = data; in mon_text_error() local
276 if (rp->nevents >= EVENT_MAX || in mon_text_error()
277 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) { in mon_text_error()
278 rp->r.m_bus->cnt_text_lost++; in mon_text_error()
296 rp->nevents++; in mon_text_error()
297 list_add_tail(&ep->e_link, &rp->e_list); in mon_text_error()
298 wake_up(&rp->wait); in mon_text_error()
304 static struct mon_event_text *mon_text_fetch(struct mon_reader_text *rp, in mon_text_fetch() argument
311 if (list_empty(&rp->e_list)) { in mon_text_fetch()
315 p = rp->e_list.next; in mon_text_fetch()
317 --rp->nevents; in mon_text_fetch()
327 struct mon_reader_text *rp; in mon_text_open() local
333 rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL); in mon_text_open()
334 if (rp == NULL) { in mon_text_open()
338 INIT_LIST_HEAD(&rp->e_list); in mon_text_open()
339 init_waitqueue_head(&rp->wait); in mon_text_open()
340 mutex_init(&rp->printf_lock); in mon_text_open()
342 rp->printf_size = PRINTF_DFL; in mon_text_open()
343 rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL); in mon_text_open()
344 if (rp->printf_buf == NULL) { in mon_text_open()
349 rp->r.m_bus = mbus; in mon_text_open()
350 rp->r.r_data = rp; in mon_text_open()
351 rp->r.rnf_submit = mon_text_submit; in mon_text_open()
352 rp->r.rnf_error = mon_text_error; in mon_text_open()
353 rp->r.rnf_complete = mon_text_complete; in mon_text_open()
355 snprintf(rp->slab_name, SLAB_NAME_SZ, "mon_text_%p", rp); in mon_text_open()
356 rp->e_slab = kmem_cache_create(rp->slab_name, in mon_text_open()
359 if (rp->e_slab == NULL) { in mon_text_open()
364 mon_reader_add(mbus, &rp->r); in mon_text_open()
366 file->private_data = rp; in mon_text_open()
373 kfree(rp->printf_buf); in mon_text_open()
375 kfree(rp); in mon_text_open()
381 static ssize_t mon_text_copy_to_user(struct mon_reader_text *rp, in mon_text_copy_to_user() argument
384 const size_t togo = min(nbytes, rp->printf_togo); in mon_text_copy_to_user()
386 if (copy_to_user(buf, &rp->printf_buf[rp->printf_offset], togo)) in mon_text_copy_to_user()
388 rp->printf_togo -= togo; in mon_text_copy_to_user()
389 rp->printf_offset += togo; in mon_text_copy_to_user()
397 struct mon_reader_text *rp = file->private_data; in mon_text_read_t() local
402 mutex_lock(&rp->printf_lock); in mon_text_read_t()
404 if (rp->printf_togo == 0) { in mon_text_read_t()
406 ep = mon_text_read_wait(rp, file); in mon_text_read_t()
408 mutex_unlock(&rp->printf_lock); in mon_text_read_t()
412 ptr.pbuf = rp->printf_buf; in mon_text_read_t()
413 ptr.limit = rp->printf_size; in mon_text_read_t()
415 mon_text_read_head_t(rp, &ptr, ep); in mon_text_read_t()
416 mon_text_read_statset(rp, &ptr, ep); in mon_text_read_t()
419 mon_text_read_data(rp, &ptr, ep); in mon_text_read_t()
421 rp->printf_togo = ptr.cnt; in mon_text_read_t()
422 rp->printf_offset = 0; in mon_text_read_t()
424 kmem_cache_free(rp->e_slab, ep); in mon_text_read_t()
427 ret = mon_text_copy_to_user(rp, buf, nbytes); in mon_text_read_t()
428 mutex_unlock(&rp->printf_lock); in mon_text_read_t()
436 struct mon_reader_text *rp = file->private_data; in mon_text_read_u() local
441 mutex_lock(&rp->printf_lock); in mon_text_read_u()
443 if (rp->printf_togo == 0) { in mon_text_read_u()
445 ep = mon_text_read_wait(rp, file); in mon_text_read_u()
447 mutex_unlock(&rp->printf_lock); in mon_text_read_u()
451 ptr.pbuf = rp->printf_buf; in mon_text_read_u()
452 ptr.limit = rp->printf_size; in mon_text_read_u()
454 mon_text_read_head_u(rp, &ptr, ep); in mon_text_read_u()
456 mon_text_read_statset(rp, &ptr, ep); in mon_text_read_u()
458 mon_text_read_isostat(rp, &ptr, ep); in mon_text_read_u()
459 mon_text_read_isodesc(rp, &ptr, ep); in mon_text_read_u()
461 mon_text_read_intstat(rp, &ptr, ep); in mon_text_read_u()
463 mon_text_read_statset(rp, &ptr, ep); in mon_text_read_u()
467 mon_text_read_data(rp, &ptr, ep); in mon_text_read_u()
469 rp->printf_togo = ptr.cnt; in mon_text_read_u()
470 rp->printf_offset = 0; in mon_text_read_u()
472 kmem_cache_free(rp->e_slab, ep); in mon_text_read_u()
475 ret = mon_text_copy_to_user(rp, buf, nbytes); in mon_text_read_u()
476 mutex_unlock(&rp->printf_lock); in mon_text_read_u()
480 static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp, in mon_text_read_wait() argument
483 struct mon_bus *mbus = rp->r.m_bus; in mon_text_read_wait()
487 add_wait_queue(&rp->wait, &waita); in mon_text_read_wait()
489 while ((ep = mon_text_fetch(rp, mbus)) == NULL) { in mon_text_read_wait()
492 remove_wait_queue(&rp->wait, &waita); in mon_text_read_wait()
501 remove_wait_queue(&rp->wait, &waita); in mon_text_read_wait()
507 remove_wait_queue(&rp->wait, &waita); in mon_text_read_wait()
511 static void mon_text_read_head_t(struct mon_reader_text *rp, in mon_text_read_head_t() argument
529 static void mon_text_read_head_u(struct mon_reader_text *rp, in mon_text_read_head_u() argument
547 static void mon_text_read_statset(struct mon_reader_text *rp, in mon_text_read_statset() argument
568 static void mon_text_read_intstat(struct mon_reader_text *rp, in mon_text_read_intstat() argument
575 static void mon_text_read_isostat(struct mon_reader_text *rp, in mon_text_read_isostat() argument
588 static void mon_text_read_isodesc(struct mon_reader_text *rp, in mon_text_read_isodesc() argument
610 static void mon_text_read_data(struct mon_reader_text *rp, in mon_text_read_data() argument
644 struct mon_reader_text *rp = file->private_data; in mon_text_release() local
658 mon_reader_del(mbus, &rp->r); in mon_text_release()
668 while (!list_empty(&rp->e_list)) { in mon_text_release()
669 p = rp->e_list.next; in mon_text_release()
672 --rp->nevents; in mon_text_release()
673 kmem_cache_free(rp->e_slab, ep); in mon_text_release()
677 kmem_cache_destroy(rp->e_slab); in mon_text_release()
678 kfree(rp->printf_buf); in mon_text_release()
679 kfree(rp); in mon_text_release()